Kotlin: Fix extension and dispatch parameter order in $default functions

This commit is contained in:
Tamas Vajk
2022-12-07 12:24:41 +01:00
parent 6457e059f5
commit d93dce0fa9
8 changed files with 71 additions and 50 deletions

View File

@@ -326,7 +326,7 @@
| methods3.kt:6:5:6:45 | fooBarMethodExt(...) | MethodAccess |
| methods3.kt:6:5:6:45 | int | TypeAccess |
| methods3.kt:6:5:6:45 | int | TypeAccess |
| methods3.kt:6:5:6:45 | p1 | VarAccess |
| methods3.kt:6:5:6:45 | p0 | VarAccess |
| methods3.kt:6:5:6:45 | p2 | VarAccess |
| methods3.kt:6:5:6:45 | p2 | VarAccess |
| methods3.kt:6:5:6:45 | p3 | VarAccess |

View File

@@ -41,7 +41,7 @@ methods
| methods3.kt:0:0:0:0 | Methods3Kt | methods3.kt:3:1:3:49 | fooBarTopLevelMethodExt | fooBarTopLevelMethodExt(java.lang.String,int) | final, public, static | |
| methods3.kt:0:0:0:0 | Methods3Kt | methods3.kt:3:1:3:49 | fooBarTopLevelMethodExt$default | fooBarTopLevelMethodExt$default(java.lang.String,int,int,java.lang.Object) | public, static | Compiler generated |
| methods3.kt:5:1:7:1 | Class3 | methods3.kt:6:5:6:45 | fooBarMethodExt | fooBarMethodExt(java.lang.String,int) | final, public | |
| methods3.kt:5:1:7:1 | Class3 | methods3.kt:6:5:6:45 | fooBarMethodExt$default | fooBarMethodExt$default(java.lang.String,foo.bar.Class3,int,int,java.lang.Object) | public, static | Compiler generated |
| methods3.kt:5:1:7:1 | Class3 | methods3.kt:6:5:6:45 | fooBarMethodExt$default | fooBarMethodExt$default(foo.bar.Class3,java.lang.String,int,int,java.lang.Object) | public, static | Compiler generated |
| methods4.kt:5:3:9:3 | InsideNestedTest | methods4.kt:7:5:7:34 | m | m(foo.bar.NestedTest.InsideNestedTest) | final, public | |
| methods5.kt:0:0:0:0 | Methods5Kt | methods5.kt:3:1:11:1 | x | x() | final, public, static | |
| methods5.kt:5:3:5:27 | | methods5.kt:5:3:5:27 | a | a(int) | final, public | |
@@ -82,3 +82,9 @@ extensions
| methods3.kt:6:5:6:45 | fooBarMethodExt$default | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String |
| methods5.kt:9:3:9:32 | f1 | file:///!unknown-binary-location/foo/bar/C1.class:0:0:0:0 | C1<T1> |
extensionsMismatch
extensionIndex
| methods3.kt:3:1:3:49 | fooBarTopLevelMethodExt | 0 | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String |
| methods3.kt:3:1:3:49 | fooBarTopLevelMethodExt$default | 0 | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String |
| methods3.kt:6:5:6:45 | fooBarMethodExt | 0 | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String |
| methods3.kt:6:5:6:45 | fooBarMethodExt$default | 1 | file:///modules/java.base/java/lang/String.class:0:0:0:0 | String |
| methods5.kt:9:3:9:32 | f1 | 0 | file:///!unknown-binary-location/foo/bar/C1.class:0:0:0:0 | C1<T1> |

View File

@@ -26,3 +26,10 @@ query predicate extensionsMismatch(Method src, Method def) {
def instanceof ExtensionMethod and not src instanceof ExtensionMethod
)
}
query predicate extensionIndex(ExtensionMethod m, int i, Type t) {
m.fromSource() and
m.getExtensionParameterIndex() = i and
m.getExtendedType() = t and
m.getParameter(i).getType() = t
}

View File

@@ -525,13 +525,13 @@ test.kt:
# 21| 0: [MethodAccess] sink(...)
# 21| -1: [TypeAccess] TestKt
# 21| 0: [VarAccess] y
# 19| 3: [Method] f$default
# 19| 3: [ExtensionMethod] f$default
# 19| 3: [TypeAccess] Unit
#-----| 4: (Parameters)
# 19| 0: [Parameter] p0
# 19| 0: [TypeAccess] String
# 19| 1: [Parameter] p1
# 19| 0: [TypeAccess] TestExtensionMember
# 19| 1: [Parameter] p1
# 19| 0: [TypeAccess] String
# 19| 2: [Parameter] p2
# 19| 0: [TypeAccess] String
# 19| 3: [Parameter] p3
@@ -565,8 +565,8 @@ test.kt:
# 19| 1: [StringLiteral] "hello world"
# 19| 2: [ReturnStmt] return ...
# 19| 0: [MethodAccess] f(...)
# 19| -1: [VarAccess] p1
# 19| 0: [VarAccess] p0
# 19| -1: [VarAccess] p0
# 19| 0: [ExtensionReceiverAccess] this
# 19| 1: [VarAccess] p2
# 19| 2: [VarAccess] p3
# 19| 3: [VarAccess] p4
@@ -579,8 +579,8 @@ test.kt:
# 25| 0: [ExprStmt] <Expr>;
# 25| 0: [MethodAccess] f$default(...)
# 25| -1: [TypeAccess] TestExtensionMember
# 25| 0: [VarAccess] sunk
# 25| 1: [ThisAccess] this
# 25| 0: [ThisAccess] this
# 25| 1: [VarAccess] sunk
# 25| 2: [StringLiteral] "extension sunk"
# 1| 3: [NullLiteral] null
# 1| 4: [NullLiteral] null
@@ -589,8 +589,8 @@ test.kt:
# 26| 1: [ExprStmt] <Expr>;
# 26| 0: [MethodAccess] f$default(...)
# 26| -1: [TypeAccess] TestExtensionMember
# 26| 0: [VarAccess] sunk
# 26| 1: [ThisAccess] this
# 26| 0: [ThisAccess] this
# 26| 1: [VarAccess] sunk
# 26| 2: [StringLiteral] "extension sunk fp"
# 26| 3: [StringLiteral] "extension sunk 2"
# 1| 4: [NullLiteral] null
@@ -729,13 +729,13 @@ test.kt:
# 57| 0: [MethodAccess] sink(...)
# 57| -1: [TypeAccess] TestKt
# 57| 0: [VarAccess] y
# 56| 4: [Method] test$default
# 56| 4: [ExtensionMethod] test$default
# 56| 3: [TypeAccess] Unit
#-----| 4: (Parameters)
# 56| 0: [Parameter] p0
# 56| 0: [TypeAccess] ExtendMe
# 56| 1: [Parameter] p1
# 56| 0: [TypeAccess] TestReceiverReferences
# 56| 1: [Parameter] p1
# 56| 0: [TypeAccess] ExtendMe
# 56| 2: [Parameter] p2
# 56| 0: [TypeAccess] String
# 56| 3: [Parameter] p3
@@ -759,7 +759,7 @@ test.kt:
# 56| 1: [MethodAccess] f(...)
# 56| -1: [VarAccess] p0
# 56| 0: [MethodAccess] g(...)
# 56| -1: [VarAccess] p1
# 56| -1: [VarAccess] p0
# 56| 0: [VarAccess] p2
# 56| 1: [IfStmt] if (...)
# 56| 0: [EQExpr] ... == ...
@@ -773,8 +773,8 @@ test.kt:
# 56| 1: [StringLiteral] "hello world"
# 56| 2: [ReturnStmt] return ...
# 56| 0: [MethodAccess] test(...)
# 56| -1: [VarAccess] p1
# 56| 0: [VarAccess] p0
# 56| -1: [VarAccess] p0
# 56| 0: [ExtensionReceiverAccess] this
# 56| 1: [VarAccess] p2
# 56| 2: [VarAccess] p3
# 56| 3: [VarAccess] p4
@@ -787,8 +787,8 @@ test.kt:
# 61| 0: [ExprStmt] <Expr>;
# 61| 0: [MethodAccess] test$default(...)
# 61| -1: [TypeAccess] TestReceiverReferences
# 61| 0: [VarAccess] t
# 61| 1: [ThisAccess] this
# 61| 0: [ThisAccess] this
# 61| 1: [VarAccess] t
# 61| 2: [StringLiteral] "receiver refs sunk"
# 1| 3: [NullLiteral] null
# 1| 4: [NullLiteral] null
@@ -797,8 +797,8 @@ test.kt:
# 62| 1: [ExprStmt] <Expr>;
# 62| 0: [MethodAccess] test$default(...)
# 62| -1: [TypeAccess] TestReceiverReferences
# 62| 0: [VarAccess] t
# 62| 1: [ThisAccess] this
# 62| 0: [ThisAccess] this
# 62| 1: [VarAccess] t
# 62| 2: [StringLiteral] "receiver refs sunk fp"
# 62| 3: [StringLiteral] "receiver refs sunk 2"
# 1| 4: [NullLiteral] null