mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Support unbound callable function references in inliner
This commit is contained in:
18
compiler/testData/codegen/bytecodeText/callableReference/boundFieldReferenceInInline.kt
vendored
Normal file
18
compiler/testData/codegen/bytecodeText/callableReference/boundFieldReferenceInInline.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// FILE: JClass.java
|
||||
|
||||
public class JClass {
|
||||
public int field;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun box(): String {
|
||||
return if (call(10, JClass()::field) == 5) "OK" else "fail"
|
||||
}
|
||||
|
||||
inline fun call(p: Int, s: () -> Int): Int {
|
||||
return s()
|
||||
}
|
||||
|
||||
// 1 NEW JClass
|
||||
// 1 NEW
|
||||
17
compiler/testData/codegen/bytecodeText/callableReference/boundFunReferenceInInline.kt
vendored
Normal file
17
compiler/testData/codegen/bytecodeText/callableReference/boundFunReferenceInInline.kt
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun box(): String {
|
||||
return if (call(10, A()::calc) == 5) "OK" else "fail"
|
||||
}
|
||||
|
||||
class A {
|
||||
fun calc(p: Int): Int {
|
||||
return p / 2
|
||||
}
|
||||
}
|
||||
|
||||
inline fun call(p: Int, s: (Int) -> Int): Int {
|
||||
return s(p)
|
||||
}
|
||||
|
||||
// 1 NEW A
|
||||
// 1 NEW
|
||||
16
compiler/testData/codegen/bytecodeText/callableReference/boundPropertyReferenceInInline.kt
vendored
Normal file
16
compiler/testData/codegen/bytecodeText/callableReference/boundPropertyReferenceInInline.kt
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun box(): String {
|
||||
return if (call(A(10)::calc) == 5) "OK" else "fail"
|
||||
}
|
||||
|
||||
class A(val p: Int) {
|
||||
val calc: Int
|
||||
get() = p / 2
|
||||
}
|
||||
|
||||
inline fun call( s: () -> Int): Int {
|
||||
return s()
|
||||
}
|
||||
|
||||
// 1 NEW A
|
||||
// 1 NEW
|
||||
16
compiler/testData/codegen/bytecodeText/callableReference/unboundFieldReferenceInInline.kt
vendored
Normal file
16
compiler/testData/codegen/bytecodeText/callableReference/unboundFieldReferenceInInline.kt
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// FILE: JClass.java
|
||||
|
||||
public class JClass {
|
||||
public static int field;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun box(): String {
|
||||
return if (call(10, JClass::field) == 5) "OK" else "fail"
|
||||
}
|
||||
|
||||
inline fun call(p: Int, s: () -> Int): Int {
|
||||
return s()
|
||||
}
|
||||
|
||||
// 0 NEW
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
fun box(): String {
|
||||
return if (call(10, ::calc) == 5) "OK" else "fail"
|
||||
}
|
||||
12
compiler/testData/codegen/bytecodeText/callableReference/unboundPropertyReferenceInInline.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/callableReference/unboundPropertyReferenceInInline.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
fun box(): String {
|
||||
return if (call(10, Int::calc) == 5) "OK" else "fail"
|
||||
}
|
||||
|
||||
val Int.calc: Int
|
||||
get() = this / 2
|
||||
|
||||
inline fun call(p: Int, s: (Int) -> Int): Int {
|
||||
return s(p)
|
||||
}
|
||||
|
||||
// 0 NEW
|
||||
Reference in New Issue
Block a user