-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use bounds of type system where possible (#899)
### Summary of Changes * `isSubtypeOf(Nothing, X)` now always returns `true`. * `isSubtypeOf(X, Any?)` now always returns `true`. * `lowestCommonSupertype` now returns `Any` or `Any?` if given `$unknown` or some other unexpected type, instead of propagating `$unknown`.
- Loading branch information
1 parent
9d6ce28
commit cf92762
Showing
6 changed files
with
111 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...s/safe-ds-lang/tests/resources/typing/lowest common supertype/unhandled type/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tests.typing.lowestCommonSupertype.unhandledType | ||
|
||
class C | ||
@Pure fun f() -> (r1: Int, r2: Int) | ||
|
||
segment mySegment() { | ||
// $TEST$ serialization List<Any> | ||
»[1, f]«; | ||
|
||
// $TEST$ serialization List<Any?> | ||
»[null, f]«; | ||
|
||
// $TEST$ serialization List<Any> | ||
»[1, C]«; | ||
|
||
// $TEST$ serialization List<Any?> | ||
»[null, C]«; | ||
|
||
// $TEST$ serialization List<Any> | ||
»[1, f()]«; | ||
|
||
// $TEST$ serialization List<Any?> | ||
»[null, f()]«; | ||
} |
23 changes: 0 additions & 23 deletions
23
...afe-ds-lang/tests/resources/typing/lowest common supertype/unknown supertype/main.sdstest
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...ges/safe-ds-lang/tests/resources/typing/lowest common supertype/unknown type/main.sdstest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package tests.typing.lowestCommonSupertype.unknownType | ||
|
||
segment mySegment() { | ||
// $TEST$ serialization List<Any?> | ||
»[1, unknown]«; | ||
|
||
// $TEST$ serialization List<Any?> | ||
»[null, unknown]«; | ||
} |