Add source mapping tests for default lambda inlining
This commit is contained in:
@@ -657,7 +657,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
|||||||
@NotNull
|
@NotNull
|
||||||
public DefaultSourceMapper getOrCreateSourceMapper() {
|
public DefaultSourceMapper getOrCreateSourceMapper() {
|
||||||
if (sourceMapper == null) {
|
if (sourceMapper == null) {
|
||||||
// note: this is used for in InlineCodegen and the element is always physical (KtElement) there
|
// note: this is used in InlineCodegen and the element is always physical (KtElement) there
|
||||||
sourceMapper = new DefaultSourceMapper(SourceInfo.Companion.createInfo((KtElement)element, getClassName()));
|
sourceMapper = new DefaultSourceMapper(SourceInfo.Companion.createInfo((KtElement)element, getClassName()));
|
||||||
}
|
}
|
||||||
return sourceMapper;
|
return sourceMapper;
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
package test
|
||||||
|
|
||||||
|
inline fun inlineFun(capturedParam: String, noinline lambda: () -> String = { capturedParam }): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
//NO_CHECK_LAMBDA_INLINING
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun("OK")
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1.smap
|
||||||
|
//TODO maybe do smth with default method body mapping
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
5#1:9
|
||||||
|
*E
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt$inlineFun$1
|
||||||
|
*L
|
||||||
|
1#1,8:1
|
||||||
|
*E
|
||||||
|
|
||||||
|
// FILE: 2.TODO
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||||
|
package test
|
||||||
|
|
||||||
|
@Suppress("NOT_YET_SUPPORTED_IN_INLINE")
|
||||||
|
inline fun inlineFun(capturedParam: String, crossinline lambda: () -> String = { capturedParam }): String {
|
||||||
|
return {
|
||||||
|
lambda()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun("OK")
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1.smap
|
||||||
|
//TODO maybe do smth with default method body mapping
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt
|
||||||
|
*L
|
||||||
|
1#1,12:1
|
||||||
|
7#1:13
|
||||||
|
*E
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt$inlineFun$2
|
||||||
|
*L
|
||||||
|
1#1,12:1
|
||||||
|
*E
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt$inlineFun$1
|
||||||
|
*L
|
||||||
|
1#1,12:1
|
||||||
|
*E
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1.kt
|
||||||
|
test/_1Kt
|
||||||
|
*L
|
||||||
|
1#1,9:1
|
||||||
|
6#2,2:10
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
6#1,2:10
|
||||||
|
*E
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt$inlineFun$2
|
||||||
|
+ 2 1.kt
|
||||||
|
test/_1Kt$inlineFun$1
|
||||||
|
*L
|
||||||
|
1#1,12:1
|
||||||
|
6#2:13
|
||||||
|
*E
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||||
|
package test
|
||||||
|
|
||||||
|
@Suppress("NOT_YET_SUPPORTED_IN_INLINE")
|
||||||
|
inline fun inlineFun(capturedParam: String, lambda: () -> String = { capturedParam }): String {
|
||||||
|
return lambda()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return inlineFun("OK")
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 1.smap
|
||||||
|
//TODO maybe do smth with default method body mapping
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt
|
||||||
|
*L
|
||||||
|
1#1,10:1
|
||||||
|
7#1:11
|
||||||
|
*E
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
1.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 1.kt
|
||||||
|
test/_1Kt$inlineFun$1
|
||||||
|
*L
|
||||||
|
1#1,10:1
|
||||||
|
*E
|
||||||
|
|
||||||
|
// FILE: 2.smap
|
||||||
|
|
||||||
|
SMAP
|
||||||
|
2.kt
|
||||||
|
Kotlin
|
||||||
|
*S Kotlin
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
+ 2 1.kt
|
||||||
|
test/_1Kt
|
||||||
|
*L
|
||||||
|
1#1,9:1
|
||||||
|
6#2,2:10
|
||||||
|
*E
|
||||||
|
*S KotlinDebug
|
||||||
|
*F
|
||||||
|
+ 1 2.kt
|
||||||
|
_2Kt
|
||||||
|
*L
|
||||||
|
6#1,2:10
|
||||||
|
*E
|
||||||
@@ -2375,6 +2375,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultFunction.kt")
|
||||||
|
public void testDefaultFunction() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("oneFile.kt")
|
@TestMetadata("oneFile.kt")
|
||||||
public void testOneFile() throws Exception {
|
public void testOneFile() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
||||||
@@ -2450,6 +2456,27 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class DefaultLambda extends AbstractBlackBoxInlineCodegenTest {
|
||||||
|
public void testAllFilesPresentInDefaultLambda() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/defaultLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nested.kt")
|
||||||
|
public void testNested() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/nested.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
+27
@@ -2375,6 +2375,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("defaultFunction.kt")
|
||||||
|
public void testDefaultFunction() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultFunction.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("oneFile.kt")
|
@TestMetadata("oneFile.kt")
|
||||||
public void testOneFile() throws Exception {
|
public void testOneFile() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/oneFile.kt");
|
||||||
@@ -2450,6 +2456,27 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class DefaultLambda extends AbstractCompileKotlinAgainstInlineKotlinTest {
|
||||||
|
public void testAllFilesPresentInDefaultLambda() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/defaultLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nested.kt")
|
||||||
|
public void testNested() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/nested.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("simple.kt")
|
||||||
|
public void testSimple() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")
|
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user