JVM_IR indy-SAM conversions: minor updates
See: KT-44575 KT-44577 KT-44278 KT-26060 KT-42621
This commit is contained in:
+6
@@ -18475,6 +18475,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/primitiveVsWrapperInSam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConversionInsideSamConvertedLambda.kt")
|
||||
public void testSamConversionInsideSamConvertedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionInsideSamConvertedLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConversionOnFunctionReference.kt")
|
||||
public void testSamConversionOnFunctionReference() throws Exception {
|
||||
|
||||
+5
-9
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.backend.common.lower.parents
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.representativeUpperBound
|
||||
import org.jetbrains.kotlin.backend.jvm.ir.*
|
||||
import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi
|
||||
import org.jetbrains.kotlin.config.JvmSamConversions
|
||||
@@ -170,15 +169,12 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
private fun IrType.isProhibitedTypeForIndySamConversion(): Boolean {
|
||||
if (this !is IrSimpleType) return false
|
||||
|
||||
val erasedType = when (val classifier = classifier.owner) {
|
||||
is IrTypeParameter ->
|
||||
classifier.representativeUpperBound.withHasQuestionMark(hasQuestionMark)
|
||||
else ->
|
||||
this
|
||||
val erasedClass = when (val classifier = classifier.owner) {
|
||||
is IrTypeParameter -> classifier.erasedUpperBound
|
||||
is IrClass -> classifier
|
||||
else -> throw AssertionError("Unexpected classifier: ${classifier.render()}")
|
||||
}
|
||||
val erasedClass = erasedType.getClass() ?: return false
|
||||
|
||||
if (!erasedType.isInlined()) return false
|
||||
if (!erasedClass.isInline) return false
|
||||
|
||||
val underlyingType = getInlineClassUnderlyingType(erasedClass) as? IrSimpleType
|
||||
?: throw AssertionError("Underlying type for inline class should be a simple type: ${erasedClass.render()}")
|
||||
|
||||
+3
@@ -92,6 +92,9 @@ where advanced options include:
|
||||
profilerPath is a path to libasyncProfiler.so
|
||||
Example: -Xprofile=<PATH_TO_ASYNC_PROFILER>/async-profiler/build/libasyncProfiler.so:event=cpu,interval=1ms,threads,start,framebuf=50000000:<SNAPSHOT_DIR_PATH>
|
||||
-Xrepeat=<number> Debug option: Repeats modules compilation <number> times
|
||||
-Xsam-conversions={class|indy} Select code generation scheme for SAM conversions.
|
||||
-Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 8` or greater.
|
||||
-Xsam-conversions=class Generate SAM conversions as explicit classes
|
||||
-Xsanitize-parentheses Transform '(' and ')' in method names to some other character sequence.
|
||||
This mode can BREAK BINARY COMPATIBILITY and is only supposed to be used to workaround
|
||||
problems with parentheses in identifiers on certain platforms
|
||||
|
||||
Vendored
+2
@@ -1,4 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
|
||||
Vendored
+2
@@ -1,4 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
|
||||
compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNAny.kt
Vendored
+2
@@ -1,4 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
|
||||
compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNInt.kt
Vendored
+2
@@ -1,4 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
|
||||
fun interface IFoo {
|
||||
fun foo(k: String): String
|
||||
}
|
||||
|
||||
fun fooK(iFoo: IFoo) = iFoo.foo("K")
|
||||
|
||||
fun box() =
|
||||
fooK {
|
||||
fooK {
|
||||
fooK { k -> "O" + k }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// WITH_RUNTIME
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// WITH_RUNTIME
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// !LANGUAGE: +SuspendFunctionsInFunInterfaces +JvmIrEnabledByDefault
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_LIGHT_ANALYSIS
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// WITH_RUNTIME
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// JVM_TARGET: 1.8
|
||||
// SAM_CONVERSIONS: INDY
|
||||
// WITH_RUNTIME
|
||||
|
||||
+6
@@ -18475,6 +18475,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/primitiveVsWrapperInSam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConversionInsideSamConvertedLambda.kt")
|
||||
public void testSamConversionInsideSamConvertedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionInsideSamConvertedLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConversionOnFunctionReference.kt")
|
||||
public void testSamConversionOnFunctionReference() throws Exception {
|
||||
|
||||
+6
@@ -18475,6 +18475,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/primitiveVsWrapperInSam.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConversionInsideSamConvertedLambda.kt")
|
||||
public void testSamConversionInsideSamConvertedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionInsideSamConvertedLambda.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("samConversionOnFunctionReference.kt")
|
||||
public void testSamConversionOnFunctionReference() throws Exception {
|
||||
|
||||
+40
-35
@@ -16125,6 +16125,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Sam extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("suspendFunInterface.kt")
|
||||
public void ignoreSuspendFunInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
@@ -16198,6 +16203,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/primitiveVsWrapperInSam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("samConversionInsideSamConvertedLambda.kt")
|
||||
public void testSamConversionInsideSamConvertedLambda() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionInsideSamConvertedLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("samConversionOnFunctionReference.kt")
|
||||
public void testSamConversionOnFunctionReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/samConversionOnFunctionReference.kt");
|
||||
@@ -16223,11 +16233,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/streamApi2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunInterface.kt")
|
||||
public void testSuspendFunInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/suspendFunInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unboundFunctionReferenceEquality.kt")
|
||||
public void testUnboundFunctionReferenceEquality() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/unboundFunctionReferenceEquality.kt");
|
||||
@@ -16270,6 +16275,36 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class InlineClassInSignature extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("funInterfaceWithInlineAny.kt")
|
||||
public void ignoreFunInterfaceWithInlineAny() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineInt.kt")
|
||||
public void ignoreFunInterfaceWithInlineInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineNAny.kt")
|
||||
public void ignoreFunInterfaceWithInlineNAny() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineNInt.kt")
|
||||
public void ignoreFunInterfaceWithInlineNInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineNString.kt")
|
||||
public void ignoreFunInterfaceWithInlineNString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineString.kt")
|
||||
public void ignoreFunInterfaceWithInlineString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineString.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
@@ -16278,36 +16313,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineAny.kt")
|
||||
public void testFunInterfaceWithInlineAny() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineInt.kt")
|
||||
public void testFunInterfaceWithInlineInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineNAny.kt")
|
||||
public void testFunInterfaceWithInlineNAny() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNAny.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineNInt.kt")
|
||||
public void testFunInterfaceWithInlineNInt() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineNString.kt")
|
||||
public void testFunInterfaceWithInlineNString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineNString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("funInterfaceWithInlineString.kt")
|
||||
public void testFunInterfaceWithInlineString() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/funInterfaceWithInlineString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericFunInterfaceWithInlineAny.kt")
|
||||
public void testGenericFunInterfaceWithInlineAny() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/invokedynamic/sam/inlineClassInSignature/genericFunInterfaceWithInlineAny.kt");
|
||||
|
||||
Reference in New Issue
Block a user