Kotlin: specialise extension receivers the same as other function parameters

This arises when a generic class extends one of its parameters; for example, `class G<T> { val T.v; get() = 1 }`, where specialisation `G<List>` should generate a method specialisation `getV(List)`.
This commit is contained in:
Chris Smowton
2022-10-27 18:29:36 +01:00
parent 19b7e9ebc7
commit 45a4cd89a6
6 changed files with 34 additions and 11 deletions

View File

@@ -0,0 +1,9 @@
public class User {
public static void test(KotlinClass<String> kc) {
kc.getKotlinVal("Hello world");
}
}

View File

@@ -0,0 +1,4 @@
| User.java:5:5:5:34 | getKotlinVal(...) | getKotlinVal | String |
| test.kt:8:43:8:78 | with(...) | with | Function1<? super T,? extends R> |
| test.kt:8:43:8:78 | with(...) | with | T |
| test.kt:8:68:8:76 | getKotlinVal(...) | getKotlinVal | String |

View File

@@ -0,0 +1,8 @@
class KotlinClass<T> {
val T.kotlinVal: Int
get() = 1
}
fun kotlinUser(kc: KotlinClass<String>) = with(kc) { "hello world".kotlinVal }

View File

@@ -0,0 +1,4 @@
from create_database_utils import *
os.mkdir('build')
run_codeql_database_create(["kotlinc test.kt -d build", "javac User.java -cp build"], lang="java")

View File

@@ -0,0 +1,4 @@
import java
from MethodAccess ma
select ma, ma.getCallee().toString(), ma.getCallee().getAParamType().toString()