FIR: fix Clonable detection condition in inline checker

This commit is contained in:
pyos
2022-11-02 13:02:35 +01:00
committed by Mikhail Glukhikh
parent cdbbead157
commit fbb54f0300
6 changed files with 40 additions and 2 deletions
@@ -38,7 +38,6 @@ object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
private val javaLangFqName = FqName("java.lang")
private val cloneableFqName = FqName("Cloneable")
@Suppress("NAME_SHADOWING")
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
if (!declaration.symbol.isInlineOrValueClass()) {
return
@@ -274,5 +273,5 @@ object FirInlineClassDeclarationChecker : FirRegularClassChecker() {
private fun ClassId.isCloneableId(): Boolean =
relativeClassName == cloneableFqName &&
packageFqName == StandardClassIds.BASE_KOTLIN_PACKAGE || packageFqName == javaLangFqName
(packageFqName == StandardClassIds.BASE_KOTLIN_PACKAGE || packageFqName == javaLangFqName)
}
@@ -21515,6 +21515,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollectionGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@Test
@TestMetadata("inlineClassImplementsJavaLangInterface.kt")
public void testInlineClassImplementsJavaLangInterface() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsJavaLangInterface.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@Test
@TestMetadata("inlineClassInInitBlock.kt")
public void testInlineClassInInitBlock() throws Exception {
@@ -0,0 +1,16 @@
// TARGET_BACKEND: JVM
// FULL_JDK
// WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses
OPTIONAL_JVM_INLINE_ANNOTATION
value class InlineRunnable(val block: () -> Unit) : Runnable {
override fun run() = block()
}
fun box(): String {
var result = "fail"
(InlineRunnable { result = "OK" } as Runnable).run()
return result
}
@@ -20765,6 +20765,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollectionGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@Test
@TestMetadata("inlineClassImplementsJavaLangInterface.kt")
public void testInlineClassImplementsJavaLangInterface() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsJavaLangInterface.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@Test
@TestMetadata("inlineClassInInitBlock.kt")
public void testInlineClassInInitBlock() throws Exception {
@@ -21515,6 +21515,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollectionGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@Test
@TestMetadata("inlineClassImplementsJavaLangInterface.kt")
public void testInlineClassImplementsJavaLangInterface() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsJavaLangInterface.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@Test
@TestMetadata("inlineClassInInitBlock.kt")
public void testInlineClassInInitBlock() throws Exception {
@@ -17470,6 +17470,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsCollectionGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@TestMetadata("inlineClassImplementsJavaLangInterface.kt")
public void testInlineClassImplementsJavaLangInterface() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassImplementsJavaLangInterface.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());
}
@TestMetadata("inlineClassInInitBlock.kt")
public void testInlineClassInInitBlock() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassInInitBlock.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal());