Kotlin: add test to show suspend function inconsistency between source and bytecode extraction

This commit is contained in:
Tamas Vajk
2022-09-19 13:13:41 +02:00
parent a6e44ed1cf
commit 85d883c647
7 changed files with 72 additions and 6 deletions

View File

@@ -0,0 +1,4 @@
package kotlin.coroutines;
// This is a stub for the Kotlin Continuation interface.
public interface Continuation<T> { }

View File

@@ -1,5 +1,19 @@
import kotlin.coroutines.Continuation;
public class Java {
void javaFun() {
new Kotlin().kotlinFun();
}
public class Djava extends Base {
@Override
public String fn0(int x) {
return super.fn0(x);
}
@Override
public Object fn1(int x, Continuation<? super String> $completion) {
return super.fn1(x, $completion);
}
}
}

View File

@@ -3,3 +3,13 @@ public class Kotlin {
// TODO: Java().javaFun();
}
}
open class Base {
open fun fn0(x: Int) : String = ""
open suspend fun fn1(x: Int) : String = ""
}
class Dkotlin : Base() {
override fun fn0(x: Int): String = super.fn0(x)
override suspend fun fn1(x: Int): String = super.fn1(x)
}

View File

@@ -1 +0,0 @@
| Java.java:3:3:3:26 | kotlinFun(...) | Kotlin.kt:2:2:4:2 | kotlinFun |

View File

@@ -1,5 +0,0 @@
import java
from MethodAccess ma, Method m
where m = ma.getMethod()
select ma, m

View File

@@ -0,0 +1,23 @@
methods
| Java.java:4:7:4:13 | javaFun | javaFun() |
| Java.java:10:17:10:19 | fn0 | fn0(int) |
| Java.java:15:17:15:19 | fn1 | fn1(int,kotlin.coroutines.Continuation) |
| Kotlin.kt:2:2:4:2 | kotlinFun | kotlinFun() |
| Kotlin.kt:8:10:8:38 | fn0 | fn0(int) |
| Kotlin.kt:9:18:9:46 | fn1 | fn1(int) |
| Kotlin.kt:13:14:13:51 | fn0 | fn0(int) |
| Kotlin.kt:14:22:14:59 | fn1 | fn1(int) |
overrides
| Java.java:10:17:10:19 | fn0 | Kotlin.kt:8:10:8:38 | fn0 |
| Java.java:15:17:15:19 | fn1 | java_and_kotlin.testproj/test.class.files/Base.class:0:0:0:0 | fn1 |
| Kotlin.kt:13:14:13:51 | fn0 | Kotlin.kt:8:10:8:38 | fn0 |
| Kotlin.kt:14:22:14:59 | fn1 | Kotlin.kt:9:18:9:46 | fn1 |
signature_mismatch
| Kotlin.kt:9:18:9:46 | fn1 | fn1(int) |
| java_and_kotlin.testproj/test.class.files/Base.class:0:0:0:0 | fn1 | fn1(int,kotlin.coroutines.Continuation) |
#select
| Java.java:5:3:5:26 | kotlinFun(...) | Kotlin.kt:2:2:4:2 | kotlinFun |
| Java.java:11:11:11:22 | fn0(...) | Kotlin.kt:8:10:8:38 | fn0 |
| Java.java:16:11:16:35 | fn1(...) | java_and_kotlin.testproj/test.class.files/Base.class:0:0:0:0 | fn1 |
| Kotlin.kt:13:46:13:51 | fn0(...) | Kotlin.kt:8:10:8:38 | fn0 |
| Kotlin.kt:14:54:14:59 | fn1(...) | Kotlin.kt:9:18:9:46 | fn1 |

View File

@@ -0,0 +1,21 @@
import java
from MethodAccess ma, Method m
where m = ma.getMethod()
select ma, m
query predicate methods(Method m, string sig) {
m.fromSource() and
m.getSignature() = sig
}
query predicate overrides(Method m1, Method m2) {
m1.fromSource() and
m1.overrides(m2)
}
query predicate signature_mismatch(Method m, string sig) {
m.getDeclaringType().getQualifiedName() = "Base" and
m.getName() = "fn1" and
m.getSignature() = sig
}