-
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: scoping for type arguments (#585)
Closes partially #540 ### Summary of Changes Implement scoping rules for the `typeParameter` property of a type argument. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
- Loading branch information
1 parent
ed0aa97
commit 3da8dd0
Showing
11 changed files
with
180 additions
and
0 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
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
8 changes: 8 additions & 0 deletions
8
tests/resources/scoping/type arguments/to something other than type parameter/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,8 @@ | ||
package test.scoping.typeArguments.toSomethingOtherThanTypeParameter | ||
|
||
// $TEST$ unresolved | ||
segment mySegment(p: MyClass<»notAtypeParameter« = Int>) {} | ||
|
||
class MyClass<T> | ||
|
||
fun notAtypeParameter() |
66 changes: 66 additions & 0 deletions
66
...coping/type arguments/to type parameter in containing named type declaration/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,66 @@ | ||
package test.scoping.typeArguments.toTypeParameterInContainingNamedTypeDeclaration | ||
|
||
// $TEST$ target outerClass | ||
class MyClass<»T«>( | ||
// $TEST$ references outerClass | ||
p: MyClass<»T« = Int>, | ||
|
||
// $TEST$ references outerClass | ||
) sub MyClass<»T« = Int> where { | ||
|
||
// $TEST$ references outerClass | ||
T sub MyClass<»T« = Int>, | ||
} { | ||
// $TEST$ references outerClass | ||
attr a: MyClass<»T« = Int> | ||
|
||
fun f<T>( | ||
// $TEST$ references outerClass | ||
p: MyClass<»T« = Int>, | ||
) -> ( | ||
// $TEST$ references outerClass | ||
r: MyClass<»T« = Int>, | ||
) where { | ||
// $TEST$ references outerClass | ||
T sub MyClass<»T« = Int>, | ||
} | ||
|
||
enum MyEnum { | ||
// $TEST$ target variant | ||
MyEnumVariant<»T«>( | ||
// $TEST$ references outerClass | ||
p1: MyClass<»T« = Int>, | ||
|
||
// $TEST$ references variant | ||
p3: MyEnumVariant<»T« = Int>, | ||
) where { | ||
// $TEST$ references outerClass | ||
T sub MyClass<»T« = Int>, | ||
|
||
// $TEST$ references variant | ||
T sub MyEnumVariant<»T« = Int>, | ||
} | ||
} | ||
|
||
// $TEST$ target innerClass | ||
class MyClass<»T«>( | ||
// $TEST$ references innerClass | ||
p: MyClass<»T« = Int>, | ||
|
||
// $TEST$ references innerClass | ||
) sub MyClass<»T« = Int> { | ||
// $TEST$ references innerClass | ||
attr a: MyClass<»T« = Int> | ||
|
||
fun f<T>( | ||
// $TEST$ references innerClass | ||
p: MyClass<»T« = Int>, | ||
) -> ( | ||
// $TEST$ references innerClass | ||
r: MyClass<»T« = Int>, | ||
) where { | ||
// $TEST$ references innerClass | ||
T sub MyClass<»T« = Int>, | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...rces/scoping/type arguments/to type parameter in enum variant in global enum/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,11 @@ | ||
package test.scoping.typeArguments.toTypeParameterInEnumVariantInGlobalEnum | ||
|
||
enum MyEnum { | ||
// $TEST$ target t | ||
MyEnumVariant<»T«> | ||
} | ||
|
||
segment mySegment( | ||
// $TEST$ references t | ||
p: MyEnum.MyEnumVariant<»T« = Int> | ||
) {} |
13 changes: 13 additions & 0 deletions
13
...rces/scoping/type arguments/to type parameter in enum variant in nested enum/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,13 @@ | ||
package test.scoping.typeArguments.toTypeParameterInEnumVariantInNestedEnum | ||
|
||
class MyClass<T> { | ||
enum MyEnum { | ||
// $TEST$ target t | ||
MyEnumVariant<»T«> | ||
} | ||
} | ||
|
||
segment mySegment( | ||
// $TEST$ references t | ||
p: MyClass.MyEnum.MyEnumVariant<»T« = Int> | ||
) {} |
9 changes: 9 additions & 0 deletions
9
tests/resources/scoping/type arguments/to type parameter in global class/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 test.scoping.typeArguments.toTypeParameterInGlobalClass | ||
|
||
// $TEST$ target t | ||
class MyClass<»T«> | ||
|
||
segment mySegment( | ||
// $TEST$ references t | ||
p: MyClass<»T« = Int> | ||
) {} |
11 changes: 11 additions & 0 deletions
11
tests/resources/scoping/type arguments/to type parameter in nested class/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,11 @@ | ||
package test.scoping.typeArguments.toTypeParameterInNestedClass | ||
|
||
class MyClass<T> { | ||
// $TEST$ target t | ||
class MyNestedClass<»T«> | ||
} | ||
|
||
segment mySegment( | ||
// $TEST$ references t | ||
p: MyClass.MyNestedClass<»T« = Int> | ||
) {} |
11 changes: 11 additions & 0 deletions
11
tests/resources/scoping/type arguments/to unresolved/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,11 @@ | ||
package test.scoping.typeArguments.toUnresolved | ||
|
||
segment mySegment( | ||
// $TEST$ unresolved | ||
p1: MyClass<»unresolved« = Int>, | ||
|
||
// $TEST$ unresolved | ||
p2: unresolved<»T« = Int>, | ||
) {} | ||
|
||
class MyClass<T> |