Add new test on receiver clash during default lambda inlining
This commit is contained in:
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
inline fun String.inlineFun(crossinline lambda: () -> String = { this }): String {
|
||||
return {
|
||||
this + lambda()
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val result = "OK".inlineFun()
|
||||
return if (result == "OKOK") "OK" else "fail 1: $result"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
inline fun String.inlineFun(crossinline lambda: () -> String, crossinline dlambda: () -> String = { this }): String {
|
||||
return {
|
||||
"${this} ${lambda()} ${dlambda()}"
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun String.test(): String = "INLINE".inlineFun({ this })
|
||||
|
||||
fun box(): String {
|
||||
val result = "TEST".test()
|
||||
return if (result == "INLINE TEST INLINE") "OK" else "fail 1: $result"
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
class A(val value: String) {
|
||||
|
||||
inline fun String.inlineFun(crossinline lambda: () -> String = { this }): String {
|
||||
return {
|
||||
"$value ${this} ${lambda()}"
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
//WITH_RUNTIME
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val result = with(A("VALUE")) { "OK".inlineFun() }
|
||||
return if (result == "VALUE OK OK") "OK" else "fail 1: $result"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
class A(val value: String) {
|
||||
|
||||
inline fun String.inlineFun(crossinline lambda: () -> String, crossinline dlambda: () -> String = { this }): String {
|
||||
return {
|
||||
"$value ${this} ${lambda()} ${dlambda()}"
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
//WIH_RUNTIME
|
||||
import test.*
|
||||
|
||||
fun String.test(): String = with(A("VALUE")) { "INLINE".inlineFun({ this@test }) }
|
||||
|
||||
fun box(): String {
|
||||
val result = "TEST".test()
|
||||
return if (result == "VALUE INLINE TEST INLINE") "OK" else "fail 1: $result"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
inline fun inlineFun(param: String, lambda: String.() -> String = { this }): String {
|
||||
return param.lambda()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return inlineFun("OK")
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
inline fun String.inlineFun(crossinline lambda: () -> String = { { this }() }): String {
|
||||
return {
|
||||
{
|
||||
this + lambda()
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val result = "OK".inlineFun()
|
||||
return if (result == "OKOK") "OK" else "fail 1: $result"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: 1.kt
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
package test
|
||||
|
||||
class A(val value: String) {
|
||||
inline fun String.inlineFun(crossinline lambda: () -> String = { { this }() }): String {
|
||||
return {
|
||||
{
|
||||
this + lambda()
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
//WITH_RUNTIME
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val result = with(A("VALUE")) { "OK".inlineFun() }
|
||||
return if (result == "OKOK") "OK" else "fail 1: $result"
|
||||
}
|
||||
@@ -997,6 +997,30 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClash.kt")
|
||||
public void testReceiverClash() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClash.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClash2.kt")
|
||||
public void testReceiverClash2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClash2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClashInClass.kt")
|
||||
public void testReceiverClashInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClashInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClashInClass2.kt")
|
||||
public void testReceiverClashInClass2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClashInClass2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/simple.kt");
|
||||
@@ -1015,6 +1039,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleExtension.kt")
|
||||
public void testSimpleExtension() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/simpleExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleGeneric.kt")
|
||||
public void testSimpleGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/simpleGeneric.kt");
|
||||
@@ -1027,6 +1057,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("thisClash.kt")
|
||||
public void testThisClash() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/thisClash.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("thisClashInClass.kt")
|
||||
public void testThisClashInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/thisClashInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+42
@@ -997,6 +997,30 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClash.kt")
|
||||
public void testReceiverClash() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClash.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClash2.kt")
|
||||
public void testReceiverClash2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClash2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClashInClass.kt")
|
||||
public void testReceiverClashInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClashInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("receiverClashInClass2.kt")
|
||||
public void testReceiverClashInClass2() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/receiverClashInClass2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/simple.kt");
|
||||
@@ -1015,6 +1039,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleExtension.kt")
|
||||
public void testSimpleExtension() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/simpleExtension.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleGeneric.kt")
|
||||
public void testSimpleGeneric() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/simpleGeneric.kt");
|
||||
@@ -1027,6 +1057,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("thisClash.kt")
|
||||
public void testThisClash() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/thisClash.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("thisClashInClass.kt")
|
||||
public void testThisClashInClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/thisClashInClass.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/callableReferences")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user