-
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: allow any widening/narrowing type cast
- Loading branch information
1 parent
114fee6
commit 5f7d8b9
Showing
2 changed files
with
27 additions
and
6 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
21 changes: 17 additions & 4 deletions
21
packages/safe-ds-lang/tests/resources/validation/types/checking/type casts/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 |
---|---|---|
@@ -1,9 +1,22 @@ | ||
package tests.validation.types.checking.typeCasts | ||
|
||
class C() | ||
class D() sub C | ||
class E() sub C | ||
|
||
pipeline test { | ||
// $TEST$ no error "Type casts can only be applied to expressions of unknown type." | ||
»unresolved« as Int; | ||
// $TEST$ error "This type cast can never succeed." | ||
»D()« as E; | ||
|
||
// $TEST$ no error "This type cast can never succeed." | ||
»C()« as C; | ||
|
||
// $TEST$ error "Type casts can only be applied to expressions of unknown type." | ||
»1« as Int; | ||
// $TEST$ no error "This type cast can never succeed." | ||
»C()« as D; | ||
|
||
// $TEST$ no error "This type cast can never succeed." | ||
»D()« as C; | ||
|
||
// $TEST$ no error "This type cast can never succeed." | ||
»unresolved« as Int; | ||
} |