-
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: apply type parameter substitutions of receiver type for member …
…accesses (#859) Closes partially #23 ### Summary of Changes Let's look at the following example: ``` class C<T> { attr member: T } segment mySegment(p: C<Int>) { val a = p.member; ``` Previously, the type of the placeholder `a` was computed as `T` (type parameter type). Now, the type parameter substitutions that were computed for the receiver get applied, so `a` now gets the correct type `Int`.
- Loading branch information
1 parent
9f283d3
commit 5780ed7
Showing
5 changed files
with
75 additions
and
2 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
40 changes: 40 additions & 0 deletions
40
...s/resources/typing/expressions/member accesses/on class with type parameters/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,40 @@ | ||
package tests.typing.expressions.memberAccesses.onClassWithTypeParameters | ||
|
||
class C<T> { | ||
attr nonNullableMember: T | ||
attr nullableMember: T? | ||
@Pure fun method() -> r: T | ||
} | ||
|
||
@Pure fun nullableC() -> result: C<Int>? | ||
|
||
segment mySegment(p: C<Int>) { | ||
// $TEST$ serialization Int | ||
»p.nonNullableMember«; | ||
// $TEST$ serialization Int? | ||
»p.nullableMember«; | ||
// $TEST$ serialization () -> (r: Int) | ||
»p.method«; | ||
|
||
// $TEST$ serialization Int | ||
»p?.nonNullableMember«; | ||
// $TEST$ serialization Int? | ||
»p?.nullableMember«; | ||
// $TEST$ serialization () -> (r: Int) | ||
»p?.method«; | ||
|
||
|
||
// $TEST$ serialization Int | ||
»nullableC().nonNullableMember«; | ||
// $TEST$ serialization Int? | ||
»nullableC().nullableMember«; | ||
// $TEST$ serialization () -> (r: Int) | ||
»nullableC().method«; | ||
|
||
// $TEST$ serialization Int? | ||
»nullableC()?.nonNullableMember«; | ||
// $TEST$ serialization Int? | ||
»nullableC()?.nullableMember«; | ||
// $TEST$ serialization union<() -> (r: Int), literal<null>> | ||
»nullableC()?.method«; | ||
} |
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