Merge pull request #11665 from smowton/smowton/admin/revert-kotlin-default-method-type-erasure

Kotlin: Revert type erasure within $default functions
This commit is contained in:
Chris Smowton
2022-12-19 16:33:20 +00:00
committed by GitHub
5 changed files with 48 additions and 31 deletions

View File

@@ -1337,7 +1337,7 @@ test.kt:
# 145| 0: [AssignExpr] ...=...
# 145| 0: [VarAccess] p4
# 145| 1: [MethodAccess] listOf(...)
# 145| -2: [TypeAccess] Object
# 145| -2: [TypeAccess] T
# 145| -1: [TypeAccess] CollectionsKt
# 145| 0: [VarAccess] p2
# 145| 3: [IfStmt] if (...)
@@ -1360,7 +1360,7 @@ test.kt:
# 145| 0: [AssignExpr] ...=...
# 145| 0: [VarAccess] p6
# 145| 1: [MethodAccess] listOf(...)
# 145| -2: [TypeAccess] Object
# 145| -2: [TypeAccess] S
# 145| -1: [TypeAccess] CollectionsKt
# 145| 0: [VarAccess] p1
# 145| 5: [ReturnStmt] return ...

View File

@@ -0,0 +1,36 @@
| test.kt:124:3:126:3 | ...=... | test.kt:122:19:122:19 | T |
| test.kt:124:3:126:3 | ...=... | test.kt:122:19:122:19 | T |
| test.kt:124:3:126:3 | p1 | test.kt:122:19:122:19 | T |
| test.kt:124:3:126:3 | p2 | test.kt:122:19:122:19 | T |
| test.kt:124:3:126:3 | p2 | test.kt:122:19:122:19 | T |
| test.kt:124:3:126:3 | p3 | test.kt:122:19:122:19 | T |
| test.kt:124:3:126:3 | p3 | test.kt:122:19:122:19 | T |
| test.kt:124:22:124:22 | p1 | test.kt:122:19:122:19 | T |
| test.kt:135:3:135:43 | ...=... | test.kt:122:19:122:19 | T |
| test.kt:135:3:135:43 | p1 | test.kt:122:19:122:19 | T |
| test.kt:135:3:135:43 | p2 | test.kt:122:19:122:19 | T |
| test.kt:135:3:135:43 | p2 | test.kt:122:19:122:19 | T |
| test.kt:135:3:135:43 | testReturn(...) | test.kt:122:19:122:19 | T |
| test.kt:145:3:147:3 | ...=... | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<S> |
| test.kt:145:3:147:3 | ...=... | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<T> |
| test.kt:145:3:147:3 | ...=... | test.kt:143:27:143:27 | T |
| test.kt:145:3:147:3 | ...=... | test.kt:143:27:143:27 | T |
| test.kt:145:3:147:3 | ...=... | test.kt:145:8:145:12 | S |
| test.kt:145:3:147:3 | p1 | test.kt:145:8:145:12 | S |
| test.kt:145:3:147:3 | p2 | test.kt:143:27:143:27 | T |
| test.kt:145:3:147:3 | p2 | test.kt:143:27:143:27 | T |
| test.kt:145:3:147:3 | p3 | test.kt:143:27:143:27 | T |
| test.kt:145:3:147:3 | p3 | test.kt:143:27:143:27 | T |
| test.kt:145:3:147:3 | p4 | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<T> |
| test.kt:145:3:147:3 | p4 | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<T> |
| test.kt:145:3:147:3 | p5 | test.kt:145:8:145:12 | S |
| test.kt:145:3:147:3 | p5 | test.kt:145:8:145:12 | S |
| test.kt:145:3:147:3 | p6 | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<S> |
| test.kt:145:3:147:3 | p6 | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<S> |
| test.kt:145:30:145:30 | p1 | test.kt:145:8:145:12 | S |
| test.kt:145:66:145:74 | T | test.kt:143:27:143:27 | T |
| test.kt:145:66:145:74 | listOf(...) | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<T> |
| test.kt:145:73:145:73 | p2 | test.kt:143:27:143:27 | T |
| test.kt:145:111:145:119 | S | test.kt:145:8:145:12 | S |
| test.kt:145:111:145:119 | listOf(...) | file:///modules/java.base/java/util/List.class:0:0:0:0 | List<S> |
| test.kt:145:118:145:118 | p1 | test.kt:145:8:145:12 | S |

View File

@@ -5,6 +5,8 @@ class InstantiatedType extends ParameterizedType {
}
// This checks that all type parameter references are erased in the context of a $default function.
// Note this is currently expected to fail since for the time being we extract type variable references
// even where they should be out of scope.
predicate containsTypeVariables(Type t) {
t instanceof TypeVariable or
containsTypeVariables(t.(InstantiatedType).getATypeArgument()) or