From 12caf5d743501ba8e179f6810eb9656a6b1fbfb3 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 13 Jan 2021 18:18:14 +0300 Subject: [PATCH 001/122] Fix test BE JvmBoxRunner to be able to see FIR BB tests exceptions --- .../kotlin/test/backend/handlers/JvmBoxRunner.kt | 9 ++++++++- .../org/jetbrains/kotlin/codegen/CodegenTestUtil.java | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt index 714a5978738..9cbf73360da 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBoxRunner.kt @@ -76,7 +76,14 @@ class JvmBoxRunner(testServices: TestServices) : JvmBinaryArtifactHandler(testSe callBoxMethodAndCheckResult(classLoader, clazz, method, unexpectedBehaviour) } catch (e: Throwable) { if (reportProblems) { - println(factory.createText()) + try { + println(factory.createText()) + } catch (_: Throwable) { + // In FIR we have factory which can't print bytecode + // and it throws exception otherwise. So we need + // ignore that exception to report original one + // TODO: fix original problem + } } throw e } finally { diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java index a83a33699df..d5a39012f2f 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/codegen/CodegenTestUtil.java @@ -218,8 +218,15 @@ public class CodegenTestUtil { } catch (Throwable e) { if (reportProblems) { - System.err.println(file.asText()); - System.err.println(classNode.name + "::" + method.name + method.desc); + try { + System.err.println(file.asText()); + System.err.println(classNode.name + "::" + method.name + method.desc); + } catch (Throwable ex) { + // In FIR we have factory which can't print bytecode + // and it throws exception otherwise. So we need + // ignore that exception to report original one + // TODO: fix original problem + } //noinspection InstanceofCatchParameter if (e instanceof AnalyzerException) { From 3787018e40b04814fe10e6adeaba503bef8c81b0 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 14 Jan 2021 14:31:13 +0300 Subject: [PATCH 002/122] [FIR] Fix parameter index storage in contract serializer --- .../jetbrains/kotlin/fir/serialization/FirContractSerializer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirContractSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirContractSerializer.kt index 2e1a404b597..035e997908f 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirContractSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirContractSerializer.kt @@ -178,7 +178,7 @@ class FirContractSerializer { ): ProtoBuf.Expression.Builder { val builder = ProtoBuf.Expression.newBuilder() - val indexOfParameter = valueParameterReference.parameterIndex + val indexOfParameter = valueParameterReference.parameterIndex + 1 builder.valueParameterReference = indexOfParameter return builder From 795bd26eaf9841cef7f94c75b398f5a59662f738 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 15 Jan 2021 13:45:54 +0300 Subject: [PATCH 003/122] FIR bootstrap: don't use -Werror in useFIR mode --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index cb474bf66bf..971679c1dc2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -470,7 +470,7 @@ allprojects { } } - if (!kotlinBuildProperties.isInJpsBuildIdeaSync) { + if (!kotlinBuildProperties.isInJpsBuildIdeaSync && !kotlinBuildProperties.useFir) { // For compiler and stdlib, allWarningsAsErrors is configured in the corresponding "root" projects // (compiler/build.gradle.kts and libraries/commonConfiguration.gradle). val projectsWithWarningsAsErrors = listOf("core", "plugins").map { File(it).absoluteFile } From 6cee4e968e63f6e3d98f6948252ba5fa0f74b726 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 13 Jan 2021 15:00:00 +0300 Subject: [PATCH 004/122] [FIR] Don't call componentX for anonymous destructuring entry --- .../fir/lightTree/converter/ConverterUtil.kt | 1 + .../converter/DeclarationsConverter.kt | 5 +++-- .../lightTree/fir/DestructuringDeclaration.kt | 2 +- .../kotlin/fir/builder/PsiConversionUtils.kt | 1 + .../rawBuilder/expressions/destructuring.kt | 4 ++++ .../expressions/destructuring.lazyBodies.txt | 1 + .../rawBuilder/expressions/destructuring.txt | 5 +++++ .../RawFirBuilderTotalKotlinTestCase.kt | 1 + .../underscoreNames.kt | 1 - .../UnderscoreNamesDontCallComponent.kt | 1 - .../ForLoopMissingLoopParameter.fir.kt | 2 +- ...turingDeclarationAssignedUnresolved.fir.kt | 2 +- ...turingDeclarationMissingInitializer.fir.kt | 2 +- .../underscore.fir.kt | 14 ++++++------- .../destructuringInLambdas/underscore.fir.kt | 20 +++++++++---------- .../destructuringWithUnderscore.fir.kt.txt | 1 - .../destructuringWithUnderscore.fir.txt | 4 ---- .../lambdas/destructuringInLambda.fir.kt.txt | 1 - .../lambdas/destructuringInLambda.fir.txt | 3 --- 19 files changed, 37 insertions(+), 34 deletions(-) diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt index b86ece21490..ee93104dd3c 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ConverterUtil.kt @@ -112,6 +112,7 @@ fun generateDestructuringBlock( } val isVar = multiDeclaration.isVar for ((index, entry) in multiDeclaration.entries.withIndex()) { + if (entry == null) continue statements += buildProperty { this.session = session origin = FirDeclarationOrigin.Source diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 1482b8696ea..283b1afb22b 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -1068,7 +1068,7 @@ class DeclarationsConverter( */ private fun convertDestructingDeclaration(destructingDeclaration: LighterASTNode): DestructuringDeclaration { var isVar = false - val entries = mutableListOf>() + val entries = mutableListOf?>() val source = destructingDeclaration.toFirSourceElement() var firExpression: FirExpression = buildErrorExpression(null, ConeSimpleDiagnostic("Initializer required for destructuring declaration", DiagnosticKind.Syntax)) @@ -1087,7 +1087,7 @@ class DeclarationsConverter( /** * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseMultiDeclarationName */ - private fun convertDestructingDeclarationEntry(entry: LighterASTNode): FirVariable<*> { + private fun convertDestructingDeclarationEntry(entry: LighterASTNode): FirVariable<*>? { var modifiers = Modifier() var identifier: String? = null var firType: FirTypeRef? = null @@ -1099,6 +1099,7 @@ class DeclarationsConverter( } } + if (identifier == "_") return null val name = identifier.nameAsSafeName() return buildProperty { source = entry.toFirSourceElement() diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt index 765246daee9..19c69a3a418 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/fir/DestructuringDeclaration.kt @@ -14,7 +14,7 @@ import org.jetbrains.kotlin.fir.lightTree.converter.generateDestructuringBlock data class DestructuringDeclaration( val isVar: Boolean, - val entries: List>, + val entries: List?>, val initializer: FirExpression, val source: FirSourceElement ) { diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt index 0764dad252d..289c9af8859 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/PsiConversionUtils.kt @@ -96,6 +96,7 @@ internal fun generateDestructuringBlock( } val isVar = multiDeclaration.isVar for ((index, entry) in multiDeclaration.entries.withIndex()) { + if (entry.nameIdentifier?.text == "_") continue val entrySource = entry.toFirPsiSourceElement() val name = entry.nameAsSafeName statements += buildProperty { diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt index cbd1e4c459d..3153d704733 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt @@ -6,4 +6,8 @@ fun foo(some: Some) { x++ y *= 2.0 z = "" +} + +fun bar(some: Some) { + val (a, _, `_`) = some } \ No newline at end of file diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt index 448ffb13fdc..be3cbea5662 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt @@ -23,3 +23,4 @@ FILE: destructuring.kt } public? final? fun foo(some: Some): R|kotlin/Unit| { LAZY_BLOCK } + public? final? fun bar(some: Some): R|kotlin/Unit| { LAZY_BLOCK } diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt index e57b8b034fa..e912e0574ac 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -33,3 +33,8 @@ FILE: destructuring.kt *=(y#, Double(2.0)) z# = String() } + public? final? fun bar(some: Some): R|kotlin/Unit| { + lval : = some# + lval a: = R|/|.component1#() + lval _: = R|/|.component3#() + } diff --git a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt index 351c4bd85bb..635204ce4c5 100644 --- a/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt +++ b/compiler/fir/raw-fir/psi2fir/tests/org/jetbrains/kotlin/fir/builder/RawFirBuilderTotalKotlinTestCase.kt @@ -264,6 +264,7 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() { it.getStrictParentOfType() != null || it.getStrictParentOfType() != null || (it is KtPropertyAccessor && !it.hasBody()) || + it is KtDestructuringDeclarationEntry && it.text == "_" || it is KtConstantExpression && it.parent.let { parent -> parent is KtPrefixExpression && (parent.operationToken == KtTokens.MINUS || parent.operationToken == KtTokens.PLUS) } diff --git a/compiler/testData/codegen/box/destructuringDeclInLambdaParam/underscoreNames.kt b/compiler/testData/codegen/box/destructuringDeclInLambdaParam/underscoreNames.kt index 70e03674326..8db07f7778e 100644 --- a/compiler/testData/codegen/box/destructuringDeclInLambdaParam/underscoreNames.kt +++ b/compiler/testData/codegen/box/destructuringDeclInLambdaParam/underscoreNames.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { operator fun component1() = "O" operator fun component2(): String = throw RuntimeException("fail 0") diff --git a/compiler/testData/codegen/box/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt b/compiler/testData/codegen/box/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt index 4495ab9f6d5..644125c9809 100644 --- a/compiler/testData/codegen/box/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt +++ b/compiler/testData/codegen/box/multiDecl/forRange/UnderscoreNamesDontCallComponent.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A { operator fun component1() = "O" operator fun component2(): String = throw RuntimeException("fail 0") diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt index 9bbbd640e91..0bc48dd8f5b 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt @@ -7,7 +7,7 @@ fun useDeclaredVariables() { } fun checkersShouldRun() { - for ((@A a, _)) { + for ((@A a, _)) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt index d4235c70ed3..da599329974 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt @@ -5,7 +5,7 @@ fun useDeclaredVariables() { } fun checkersShouldRun() { - val (@A a, _) = unresolved + val (@A a, _) = unresolved } annotation class A diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt index d1b014c2579..307dc46e555 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt @@ -5,7 +5,7 @@ fun useDeclaredVariables() { } fun checkersShouldRun() { - val (@A a, _) + val (@A a, _) } annotation class A diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.fir.kt index 10556a5c3dc..5760a1440ba 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/underscore.fir.kt @@ -11,31 +11,31 @@ class C { fun test() { for ((x, _) in C()) { - foo(x, _) + foo(x, _) } for ((_, y) in C()) { - foo(_, y) + foo(_, y) } for ((_, _) in C()) { - foo(_, _) + foo(_, _) } for ((_ : Int, _ : String) in C()) { - foo(_, _) + foo(_, _) } for ((_ : String, _ : Int) in C()) { - foo(_, _) + foo(_, _) } val (x, _) = A() val (_, y) = A() foo(x, y) - foo(x, _) - foo(_, y) + foo(x, _) + foo(_, y) val (`_`, z) = A() diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt index f08a2af15d7..0dda6673162 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt @@ -8,39 +8,39 @@ fun foo(block: (A) -> Unit) { } fun bar() { foo { (_, b) -> - _.hashCode() + _.hashCode() b checkType { _() } } foo { (a, _) -> a checkType { _() } - _.hashCode() + _.hashCode() } foo { (_, _) -> - _.hashCode() + _.hashCode() } foo { (_: Int, b: String) -> - _.hashCode() + _.hashCode() b checkType { _() } } foo { (a: Int, _: String) -> a checkType { _() } - _.hashCode() + _.hashCode() } foo { (_: Int, _: String) -> - _.hashCode() + _.hashCode() } foo { (_, _): A -> - _.hashCode() + _.hashCode() } foo { (`_`, _) -> - _ checkType { _() } + _ checkType { _() } } foo { (_, `_`) -> @@ -52,12 +52,12 @@ fun bar() { } foo { (_: String, b) -> - _.hashCode() + _.hashCode() b checkType { _() } } foo { (_, b): B -> - _.hashCode() + _.hashCode() b checkType { _() } } } diff --git a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.kt.txt b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.kt.txt index dff11a75023..ae855d61c3d 100644 --- a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.kt.txt @@ -31,6 +31,5 @@ object B { fun B.test() { val : A = A val x: Int = (, ).component1() - val _: Int = (, ).component2() val z: Int = (, ).component3() } diff --git a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt index d7408b4e2cc..efb3de95417 100644 --- a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt +++ b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt @@ -64,10 +64,6 @@ FILE fqName: fileName:/destructuringWithUnderscore.kt CALL 'public final fun component1 (): kotlin.Int [operator] declared in .B' type=kotlin.Int origin=null $this: GET_VAR ': .B declared in .test' type=.B origin=null $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test' type=.A origin=null - VAR name:_ type:kotlin.Int [val] - CALL 'public final fun component2 (): kotlin.Int [operator] declared in .B' type=kotlin.Int origin=null - $this: GET_VAR ': .B declared in .test' type=.B origin=null - $receiver: GET_VAR 'val tmp_0: .A [val] declared in .test' type=.A origin=null VAR name:z type:kotlin.Int [val] CALL 'public final fun component3 (): kotlin.Int [operator] declared in .B' type=kotlin.Int origin=null $this: GET_VAR ': .B declared in .test' type=.B origin=null diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt index 801757a9b58..23eb3ba3ee1 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt @@ -56,7 +56,6 @@ data class A { var fn: Function1 field = local fun (: A): Int { - val _: Int = .component1() val y: Int = .component2() return 42.plus(other = y) } diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt index ea4206cd8b8..f47ca804e57 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt @@ -142,9 +142,6 @@ FILE fqName: fileName:/destructuringInLambda.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (:.A) returnType:kotlin.Int VALUE_PARAMETER name: index:0 type:.A BLOCK_BODY - VAR name:_ type:kotlin.Int [val] - CALL 'public final fun component1 (): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: GET_VAR ': .A declared in .fn.' type=.A origin=null VAR name:y type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int declared in .A' type=kotlin.Int origin=null $this: GET_VAR ': .A declared in .fn.' type=.A origin=null From 9f06c1a500a856bbca298d7db9a6aed9e5ca9fb5 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 14 Jan 2021 18:26:32 +0300 Subject: [PATCH 005/122] FIR cleanup: runResolverForDelegatingConstructor --- .../resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt | 2 +- .../body/resolve/FirExpressionsResolveTransformer.kt | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 96063040316..655c3f8994e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -289,7 +289,7 @@ class FirCallResolver( fun resolveDelegatingConstructorCall( delegatedConstructorCall: FirDelegatedConstructorCall, constructedType: ConeClassLikeType - ): FirDelegatedConstructorCall? { + ): FirDelegatedConstructorCall { val name = Name.special("") val symbol = constructedType.lookupTag.toSymbol(components.session) val typeArguments = diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 1c186683cf5..62c48e0ceb6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -809,9 +809,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform else -> return delegatedConstructorCall.compose() } - val resolvedCall = - callResolver.resolveDelegatingConstructorCall(delegatedConstructorCall, constructorType) - ?: return delegatedConstructorCall.compose() + val resolvedCall = callResolver.resolveDelegatingConstructorCall(delegatedConstructorCall, constructorType) if (reference is FirThisReference && reference.boundSymbol == null) { resolvedCall.dispatchReceiver.typeRef.coneTypeSafe()?.lookupTag?.toSymbol(session)?.let { reference.replaceBoundSymbol(it) From f282c3e5474cf11d149a92cf3060eaf85cbec593 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 14 Jan 2021 18:39:16 +0300 Subject: [PATCH 006/122] Cleanup: FirTowerResolveTask --- .../kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt index 5d1d8bfde07..f3f765ab45a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/FirTowerResolveTask.kt @@ -16,13 +16,11 @@ import org.jetbrains.kotlin.fir.resolve.FirTowerDataContext import org.jetbrains.kotlin.fir.resolve.calls.* import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction -import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST -import java.util.* internal class TowerDataElementsForName( From f85fc47383bb1ba0c0933c11742c147927cd8117 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 14 Jan 2021 18:23:05 +0300 Subject: [PATCH 007/122] FIR: introduce separate companion object resolve context Before this commit, during the resolve of companion objects we used the same context than for any nested class. However, during companion object resolve we should not have companion object receiver itself accessible in any case (in particular, it should not be accessible in constructor). So in this commit we introduced separate context for this purpose. --- .../selfReferenceToCompanionObject.fir.txt | 36 +++++++++++++++++++ .../selfReferenceToCompanionObject.kt | 9 +++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++++ .../fir/resolve/BodyResolveComponents.kt | 1 + .../body/resolve/BodyResolveContext.kt | 3 ++ .../FirDeclarationsResolveTransformer.kt | 28 ++++++++------- ...ectInInlineLambdaInSuperConstructorCall.kt | 1 - ...ectInInlineLambdaInSuperConstructorCall.kt | 1 - ...nionObjectSuperConstructorArguments.fir.kt | 19 ---------- ...ompanionObjectSuperConstructorArguments.kt | 1 + 10 files changed, 72 insertions(+), 33 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt delete mode 100644 compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt new file mode 100644 index 00000000000..52c10711859 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt @@ -0,0 +1,36 @@ +FILE: selfReferenceToCompanionObject.kt + public abstract class Base : R|kotlin/Any| { + public constructor(fn: R|() -> kotlin/String|): R|Base| { + super() + } + + public final val fn: R|() -> kotlin/String| = R|/fn| + public get(): R|() -> kotlin/String| + + } + public final class Host : R|kotlin/Any| { + public constructor(): R|Host| { + super() + } + + public final companion object Companion : R|Base| { + private constructor(): R|Host.Companion| { + super(R|kotlin/run| kotlin/String|>( = run@fun (): R|() -> kotlin/String| { + ^ run@fun (): R|kotlin/String| { + ^ Q|Host|.R|/Host.Companion.ok|() + } + + } + )) + } + + public final fun ok(): R|kotlin/String| { + ^ok String(OK) + } + + } + + } + public final fun box(): R|kotlin/String| { + ^box Q|Host.Companion|.R|/Base.fn|.R|SubstitutionOverride|() + } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt new file mode 100644 index 00000000000..0d2dcfa78a4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt @@ -0,0 +1,9 @@ +abstract class Base(val fn: () -> String) + +class Host { + companion object : Base(run { { Host.ok() } }) { + fun ok() = "OK" + } +} + +fun box() = Host.Companion.fn() diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 65e5c6b13af..adb9a067766 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -4889,6 +4889,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/receiverResolutionInLambda.kt"); } + @Test + @TestMetadata("selfReferenceToCompanionObject.kt") + public void testSelfReferenceToCompanionObject() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt"); + } + @Test @TestMetadata("SpecialCallsWithLambdas.kt") public void testSpecialCallsWithLambdas() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/BodyResolveComponents.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/BodyResolveComponents.kt index 886de9e44da..38c4a2d54a9 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/BodyResolveComponents.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/BodyResolveComponents.kt @@ -143,6 +143,7 @@ typealias TowerDataContextForAnonymousFunctions = Map String) class Host { diff --git a/compiler/testData/codegen/box/objects/selfReferenceToInterfaceCompanionObjectInInlineLambdaInSuperConstructorCall.kt b/compiler/testData/codegen/box/objects/selfReferenceToInterfaceCompanionObjectInInlineLambdaInSuperConstructorCall.kt index c0f50527d87..226506094b2 100644 --- a/compiler/testData/codegen/box/objects/selfReferenceToInterfaceCompanionObjectInInlineLambdaInSuperConstructorCall.kt +++ b/compiler/testData/codegen/box/objects/selfReferenceToInterfaceCompanionObjectInInlineLambdaInSuperConstructorCall.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR abstract class Base(val fn: () -> String) interface Host { diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.fir.kt deleted file mode 100644 index 6de00281a0b..00000000000 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.fir.kt +++ /dev/null @@ -1,19 +0,0 @@ -open class S(val a: Any, val b: Any, val c: Any) {} - -interface A { - companion object : S(prop1, prop2, func()) { - val prop1 = 1 - val prop2: Int - get() = 1 - fun func() {} - } -} - -class B { - companion object : S(prop1, prop2, func()) { - val prop1 = 1 - val prop2: Int - get() = 1 - fun func() {} - } -} diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.kt index 2eb3300447f..f03b9903174 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/companionObjectSuperConstructorArguments.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL open class S(val a: Any, val b: Any, val c: Any) {} interface A { From 9a5791ad6d8e66bd6baae2c859620bf1f1e5e016 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 15 Jan 2021 18:37:06 +0300 Subject: [PATCH 008/122] FIR: use correct context for enum entry resolve Now the same resolve context is used for enum entries and for constructors. --- .../selfReferenceToCompanionObject.fir.txt | 49 +++++++++++++++++++ .../selfReferenceToCompanionObject.kt | 11 +++++ .../body/resolve/FirBodyResolveTransformer.kt | 4 ++ .../FirDeclarationsResolveTransformer.kt | 6 +++ .../codegen/box/enum/kt20651_inlineLambda.kt | 1 - 5 files changed, 70 insertions(+), 1 deletion(-) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt index 52c10711859..70951a63eaa 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.fir.txt @@ -30,6 +30,55 @@ FILE: selfReferenceToCompanionObject.kt } + } + public final enum class Test : R|kotlin/Enum| { + private constructor(x: R|kotlin/String|, closure1: R|() -> kotlin/String|): R|Test| { + super|>() + } + + public final val x: R|kotlin/String| = R|/x| + public get(): R|kotlin/String| + + public final val closure1: R|() -> kotlin/String| = R|/closure1| + public get(): R|() -> kotlin/String| + + public final static enum entry FOO: R|Test| = object : R|Test| { + private constructor(): R|| { + super(String(O), this@R|kotlin/Enum.Companion|.R|kotlin/run| kotlin/String|>( = run@fun R|kotlin/Enum.Companion|.(): R|() -> kotlin/String| { + ^ run@fun (): R|kotlin/String| { + ^ R|/Test.FOO|.R|/Test.x| + } + + } + )) + } + + public final override val y: R|kotlin/String| = String(K) + public get(): R|kotlin/String| + + public final val closure2: R|() -> kotlin/String| = fun (): R|kotlin/String| { + ^ this@R|/|.R|/.y| + } + + public get(): R|() -> kotlin/String| + + public final override val z: R|kotlin/String| = this@R|/|.R|/.closure2|.R|SubstitutionOverride|() + public get(): R|kotlin/String| + + } + + public abstract val y: R|kotlin/String| + public get(): R|kotlin/String| + + public abstract val z: R|kotlin/String| + public get(): R|kotlin/String| + + public final static fun values(): R|kotlin/Array| { + } + + public final static fun valueOf(value: R|kotlin/String|): R|Test| { + } + } public final fun box(): R|kotlin/String| { ^box Q|Host.Companion|.R|/Base.fn|.R|SubstitutionOverride|() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt index 0d2dcfa78a4..107b41f7310 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/selfReferenceToCompanionObject.kt @@ -6,4 +6,15 @@ class Host { } } +enum class Test(val x: String, val closure1: () -> String) { + FOO("O", run { { FOO.x } }) { + override val y: String = "K" + val closure2 = { y } // Implicit 'FOO' + override val z: String = closure2() + }; + + abstract val y: String + abstract val z: String +} + fun box() = Host.Companion.fn() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt index 59618303921..3243455d96b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt @@ -250,6 +250,10 @@ open class FirBodyResolveTransformer( return declarationsTransformer.transformDeclarationStatus(declarationStatus, data) } + override fun transformEnumEntry(enumEntry: FirEnumEntry, data: ResolutionMode): CompositeTransformResult { + return declarationsTransformer.transformEnumEntry(enumEntry, data) + } + override fun transformProperty(property: FirProperty, data: ResolutionMode): CompositeTransformResult { return declarationsTransformer.transformProperty(property, data) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 42e5189ef16..b160becbf98 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -99,6 +99,12 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor } } + override fun transformEnumEntry(enumEntry: FirEnumEntry, data: ResolutionMode): CompositeTransformResult { + context.withTowerDataContext(context.getTowerDataContextForConstructorResolution()) { + return (enumEntry.transformChildren(this, data) as FirEnumEntry).compose() + } + } + override fun transformProperty(property: FirProperty, data: ResolutionMode): CompositeTransformResult { require(property !is FirSyntheticProperty) { "Synthetic properties should not be processed by body transfromers" } diff --git a/compiler/testData/codegen/box/enum/kt20651_inlineLambda.kt b/compiler/testData/codegen/box/enum/kt20651_inlineLambda.kt index dbaefe3c9b2..d1f12734575 100644 --- a/compiler/testData/codegen/box/enum/kt20651_inlineLambda.kt +++ b/compiler/testData/codegen/box/enum/kt20651_inlineLambda.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR enum class Test(val x: String, val closure1: () -> String) { FOO("O", run { { FOO.x } }) { override val y: String = "K" From bf5feb1b4a716ab96ee828af0206dff9688eaa79 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmair Date: Mon, 18 Jan 2021 08:49:30 +0000 Subject: [PATCH 009/122] Remove KotlinMetadataTarget's KotlinTargetComponent in favour of KotlinSoftwareComponent.kt ^KT-44322 fixed --- .../kotlin/gradle/NewMultiplatformIT.kt | 60 ++++---- .../dsl/KotlinMultiplatformExtension.kt | 7 +- .../gradle/dsl/KotlinProjectExtension.kt | 20 +-- .../gradle/plugin/mpp/KotlinMetadataTarget.kt | 62 +-------- .../plugin/mpp/KotlinMultiplatformPlugin.kt | 110 --------------- .../plugin/mpp/KotlinSoftwareComponent.kt | 91 +++++++++--- .../kotlin/gradle/plugin/mpp/Publishing.kt | 131 ++++++++++++++++++ .../KotlinMetadataTargetConfigurator.kt | 1 + 8 files changed, 259 insertions(+), 223 deletions(-) create mode 100644 libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/Publishing.kt diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt index 7f098031483..83dec6bfea6 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/NewMultiplatformIT.kt @@ -714,16 +714,18 @@ class NewMultiplatformIT : BaseGradleIT() { } } - gradleBuildScript().appendText("\n" + """ + gradleBuildScript().appendText( + "\n" + """ kotlin.sourceSets.all { it.languageSettings { languageVersion = '1.3' apiVersion = '1.3' } } - """.trimIndent()) + """.trimIndent() + ) - listOf( "compileKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach { + listOf("compileKotlinMetadata", "compileKotlinJvm6", "compileKotlinNodeJs").forEach { build(it) { assertSuccessful() assertTasksExecuted(":$it") @@ -1015,15 +1017,20 @@ class NewMultiplatformIT : BaseGradleIT() { assertSuccessful() val groupDir = projectDir.resolve("repo/com/example/") - val targetArtifactIdAppendices = listOf("metadata", "jvm6", "nodejs", "linux64") + val targetArtifactIdAppendices = listOf(null, "jvm6", "nodejs", "linux64") - val sourceJarSourceRoots = targetArtifactIdAppendices.associate { artifact -> - val sourcesJar = JarFile(groupDir.resolve("sample-lib-$artifact/1.0/sample-lib-$artifact-1.0-sources.jar")) + val sourceJarSourceRoots = targetArtifactIdAppendices.associateWith { artifact -> + val sourcesJarPath = if (artifact != null) "sample-lib-$artifact/1.0/sample-lib-$artifact-1.0-sources.jar" + else "sample-lib/1.0/sample-lib-1.0-sources.jar" + val sourcesJar = JarFile(groupDir.resolve(sourcesJarPath)) val sourcesDirs = sourcesJar.entries().asSequence().map { it.name.substringBefore("/") }.toSet() - "META-INF" - artifact to sourcesDirs + sourcesDirs } - assertEquals(setOf("commonMain"), sourceJarSourceRoots["metadata"]) + assertEquals( + setOf("commonMain", "jvm6Main", "linux64Main", "macos64Main", "mingw64Main", "mingw86Main", "nodeJsMain"), + sourceJarSourceRoots[null] + ) assertEquals(setOf("commonMain", "jvm6Main"), sourceJarSourceRoots["jvm6"]) assertEquals(setOf("commonMain", "nodeJsMain"), sourceJarSourceRoots["nodejs"]) assertEquals(setOf("commonMain", "linux64Main"), sourceJarSourceRoots["linux64"]) @@ -1361,26 +1368,29 @@ class NewMultiplatformIT : BaseGradleIT() { fun testDependenciesDsl() = with(transformProjectWithPluginsDsl("newMppDependenciesDsl")) { val originalBuildscriptContent = gradleBuildScript("app").readText() - fun testDependencies() = testResolveAllConfigurations("app", options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) { - assertContains(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata --> junit-4.12.jar") - assertEquals( - 1, - (Regex.escape(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata") + " .*").toRegex().findAll(output).count() - ) + fun testDependencies() = + testResolveAllConfigurations("app", options = defaultBuildOptions().copy(warningMode = WarningMode.Summary)) { + assertContains(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata --> junit-4.12.jar") + assertEquals( + 1, + (Regex.escape(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata") + " .*").toRegex().findAll(output) + .count() + ) - assertContains(">> :app:testNonTransitiveDependencyNotationApiDependenciesMetadata --> kotlin-reflect-${defaultBuildOptions().kotlinVersion}.jar") - assertEquals( - 1, - (Regex.escape(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata") + " .*").toRegex().findAll(output).count() - ) + assertContains(">> :app:testNonTransitiveDependencyNotationApiDependenciesMetadata --> kotlin-reflect-${defaultBuildOptions().kotlinVersion}.jar") + assertEquals( + 1, + (Regex.escape(">> :app:testNonTransitiveStringNotationApiDependenciesMetadata") + " .*").toRegex().findAll(output) + .count() + ) - assertContains(">> :app:testExplicitKotlinVersionApiDependenciesMetadata --> kotlin-reflect-1.3.0.jar") - assertContains(">> :app:testExplicitKotlinVersionImplementationDependenciesMetadata --> kotlin-reflect-1.2.71.jar") - assertContains(">> :app:testExplicitKotlinVersionCompileOnlyDependenciesMetadata --> kotlin-reflect-1.2.70.jar") - assertContains(">> :app:testExplicitKotlinVersionRuntimeOnlyDependenciesMetadata --> kotlin-reflect-1.2.60.jar") + assertContains(">> :app:testExplicitKotlinVersionApiDependenciesMetadata --> kotlin-reflect-1.3.0.jar") + assertContains(">> :app:testExplicitKotlinVersionImplementationDependenciesMetadata --> kotlin-reflect-1.2.71.jar") + assertContains(">> :app:testExplicitKotlinVersionCompileOnlyDependenciesMetadata --> kotlin-reflect-1.2.70.jar") + assertContains(">> :app:testExplicitKotlinVersionRuntimeOnlyDependenciesMetadata --> kotlin-reflect-1.2.60.jar") - assertContains(">> :app:testProjectWithConfigurationApiDependenciesMetadata --> output.txt") - } + assertContains(">> :app:testProjectWithConfigurationApiDependenciesMetadata --> output.txt") + } testDependencies() diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt index a846453e646..c882900a9d3 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinMultiplatformExtension.kt @@ -8,12 +8,13 @@ package org.jetbrains.kotlin.gradle.dsl import groovy.lang.Closure import org.gradle.api.InvalidUserCodeException import org.gradle.api.NamedDomainObjectCollection +import org.gradle.api.Project import org.gradle.util.ConfigureUtil import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.plugin.mpp.* -open class KotlinMultiplatformExtension : - KotlinProjectExtension(), +open class KotlinMultiplatformExtension(project: Project) : + KotlinProjectExtension(project), KotlinTargetContainerWithPresetFunctions, KotlinTargetContainerWithJsPresetFunctions, KotlinTargetContainerWithNativeShortcuts { @@ -50,7 +51,7 @@ open class KotlinMultiplatformExtension : fun targetFromPreset(preset: KotlinTargetPreset<*>, configure: Closure<*>) = targetFromPreset(preset, preset.name, configure) internal val rootSoftwareComponent: KotlinSoftwareComponent by lazy { - KotlinSoftwareComponentWithCoordinatesAndPublication("kotlin", targets) + KotlinSoftwareComponentWithCoordinatesAndPublication(project, "kotlin", targets) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt index f43a5d6a426..d09ee4071e1 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinProjectExtension.kt @@ -26,7 +26,7 @@ import kotlin.reflect.KClass private const val KOTLIN_PROJECT_EXTENSION_NAME = "kotlin" internal fun Project.createKotlinExtension(extensionClass: KClass): KotlinProjectExtension { - val kotlinExt = extensions.create(KOTLIN_PROJECT_EXTENSION_NAME, extensionClass.java) + val kotlinExt = extensions.create(KOTLIN_PROJECT_EXTENSION_NAME, extensionClass.java, this) DslObject(kotlinExt).extensions.create("experimental", ExperimentalExtension::class.java) return kotlinExtension } @@ -43,7 +43,7 @@ internal val Project.multiplatformExtensionOrNull: KotlinMultiplatformExtension? internal val Project.multiplatformExtension: KotlinMultiplatformExtension get() = extensions.getByName(KOTLIN_PROJECT_EXTENSION_NAME) as KotlinMultiplatformExtension -open class KotlinProjectExtension : KotlinSourceSetContainer { +open class KotlinProjectExtension(internal val project: Project) : KotlinSourceSetContainer { val experimental: ExperimentalExtension get() = DslObject(this).extensions.getByType(ExperimentalExtension::class.java) @@ -67,32 +67,32 @@ open class KotlinProjectExtension : KotlinSourceSetContainer { } } -abstract class KotlinSingleTargetExtension : KotlinProjectExtension() { +abstract class KotlinSingleTargetExtension(project: Project) : KotlinProjectExtension(project) { abstract val target: KotlinTarget open fun target(body: Closure) = ConfigureUtil.configure(body, target) } -abstract class KotlinSingleJavaTargetExtension : KotlinSingleTargetExtension() { +abstract class KotlinSingleJavaTargetExtension(project: Project) : KotlinSingleTargetExtension(project) { abstract override val target: KotlinWithJavaTarget<*> } -open class KotlinJvmProjectExtension : KotlinSingleJavaTargetExtension() { +open class KotlinJvmProjectExtension(project: Project) : KotlinSingleJavaTargetExtension(project) { override lateinit var target: KotlinWithJavaTarget internal set open fun target(body: KotlinWithJavaTarget.() -> Unit) = target.run(body) } -open class Kotlin2JsProjectExtension : KotlinSingleJavaTargetExtension() { +open class Kotlin2JsProjectExtension(project: Project) : KotlinSingleJavaTargetExtension(project) { override lateinit var target: KotlinWithJavaTarget internal set open fun target(body: KotlinWithJavaTarget.() -> Unit) = target.run(body) } -open class KotlinJsProjectExtension : - KotlinSingleTargetExtension(), +open class KotlinJsProjectExtension(project: Project) : + KotlinSingleTargetExtension(project), KotlinJsCompilerTypeHolder { lateinit var irPreset: KotlinJsIrSingleTargetPreset @@ -224,14 +224,14 @@ open class KotlinJsProjectExtension : } } -open class KotlinCommonProjectExtension : KotlinSingleJavaTargetExtension() { +open class KotlinCommonProjectExtension(project: Project) : KotlinSingleJavaTargetExtension(project) { override lateinit var target: KotlinWithJavaTarget internal set open fun target(body: KotlinWithJavaTarget.() -> Unit) = target.run(body) } -open class KotlinAndroidProjectExtension : KotlinSingleTargetExtension() { +open class KotlinAndroidProjectExtension(project: Project) : KotlinSingleTargetExtension(project) { override lateinit var target: KotlinAndroidTarget internal set diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMetadataTarget.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMetadataTarget.kt index 9dad926fe98..e0d7989f6a6 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMetadataTarget.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMetadataTarget.kt @@ -15,8 +15,6 @@ import org.jetbrains.kotlin.gradle.targets.metadata.isCompatibilityMetadataVaria import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled import javax.inject.Inject -internal const val COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME = "commonMainMetadataElements" - open class KotlinMetadataTarget @Inject constructor(project: Project) : KotlinOnlyTarget>(project, KotlinPlatformType.common) { @@ -29,57 +27,11 @@ open class KotlinMetadataTarget @Inject constructor(project: Project) : get() = super.artifactsTaskName override val kotlinComponents: Set by lazy { - if (!project.isKotlinGranularMetadataEnabled) - super.kotlinComponents - else { - val usageContexts = mutableSetOf() - - // This usage value is only needed for Maven scope mapping. Don't replace it with a custom Kotlin Usage value - val javaApiUsage = project.usageByName("java-api-jars") - - usageContexts += run { - val allMetadataJar = project.tasks.named(KotlinMetadataTargetConfigurator.ALL_METADATA_JAR_NAME) - val allMetadataArtifact = project.artifacts.add(Dependency.ARCHIVES_CONFIGURATION, allMetadataJar) { - it.classifier = if (project.isCompatibilityMetadataVariantEnabled) "all" else "" - } - - DefaultKotlinUsageContext( - compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME), - javaApiUsage, - apiElementsConfigurationName, - overrideConfigurationArtifacts = setOf(allMetadataArtifact) - ) - } - - if (PropertiesProvider(project).enableCompatibilityMetadataVariant == true) { - // Ensure that consumers who expect Kotlin 1.2.x metadata package can still get one: - // publish the old metadata artifact: - usageContexts += run { - DefaultKotlinUsageContext( - compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME), - javaApiUsage, - /** this configuration is created by [KotlinMetadataTargetConfigurator.createCommonMainElementsConfiguration] */ - COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME - ) - } - } - - val component = - createKotlinVariant(targetName, compilations.getByName(KotlinCompilation.MAIN_COMPILATION_NAME), usageContexts).apply { - publishable = false // this component is not published on its own, its variants are included in the 'root' module - } - - val sourcesJarTask = - sourcesJarTask(project, lazy { project.kotlinExtension.sourceSets.toSet() }, null, targetName.toLowerCase()) - - component.sourcesArtifacts = setOf( - project.artifacts.add(Dependency.ARCHIVES_CONFIGURATION, sourcesJarTask).apply { - this as ConfigurablePublishArtifact - classifier = "sources" - } - ) - - setOf(component) - } + /* + Metadata Target does not have a KotlinTargetComponent on it's own. + Responsibility is shifted to the root KotlinSoftwareComponent + */ + emptySet() } -} \ No newline at end of file +} + diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt index 167b83fca05..ebc24f0297d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinMultiplatformPlugin.kt @@ -200,116 +200,6 @@ class KotlinMultiplatformPlugin( } } - private fun configurePublishingWithMavenPublish(project: Project) = project.pluginManager.withPlugin("maven-publish") { _ -> - - val targets = project.multiplatformExtension.targets - val metadataTarget = project.multiplatformExtension.metadata() - val kotlinSoftwareComponent = project.multiplatformExtension.rootSoftwareComponent - - project.extensions.configure(PublishingExtension::class.java) { publishing -> - - // The root publication that references the platform specific publications as its variants: - publishing.publications.create("kotlinMultiplatform", MavenPublication::class.java).apply { - from(kotlinSoftwareComponent) - (this as MavenPublicationInternal).publishWithOriginalFileName() - kotlinSoftwareComponent.publicationDelegate = this@apply - - metadataTarget.kotlinComponents.filterIsInstance() - .single().publicationDelegate = this@apply - - project.whenEvaluated { - if (!metadataTarget.publishable) return@whenEvaluated - metadataTarget.kotlinComponents - .flatMap { component -> component.sourcesArtifacts } - .forEach { sourcesArtifact -> artifact(sourcesArtifact) } - } - } - - // Enforce the order of creating the publications, since the metadata publication is used in the other publications: - metadataTarget.createMavenPublications(publishing.publications) - targets - .withType(AbstractKotlinTarget::class.java).matching { it.publishable && it.name != METADATA_TARGET_NAME } - .all { - if (it is KotlinAndroidTarget || it is KotlinMetadataTarget) - // Android targets have their variants created in afterEvaluate; TODO handle this better? - // Kotlin Metadata targets rely on complete source sets hierearchy and cannot be inspected for publication earlier - project.whenEvaluated { it.createMavenPublications(publishing.publications) } - else - it.createMavenPublications(publishing.publications) - } - } - - project.components.add(kotlinSoftwareComponent) - } - - private fun rewritePom( - pom: MavenPom, - pomRewriter: PomDependenciesRewriter, - shouldRewritePomDependencies: Provider, - includeOnlySpecifiedDependencies: Provider>? - ) { - pom.withXml { xml -> - if (shouldRewritePomDependencies.get()) - pomRewriter.rewritePomMppDependenciesToActualTargetModules(xml, includeOnlySpecifiedDependencies) - } - } - - private fun AbstractKotlinTarget.createMavenPublications(publications: PublicationContainer) { - components - .map { gradleComponent -> gradleComponent to kotlinComponents.single { it.name == gradleComponent.name } } - .filter { (_, kotlinComponent) -> kotlinComponent.publishable } - .forEach { (gradleComponent, kotlinComponent) -> - val componentPublication = publications.create(kotlinComponent.name, MavenPublication::class.java).apply { - // do this in whenEvaluated since older Gradle versions seem to check the files in the variant eagerly: - project.whenEvaluated { - from(gradleComponent) - kotlinComponent.sourcesArtifacts.forEach { sourceArtifact -> - artifact(sourceArtifact) - } - } - (this as MavenPublicationInternal).publishWithOriginalFileName() - artifactId = kotlinComponent.defaultArtifactId - - val pomRewriter = PomDependenciesRewriter(project, kotlinComponent) - val shouldRewritePomDependencies = - project.provider { PropertiesProvider(project).keepMppDependenciesIntactInPoms != true } - - rewritePom( - pom, - pomRewriter, - shouldRewritePomDependencies, - dependenciesForPomRewriting(this@createMavenPublications) - ) - } - - (kotlinComponent as? KotlinTargetComponentWithPublication)?.publicationDelegate = componentPublication - publicationConfigureActions.all { it.execute(componentPublication) } - } - } - - /** - * The metadata targets need their POMs to only include the dependencies from the commonMain API configuration. - * The actual apiElements configurations of metadata targets now contain dependencies from all source sets, but, as the consumers who - * can't read Gradle module metadata won't resolve a dependency on an MPP to the granular metadata variant and won't then choose the - * right dependencies for each source set, we put only the dependencies of the legacy common variant into the POM, i.e. commonMain API. - */ - private fun dependenciesForPomRewriting(target: AbstractKotlinTarget): Provider>? = - if (target !is KotlinMetadataTarget || !target.project.isKotlinGranularMetadataEnabled) - null - else { - val commonMain = target.project.kotlinExtension.sourceSets.findByName(KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) - if (commonMain == null) - null - else - target.project.provider { - val project = target.project - - // Only the commonMain API dependencies can be published for consumers who can't read Gradle project metadata - val commonMainApi = project.sourceSetDependencyConfigurationByScope(commonMain, KotlinDependencyScope.API_SCOPE) - val commonMainDependencies = commonMainApi.allDependencies - commonMainDependencies.map { ModuleCoordinates(it.group, it.name, it.version) }.toSet() - } - } private fun configureSourceSets(project: Project) = with(project.multiplatformExtension) { val production = sourceSets.create(KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinSoftwareComponent.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinSoftwareComponent.kt index ccfdaec5c5d..44c9edfea7c 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinSoftwareComponent.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/KotlinSoftwareComponent.kt @@ -17,44 +17,95 @@ import org.gradle.api.component.SoftwareComponent import org.gradle.api.internal.component.SoftwareComponentInternal import org.gradle.api.internal.component.UsageContext import org.gradle.api.publish.maven.MavenPublication -import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation -import org.jetbrains.kotlin.gradle.plugin.KotlinTarget -import org.jetbrains.kotlin.gradle.plugin.ProjectLocalConfigurations +import org.jetbrains.kotlin.gradle.dsl.kotlinExtension +import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.* +import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME +import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider +import org.jetbrains.kotlin.gradle.plugin.usageByName +import org.jetbrains.kotlin.gradle.targets.metadata.COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME +import org.jetbrains.kotlin.gradle.targets.metadata.KotlinMetadataTargetConfigurator +import org.jetbrains.kotlin.gradle.targets.metadata.isCompatibilityMetadataVariantEnabled +import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled abstract class KotlinSoftwareComponent( + private val project: Project, private val name: String, protected val kotlinTargets: Iterable ) : SoftwareComponentInternal, ComponentWithVariants { - private val metadataTarget: KotlinMetadataTarget - get() = kotlinTargets.filterIsInstance().single() - - override fun getUsages(): Set = (metadataTarget.components.single() as SoftwareComponentInternal).usages - - override fun getVariants(): Set = - kotlinTargets.minus(metadataTarget).flatMap { it.components }.toSet() - override fun getName(): String = name + override fun getVariants(): Set = kotlinTargets + .filter { target -> target !is KotlinMetadataTarget } + .flatMap { it.components }.toSet() + + private val _usages: Set by lazy { + val metadataTarget = project.multiplatformExtension.metadata() + + if (!project.isKotlinGranularMetadataEnabled) { + val metadataCompilation = metadataTarget.compilations.getByName(MAIN_COMPILATION_NAME) + return@lazy metadataTarget.createUsageContexts(metadataCompilation) + } + + mutableSetOf().apply { + // This usage value is only needed for Maven scope mapping. Don't replace it with a custom Kotlin Usage value + val javaApiUsage = project.usageByName("java-api-jars") + + val allMetadataJar = project.tasks.named(KotlinMetadataTargetConfigurator.ALL_METADATA_JAR_NAME) + val allMetadataArtifact = project.artifacts.add(Dependency.ARCHIVES_CONFIGURATION, allMetadataJar) { allMetadataArtifact -> + allMetadataArtifact.classifier = if (project.isCompatibilityMetadataVariantEnabled) "all" else "" + } + + this += DefaultKotlinUsageContext( + compilation = metadataTarget.compilations.getByName(MAIN_COMPILATION_NAME), + usage = javaApiUsage, + dependencyConfigurationName = metadataTarget.apiElementsConfigurationName, + overrideConfigurationArtifacts = setOf(allMetadataArtifact) + ) + + + if (project.isCompatibilityMetadataVariantEnabled) { + // Ensure that consumers who expect Kotlin 1.2.x metadata package can still get one: + // publish the old metadata artifact: + this += run { + DefaultKotlinUsageContext( + metadataTarget.compilations.getByName(MAIN_COMPILATION_NAME), + javaApiUsage, + /** this configuration is created by [KotlinMetadataTargetConfigurator.createCommonMainElementsConfiguration] */ + COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME + ) + } + } + } + } + + override fun getUsages(): Set { + return _usages + } + + + val sourcesArtifacts: Set by lazy { + val sourcesJarTask = sourcesJarTask(project, lazy { project.kotlinExtension.sourceSets.toSet() }, null, name.toLowerCase()) + val sourcesJarArtifact = project.artifacts.add(Dependency.ARCHIVES_CONFIGURATION, sourcesJarTask) { sourcesJarArtifact -> + sourcesJarArtifact.classifier = "sources" + } + setOf(sourcesJarArtifact) + } + // This property is declared in the parent type to allow the usages to reference it without forcing the subtypes to load, // which is needed for compatibility with older Gradle versions var publicationDelegate: MavenPublication? = null } -class KotlinSoftwareComponentWithCoordinatesAndPublication(name: String, kotlinTargets: Iterable) : - KotlinSoftwareComponent(name, kotlinTargets), ComponentWithCoordinates { +class KotlinSoftwareComponentWithCoordinatesAndPublication(project: Project, name: String, kotlinTargets: Iterable) : + KotlinSoftwareComponent(project, name, kotlinTargets), ComponentWithCoordinates { override fun getCoordinates(): ModuleVersionIdentifier = getCoordinatesFromPublicationDelegateAndProject( publicationDelegate, kotlinTargets.first().project, null ) } -// At the moment all KN artifacts have JAVA_API usage. -// TODO: Replace it with a specific usage -object NativeUsage { - const val KOTLIN_KLIB = "kotlin-klib" -} - interface KotlinUsageContext : UsageContext { val compilation: KotlinCompilation<*> val dependencyConfigurationName: String @@ -117,4 +168,4 @@ class DefaultKotlinUsageContext( override fun getCapabilities(): Set = emptySet() override fun getGlobalExcludes(): Set = emptySet() -} \ No newline at end of file +} diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/Publishing.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/Publishing.kt new file mode 100644 index 00000000000..4b6556bb3e8 --- /dev/null +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/mpp/Publishing.kt @@ -0,0 +1,131 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.gradle.plugin.mpp + +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import org.gradle.api.publish.PublicationContainer +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPom +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal +import org.jetbrains.kotlin.gradle.dsl.kotlinExtension +import org.jetbrains.kotlin.gradle.dsl.multiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider +import org.jetbrains.kotlin.gradle.plugin.sources.KotlinDependencyScope +import org.jetbrains.kotlin.gradle.plugin.sources.sourceSetDependencyConfigurationByScope +import org.jetbrains.kotlin.gradle.plugin.whenEvaluated +import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled + +internal fun configurePublishingWithMavenPublish(project: Project) = project.pluginManager.withPlugin("maven-publish") { + project.extensions.configure(PublishingExtension::class.java) { publishing -> + createRootPublication(project, publishing) + createTargetPublications(project, publishing) + } + + project.components.add(project.multiplatformExtension.rootSoftwareComponent) +} + +/** + * The root publication that references the platform specific publications as its variants + */ +private fun createRootPublication(project: Project, publishing: PublishingExtension) { + val kotlinSoftwareComponent = project.multiplatformExtension.rootSoftwareComponent + + publishing.publications.create("kotlinMultiplatform", MavenPublication::class.java).apply { + from(kotlinSoftwareComponent) + (this as MavenPublicationInternal).publishWithOriginalFileName() + kotlinSoftwareComponent.publicationDelegate = this@apply + kotlinSoftwareComponent.sourcesArtifacts.forEach { sourceArtifact -> + artifact(sourceArtifact) + } + } +} + +private fun createTargetPublications(project: Project, publishing: PublishingExtension) { + val kotlin = project.multiplatformExtension + // Enforce the order of creating the publications, since the metadata publication is used in the other publications: + kotlin.targets + .withType(AbstractKotlinTarget::class.java) + .matching { it.publishable } + .all { kotlinTarget -> + if (kotlinTarget is KotlinAndroidTarget) + // Android targets have their variants created in afterEvaluate; TODO handle this better? + project.whenEvaluated { kotlinTarget.createMavenPublications(publishing.publications) } + else + kotlinTarget.createMavenPublications(publishing.publications) + } +} + +private fun AbstractKotlinTarget.createMavenPublications(publications: PublicationContainer) { + components + .map { gradleComponent -> gradleComponent to kotlinComponents.single { it.name == gradleComponent.name } } + .filter { (_, kotlinComponent) -> kotlinComponent.publishable } + .forEach { (gradleComponent, kotlinComponent) -> + val componentPublication = publications.create(kotlinComponent.name, MavenPublication::class.java).apply { + // do this in whenEvaluated since older Gradle versions seem to check the files in the variant eagerly: + project.whenEvaluated { + from(gradleComponent) + kotlinComponent.sourcesArtifacts.forEach { sourceArtifact -> + artifact(sourceArtifact) + } + } + (this as MavenPublicationInternal).publishWithOriginalFileName() + artifactId = kotlinComponent.defaultArtifactId + + val pomRewriter = PomDependenciesRewriter(project, kotlinComponent) + val shouldRewritePomDependencies = + project.provider { PropertiesProvider(project).keepMppDependenciesIntactInPoms != true } + + rewritePom( + pom, + pomRewriter, + shouldRewritePomDependencies, + dependenciesForPomRewriting(this@createMavenPublications) + ) + } + + (kotlinComponent as? KotlinTargetComponentWithPublication)?.publicationDelegate = componentPublication + publicationConfigureActions.all { it.execute(componentPublication) } + } +} + +private fun rewritePom( + pom: MavenPom, + pomRewriter: PomDependenciesRewriter, + shouldRewritePomDependencies: Provider, + includeOnlySpecifiedDependencies: Provider>? +) { + pom.withXml { xml -> + if (shouldRewritePomDependencies.get()) + pomRewriter.rewritePomMppDependenciesToActualTargetModules(xml, includeOnlySpecifiedDependencies) + } +} + +/** + * The metadata targets need their POMs to only include the dependencies from the commonMain API configuration. + * The actual apiElements configurations of metadata targets now contain dependencies from all source sets, but, as the consumers who + * can't read Gradle module metadata won't resolve a dependency on an MPP to the granular metadata variant and won't then choose the + * right dependencies for each source set, we put only the dependencies of the legacy common variant into the POM, i.e. commonMain API. + */ +private fun dependenciesForPomRewriting(target: AbstractKotlinTarget): Provider>? = + if (target !is KotlinMetadataTarget || !target.project.isKotlinGranularMetadataEnabled) + null + else { + val commonMain = target.project.kotlinExtension.sourceSets.findByName(KotlinSourceSet.COMMON_MAIN_SOURCE_SET_NAME) + if (commonMain == null) + null + else + target.project.provider { + val project = target.project + + // Only the commonMain API dependencies can be published for consumers who can't read Gradle project metadata + val commonMainApi = project.sourceSetDependencyConfigurationByScope(commonMain, KotlinDependencyScope.API_SCOPE) + val commonMainDependencies = commonMainApi.allDependencies + commonMainDependencies.map { ModuleCoordinates(it.group, it.name, it.version) }.toSet() + } + } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt index 2d69d8d6f75..18edd842078 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/metadata/KotlinMetadataTargetConfigurator.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation import org.jetbrains.kotlin.gradle.utils.lowerCamelCaseName import org.jetbrains.kotlin.statistics.metrics.BooleanMetrics +internal const val COMMON_MAIN_ELEMENTS_CONFIGURATION_NAME = "commonMainMetadataElements" internal const val ALL_COMPILE_METADATA_CONFIGURATION_NAME = "allSourceSetsCompileDependenciesMetadata" internal const val ALL_RUNTIME_METADATA_CONFIGURATION_NAME = "allSourceSetsRuntimeDependenciesMetadata" From 167bfcf6eaadec936a397d09f2e429f7acd76bdc Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Mon, 18 Jan 2021 10:13:44 +0100 Subject: [PATCH 010/122] Minor. Remove accidentally added bunch file --- .../backend/jvm/codegen/ClassCodegen.kt.201 | 507 ------------------ 1 file changed, 507 deletions(-) delete mode 100644 compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 deleted file mode 100644 index 134d805adca..00000000000 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ClassCodegen.kt.201 +++ /dev/null @@ -1,507 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.backend.jvm.codegen - -import org.jetbrains.kotlin.backend.jvm.JvmBackendContext -import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin -import org.jetbrains.kotlin.backend.jvm.lower.MultifileFacadeFileEntry -import org.jetbrains.kotlin.backend.jvm.lower.buildAssertionsDisabledField -import org.jetbrains.kotlin.backend.jvm.lower.hasAssertionsDisabledField -import org.jetbrains.kotlin.codegen.DescriptorAsmUtil -import org.jetbrains.kotlin.codegen.inline.* -import org.jetbrains.kotlin.codegen.writeKotlinMetadata -import org.jetbrains.kotlin.config.LanguageFeature -import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.descriptors.DescriptorVisibilities -import org.jetbrains.kotlin.descriptors.DescriptorVisibility -import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.ir.builders.declarations.addFunction -import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor -import org.jetbrains.kotlin.ir.expressions.IrBlockBody -import org.jetbrains.kotlin.ir.expressions.IrConst -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrFunctionReference -import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrSetFieldImpl -import org.jetbrains.kotlin.ir.util.* -import org.jetbrains.kotlin.load.java.JvmAnnotationNames -import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader -import org.jetbrains.kotlin.metadata.jvm.serialization.JvmStringTable -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.protobuf.MessageLite -import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_RECORD_ANNOTATION_FQ_NAME -import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_SYNTHETIC_ANNOTATION_FQ_NAME -import org.jetbrains.kotlin.resolve.jvm.annotations.TRANSIENT_ANNOTATION_FQ_NAME -import org.jetbrains.kotlin.resolve.jvm.annotations.VOLATILE_ANNOTATION_FQ_NAME -import org.jetbrains.kotlin.resolve.jvm.checkers.JvmSimpleNameBacktickChecker -import org.jetbrains.kotlin.resolve.jvm.diagnostics.* -import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature -import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull -import org.jetbrains.kotlin.utils.addToStdlib.safeAs -import org.jetbrains.org.objectweb.asm.* -import org.jetbrains.org.objectweb.asm.commons.Method -import org.jetbrains.org.objectweb.asm.tree.MethodNode -import java.io.File - -interface MetadataSerializer { - fun serialize(metadata: MetadataSource): Pair? - fun bindMethodMetadata(metadata: MetadataSource.Property, signature: Method) - fun bindMethodMetadata(metadata: MetadataSource.Function, signature: Method) - fun bindFieldMetadata(metadata: MetadataSource.Property, signature: Pair) -} - -class ClassCodegen private constructor( - val irClass: IrClass, - val context: JvmBackendContext, - private val parentFunction: IrFunction?, -) : InnerClassConsumer { - private val parentClassCodegen = (parentFunction?.parentAsClass ?: irClass.parent as? IrClass)?.let { getOrCreate(it, context) } - private val withinInline: Boolean = parentClassCodegen?.withinInline == true || parentFunction?.isInline == true - - private val state get() = context.state - private val typeMapper get() = context.typeMapper - - val type: Type = typeMapper.mapClass(irClass) - - val reifiedTypeParametersUsages = ReifiedTypeParametersUsages() - - private val jvmSignatureClashDetector = JvmSignatureClashDetector(irClass, type, context) - - private val classOrigin = irClass.descriptorOrigin - - private val visitor = state.factory.newVisitor(classOrigin, type, irClass.fileParent.loadSourceFilesInfo()).apply { - val signature = typeMapper.mapClassSignature(irClass, type) - // Ensure that the backend only produces class names that would be valid in the frontend for JVM. - if (context.state.classBuilderMode.generateBodies && signature.hasInvalidName()) { - throw IllegalStateException("Generating class with invalid name '${type.className}': ${irClass.dump()}") - } - defineClass( - irClass.psiElement, - state.classFileVersion, - irClass.flags, - signature.name, - signature.javaGenericSignature, - signature.superclassName, - signature.interfaces.toTypedArray() - ) - } - - // TODO: the order of entries in this set depends on the order in which methods are generated; this means it is unstable - // under incremental compilation, as calls to `inline fun`s declared in this class cause them to be generated out of order. - private val innerClasses = linkedSetOf() - - // TODO: the names produced by generators in this map depend on the order in which methods are generated; see above. - private val regeneratedObjectNameGenerators = mutableMapOf() - - fun getRegeneratedObjectNameGenerator(function: IrFunction): NameGenerator { - val name = if (function.name.isSpecial) "special" else function.name.asString() - return regeneratedObjectNameGenerators.getOrPut(name) { - NameGenerator("${type.internalName}\$$name\$\$inlined") - } - } - - private var generated = false - - fun generate() { - // TODO: reject repeated generate() calls; currently, these can happen for objects in finally - // blocks since they are `accept`ed once per each CFG edge out of the try-finally. - if (generated) return - generated = true - - // We remove reads of `$$delegatedProperties` (and the field itself) if they are not in fact used for anything. - val delegatedProperties = irClass.fields.singleOrNull { it.origin == JvmLoweredDeclarationOrigin.GENERATED_PROPERTY_REFERENCE } - val delegatedPropertyOptimizer = if (delegatedProperties != null) DelegatedPropertyOptimizer() else null - // Generating a method node may cause the addition of a field with an initializer if an inline function - // call uses `assert` and the JVM assertions mode is enabled. To avoid concurrent modification errors, - // there is a very specific generation order. - val smap = context.getSourceMapper(irClass) - // 1. Any method other than `` can add a field and a `` statement: - for (method in irClass.declarations.filterIsInstance()) { - if (method.name.asString() != "") { - generateMethod(method, smap, delegatedPropertyOptimizer) - } - } - // 2. `` itself can add a field, but the statement is generated via the `return init` hack: - irClass.functions.find { it.name.asString() == "" }?.let { generateMethod(it, smap, delegatedPropertyOptimizer) } - // 3. Now we have all the fields (`$$delegatedProperties` might be redundant if all reads were optimized out): - for (field in irClass.fields) { - if (field !== delegatedProperties || delegatedPropertyOptimizer?.needsDelegatedProperties == true) { - generateField(field) - } - } - // 4. Generate nested classes at the end, to ensure that when the companion's metadata is serialized - // everything moved to the outer class has already been recorded in `globalSerializationBindings`. - for (declaration in irClass.declarations) { - if (declaration is IrClass) { - getOrCreate(declaration, context).generate() - } - } - - object : AnnotationCodegen(this@ClassCodegen, context) { - override fun visitAnnotation(descr: String?, visible: Boolean): AnnotationVisitor { - return visitor.visitor.visitAnnotation(descr, visible) - } - }.genAnnotations(irClass, null, null) - generateKotlinMetadataAnnotation() - - generateInnerAndOuterClasses() - - if (withinInline || !smap.isTrivial) { - visitor.visitSMAP(smap, !context.state.languageVersionSettings.supportsFeature(LanguageFeature.CorrectSourceMappingSyntax)) - } else { - smap.sourceInfo!!.sourceFileName?.let { - visitor.visitSource(it, null) - } - } - - visitor.done() - jvmSignatureClashDetector.reportErrors(classOrigin) - } - - fun generateAssertFieldIfNeeded(generatingClInit: Boolean): IrExpression? { - if (irClass.hasAssertionsDisabledField(context)) - return null - val topLevelClass = generateSequence(this) { it.parentClassCodegen }.last().irClass - val field = irClass.buildAssertionsDisabledField(context, topLevelClass) - generateField(field) - // Normally, `InitializersLowering` would move the initializer to , but - // it's obviously too late for that. - val init = IrSetFieldImpl( - field.startOffset, field.endOffset, field.symbol, null, - field.initializer!!.expression, context.irBuiltIns.unitType - ) - if (generatingClInit) { - // Too late to modify the IR; have to ask the currently active `ExpressionCodegen` - // to generate this statement directly. - return init - } - val classInitializer = irClass.functions.singleOrNull { it.name.asString() == "" } ?: irClass.addFunction { - name = Name.special("") - returnType = context.irBuiltIns.unitType - }.apply { - body = IrBlockBodyImpl(startOffset, endOffset) - } - (classInitializer.body as IrBlockBody).statements.add(0, init) - return null - } - - private val metadataSerializer: MetadataSerializer = - context.backendExtension.createSerializer( - context, irClass, type, visitor.serializationBindings, parentClassCodegen?.metadataSerializer - ) - - private fun generateKotlinMetadataAnnotation() { - // TODO: if `-Xmultifile-parts-inherit` is enabled, write the corresponding flag for parts and facades to [Metadata.extraInt]. - val extraFlags = context.backendExtension.generateMetadataExtraFlags(state.abiStability) - - val facadeClassName = context.multifileFacadeForPart[irClass.attributeOwnerId] - val metadata = irClass.metadata - val entry = irClass.fileParent.fileEntry - val kind = when { - facadeClassName != null -> KotlinClassHeader.Kind.MULTIFILE_CLASS_PART - metadata is MetadataSource.Class -> KotlinClassHeader.Kind.CLASS - metadata is MetadataSource.File -> KotlinClassHeader.Kind.FILE_FACADE - metadata is MetadataSource.Function -> KotlinClassHeader.Kind.SYNTHETIC_CLASS - entry is MultifileFacadeFileEntry -> KotlinClassHeader.Kind.MULTIFILE_CLASS - else -> KotlinClassHeader.Kind.SYNTHETIC_CLASS - } - writeKotlinMetadata(visitor, state, kind, extraFlags) { - if (metadata != null) { - metadataSerializer.serialize(metadata)?.let { (proto, stringTable) -> - DescriptorAsmUtil.writeAnnotationData(it, proto, stringTable) - } - } - - if (entry is MultifileFacadeFileEntry) { - val arv = it.visitArray(JvmAnnotationNames.METADATA_DATA_FIELD_NAME) - for (partFile in entry.partFiles) { - val fileClass = partFile.declarations.singleOrNull { it.isFileClass } as IrClass? - if (fileClass != null) arv.visit(null, typeMapper.mapClass(fileClass).internalName) - } - arv.visitEnd() - } - - if (facadeClassName != null) { - it.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME, facadeClassName.internalName) - } - - if (irClass in context.classNameOverride) { - val isFileClass = kind == KotlinClassHeader.Kind.MULTIFILE_CLASS || - kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART || - kind == KotlinClassHeader.Kind.FILE_FACADE - assert(isFileClass) { "JvmPackageName is not supported for classes: ${irClass.render()}" } - it.visit(JvmAnnotationNames.METADATA_PACKAGE_NAME_FIELD_NAME, irClass.fqNameWhenAvailable!!.parent().asString()) - } - } - } - - private fun IrFile.loadSourceFilesInfo(): List { - val entry = fileEntry - if (entry is MultifileFacadeFileEntry) { - return entry.partFiles.flatMap { it.loadSourceFilesInfo() } - } - return listOfNotNull(context.psiSourceManager.getFileEntry(this)?.let { File(it.name) }) - } - - companion object { - fun getOrCreate( - irClass: IrClass, - context: JvmBackendContext, - // The `parentFunction` is only set for classes nested inside of functions. This is usually safe, since there is no - // way to refer to (inline) members of such a class from outside of the function unless the function in question is - // itself declared as inline. In that case, the function will be compiled before we can refer to the nested class. - // - // The one exception to this rule are anonymous objects defined as members of a class. These are nested inside of the - // class initializer, but can be referred to from anywhere within the scope of the class. That's why we have to ensure - // that all references to classes inside of have a non-null `parentFunction`. - parentFunction: IrFunction? = irClass.parent.safeAs()?.takeIf { - it.origin == JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER - }, - ): ClassCodegen = - context.classCodegens.getOrPut(irClass) { ClassCodegen(irClass, context, parentFunction) }.also { - assert(parentFunction == null || it.parentFunction == parentFunction) { - "inconsistent parent function for ${irClass.render()}:\n" + - "New: ${parentFunction!!.render()}\n" + - "Old: ${it.parentFunction?.render()}" - } - } - - private fun JvmClassSignature.hasInvalidName() = - name.splitToSequence('/').any { identifier -> identifier.any { it in JvmSimpleNameBacktickChecker.INVALID_CHARS } } - } - - private fun generateField(field: IrField) { - val fieldType = typeMapper.mapType(field) - val fieldSignature = - if (field.origin == IrDeclarationOrigin.PROPERTY_DELEGATE) null - else context.methodSignatureMapper.mapFieldSignature(field) - val fieldName = field.name.asString() - val flags = field.computeFieldFlags(context, state.languageVersionSettings) - val fv = visitor.newField( - field.descriptorOrigin, flags, fieldName, fieldType.descriptor, - fieldSignature, (field.initializer?.expression as? IrConst<*>)?.value - ) - - jvmSignatureClashDetector.trackField(field, RawSignature(fieldName, fieldType.descriptor, MemberKind.FIELD)) - - if (field.origin != JvmLoweredDeclarationOrigin.CONTINUATION_CLASS_RESULT_FIELD) { - val skipNullabilityAnnotations = - flags and (Opcodes.ACC_SYNTHETIC or Opcodes.ACC_ENUM) != 0 || - field.origin == JvmLoweredDeclarationOrigin.FIELD_FOR_STATIC_CALLABLE_REFERENCE_INSTANCE - object : AnnotationCodegen(this@ClassCodegen, context, skipNullabilityAnnotations) { - override fun visitAnnotation(descr: String?, visible: Boolean): AnnotationVisitor { - return fv.visitAnnotation(descr, visible) - } - - override fun visitTypeAnnotation(descr: String?, path: TypePath?, visible: Boolean): AnnotationVisitor { - return fv.visitTypeAnnotation(TypeReference.newTypeReference(TypeReference.FIELD).value, path, descr, visible) - } - }.genAnnotations(field, fieldType, field.type) - } - - (field.metadata as? MetadataSource.Property)?.let { - metadataSerializer.bindFieldMetadata(it, fieldType to fieldName) - } - - if (irClass.hasAnnotation(JVM_RECORD_ANNOTATION_FQ_NAME) && !field.isStatic) { - // TODO: Write annotations to the component - // visitor.newRecordComponent(fieldName, fieldType.descriptor, fieldSignature) - } - } - - private val generatedInlineMethods = mutableMapOf() - - fun generateMethodNode(method: IrFunction): SMAPAndMethodNode { - if (!method.isInline && !method.isSuspendCapturingCrossinline()) { - // Inline methods can be used multiple times by `IrSourceCompilerForInline`, suspend methods - // are used twice (`f` and `f$$forInline`) if they capture crossinline lambdas, and everything - // else is only generated by `generateMethod` below so does not need caching. - // TODO: inline lambdas are not marked `isInline`, and are generally used once, but may be needed - // multiple times if declared in a `finally` block - should they be cached? - return FunctionCodegen(method, this).generate() - } - val (node, smap) = generatedInlineMethods.getOrPut(method) { FunctionCodegen(method, this).generate() } - val copy = with(node) { MethodNode(Opcodes.API_VERSION, access, name, desc, signature, exceptions.toTypedArray()) } - node.instructions.resetLabels() - node.accept(copy) - return SMAPAndMethodNode(copy, smap) - } - - private fun generateMethod(method: IrFunction, classSMAP: SourceMapper, delegatedPropertyOptimizer: DelegatedPropertyOptimizer?) { - if (method.isFakeOverride) { - jvmSignatureClashDetector.trackFakeOverrideMethod(method) - return - } - - val (node, smap) = generateMethodNode(method) - if (delegatedPropertyOptimizer != null) { - delegatedPropertyOptimizer.transform(node) - if (method.name.asString() == "") { - delegatedPropertyOptimizer.transformClassInitializer(node) - } - } - node.preprocessSuspendMarkers( - method.origin == JvmLoweredDeclarationOrigin.FOR_INLINE_STATE_MACHINE_TEMPLATE || method.isEffectivelyInlineOnly(), - method.origin == JvmLoweredDeclarationOrigin.FOR_INLINE_STATE_MACHINE_TEMPLATE_CAPTURES_CROSSINLINE - ) - val mv = with(node) { visitor.newMethod(method.descriptorOrigin, access, name, desc, signature, exceptions.toTypedArray()) } - val smapCopier = SourceMapCopier(classSMAP, smap) - val smapCopyingVisitor = object : MethodVisitor(Opcodes.API_VERSION, mv) { - override fun visitLineNumber(line: Int, start: Label) = - super.visitLineNumber(smapCopier.mapLineNumber(line), start) - } - if (method.hasContinuation()) { - // Generate a state machine within this method. The continuation class for it should be generated - // lazily so that if tail call optimization kicks in, the unused class will not be written to the output. - val continuationClass = method.continuationClass() // null if `SuspendLambda.invokeSuspend` - `this` is continuation itself - val continuationClassCodegen = lazy { if (continuationClass != null) getOrCreate(continuationClass, context, method) else this } - - // For suspend lambdas continuation class is null, and we need to use containing class to put L$ fields - val attributeContainer = continuationClass?.attributeOwnerId ?: irClass.attributeOwnerId - - node.acceptWithStateMachine( - method, - this, - smapCopyingVisitor, - context.continuationClassesVarsCountByType[attributeContainer] ?: emptyMap() - ) { - continuationClassCodegen.value.visitor - } - - if (continuationClass != null && (continuationClassCodegen.isInitialized() || method.isSuspendCapturingCrossinline())) { - continuationClassCodegen.value.generate() - } - } else { - node.accept(smapCopyingVisitor) - } - jvmSignatureClashDetector.trackMethod(method, RawSignature(node.name, node.desc, MemberKind.METHOD)) - - when (val metadata = method.metadata) { - is MetadataSource.Property -> { - assert(method.origin == JvmLoweredDeclarationOrigin.SYNTHETIC_METHOD_FOR_PROPERTY_OR_TYPEALIAS_ANNOTATIONS) { - "MetadataSource.Property on IrFunction should only be used for synthetic \$annotations methods: ${method.render()}" - } - metadataSerializer.bindMethodMetadata(metadata, Method(node.name, node.desc)) - } - is MetadataSource.Function -> metadataSerializer.bindMethodMetadata(metadata, Method(node.name, node.desc)) - null -> Unit - else -> error("Incorrect metadata source $metadata for:\n${method.dump()}") - } - } - - private fun generateInnerAndOuterClasses() { - // JVMS7 (4.7.6): a nested class or interface member will have InnerClasses information - // for each enclosing class and for each immediate member - parentClassCodegen?.innerClasses?.add(irClass) - for (codegen in generateSequence(this) { it.parentClassCodegen }.takeWhile { it.parentClassCodegen != null }) { - innerClasses.add(codegen.irClass) - } - - // JVMS7 (4.7.7): A class must have an EnclosingMethod attribute if and only if - // it is a local class or an anonymous class. - // - // The attribute contains the innermost class that encloses the declaration of - // the current class. If the current class is immediately enclosed by a method - // or constructor, the name and type of the function is recorded as well. - if (parentClassCodegen != null) { - // In case there's no primary constructor, it's unclear which constructor should be the enclosing one, so we select the first. - val enclosingFunction = if (irClass.attributeOwnerId in context.isEnclosedInConstructor) { - val containerClass = parentClassCodegen.irClass - containerClass.primaryConstructor - ?: containerClass.declarations.firstIsInstanceOrNull() - ?: error("Class in a non-static initializer found, but container has no constructors: ${containerClass.render()}") - } else parentFunction - if (enclosingFunction != null || irClass.isAnonymousObject) { - val method = enclosingFunction?.let(context.methodSignatureMapper::mapAsmMethod) - visitor.visitOuterClass(parentClassCodegen.type.internalName, method?.name, method?.descriptor) - } - } - - for (klass in innerClasses) { - val innerClass = typeMapper.classInternalName(klass) - val outerClass = - if (klass.attributeOwnerId in context.isEnclosedInConstructor) null - else klass.parent.safeAs()?.let(typeMapper::classInternalName) - val innerName = klass.name.takeUnless { it.isSpecial }?.asString() - visitor.visitInnerClass(innerClass, outerClass, innerName, klass.calculateInnerClassAccessFlags(context)) - } - } - - override fun addInnerClassInfoFromAnnotation(innerClass: IrClass) { - // It's necessary for proper recovering of classId by plain string JVM descriptor when loading annotations - // See FileBasedKotlinClass.convertAnnotationVisitor - generateSequence(innerClass) { it.parent as? IrDeclaration }.takeWhile { !it.isTopLevelDeclaration }.forEach { - if (it is IrClass) { - innerClasses.add(it) - } - } - } - - private val IrDeclaration.descriptorOrigin: JvmDeclarationOrigin - get() { - val psiElement = context.psiSourceManager.findPsiElement(this) - // For declarations inside lambdas, produce a descriptor which refers back to the original function. - // This is needed for plugins which check for lambdas inside of inline functions using the descriptor - // contained in JvmDeclarationOrigin. This matches the behavior of the JVM backend. - // TODO: this is really not very useful, as this does nothing for other anonymous objects. - val isLambda = irClass.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL || - irClass.origin == JvmLoweredDeclarationOrigin.SUSPEND_LAMBDA - val descriptor = if (isLambda) - irClass.attributeOwnerId.safeAs()?.symbol?.owner?.toIrBasedDescriptor() ?: toIrBasedDescriptor() - else - toIrBasedDescriptor() - return if (origin == IrDeclarationOrigin.FILE_CLASS) - JvmDeclarationOrigin(JvmDeclarationOriginKind.PACKAGE_PART, psiElement, descriptor) - else - OtherOrigin(psiElement, descriptor) - } -} - -private val IrClass.flags: Int - get() = origin.flags or getVisibilityAccessFlagForClass() or - (if (isAnnotatedWithDeprecated) Opcodes.ACC_DEPRECATED else 0) or - (if (hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME)) Opcodes.ACC_SYNTHETIC else 0) or - when { - isAnnotationClass -> Opcodes.ACC_ANNOTATION or Opcodes.ACC_INTERFACE or Opcodes.ACC_ABSTRACT - isInterface -> Opcodes.ACC_INTERFACE or Opcodes.ACC_ABSTRACT - isEnumClass -> Opcodes.ACC_ENUM or Opcodes.ACC_SUPER or modality.flags - else -> Opcodes.ACC_SUPER or modality.flags - } - -private fun IrField.computeFieldFlags(context: JvmBackendContext, languageVersionSettings: LanguageVersionSettings): Int = - origin.flags or visibility.flags or - (if (isDeprecatedCallable(context) || - correspondingPropertySymbol?.owner?.isDeprecatedCallable(context) == true - ) Opcodes.ACC_DEPRECATED else 0) or - (if (isFinal) Opcodes.ACC_FINAL else 0) or - (if (isStatic) Opcodes.ACC_STATIC else 0) or - (if (hasAnnotation(VOLATILE_ANNOTATION_FQ_NAME)) Opcodes.ACC_VOLATILE else 0) or - (if (hasAnnotation(TRANSIENT_ANNOTATION_FQ_NAME)) Opcodes.ACC_TRANSIENT else 0) or - (if (hasAnnotation(JVM_SYNTHETIC_ANNOTATION_FQ_NAME) || - isPrivateCompanionFieldInInterface(languageVersionSettings) - ) Opcodes.ACC_SYNTHETIC else 0) - -private fun IrField.isPrivateCompanionFieldInInterface(languageVersionSettings: LanguageVersionSettings): Boolean = - origin == IrDeclarationOrigin.FIELD_FOR_OBJECT_INSTANCE && - languageVersionSettings.supportsFeature(LanguageFeature.ProperVisibilityForCompanionObjectInstanceField) && - parentAsClass.isJvmInterface && - DescriptorVisibilities.isPrivate(parentAsClass.companionObject()!!.visibility) - -private val IrDeclarationOrigin.flags: Int - get() = (if (isSynthetic) Opcodes.ACC_SYNTHETIC else 0) or - (if (this == IrDeclarationOrigin.FIELD_FOR_ENUM_ENTRY) Opcodes.ACC_ENUM else 0) - -private val Modality.flags: Int - get() = when (this) { - Modality.ABSTRACT, Modality.SEALED -> Opcodes.ACC_ABSTRACT - Modality.FINAL -> Opcodes.ACC_FINAL - Modality.OPEN -> 0 - else -> throw AssertionError("Unsupported modality $this") - } - -private val DescriptorVisibility.flags: Int - get() = DescriptorAsmUtil.getVisibilityAccessFlag(this) ?: throw AssertionError("Unsupported visibility $this") From 6331a135c8c7a966d2688326bf203b1873734dc5 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Fri, 15 Jan 2021 17:41:10 +0100 Subject: [PATCH 011/122] Add LightClassUtil.getLightClassMethodsByName to avoid resolving all lightClassMethods and filtration later on --- .../src/org/jetbrains/kotlin/asJava/LightClassUtil.kt | 7 ++++++- .../jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.kt b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.kt index bac4675f137..84cc7f22440 100644 --- a/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.kt +++ b/compiler/light-classes/src/org/jetbrains/kotlin/asJava/LightClassUtil.kt @@ -124,13 +124,18 @@ object LightClassUtil { return getPsiMethodWrappers(function).toList() } + fun getLightClassMethodsByName(function: KtFunction, name: String): Sequence { + return getPsiMethodWrappers(function, name) + } + private fun getPsiMethodWrapper(declaration: KtDeclaration): PsiMethod? { return getPsiMethodWrappers(declaration).firstOrNull() } - private fun getPsiMethodWrappers(declaration: KtDeclaration): Sequence = + private fun getPsiMethodWrappers(declaration: KtDeclaration, name: String? = null): Sequence = getWrappingClasses(declaration).flatMap { it.methods.asSequence() } .filterIsInstance() + .filter { name == null || name == it.name } .filter { it.kotlinOrigin === declaration || it.navigationElement === declaration } private fun getWrappingClass(declaration: KtDeclaration): PsiClass? { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt index c8afb190af6..09839a242fd 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/KotlinShortNamesCache.kt @@ -192,7 +192,7 @@ class KotlinShortNamesCache(private val project: Project) : PsiShortNamesCache() filter, KtNamedFunction::class.java ) { ktNamedFunction -> - val methods = LightClassUtil.getLightClassMethods(ktNamedFunction).filter { it.name == name } + val methods = LightClassUtil.getLightClassMethodsByName(ktNamedFunction, name) return@processElements methods.all { method -> processor.process(method) } From 23332bac1391349b960a56e4d35d93e11c509015 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Mon, 18 Jan 2021 12:51:23 +0100 Subject: [PATCH 012/122] More precise message for "this test can be unmuted" --- .../tests/org/jetbrains/kotlin/test/KotlinTestUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java index aa821066581..7f1914cd3d0 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -621,7 +621,7 @@ public class KotlinTestUtils { } } - throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive."); + throw new AssertionError(String.format("Looks like this test can be unmuted. Remove \"%s%s\" directive.", ignoreDirective, targetBackend)); } }; } From acdc1f532b97fbe3a744dd6ee12145c581ea6fc6 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 15 Jan 2021 15:05:19 +0100 Subject: [PATCH 013/122] Rewrite CommonizerTask params to fix ^KT-42098 --- .../targets/native/internal/CommonizerTask.kt | 330 ++++++++---------- .../KotlinNativePlatformDependencies.kt | 22 +- 2 files changed, 157 insertions(+), 195 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt index ae524b03a9d..2da6a510bdb 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/CommonizerTask.kt @@ -9,6 +9,10 @@ import org.gradle.api.DefaultTask import org.gradle.api.Project import org.gradle.api.tasks.* import org.jetbrains.kotlin.compilerRunner.KotlinNativeKlibCommonizerToolRunner +import org.jetbrains.kotlin.compilerRunner.konanHome +import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion +import org.jetbrains.kotlin.gradle.targets.native.internal.SuccessMarker.Companion.getSuccessMarker +import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_COMMONIZED_LIBS_DIR import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_COMMON_LIBS_DIR import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_KLIB_DIR import org.jetbrains.kotlin.konan.library.KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR @@ -22,202 +26,168 @@ import java.time.* import java.util.* import javax.inject.Inject -/** - * Note: Using [resultingLibsDirs] isn't the safest option for up-to-date checker, as in multi-project build - * this may cause re-running the commonizer for the same groups several times. Hopefully, the commonizer has - * inner up-to-date check that prevents doing extra work. - */ -internal data class CommonizerSubtaskParams( - // The ordered list of unique targets. - @get:Input val orderedTargetNames: List, - - // Only for up-to-date checker. The directories with the resulting libs - // (common first, then platforms in the same order as in 'orderedTargetNames'). - @get:OutputDirectories val resultingLibsDirs: List, - - // Only for up-to-date checker. The file exists if and only if a commonizer subtask was successfully accomplished. - @get:OutputFile val successMarker: File, - - @get:Internal val destinationDir: File -) - -internal data class CommonizerTaskParams( - @get:Input val kotlinVersion: String, - - // Only for up-to-date checker. The directory with the original common libs. - @get:InputDirectory val originalCommonLibsDir: File, - - // Only for up-to-date checker. The directory with the original platform libs. - @get:InputDirectory val originalPlatformLibsDir: File, - - @get:Internal val baseDestinationDir: File, - - @get:Nested val subtasks: List -) { - @get:Internal - lateinit var commandLineArguments: List - - @get:Internal - lateinit var successPostActions: List<() -> Unit> - - @get:Internal - lateinit var failurePostActions: List<() -> Unit> - - companion object { - private const val SUCCESS_MARKER = ".commonized" - private const val SUCCESS_MARKER_CONTENT = "1" - - fun build( - kotlinVersion: String, - targetGroups: List>, - distributionDir: File, - baseDestinationDir: File - ): CommonizerTaskParams { - val distributionLibsDir = distributionDir.resolve(KONAN_DISTRIBUTION_KLIB_DIR) - - val commandLineArguments = mutableListOf() - val successPostActions = mutableListOf<() -> Unit>() - val failurePostActions = mutableListOf<() -> Unit>() - - val subtasks = targetGroups.map { targets -> - val orderedTargetNames = targets.map { it.name }.sorted() - if (orderedTargetNames.size == 1) { - // no need to commonize, just use the libraries from the distribution - val successMarker = successMarker(distributionLibsDir).also(::writeSuccess) - buildSubtask( - destinationDir = distributionLibsDir, - orderedTargetNames = orderedTargetNames, - successMarker = successMarker - ) - } else { - val discriminator = buildString { - orderedTargetNames.joinTo(this, separator = "-") - append("-") - append(kotlinVersion.toLowerCase().base64) - } - - val destinationDir = baseDestinationDir.resolve(discriminator) - val successMarker = successMarker(destinationDir) - - if (!isSuccess(successMarker)) { - successMarker.delete() - - val parentDir = destinationDir.parentFile - parentDir.mkdirs() - - val destinationTmpDir = Files.createTempDirectory( - /* dir = */ parentDir.toPath(), - /* prefix = */ "tmp-new-" + destinationDir.name - ).toFile() - - commandLineArguments += "native-dist-commonize" - commandLineArguments += "-distribution-path" - commandLineArguments += distributionDir.toString() - commandLineArguments += "-output-path" - commandLineArguments += destinationTmpDir.toString() - commandLineArguments += "-targets" - commandLineArguments += orderedTargetNames.joinToString(separator = ",") - - successPostActions.add { - renameDirectory(destinationTmpDir, destinationDir) - writeSuccess(successMarker) - } - - failurePostActions.add { - renameToTempAndDelete(destinationTmpDir) - } - } - - buildSubtask( - destinationDir = destinationDir, - orderedTargetNames = orderedTargetNames, - successMarker = successMarker - ) - } - } - - return CommonizerTaskParams( - kotlinVersion = kotlinVersion, - originalCommonLibsDir = commonLibsDir(distributionLibsDir), - originalPlatformLibsDir = platformLibsDir(distributionLibsDir), - baseDestinationDir = baseDestinationDir, - subtasks = subtasks - ).also { - it.commandLineArguments = commandLineArguments - it.successPostActions = successPostActions - it.failurePostActions = failurePostActions - } - } - - private fun commonLibsDir(baseDir: File): File = baseDir.resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR) - private fun platformLibsDir(baseDir: File): File = baseDir.resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR) - - private fun platformLibsDirs(baseDir: File, orderedTargetNames: List): List { - val platformLibsDir = platformLibsDir(baseDir) - return orderedTargetNames.map(platformLibsDir::resolve) - } - - private fun resultingLibsDirs(baseDir: File, orderedTargetNames: List): List { - return mutableListOf().apply { - this += commonLibsDir(baseDir) - this += platformLibsDirs(baseDir, orderedTargetNames) - } - } - - private fun buildSubtask( - destinationDir: File, - orderedTargetNames: List, - successMarker: File - ) = CommonizerSubtaskParams( - orderedTargetNames = orderedTargetNames, - resultingLibsDirs = resultingLibsDirs(destinationDir, orderedTargetNames), - successMarker = successMarker, - destinationDir = destinationDir - ) - - private fun successMarker(destinationDir: File) = destinationDir.resolve(SUCCESS_MARKER) - private fun isSuccess(successMarker: File) = successMarker.isFile && successMarker.readText() == SUCCESS_MARKER_CONTENT - - private fun writeSuccess(successMarker: File) { - if (successMarker.exists()) { - when { - successMarker.isDirectory -> renameToTempAndDelete(successMarker) - isSuccess(successMarker) -> return - else -> successMarker.delete() - } - } - - successMarker.writeText(SUCCESS_MARKER_CONTENT) - } - } -} - internal const val COMMONIZER_TASK_NAME = "runCommonizer" -internal open class CommonizerTask @Inject constructor( - @get:Nested val params: CommonizerTaskParams -) : DefaultTask() { +internal typealias KonanTargetGroup = Set + +internal open class CommonizerTask : DefaultTask() { + + private val konanHome = project.file(project.konanHome) + + @get:Input + var targetGroups: Set = emptySet() + + @get:InputDirectory + @Suppress("unused") // Only for up-to-date checker. The directory with the original common libs. + val originalCommonLibrariesDirectory = konanHome + .resolve(KONAN_DISTRIBUTION_KLIB_DIR) + .resolve(KONAN_DISTRIBUTION_COMMON_LIBS_DIR) + + @get:InputDirectory + @Suppress("unused") // Only for up-to-date checker. The directory with the original platform libs. + val originalPlatformLibrariesDirectory = konanHome + .resolve(KONAN_DISTRIBUTION_KLIB_DIR) + .resolve(KONAN_DISTRIBUTION_PLATFORM_LIBS_DIR) + + @get:OutputDirectories + val commonizerTargetOutputDirectories + get() = targetGroups.map { targets -> project.nativeDistributionCommonizerOutputDirectory(targets) } + + @get:InputFiles + @Suppress("unused") // Only for up-to-date checker. + val successMarkers + get() = targetGroups.map { targets -> project.getSuccessMarker(targets).file } + + /* + Ensures that only one CommonizerTask can run at a time. + This is necessary because of the sucess-marker mechansim of this task. + This is a phantom file: No one has the intention to actually create this output file. + However, telling Gradle that all those tasks rely on the same output file will enforce + non-parallel execution. + */ + @get:OutputFile + @Suppress("unused") + val taskMutex: File = project.rootProject.file(".commonizer-phantom-output") @TaskAction fun run() { // first of all remove directories with unused commonized libraries plus temporary directories with commonized libraries // that accidentally were not cleaned up before cleanUp( - baseDirectory = params.baseDestinationDir, - excludedDirectories = params.subtasks.map { it.destinationDir } + baseDirectory = konanHome.resolve(KONAN_DISTRIBUTION_KLIB_DIR).resolve(KONAN_DISTRIBUTION_COMMONIZED_LIBS_DIR), + excludedDirectories = commonizerTargetOutputDirectories ) + val executionEnvironment = createExecutionEnvironment() + try { - callCommonizerCLI(project, params.commandLineArguments) - params.successPostActions.forEach { it() } - } catch (e: Exception) { - params.failurePostActions.forEach { it() } + callCommonizerCLI(project, executionEnvironment.commandLineArguments) + executionEnvironment.stagedDirectories.forEach { stagedDirectory -> stagedDirectory.onSuccess() } + executionEnvironment.successMarkers.forEach { successMarker -> successMarker.writeSuccess() } + } catch (e: Throwable) { + executionEnvironment.stagedDirectories.forEach { stagedDirectory -> stagedDirectory.onFailure() } + executionEnvironment.successMarkers.forEach { successMarker -> successMarker.delete() } throw e } } + + private fun createExecutionEnvironment(): CommonizerExecutionEnvironment { + val stagedDirectories = mutableListOf() + val successMarkers = mutableListOf() + val arguments = mutableListOf() + + targetGroups.forEach { targets -> + // no need to commonize, just use the libraries from the distribution + if (targets.size <= 1) return@forEach + val orderedTargetNames = targets.map { it.name }.sorted() + val successMarker = project.getSuccessMarker(targets) + if (successMarker.isSuccess) return@forEach + + val stagedDirectory = TemporaryStagedDirectory( + temporaryDirectoryFile = project.createTempNativeDistributionCommonizerOutputDirectory(targets), + targetDirectoryFile = project.nativeDistributionCommonizerOutputDirectory(targets) + ) + + stagedDirectories += stagedDirectory + successMarkers += successMarker + arguments += "native-dist-commonize" + arguments += "-distribution-path" + arguments += konanHome.absolutePath + arguments += "-output-path" + arguments += stagedDirectory.temporaryDirectoryFile.absolutePath + arguments += "-targets" + arguments += orderedTargetNames.joinToString(separator = ",") + } + + return CommonizerExecutionEnvironment( + commandLineArguments = arguments, + successMarkers = successMarkers, + stagedDirectories = stagedDirectories + ) + } } -private fun callCommonizerCLI(project: Project, commandLineArguments: List) { +private class CommonizerExecutionEnvironment( + val commandLineArguments: List, + val successMarkers: List, + val stagedDirectories: List +) + +private class SuccessMarker private constructor(val file: File) { + companion object { + private const val SUCCESS_MARKER = ".commonized" + private const val SUCCESS_MARKER_CONTENT = "1" + + fun Project.getSuccessMarker(targets: KonanTargetGroup): SuccessMarker { + return SuccessMarker(nativeDistributionCommonizerOutputDirectory(targets).resolve(SUCCESS_MARKER)) + } + } + + val isSuccess get() = file.isFile && file.readText() == SUCCESS_MARKER_CONTENT + + fun delete(): Boolean = file.delete() + + fun writeSuccess() { + if (isSuccess) return + if (!file.parentFile.exists()) { + file.parentFile.mkdirs() + } + if (file.isDirectory) { + renameToTempAndDelete(file) + } + file.writeText(SUCCESS_MARKER_CONTENT) + } +} + +private class TemporaryStagedDirectory(val temporaryDirectoryFile: File, private val targetDirectoryFile: File) { + fun onFailure() = renameToTempAndDelete(temporaryDirectoryFile) + fun onSuccess() = renameDirectory(temporaryDirectoryFile, targetDirectoryFile) +} + +internal fun Project.nativeDistributionCommonizerOutputDirectory(targets: KonanTargetGroup): File { + val kotlinVersion = checkNotNull(project.getKotlinPluginVersion()) { "Failed infering Kotlin Plugin version" } + val orderedTargetNames = targets.map { it.name }.sorted() + val discriminator = buildString { + orderedTargetNames.joinTo(this, separator = "-") + append("-") + append(kotlinVersion.toLowerCase().base64) + } + return project.file(konanHome) + .resolve(KONAN_DISTRIBUTION_KLIB_DIR) + .resolve(KONAN_DISTRIBUTION_COMMONIZED_LIBS_DIR) + .resolve(discriminator) +} + +internal fun Project.createTempNativeDistributionCommonizerOutputDirectory(targets: KonanTargetGroup): File { + val outputDirectory = nativeDistributionCommonizerOutputDirectory(targets) + outputDirectory.parentFile.mkdirs() + return Files.createTempDirectory( + /* dir = */ outputDirectory.parentFile.toPath(), + /* prefix = */ "tmp-new-${outputDirectory.name}" + ).toFile() +} + +fun callCommonizerCLI(project: Project, commandLineArguments: List) { if (commandLineArguments.isEmpty()) return KotlinNativeKlibCommonizerToolRunner(project).run(commandLineArguments) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/KotlinNativePlatformDependencies.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/KotlinNativePlatformDependencies.kt index e066a9ba6dd..ebc5ca21cfc 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/KotlinNativePlatformDependencies.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/native/internal/KotlinNativePlatformDependencies.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.gradle.targets.metadata.getMetadataCompilationForSou import org.jetbrains.kotlin.gradle.targets.metadata.isKotlinGranularMetadataEnabled import org.jetbrains.kotlin.gradle.targets.native.internal.NativePlatformDependency.* import org.jetbrains.kotlin.gradle.tasks.registerTask +import org.jetbrains.kotlin.gradle.tasks.withType import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild import org.jetbrains.kotlin.konan.library.* import org.jetbrains.kotlin.konan.target.KonanTarget @@ -106,22 +107,13 @@ private class NativePlatformDependencyResolver(val project: Project, val kotlinV val targetGroups: List = dependencies.keys.filterIsInstance() - val commonizerTaskParams = CommonizerTaskParams.build( - kotlinVersion, - targetGroups.map { it.targets }, - distributionDir, - distributionDir.resolve(KONAN_DISTRIBUTION_KLIB_DIR).resolve(KONAN_DISTRIBUTION_COMMONIZED_LIBS_DIR) - ) - val commonizerTaskProvider = project.registerTask( COMMONIZER_TASK_NAME, - CommonizerTask::class.java, - listOf(commonizerTaskParams) - ) {} + CommonizerTask::class.java + ) { commonizerTask -> + commonizerTask.targetGroups = targetGroups.map { it.targets }.toSet() + } - val commonizedLibsDirs: Map = commonizerTaskParams.subtasks.mapIndexed { index, subtask -> - targetGroups[index] to subtask.destinationDir - }.toMap() // then, resolve dependencies one by one dependencies.forEach { (dependency, actions) -> @@ -149,7 +141,7 @@ private class NativePlatformDependencyResolver(val project: Project, val kotlinV is CommonizedCommon -> { /* commonized platform libs with expect declarations */ - val commonizedLibsDir = commonizedLibsDirs.getValue(dependency) + val commonizedLibsDir = project.nativeDistributionCommonizerOutputDirectory(dependency.targets) project.files(Callable { libsInCommonDir(commonizedLibsDir) }).builtBy(commonizerTaskProvider) @@ -158,7 +150,7 @@ private class NativePlatformDependencyResolver(val project: Project, val kotlinV is CommonizedPlatform -> { /* commonized platform libs with actual declarations */ - val commonizedLibsDir = commonizedLibsDirs.getValue(dependency.common) + val commonizedLibsDir = project.nativeDistributionCommonizerOutputDirectory(dependency.common.targets) project.files(Callable { libsInPlatformDir(commonizedLibsDir, dependency.target) + libsInCommonDir(commonizedLibsDir) }).builtBy(commonizerTaskProvider) From 29f95c7df2784e746836e5048c09c7fc6bbd1391 Mon Sep 17 00:00:00 2001 From: pyos Date: Wed, 6 Jan 2021 14:39:22 +0100 Subject: [PATCH 014/122] FIR: improve inference of implicit type arguments in casts Type parameters do not necessarily match one-to-one, or preserve order. --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++ .../fir/analysis/diagnostics/FirErrors.kt | 2 +- .../fir/resolve/diagnostics/FirDiagnostics.kt | 2 +- .../FirExpressionsResolveTransformer.kt | 65 +++++++++++++------ .../box/when/inferredTypeParameters.kt | 19 ++++++ .../cast/bare/AsNullableNotEnough.fir.kt | 4 +- .../tests/cast/bare/EitherAs.fir.kt | 18 ----- .../diagnostics/tests/cast/bare/EitherAs.kt | 1 + .../tests/cast/bare/EitherIs.fir.kt | 25 ------- .../diagnostics/tests/cast/bare/EitherIs.kt | 1 + .../tests/cast/bare/EitherNotIs.fir.kt | 25 ------- .../tests/cast/bare/EitherNotIs.kt | 1 + .../tests/cast/bare/EitherSafeAs.fir.kt | 18 ----- .../tests/cast/bare/EitherSafeAs.kt | 1 + .../tests/cast/bare/EitherWhen.fir.kt | 19 ------ .../diagnostics/tests/cast/bare/EitherWhen.kt | 1 + .../cast/bare/NullableAsNotEnough.fir.kt | 4 +- .../bare/NullableAsNullableNotEnough.fir.kt | 4 +- .../tests/cast/bare/UnrelatedAs.fir.kt | 4 +- .../tests/cast/bare/UnrelatedIs.fir.kt | 2 +- .../generics/RawTypeInIsExpression.fir.kt | 6 +- .../tests/generics/RawTypeInIsPattern.fir.kt | 4 +- .../innerClasses/bareTypesComplex.fir.kt | 2 +- .../innerClasses/innerUncheckedCast.fir.kt | 4 +- .../typealias/typeAliasAsBareType.fir.kt | 8 +-- .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++ .../IrBlackBoxCodegenTestGenerated.java | 6 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ .../IrJsCodegenBoxES6TestGenerated.java | 5 ++ .../IrJsCodegenBoxTestGenerated.java | 5 ++ .../semantics/JsCodegenBoxTestGenerated.java | 5 ++ .../IrCodegenBoxWasmTestGenerated.java | 5 ++ 32 files changed, 134 insertions(+), 149 deletions(-) create mode 100644 compiler/testData/codegen/box/when/inferredTypeParameters.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/bare/EitherAs.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/bare/EitherIs.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/cast/bare/EitherWhen.fir.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 943feeabdd5..3aa57020818 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -37112,6 +37112,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @Test + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @Test @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 975966d07ab..1933753b53d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -126,7 +126,7 @@ object FirErrors { val PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT by error0() val UPPER_BOUND_VIOLATED by error2() val TYPE_ARGUMENTS_NOT_ALLOWED by error0() - val WRONG_NUMBER_OF_TYPE_ARGUMENTS by error2() + val WRONG_NUMBER_OF_TYPE_ARGUMENTS by error2>() val NO_TYPE_FOR_TYPE_PARAMETER by error0() val TYPE_PARAMETERS_IN_OBJECT by error0() val ILLEGAL_PROJECTION_USAGE by error0() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt index 209f3c17e30..e50a0be8f76 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/FirDiagnostics.kt @@ -74,7 +74,7 @@ class ConeIllegalAnnotationError(val name: Name) : ConeDiagnostic() { override val reason: String get() = "Not a legal annotation: $name" } -class ConeWrongNumberOfTypeArgumentsError(val desiredCount: Int, val type: FirRegularClassSymbol) : ConeDiagnostic() { +class ConeWrongNumberOfTypeArgumentsError(val desiredCount: Int, val type: FirClassLikeSymbol<*>) : ConeDiagnostic() { override val reason: String get() = "Wrong number of type arguments" } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 62c48e0ceb6..0f18e0da2d8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -450,30 +450,53 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform override fun shouldRunCompletion(call: T): Boolean where T : FirStatement, T : FirResolvable = false } - private fun FirTypeRef.withTypeArgumentsForBareType(argument: FirExpression): FirTypeRef { - // TODO: Everything should also work for case of checked-type itself is a type alias - val type = coneTypeSafe() - if (type !is ConeClassLikeType || type.typeArguments.isNotEmpty()) { - return this + private fun ConeClassLikeType.inheritTypeArguments( + base: FirClassLikeDeclaration<*>, + arguments: Array + ): Array? { + val firClass = lookupTag.toSymbol(session)?.fir ?: return null + if (firClass !is FirTypeParameterRefsOwner || firClass.typeParameters.isEmpty()) return arrayOf() + return when (firClass) { + base -> arguments + is FirTypeAlias -> firClass.inheritTypeArguments(firClass.expandedTypeRef, base, arguments) + // TODO: if many supertypes, check consistency + is FirClass<*> -> firClass.superTypeRefs.mapNotNull { firClass.inheritTypeArguments(it, base, arguments) }.firstOrNull() + else -> null } - val baseTypeArguments = - argument.typeRef.coneTypeSafe()?.fullyExpandedType(session)?.typeArguments + } - return if (baseTypeArguments?.isEmpty() != false) { - this - } else { - val typeParameters = (type.lookupTag.toSymbol(session)?.fir as? FirTypeParameterRefsOwner)?.typeParameters.orEmpty() - if (typeParameters.isEmpty()) { - this - } else { - withReplacedConeType( - type.withArguments( - if (baseTypeArguments.size > typeParameters.size) baseTypeArguments.take(typeParameters.size).toTypedArray() - else baseTypeArguments - ) - ) - } + private fun FirTypeParameterRefsOwner.inheritTypeArguments( + typeRef: FirTypeRef, + base: FirClassLikeDeclaration<*>, + arguments: Array + ): Array? { + val type = typeRef.coneTypeSafe() ?: return null + val indexMapping = typeParameters.map { parameter -> + // TODO: if many, check consistency of the result + type.typeArguments.indexOfFirst { it is ConeTypeParameterType && it.lookupTag.typeParameterSymbol == parameter.symbol } } + if (indexMapping.any { it == -1 }) return null + + val typeArguments = type.inheritTypeArguments(base, arguments) ?: return null + return Array(typeParameters.size) { typeArguments[indexMapping[it]] } + } + + private fun FirTypeRef.withTypeArgumentsForBareType(argument: FirExpression): FirTypeRef { + val type = coneTypeSafe() ?: return this + if (type.typeArguments.isNotEmpty()) return this + + val firClass = type.lookupTag.toSymbol(session)?.fir ?: return this + if (firClass !is FirTypeParameterRefsOwner || firClass.typeParameters.isEmpty()) return this + + val baseType = argument.typeRef.coneTypeSafe()?.fullyExpandedType(session) ?: return this + val baseFirClass = baseType.lookupTag.toSymbol(session)?.fir ?: return this + + val newArguments = type.inheritTypeArguments(baseFirClass, baseType.typeArguments) + ?: return buildErrorTypeRef { + source = this@withTypeArgumentsForBareType.source + diagnostic = ConeWrongNumberOfTypeArgumentsError(firClass.typeParameters.size, firClass.symbol) + } + return if (newArguments.isEmpty()) this else withReplacedConeType(type.withArguments(newArguments)) } override fun transformTypeOperatorCall( diff --git a/compiler/testData/codegen/box/when/inferredTypeParameters.kt b/compiler/testData/codegen/box/when/inferredTypeParameters.kt new file mode 100644 index 00000000000..fec494e1e70 --- /dev/null +++ b/compiler/testData/codegen/box/when/inferredTypeParameters.kt @@ -0,0 +1,19 @@ +sealed class C +class A(val x: T) : C() +class B(val x: U) : C() + +fun bar(x: String): C = B(x) +fun baz(x: Any) = "fail: $x" +fun baz(x: String) = x + +typealias Z = B + +fun box(): String = + when (val x = bar("O")) { + is A -> "fail??" + is B -> baz(x.x) + } + when (val y = bar("K")) { + is A -> "fail??" + is Z -> baz(y.x) + else -> "..." + } diff --git a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt index 1b46e9c5cdc..b3c7ce638eb 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/AsNullableNotEnough.fir.kt @@ -4,7 +4,7 @@ interface Tr interface G fun test(tr: Tr) { - val v = tr as G? + val v = tr as G? // If v is not nullable, there will be a warning on this line: - checkSubtype>(v!!) + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherAs.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherAs.fir.kt deleted file mode 100644 index 826e39357e0..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherAs.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -// !CHECK_TYPE - -interface Either -interface Left: Either -interface Right: Either - -class C1(val v1: Int) -class C2(val v2: Int) - -fun _as_left(e: Either): Any { - val v = e as Left - return checkSubtype>(v) -} - -fun _as_right(e: Either): Any { - val v = e as Right - return checkSubtype>(v) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt index d3c22b7fa60..22af4925558 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherAs.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE interface Either diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.fir.kt deleted file mode 100644 index 8c93645181b..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST -interface Either -interface Left: Either { - val value: A -} -interface Right: Either { - val value: B -} - -class C1(val v1: Int) -class C2(val v2: Int) - -fun _is_l(e: Either): Any { - if (e is Left) { - return e.value.v1 - } - return e -} - -fun _is_r(e: Either): Any { - if (e is Right) { - return e.value.v2 - } - return e -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt index 29725127b34..8102d393d0b 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST interface Either interface Left: Either { diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.fir.kt deleted file mode 100644 index 3f83e6c0e18..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.fir.kt +++ /dev/null @@ -1,25 +0,0 @@ -// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST -interface Either -interface Left: Either { - val value: A -} -interface Right: Either { - val value: B -} - -class C1(val v1: Int) -class C2(val v2: Int) - -fun _is_l(e: Either): Any { - if (e !is Left) { - return e - } - return e.value.v1 -} - -fun _is_r(e: Either): Any { - if (e !is Right) { - return e - } - return e.value.v2 -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt index a07e46eb9c3..9753a462ea6 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST interface Either interface Left: Either { diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.fir.kt deleted file mode 100644 index 8a1a2e70014..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -// !CHECK_TYPE - -interface Either -interface Left: Either -interface Right: Either - -class C1(val v1: Int) -class C2(val v2: Int) - -fun _as_left(e: Either): Any? { - val v = e as? Left - return checkSubtype?>(v) -} - -fun _as_right(e: Either): Any? { - val v = e as? Right - return checkSubtype?>(v) -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt index ff8660f2698..38421fee7e6 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherSafeAs.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !CHECK_TYPE interface Either diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.fir.kt deleted file mode 100644 index cc6bbd8915a..00000000000 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.fir.kt +++ /dev/null @@ -1,19 +0,0 @@ -// !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST -interface Either -interface Left: Either { - val value: A -} -interface Right: Either { - val value: B -} - -class C1(val v1: Int) -class C2(val v2: Int) - -fun _when(e: Either): Any { - return when (e) { - is Left -> e.value.v1 - is Right -> e.value.v2 - else -> e - } -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt index ca683c6efda..c83fa5057b3 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -DEBUG_INFO_SMARTCAST interface Either interface Left: Either { diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.fir.kt index e1509febc32..f85d147fc34 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNotEnough.fir.kt @@ -4,6 +4,6 @@ interface Tr interface G fun test(tr: Tr?) { - val v = tr as G - checkSubtype>(v) + val v = tr as G + checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt index 7fa8d3c395e..d9f5de77af8 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/NullableAsNullableNotEnough.fir.kt @@ -4,6 +4,6 @@ interface Tr interface G fun test(tr: Tr?) { - val v = tr as G? - checkSubtype>(v!!) + val v = tr as G? + checkSubtype>(v!!) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.fir.kt index 3c480012ddb..99ae494e82b 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedAs.fir.kt @@ -4,6 +4,6 @@ interface Tr interface G fun test(tr: Tr) { - val v = tr as G - checkSubtype>(v) + val v = tr as G + checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedIs.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedIs.fir.kt index 31a82acc515..8d2b861fab7 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedIs.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedIs.fir.kt @@ -1,4 +1,4 @@ interface Tr interface G -fun test(tr: Tr) = tr is G \ No newline at end of file +fun test(tr: Tr) = tr is G \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt b/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt index e106601f1e6..dd9049258b6 100644 --- a/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt @@ -2,13 +2,13 @@ package p public fun foo(a: Any) { a is Map - a is Map + a is Map a is Map a is Map<*, *> a is Map<> a is List - a is List + a is List a is Int - (a as Map) is Int + (a as Map) is Int } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt b/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt index f76110a228e..bfca3e37219 100644 --- a/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt @@ -1,12 +1,12 @@ public fun foo(a: Any, b: Map) { when (a) { is Map -> {} - is Map -> {} + is Map -> {} is Map -> {} is Map<*, *> -> {} is Map<> -> {} is List -> {} - is List -> {} + is List -> {} is Int -> {} else -> {} } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypesComplex.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypesComplex.fir.kt index 0bb4850fb9f..7eaeb08a95e 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypesComplex.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypesComplex.fir.kt @@ -8,7 +8,7 @@ class DerivedOuter : SuperOuter() { fun bare(x: SuperOuter<*>.SuperInner<*>, y: Any?) { if (x is SuperOuter.SuperInner) return - if (y is SuperOuter.SuperInner) { + if (y is SuperOuter.SuperInner) { return } } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/innerUncheckedCast.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/innerUncheckedCast.fir.kt index bd5a5ec222e..6b1e7bd1725 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/innerUncheckedCast.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/innerUncheckedCast.fir.kt @@ -12,7 +12,7 @@ class Outer { x.prop.checkType { _() } } - if (y is Inner) return + if (y is Inner) return if (z is Inner) { z.prop.checkType { _() } @@ -26,7 +26,7 @@ class Outer { fun bar(x: InnerBase, y: Any?, z: Outer<*>.InnerBase) { x as Inner - y as Inner + y as Inner z as Inner } } diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasAsBareType.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasAsBareType.fir.kt index 5c58097d79b..b375a2a8c49 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasAsBareType.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasAsBareType.fir.kt @@ -14,8 +14,8 @@ fun testNL1(x: Collection?): Boolean = x is NL fun testNL2(x: Collection?): List? = x as NL fun testNL3(x: Collection?): List? = x as NL? -fun testLStar(x: Collection): List = x as LStar -fun testMyList(x: Collection): List = x as MyList +fun testLStar(x: Collection): List = x as LStar +fun testMyList(x: Collection): List = x as MyList typealias MMTT = MutableMap typealias Dictionary = MutableMap @@ -24,8 +24,8 @@ typealias ReadableList = MutableList fun testWrong1(x: Map) = x is MMTT fun testWrong2(x: Map) = x is Dictionary -fun testWrong3(x: Map) = x is WriteableMap -fun testWrong4(x: List) = x is ReadableList +fun testWrong3(x: Map) = x is WriteableMap +fun testWrong4(x: List) = x is ReadableList fun testLocal(x: Any) { class C diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index bb729d71633..160aeb4416c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -37312,6 +37312,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @Test + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @Test @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 22a5574719e..021080dbbd3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -37112,6 +37112,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @Test + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @Test @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index a6bad3af3a6..40c0c116ed4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -30617,6 +30617,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { runTest("compiler/testData/codegen/box/when/integralWhenWithNoInlinedConstants.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index a878893ba18..18325dc6390 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -26438,6 +26438,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { runTest("compiler/testData/codegen/box/when/integralWhenWithNoInlinedConstants.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 7dfd2fabe16..572014b9ef3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -26438,6 +26438,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { runTest("compiler/testData/codegen/box/when/integralWhenWithNoInlinedConstants.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index f3fd0c1d277..dc44e0a72dc 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -26403,6 +26403,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @TestMetadata("integralWhenWithNoInlinedConstants.kt") public void testIntegralWhenWithNoInlinedConstants() throws Exception { runTest("compiler/testData/codegen/box/when/integralWhenWithNoInlinedConstants.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 13221bc458a..90ae451e0a9 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -14599,6 +14599,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/when/implicitExhaustiveAndReturn.kt"); } + @TestMetadata("inferredTypeParameters.kt") + public void testInferredTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/when/inferredTypeParameters.kt"); + } + @TestMetadata("kt2457.kt") public void testKt2457() throws Exception { runTest("compiler/testData/codegen/box/when/kt2457.kt"); From 284d42fd2b7b92a5fef0f11a9022daa71ce75b6d Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Mon, 18 Jan 2021 13:46:34 +0700 Subject: [PATCH 015/122] Use camelCase for cacheKind control property Because it is more intuitive for end-users. --- .../jetbrains/kotlin/gradle/native/NativePlatformLibsIT.kt | 7 ++++--- .../kotlin-library/gradle.properties | 2 +- .../second-library/gradle.properties | 2 +- .../org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativePlatformLibsIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativePlatformLibsIT.kt index 1df06316127..1176c08eeb2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativePlatformLibsIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/native/NativePlatformLibsIT.kt @@ -143,8 +143,9 @@ class NativePlatformLibsIT : BaseGradleIT() { deleteInstalledCompilers() fun buildPlatformLibrariesWithoutAndWithCaches(target: KonanTarget) { - with(platformLibrariesProject(target.presetName)) { - val targetName = target.name + val presetName = target.presetName + val targetName = target.name + with(platformLibrariesProject(presetName)) { // Build libraries without caches. buildWithLightDist("tasks") { assertSuccessful() @@ -152,7 +153,7 @@ class NativePlatformLibsIT : BaseGradleIT() { } // Change cache kind and check that platform libraries generator was executed. - buildWithLightDist("tasks", "-Pkotlin.native.cacheKind.$targetName=static") { + buildWithLightDist("tasks", "-Pkotlin.native.cacheKind.$presetName=static") { assertSuccessful() assertContains("Precompile platform libraries for $targetName (precompilation: static)") } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/kotlin-library/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/kotlin-library/gradle.properties index a1a68852174..83d2782ee73 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/kotlin-library/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/kotlin-library/gradle.properties @@ -1 +1 @@ -kotlin.native.cacheKind.ios_x64=none \ No newline at end of file +kotlin.native.cacheKind.iosX64=none \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/second-library/gradle.properties b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/second-library/gradle.properties index a1a68852174..83d2782ee73 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/second-library/gradle.properties +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/native-cocoapods-multiple/second-library/gradle.properties @@ -1 +1 @@ -kotlin.native.cacheKind.ios_x64=none \ No newline at end of file +kotlin.native.cacheKind.iosX64=none \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt index de35734af2b..d0fabeb4812 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinProperties.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.gradle.utils.SingleWarningPerBuild import org.jetbrains.kotlin.konan.target.KonanTarget +import org.jetbrains.kotlin.konan.target.presetName import org.jetbrains.kotlin.statistics.metrics.StringMetrics import java.io.File import java.util.* @@ -205,7 +206,7 @@ internal class PropertiesProvider private constructor(private val project: Proje * Dependencies caching strategy for [target]. */ fun nativeCacheKindForTarget(target: KonanTarget): NativeCacheKind? = - property("kotlin.native.cacheKind.${target.name}")?.let { NativeCacheKind.byCompilerArgument(it) } + property("kotlin.native.cacheKind.${target.presetName}")?.let { NativeCacheKind.byCompilerArgument(it) } /** * Ignore overflow in [org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessageOutputStreamHandler] From a0ad85e20d3c2b1e076af2447f0e9872526494a3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Mon, 18 Jan 2021 19:15:33 +0300 Subject: [PATCH 016/122] Build: Disable caching of test tasks Until `KTI-464 Test tasks with failed tests are cached` is resolved --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 971679c1dc2..7e7c53af5b7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -503,7 +503,7 @@ allprojects { } tasks.withType { - outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KTI-112") { !isTestDistributionEnabled() } + outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KTI-112") { true } } normalization { From 11a3126c8ce0860480efe756cf6344e0675e1fc4 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Mon, 11 Jan 2021 22:18:44 +0100 Subject: [PATCH 017/122] FIR: copy class supertypes list on iterating while calculating supertypes This list is backed by mutable list and during iterating on it we can resolve supertypes of that class via IDE light classes as IJ Java resolve may resolve a lot of stuff by fir light classes This causes ConcurrentModificationException --- .../kotlin/fir/resolve/transformers/FirSupertypesResolution.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt index 7a10ae85036..a583654d320 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSupertypesResolution.kt @@ -282,7 +282,7 @@ private class FirSupertypeResolverVisitor( supertypeRefs: List ): List { return resolveSpecificClassLikeSupertypes(classLikeDeclaration) { transformer, scope -> - supertypeRefs.mapTo(mutableListOf()) { + ArrayList(supertypeRefs).mapTo(mutableListOf()) { val superTypeRef = transformer.transformTypeRef(it, scope).single if (superTypeRef.coneTypeSafe() != null) From 2aa3c197a30bb33677f2b6a05ec7dab906647bf3 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Wed, 30 Dec 2020 23:00:51 +0300 Subject: [PATCH 018/122] [Wasm] Use non-persistent IR to speed up tests --- compiler/ir/backend.wasm/build.gradle.kts | 1 + .../jetbrains/kotlin/backend/wasm/WasmBackendContext.kt | 4 ++-- .../src/org/jetbrains/kotlin/backend/wasm/compiler.kt | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/ir/backend.wasm/build.gradle.kts b/compiler/ir/backend.wasm/build.gradle.kts index 745f12242a5..848bf2638bc 100644 --- a/compiler/ir/backend.wasm/build.gradle.kts +++ b/compiler/ir/backend.wasm/build.gradle.kts @@ -13,6 +13,7 @@ dependencies { compile(project(":compiler:ir.serialization.common")) compile(project(":compiler:ir.serialization.js")) compile(project(":compiler:ir.tree.persistent")) + compile(project(":compiler:ir.tree.impl")) compile(project(":js:js.ast")) compile(project(":js:js.frontend")) compile(project(":compiler:backend.js")) diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt index c69f3afc285..5a346fc52c9 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmBackendContext.kt @@ -23,8 +23,8 @@ import org.jetbrains.kotlin.ir.backend.js.lower.JsInnerClassesSupport import org.jetbrains.kotlin.ir.builders.declarations.buildFun import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl +import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl -import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol import org.jetbrains.kotlin.ir.util.SymbolTable @@ -43,7 +43,7 @@ class WasmBackendContext( override var inVerbosePhase: Boolean = false override val scriptMode = false override val extractedLocalClasses: MutableSet = hashSetOf() - override val irFactory: IrFactory = PersistentIrFactory + override val irFactory: IrFactory = IrFactoryImpl // Place to store declarations excluded from code generation private val excludedDeclarations = mutableMapOf() diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt index e19fc62d910..7425e543b85 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/compiler.kt @@ -9,21 +9,20 @@ import com.intellij.openapi.project.Project import org.jetbrains.kotlin.analyzer.AbstractAnalyzerWithCompilerReport import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel -import org.jetbrains.kotlin.backend.wasm.ir2wasm.WasmModuleFragmentGenerator import org.jetbrains.kotlin.backend.wasm.ir2wasm.WasmCompiledModuleFragment +import org.jetbrains.kotlin.backend.wasm.ir2wasm.WasmModuleFragmentGenerator import org.jetbrains.kotlin.backend.wasm.ir2wasm.generateStringLiteralsSupport import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.ir.backend.js.MainModule import org.jetbrains.kotlin.ir.backend.js.loadIr -import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory +import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator import org.jetbrains.kotlin.ir.util.generateTypicalIrProviderList import org.jetbrains.kotlin.ir.util.patchDeclarationParents import org.jetbrains.kotlin.library.KotlinLibrary import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.wasm.ir.convertors.WasmIrToBinary import org.jetbrains.kotlin.wasm.ir.convertors.WasmIrToText import java.io.ByteArrayOutputStream @@ -43,7 +42,7 @@ fun compileWasm( val (moduleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) = loadIr( project, mainModule, analyzer, configuration, allDependencies, friendDependencies, - PersistentIrFactory + IrFactoryImpl ) val allModules = when (mainModule) { From ba8223218fa3994d7966d789e77e5ae17fae7791 Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Tue, 15 Dec 2020 16:54:47 +0300 Subject: [PATCH 019/122] [Wasm] Add inline property accessors optimization --- .../optimizations/PropertyAccessorInlineLowering.kt | 13 +++++++++++-- .../kotlin/backend/wasm/WasmLoweringPhases.kt | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt index dea400679fc..4e44e216030 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/optimizations/PropertyAccessorInlineLowering.kt @@ -10,8 +10,9 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext import org.jetbrains.kotlin.backend.common.ir.isTopLevel import org.jetbrains.kotlin.backend.common.lower.createIrBuilder import org.jetbrains.kotlin.backend.common.lower.irBlock -import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.descriptors.DescriptorVisibilities +import org.jetbrains.kotlin.descriptors.Modality +import org.jetbrains.kotlin.ir.builders.irImplicitCast import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl @@ -83,9 +84,17 @@ class PropertyAccessorInlineLowering(private val context: CommonBackendContext) private fun tryInlineSimpleGetter(call: IrCall, callee: IrSimpleFunction, backingField: IrField): IrExpression? { if (!isSimpleGetter(callee, backingField)) return null - return call.run { + val builder = context.createIrBuilder(call.symbol, call.startOffset, call.endOffset) + + val getField = call.run { IrGetFieldImpl(startOffset, endOffset, backingField.symbol, backingField.type, call.dispatchReceiver, origin) } + + // Preserve call types when backingField have different type. This usually happens with generic field types. + return if (backingField.type != call.type) + builder.irImplicitCast(getField, call.type) + else + getField } private fun isSimpleGetter(callee: IrSimpleFunction, backingField: IrField): Boolean { diff --git a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt index 2cf8c5ba990..eb46d02bbe0 100644 --- a/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt +++ b/compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/WasmLoweringPhases.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.lower.* import org.jetbrains.kotlin.backend.common.lower.inline.FunctionInlining import org.jetbrains.kotlin.backend.common.lower.loops.ForLoopsLowering +import org.jetbrains.kotlin.backend.common.lower.optimizations.PropertyAccessorInlineLowering import org.jetbrains.kotlin.backend.common.phaser.* import org.jetbrains.kotlin.backend.wasm.lower.* import org.jetbrains.kotlin.ir.backend.js.lower.* @@ -406,6 +407,12 @@ private val forLoopsLoweringPhase = makeWasmModulePhase( description = "[Optimization] For loops lowering" ) +private val propertyAccessorInlinerLoweringPhase = makeWasmModulePhase( + ::PropertyAccessorInlineLowering, + name = "PropertyAccessorInlineLowering", + description = "[Optimization] Inline property accessors" +) + val wasmPhases = NamedCompilerPhase( name = "IrModuleLowering", description = "IR module lowering", @@ -456,6 +463,7 @@ val wasmPhases = NamedCompilerPhase( returnableBlockLoweringPhase then forLoopsLoweringPhase then + propertyAccessorInlinerLoweringPhase then defaultArgumentStubGeneratorPhase then defaultArgumentPatchOverridesPhase then From cf228bebc3ffccbc625366e765508e664e6260ba Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Thu, 14 Jan 2021 16:08:40 +0300 Subject: [PATCH 020/122] Use static year range in copyright of generated FIR and tests Dynamically calculating a year is problematic, especially in cases like FIR where generation happens in every build. When you are working on a last year's commit, each build creates a bunch of uncommited changes of updating the year in copyrights. --- compiler/fir/checkers/build.gradle.kts | 1 + compiler/fir/tree/build.gradle.kts | 1 + .../kotlin/fir/tree/generator/printer/main.kt | 9 +-------- .../kotlin/test/generators/NewTestGeneratorImpl.kt | 11 +++-------- .../kotlin/generators/impl/TestGeneratorImpl.kt | 11 +++-------- license/COPYRIGHT_HEADER.txt | 4 ++++ 6 files changed, 13 insertions(+), 24 deletions(-) create mode 100644 license/COPYRIGHT_HEADER.txt diff --git a/compiler/fir/checkers/build.gradle.kts b/compiler/fir/checkers/build.gradle.kts index ff40e2064a1..1129017f095 100644 --- a/compiler/fir/checkers/build.gradle.kts +++ b/compiler/fir/checkers/build.gradle.kts @@ -47,6 +47,7 @@ val generateCheckersComponents by tasks.registering(NoDebugJavaExec::class) { outputs.dirs(generationRoot) args(generationRoot) + workingDir = rootDir classpath = generatorClasspath main = "org.jetbrains.kotlin.fir.checkers.generator.MainKt" systemProperties["line.separator"] = "\n" diff --git a/compiler/fir/tree/build.gradle.kts b/compiler/fir/tree/build.gradle.kts index 56f2560052a..8a6b4d3d1e1 100644 --- a/compiler/fir/tree/build.gradle.kts +++ b/compiler/fir/tree/build.gradle.kts @@ -40,6 +40,7 @@ val generateTree by tasks.registering(NoDebugJavaExec::class) { outputs.dirs(generationRoot) args(generationRoot) + workingDir = rootDir classpath = generatorClasspath main = "org.jetbrains.kotlin.fir.tree.generator.MainKt" systemProperties["line.separator"] = "\n" diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt index 1a25aae8f56..d2881db706a 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/printer/main.kt @@ -6,16 +6,9 @@ package org.jetbrains.kotlin.fir.tree.generator.printer import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder - import java.io.File -import java.util.* -private val COPYRIGHT = """ -/* - * Copyright 2010-${GregorianCalendar()[Calendar.YEAR]} JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ -""".trimIndent() +private val COPYRIGHT = File("license/COPYRIGHT_HEADER.txt").readText() const val VISITOR_PACKAGE = "org.jetbrains.kotlin.fir.visitors" const val BASE_PACKAGE = "org.jetbrains.kotlin.fir" diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt index 492f658534f..83feaf37b59 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/generators/NewTestGeneratorImpl.kt @@ -115,14 +115,9 @@ object NewTestGeneratorImpl : TestGenerator(METHOD_GENERATORS) { val out = StringBuilder() val p = Printer(out) - val year = GregorianCalendar()[Calendar.YEAR] - p.println( - """/* - | * Copyright 2010-$year JetBrains s.r.o. and Kotlin Programming Language contributors. - | * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - | */ - |""".trimMargin() - ) + val copyright = File("license/COPYRIGHT_HEADER.txt").readText() + p.println(copyright) + p.println() p.println("package $suiteClassPackage;") p.println() p.println("import com.intellij.testFramework.TestDataPath;") diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt index 168d6ba83d9..a3cde41411a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/generators/impl/TestGeneratorImpl.kt @@ -111,14 +111,9 @@ private class TestGeneratorImplInstance( val out = StringBuilder() val p = Printer(out) - val year = GregorianCalendar()[Calendar.YEAR] - p.println( - """/* - | * Copyright 2010-$year JetBrains s.r.o. and Kotlin Programming Language contributors. - | * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - | */ - |""".trimMargin() - ) + val copyright = File("license/COPYRIGHT_HEADER.txt").readText() + p.println(copyright) + p.println() p.println("package ", suiteClassPackage, ";") p.println() p.println("import com.intellij.testFramework.TestDataPath;") diff --git a/license/COPYRIGHT_HEADER.txt b/license/COPYRIGHT_HEADER.txt new file mode 100644 index 00000000000..41296a422d3 --- /dev/null +++ b/license/COPYRIGHT_HEADER.txt @@ -0,0 +1,4 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ \ No newline at end of file From 6aa6f82c47cc133cf3e373d42d2d32b49c920c40 Mon Sep 17 00:00:00 2001 From: Yaroslav Chernyshev Date: Tue, 19 Jan 2021 17:06:03 +0300 Subject: [PATCH 021/122] Fix MultiplatformModelImportingContextImpl#isOrphanSourceSet predicate --- .../src/MultiplatformModelImportingContext.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/kotlin-gradle-tooling/src/MultiplatformModelImportingContext.kt b/idea/kotlin-gradle-tooling/src/MultiplatformModelImportingContext.kt index a8b6bc9d204..85ad316f5ca 100644 --- a/idea/kotlin-gradle-tooling/src/MultiplatformModelImportingContext.kt +++ b/idea/kotlin-gradle-tooling/src/MultiplatformModelImportingContext.kt @@ -113,7 +113,7 @@ internal class MultiplatformModelImportingContextImpl(override val project: Proj } // overload for small optimization - override fun isOrphanSourceSet(sourceSet: KotlinSourceSet): Boolean = sourceSet in sourceSetToParticipatedCompilations.keys + override fun isOrphanSourceSet(sourceSet: KotlinSourceSet): Boolean = sourceSet !in sourceSetToParticipatedCompilations.keys override fun compilationsBySourceSet(sourceSet: KotlinSourceSet): Collection? = sourceSetToParticipatedCompilations[sourceSet] From d1ee45b518456db2df37417be3ad0895eb57830c Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Mon, 18 Jan 2021 13:30:52 +0100 Subject: [PATCH 022/122] Add language feature for suspend functions in fun interfaces Since in 1.5 JVM_IR is enabled by default and supports suspend functions in fun interfaces, it is safe to enable the feature by default as well. --- ...irOldFrontendDiagnosticsTestGenerated.java | 22 +++++++++++++++++++ .../FunInterfaceDeclarationChecker.kt | 6 ++++- .../functionLiterals/suspend/disabled.fir.kt | 5 +++++ .../functionLiterals/suspend/disabled.kt | 5 +++++ .../functionLiterals/suspend/disabled.txt | 8 +++++++ .../tests/functionLiterals/suspend/enabled.kt | 6 +++++ .../functionLiterals/suspend/enabled.txt | 8 +++++++ .../test/runners/DiagnosticTestGenerated.java | 22 +++++++++++++++++++ .../kotlin/config/LanguageVersionSettings.kt | 1 + 9 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.fir.kt create mode 100644 compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt create mode 100644 compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.txt create mode 100644 compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt create mode 100644 compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index c77cb3516d2..5db974d7ab7 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -10054,6 +10054,28 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.kt"); } } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/functionLiterals/suspend") + @TestDataPath("$PROJECT_ROOT") + public class Suspend extends AbstractFirDiagnosticTest { + @Test + public void testAllFilesPresentInSuspend() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/functionLiterals/suspend"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("disabled.kt") + public void testDisabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt"); + } + + @Test + @TestMetadata("enabled.kt") + public void testEnabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt"); + } + } } @Nested diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/FunInterfaceDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/FunInterfaceDeclarationChecker.kt index b6b4648f2d8..09f5494a82a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/FunInterfaceDeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/FunInterfaceDeclarationChecker.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.resolve.checkers import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor @@ -60,7 +61,10 @@ class FunInterfaceDeclarationChecker : DeclarationChecker { ) { val ktFunction = abstractMember.source.getPsi() as? KtNamedFunction - if (abstractMember.isSuspend) { + if (abstractMember.isSuspend && + !(context.languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionsInFunInterfaces) && + context.languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault)) + ) { val reportOn = ktFunction?.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD) ?: funInterfaceKeyword context.trace.report(Errors.FUN_INTERFACE_WITH_SUSPEND_FUNCTION.on(reportOn)) return diff --git a/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.fir.kt new file mode 100644 index 00000000000..bed693bc60e --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.fir.kt @@ -0,0 +1,5 @@ +// LANGUAGE: -SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault + +fun interface I { + suspend fun foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt b/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt new file mode 100644 index 00000000000..13dbacc491d --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt @@ -0,0 +1,5 @@ +// LANGUAGE: -SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault + +fun interface I { + suspend fun foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.txt b/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.txt new file mode 100644 index 00000000000..a191729edc7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.txt @@ -0,0 +1,8 @@ +package + +public fun interface I { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract suspend fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt b/compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt new file mode 100644 index 00000000000..04b3a511767 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt @@ -0,0 +1,6 @@ +// FIR_IDENTICAL +// LANGUAGE: +SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault + +fun interface I { + suspend fun foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.txt b/compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.txt new file mode 100644 index 00000000000..a191729edc7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.txt @@ -0,0 +1,8 @@ +package + +public fun interface I { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract suspend fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index a975a69d80f..6a69a0267a1 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -10060,6 +10060,28 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.kt"); } } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/functionLiterals/suspend") + @TestDataPath("$PROJECT_ROOT") + public class Suspend extends AbstractDiagnosticTest { + @Test + public void testAllFilesPresentInSuspend() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/functionLiterals/suspend"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("disabled.kt") + public void testDisabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt"); + } + + @Test + @TestMetadata("enabled.kt") + public void testEnabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt"); + } + } } @Nested diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index bebb209059d..04fcbd8d981 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -198,6 +198,7 @@ enum class LanguageFeature( InlineClasses(sinceVersion = KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE), JvmInlineValueClasses(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER), + SuspendFunctionsInFunInterfaces(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER), ; val presentableName: String From b476f1cc3e7bdfa4ef9d8de482ffda05f1bbeb7d Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 19 Jan 2021 07:26:43 +0100 Subject: [PATCH 023/122] Minor. Change test to use the feature instead of suppressing error --- .../box/coroutines/featureIntersection/funInterface.kt | 6 +++--- .../test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java | 5 +++++ .../kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt index 678f8efa7bb..7941bd85f23 100644 --- a/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt @@ -1,12 +1,12 @@ // WITH_RUNTIME // WITH_COROUTINES -// TARGET_BACKEND: JVM -// IGNORE_BACKEND: JVM +// IGNORE_BACKEND: JVM, JS_IR +// IGNORE_LIGHT_ANALYSIS +// LANGUAGE: +SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault import helpers.* import kotlin.coroutines.* -@Suppress("FUN_INTERFACE_WITH_SUSPEND_FUNCTION") fun interface Action { suspend fun run() } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 18325dc6390..0269b7cfd7f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -6114,6 +6114,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt"); } + @TestMetadata("funInterface.kt") + public void testFunInterface() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt"); + } + @TestMetadata("inlineSuspendFinally.kt") public void testInlineSuspendFinally() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 572014b9ef3..87c33429a9a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -6114,6 +6114,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt"); } + @TestMetadata("funInterface.kt") + public void testFunInterface() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt"); + } + @TestMetadata("inlineSuspendFinally.kt") public void testInlineSuspendFinally() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index dc44e0a72dc..dede16d4b2d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -6114,6 +6114,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/destructuringInLambdas.kt"); } + @TestMetadata("funInterface.kt") + public void testFunInterface() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface.kt"); + } + @TestMetadata("inlineSuspendFinally.kt") public void testInlineSuspendFinally() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/inlineSuspendFinally.kt"); From 10d9259df53f2bbd4c74ac3b005e2b174ecc2c6c Mon Sep 17 00:00:00 2001 From: Sergey Shanshin Date: Tue, 19 Jan 2021 20:44:47 +0300 Subject: [PATCH 024/122] Returned support for nullable types by not null serializers Fixes Kotlin/kotlinx.serialization#1265 --- .../kotlinx/serialization/compiler/backend/common/TypeUtil.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/TypeUtil.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/TypeUtil.kt index 80eaf2f4afc..4535c4ce7c9 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/TypeUtil.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/common/TypeUtil.kt @@ -125,7 +125,7 @@ fun AbstractSerialGenerator.findTypeSerializerOrContextUnchecked( if (kType.isTypeParameter()) return null annotations.serializableWith(module)?.let { return it.toClassDescriptor } additionalSerializersInScopeOfCurrentFile[kType]?.let { return it } - + if (kType.isMarkedNullable) return findTypeSerializerOrContextUnchecked(module, kType.makeNotNullable()) if (kType in contextualKClassListInCurrentFile) return module.getClassFromSerializationPackage(SpecialBuiltins.contextSerializer) return analyzeSpecialSerializers(module, annotations) ?: findTypeSerializer(module, kType) } From cce9469e6a0b6d036ca6314bca7f54aff036e161 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Tue, 19 Jan 2021 12:28:02 +0100 Subject: [PATCH 025/122] JVM_IR: Do not unbox Result parameter in Result methods #KT-44140 Fixed --- .../codegen/FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 2 ++ .../testData/codegen/box/inlineClasses/result.kt | 13 +++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 5 +++++ .../semantics/IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../ir/semantics/IrJsCodegenBoxTestGenerated.java | 5 +++++ .../test/semantics/JsCodegenBoxTestGenerated.java | 5 +++++ .../semantics/IrCodegenBoxWasmTestGenerated.java | 5 +++++ 10 files changed, 58 insertions(+) create mode 100644 compiler/testData/codegen/box/inlineClasses/result.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 3aa57020818..de0b42c680a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -16328,6 +16328,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @Test @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 6d6e7a8777b..e81ea9f9a90 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -637,6 +637,8 @@ class ExpressionCodegen( private fun unboxResultIfNeeded(arg: IrGetValue) { if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return if (irFunction !is IrSimpleFunction) return + // Skip Result's methods + if (irFunction.parentAsClass.fqNameWhenAvailable == StandardNames.RESULT_FQ_NAME) return val index = (arg.symbol as? IrValueParameterSymbol)?.owner?.index ?: return val genericOrAnyOverride = irFunction.overriddenSymbols.any { diff --git a/compiler/testData/codegen/box/inlineClasses/result.kt b/compiler/testData/codegen/box/inlineClasses/result.kt new file mode 100644 index 00000000000..a9c33ff2884 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/result.kt @@ -0,0 +1,13 @@ +// IGNORE_BACKEND: WASM, JS_IR +// IGNORE_BACKEND_FIR: JVM_IR +// FILE: result.kt + +package kotlin + +inline class Result(val value: Any?) + +// FILE: box.kt + +fun box(): String { + return Result("OK").value as String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 160aeb4416c..c3cde334b81 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -16328,6 +16328,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @Test @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 021080dbbd3..32ae79fcaa3 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -16328,6 +16328,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @Test + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @Test @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 40c0c116ed4..1a47a345c07 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -14307,6 +14307,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 0269b7cfd7f..1e5498a872d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -12247,6 +12247,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 87c33429a9a..89da10b535e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -12247,6 +12247,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index dede16d4b2d..92459f39fae 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -12312,6 +12312,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/removeInInlineCollectionOfInlineClassAsInt.kt"); } + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 90ae451e0a9..db3a9539a99 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -6703,6 +6703,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inlineClasses/referToUnderlyingPropertyOfInlineClass.kt"); } + @TestMetadata("result.kt") + public void testResult() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/result.kt"); + } + @TestMetadata("resultInlining.kt") public void testResultInlining() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/resultInlining.kt"); From b82a44fa63a424eef63c1a681dd5fdf2a054688c Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Fri, 15 Jan 2021 16:02:47 +0300 Subject: [PATCH 026/122] Add test for KT-20996 --- .../cli/metadata/anonymousObjectType.args | 3 + .../cli/metadata/anonymousObjectType.kt | 1 + .../cli/metadata/anonymousObjectType.out | 62 +++++++++++++++++++ .../kotlin/cli/CliTestGenerated.java | 5 ++ 4 files changed, 71 insertions(+) create mode 100644 compiler/testData/cli/metadata/anonymousObjectType.args create mode 100644 compiler/testData/cli/metadata/anonymousObjectType.kt create mode 100644 compiler/testData/cli/metadata/anonymousObjectType.out diff --git a/compiler/testData/cli/metadata/anonymousObjectType.args b/compiler/testData/cli/metadata/anonymousObjectType.args new file mode 100644 index 00000000000..775a891b8b0 --- /dev/null +++ b/compiler/testData/cli/metadata/anonymousObjectType.args @@ -0,0 +1,3 @@ +$TESTDATA_DIR$/anonymousObjectType.kt +-d +$TEMP_DIR$ diff --git a/compiler/testData/cli/metadata/anonymousObjectType.kt b/compiler/testData/cli/metadata/anonymousObjectType.kt new file mode 100644 index 00000000000..2b350805e5a --- /dev/null +++ b/compiler/testData/cli/metadata/anonymousObjectType.kt @@ -0,0 +1 @@ +private val pVal = object {} diff --git a/compiler/testData/cli/metadata/anonymousObjectType.out b/compiler/testData/cli/metadata/anonymousObjectType.out new file mode 100644 index 00000000000..e1446344b7f --- /dev/null +++ b/compiler/testData/cli/metadata/anonymousObjectType.out @@ -0,0 +1,62 @@ +exception: java.lang.IllegalStateException: Cannot get FQ name of local class: class defined in private val pVal: defined in root package in file anonymousObjectType.kt + at org.jetbrains.kotlin.serialization.DescriptorAwareStringTable$DefaultImpls.getFqNameIndex(DescriptorAwareStringTable.kt:26) + at org.jetbrains.kotlin.serialization.StringTableImpl.getFqNameIndex(StringTableImpl.kt:25) + at org.jetbrains.kotlin.serialization.DescriptorSerializer.getClassifierId(DescriptorSerializer.kt:741) + at org.jetbrains.kotlin.serialization.DescriptorSerializer.fillFromPossiblyInnerType(DescriptorSerializer.kt:613) + at org.jetbrains.kotlin.serialization.DescriptorSerializer.type$serialization(DescriptorSerializer.kt:580) + at org.jetbrains.kotlin.serialization.DescriptorSerializer.typeId(DescriptorSerializer.kt:547) + at org.jetbrains.kotlin.serialization.DescriptorSerializer.propertyProto(DescriptorSerializer.kt:255) + at org.jetbrains.kotlin.serialization.DescriptorSerializer.packagePartProto(DescriptorSerializer.kt:661) + at org.jetbrains.kotlin.cli.metadata.MetadataSerializer$PackageSerializer.serializeMembers(MetadataSerializer.kt:157) + at org.jetbrains.kotlin.cli.metadata.MetadataSerializer$PackageSerializer.run(MetadataSerializer.kt:136) + at org.jetbrains.kotlin.cli.metadata.MetadataSerializer.performSerialization(MetadataSerializer.kt:94) + at org.jetbrains.kotlin.cli.metadata.MetadataSerializer.serialize(MetadataSerializer.kt:49) + at org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler.doExecute(K2MetadataCompiler.kt:111) + at org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler.doExecute(K2MetadataCompiler.kt:40) + at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88) + at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44) + at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98) + at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76) + at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45) + at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227) + at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222) + at org.jetbrains.kotlin.test.CompilerTestUtil.executeCompiler(CompilerTestUtil.kt:41) + at org.jetbrains.kotlin.cli.AbstractCliTest.executeCompilerGrabOutput(AbstractCliTest.java:73) + at org.jetbrains.kotlin.cli.AbstractCliTest.doTest(AbstractCliTest.java:105) + at org.jetbrains.kotlin.cli.AbstractCliTest.doMetadataTest(AbstractCliTest.java:285) + at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$testWithCustomIgnoreDirective$5(KotlinTestUtils.java:572) + at org.jetbrains.kotlin.test.KotlinTestUtils.runTestImpl(KotlinTestUtils.java:542) + at org.jetbrains.kotlin.test.KotlinTestUtils.runTest(KotlinTestUtils.java:485) + at org.jetbrains.kotlin.cli.CliTestGenerated$Metadata.runTest(CliTestGenerated.java:1176) + at org.jetbrains.kotlin.cli.CliTestGenerated$Metadata.testAnonymousObjectType(CliTestGenerated.java:1185) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at junit.framework.TestCase.runTest(TestCase.java:176) + at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.lambda$runTest$9(KtUsefulTestCase.java:374) + at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.lambda$invokeTestRunnable$10(KtUsefulTestCase.java:407) + at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:63) + at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.invokeTestRunnable(KtUsefulTestCase.java:406) + at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.runTest(KtUsefulTestCase.java:393) + at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.defaultRunBare(KtUsefulTestCase.java:424) + at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18) + at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13) + at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$3.run(EdtTestUtil.kt:67) + at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301) + at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) + at java.awt.EventQueue.access$500(EventQueue.java:97) + at java.awt.EventQueue$3.run(EventQueue.java:709) + at java.awt.EventQueue$3.run(EventQueue.java:703) + at java.security.AccessController.doPrivileged(Native Method) + at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) + at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) + at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:419) + at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) + at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) + at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) + at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) + at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) + at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) + +INTERNAL_ERROR diff --git a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java index 0890254a7d2..2d4fefc58f1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -1180,6 +1180,11 @@ public class CliTestGenerated extends AbstractCliTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/cli/metadata"), Pattern.compile("^(.+)\\.args$"), null, false); } + @TestMetadata("anonymousObjectType.args") + public void testAnonymousObjectType() throws Exception { + runTest("compiler/testData/cli/metadata/anonymousObjectType.args"); + } + @TestMetadata("kotlinPackage.args") public void testKotlinPackage() throws Exception { runTest("compiler/testData/cli/metadata/kotlinPackage.args"); From 2f3f75b512039d05e782e1e810f3275a521814af Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Thu, 14 Jan 2021 18:53:18 +0300 Subject: [PATCH 027/122] Fix local anonymous class name error in K2MetadataCompiler Extract the logic of approximating to denotable class supertype from JS/KLIB and use it in metadata compiler. ^KT-20996 In Progress --- .../metadata/MetadataSerializerExtension.kt | 2 + .../serialization/ApproximatingStringTable.kt | 33 +++++ .../cli/metadata/anonymousObjectType.out | 63 +-------- .../anonymousObjectTypeMetadata.kt | 13 ++ .../library/privateObjects.kt | 125 ++++++++++++++++++ .../anonymousObjectTypeMetadata/output.txt | 10 ++ .../CompileKotlinAgainstCustomBinariesTest.kt | 12 ++ .../metadata/KlibMetadataStringTable.kt | 28 +--- .../serialization/js/JavaScriptStringTable.kt | 28 +--- 9 files changed, 200 insertions(+), 114 deletions(-) create mode 100644 compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt create mode 100644 compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt create mode 100644 compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt create mode 100644 compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/output.txt diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/MetadataSerializerExtension.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/MetadataSerializerExtension.kt index c70b687bf59..51fcfdcb1eb 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/MetadataSerializerExtension.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/MetadataSerializerExtension.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.cli.metadata import org.jetbrains.kotlin.metadata.builtins.BuiltInsBinaryVersion +import org.jetbrains.kotlin.serialization.ApproximatingStringTable import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol @@ -24,4 +25,5 @@ class MetadataSerializerExtension( override val metadataVersion: BuiltInsBinaryVersion ) : KotlinSerializerExtensionBase(BuiltInSerializerProtocol) { override fun shouldUseTypeTable(): Boolean = true + override val stringTable = ApproximatingStringTable() } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt new file mode 100644 index 00000000000..1e2f3aa2029 --- /dev/null +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.serialization + +import org.jetbrains.kotlin.builtins.StandardNames +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.descriptorUtil.classId +import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers + +open class ApproximatingStringTable : StringTableImpl() { + override fun getLocalClassIdReplacement(descriptor: ClassifierDescriptorWithTypeParameters): ClassId? { + return if (descriptor.containingDeclaration is CallableMemberDescriptor) { + val superClassifiers = descriptor.getAllSuperClassifiers() + .mapNotNull { it as ClassifierDescriptorWithTypeParameters } + .filter { it != descriptor } + .toList() + if (superClassifiers.size == 1) { + superClassifiers[0].classId + } else { + val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) } + superClass?.classId ?: ClassId.topLevel(StandardNames.FqNames.any.toSafe()) + } + } else { + super.getLocalClassIdReplacement(descriptor) + } + } +} diff --git a/compiler/testData/cli/metadata/anonymousObjectType.out b/compiler/testData/cli/metadata/anonymousObjectType.out index e1446344b7f..d86bac9de59 100644 --- a/compiler/testData/cli/metadata/anonymousObjectType.out +++ b/compiler/testData/cli/metadata/anonymousObjectType.out @@ -1,62 +1 @@ -exception: java.lang.IllegalStateException: Cannot get FQ name of local class: class defined in private val pVal: defined in root package in file anonymousObjectType.kt - at org.jetbrains.kotlin.serialization.DescriptorAwareStringTable$DefaultImpls.getFqNameIndex(DescriptorAwareStringTable.kt:26) - at org.jetbrains.kotlin.serialization.StringTableImpl.getFqNameIndex(StringTableImpl.kt:25) - at org.jetbrains.kotlin.serialization.DescriptorSerializer.getClassifierId(DescriptorSerializer.kt:741) - at org.jetbrains.kotlin.serialization.DescriptorSerializer.fillFromPossiblyInnerType(DescriptorSerializer.kt:613) - at org.jetbrains.kotlin.serialization.DescriptorSerializer.type$serialization(DescriptorSerializer.kt:580) - at org.jetbrains.kotlin.serialization.DescriptorSerializer.typeId(DescriptorSerializer.kt:547) - at org.jetbrains.kotlin.serialization.DescriptorSerializer.propertyProto(DescriptorSerializer.kt:255) - at org.jetbrains.kotlin.serialization.DescriptorSerializer.packagePartProto(DescriptorSerializer.kt:661) - at org.jetbrains.kotlin.cli.metadata.MetadataSerializer$PackageSerializer.serializeMembers(MetadataSerializer.kt:157) - at org.jetbrains.kotlin.cli.metadata.MetadataSerializer$PackageSerializer.run(MetadataSerializer.kt:136) - at org.jetbrains.kotlin.cli.metadata.MetadataSerializer.performSerialization(MetadataSerializer.kt:94) - at org.jetbrains.kotlin.cli.metadata.MetadataSerializer.serialize(MetadataSerializer.kt:49) - at org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler.doExecute(K2MetadataCompiler.kt:111) - at org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler.doExecute(K2MetadataCompiler.kt:40) - at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88) - at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44) - at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98) - at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76) - at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45) - at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227) - at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222) - at org.jetbrains.kotlin.test.CompilerTestUtil.executeCompiler(CompilerTestUtil.kt:41) - at org.jetbrains.kotlin.cli.AbstractCliTest.executeCompilerGrabOutput(AbstractCliTest.java:73) - at org.jetbrains.kotlin.cli.AbstractCliTest.doTest(AbstractCliTest.java:105) - at org.jetbrains.kotlin.cli.AbstractCliTest.doMetadataTest(AbstractCliTest.java:285) - at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$testWithCustomIgnoreDirective$5(KotlinTestUtils.java:572) - at org.jetbrains.kotlin.test.KotlinTestUtils.runTestImpl(KotlinTestUtils.java:542) - at org.jetbrains.kotlin.test.KotlinTestUtils.runTest(KotlinTestUtils.java:485) - at org.jetbrains.kotlin.cli.CliTestGenerated$Metadata.runTest(CliTestGenerated.java:1176) - at org.jetbrains.kotlin.cli.CliTestGenerated$Metadata.testAnonymousObjectType(CliTestGenerated.java:1185) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) - at java.lang.reflect.Method.invoke(Method.java:498) - at junit.framework.TestCase.runTest(TestCase.java:176) - at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.lambda$runTest$9(KtUsefulTestCase.java:374) - at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.lambda$invokeTestRunnable$10(KtUsefulTestCase.java:407) - at com.intellij.testFramework.EdtTestUtilKt.runInEdtAndWait(EdtTestUtil.kt:63) - at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.invokeTestRunnable(KtUsefulTestCase.java:406) - at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.runTest(KtUsefulTestCase.java:393) - at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.defaultRunBare(KtUsefulTestCase.java:424) - at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18) - at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13) - at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$3.run(EdtTestUtil.kt:67) - at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301) - at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) - at java.awt.EventQueue.access$500(EventQueue.java:97) - at java.awt.EventQueue$3.run(EventQueue.java:709) - at java.awt.EventQueue$3.run(EventQueue.java:703) - at java.security.AccessController.doPrivileged(Native Method) - at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) - at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) - at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:419) - at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) - at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) - at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) - at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) - at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) - at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) - -INTERNAL_ERROR +OK diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt new file mode 100644 index 00000000000..67f75708502 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt @@ -0,0 +1,13 @@ +package test + +import lib.* + +val w = W() +val v1 = fn() +val v2 = O.o() +val v3 = w.w() + +// private +val e1 = o3 +val e2 = w.o7 +val e3 = O.o10 diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt new file mode 100644 index 00000000000..39a6c985e45 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt @@ -0,0 +1,125 @@ +package lib + +interface I1 { + fun i1() {} +} + +interface I2 { + fun i2() {} +} + +interface I3 : I2, I1 + +open class C { + fun c() {} +} + +open class G { + fun g() {} +} + +private val o1 = object { fun foo() {} } +private val o2 = object : I1 {} +private val o3 = object : I1, I2 {} +private val o4 = object : I3 {} +private val o5 = object : C() {} +private val o6 = object : C(), I1, I2 {} +private val o7 = object : C(), I3 {} +private val o8 = object : G() {} +private val o9 = object : G(), I1, I2 {} +private val o10 = object : G(), I3 {} + +fun fn() { + o1.foo() + o2.i1() + o3.i1() + o3.i2() + o4.i1() + o4.i2() + o5.c() + o6.c() + o6.i1() + o6.i2() + o7.c() + o7.i1() + o7.i2() + o8.g() + o9.g() + o9.i1() + o9.i2() + o10.g() + o10.i1() + o10.i2() +} + +class W { + private val o1 = object { fun foo() {} } + private val o2 = object : I1 {} + private val o3 = object : I1, I2 {} + private val o4 = object : I3 {} + private val o5 = object : C() {} + private val o6 = object : C(), I1, I2 {} + private val o7 = object : C(), I3 {} + private val o8 = object : G() {} + private val o9 = object : G(), I1, I2 {} + private val o10 = object : G(), I3 {} + + fun w() { + o1.foo() + o2.i1() + o3.i1() + o3.i2() + o4.i1() + o4.i2() + o5.c() + o6.c() + o6.i1() + o6.i2() + o7.c() + o7.i1() + o7.i2() + o8.g() + o9.g() + o9.i1() + o9.i2() + o10.g() + o10.i1() + o10.i2() + } +} + +object O { + private val o1 = object { fun foo() {} } + private val o2 = object : I1 {} + private val o3 = object : I1, I2 {} + private val o4 = object : I3 {} + private val o5 = object : C() {} + private val o6 = object : C(), I1, I2 {} + private val o7 = object : C(), I3 {} + private val o8 = object : G() {} + private val o9 = object : G(), I1, I2 {} + private val o10 = object : G(), I3 {} + + fun o() { + o1.foo() + o2.i1() + o3.i1() + o3.i2() + o4.i1() + o4.i2() + o5.c() + o6.c() + o6.i1() + o6.i2() + o7.c() + o7.i1() + o7.i2() + o8.g() + o9.g() + o9.i1() + o9.i2() + o10.g() + o10.i1() + o10.i2() + } +} diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/output.txt new file mode 100644 index 00000000000..174c604c79f --- /dev/null +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/output.txt @@ -0,0 +1,10 @@ +compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt:11:10: error: cannot access 'o3': it is private in file +val e1 = o3 + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt:12:12: error: cannot access 'o7': it is private in 'W' +val e2 = w.o7 + ^ +compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/anonymousObjectTypeMetadata.kt:13:12: error: cannot access 'o10': it is private in 'O' +val e3 = O.o10 + ^ +COMPILATION_ERROR diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index da81812e3d5..b9cc2e1570e 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -725,6 +725,18 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration loadClassFile("SourceKt", tmpdir, library) } + fun testAnonymousObjectTypeMetadata() { + val library = compileCommonLibrary( + libraryName = "library", + ) + compileKotlin( + "anonymousObjectTypeMetadata.kt", + tmpdir, + listOf(library), + K2MetadataCompiler(), + ) + } + private fun loadClassFile(className: String, dir: File, library: File) { val classLoader = URLClassLoader(arrayOf(dir.toURI().toURL(), library.toURI().toURL())) val mainClass = classLoader.loadClass(className) diff --git a/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt b/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt index 4e95c9deba5..6c4b3005076 100644 --- a/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt +++ b/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt @@ -5,30 +5,6 @@ package org.jetbrains.kotlin.backend.common.serialization.metadata -import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.descriptorUtil.classId -import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers -import org.jetbrains.kotlin.serialization.StringTableImpl +import org.jetbrains.kotlin.serialization.ApproximatingStringTable -class KlibMetadataStringTable : StringTableImpl() { - override fun getLocalClassIdReplacement(descriptor: ClassifierDescriptorWithTypeParameters): ClassId? { - return if (descriptor.containingDeclaration is CallableMemberDescriptor) { - val superClassifiers = descriptor.getAllSuperClassifiers() - .mapNotNull { it as ClassifierDescriptorWithTypeParameters } - .filter { it != descriptor } - .toList() - if (superClassifiers.size == 1) { - superClassifiers[0].classId - } else { - val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) } - superClass?.classId ?: ClassId.topLevel(StandardNames.FqNames.any.toSafe()) - } - } else { - super.getLocalClassIdReplacement(descriptor) - } - } -} +typealias KlibMetadataStringTable = ApproximatingStringTable diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt index 5137db0ea8a..3988e110008 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt @@ -16,30 +16,6 @@ package org.jetbrains.kotlin.serialization.js -import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.ClassifierDescriptorWithTypeParameters -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.descriptorUtil.classId -import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers -import org.jetbrains.kotlin.serialization.StringTableImpl +import org.jetbrains.kotlin.serialization.ApproximatingStringTable -class JavaScriptStringTable : StringTableImpl() { - override fun getLocalClassIdReplacement(descriptor: ClassifierDescriptorWithTypeParameters): ClassId? { - return if (descriptor.containingDeclaration is CallableMemberDescriptor) { - val superClassifiers = descriptor.getAllSuperClassifiers() - .mapNotNull { it as ClassifierDescriptorWithTypeParameters } - .filter { it != descriptor } - .toList() - if (superClassifiers.size == 1) { - superClassifiers[0].classId - } else { - val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) } - superClass?.classId ?: ClassId.topLevel(StandardNames.FqNames.any.toSafe()) - } - } else { - super.getLocalClassIdReplacement(descriptor) - } - } -} +typealias JavaScriptStringTable = ApproximatingStringTable From b66f5c81801f0af8981ee52868f3ee7a7fe6ba57 Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Mon, 18 Jan 2021 17:53:31 +0300 Subject: [PATCH 028/122] Drop type aliases for JS and KLIB string tables They used to use the same approximation logic anyway ^KT-20996 --- .../metadata/KlibMetadataSerializer.kt | 3 ++- .../metadata/KlibMetadataStringTable.kt | 10 --------- .../serialization/js/JavaScriptStringTable.kt | 21 ------------------- .../js/KotlinJavascriptSerializerExtension.kt | 3 ++- .../metadata/klib/KlibModuleMetadata.kt | 8 +++---- .../kotlinx/metadata/klib/impl/klibWriters.kt | 6 +++--- 6 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt delete mode 100644 js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/metadata/KlibMetadataSerializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/metadata/KlibMetadataSerializer.kt index 54a5f4ba343..34acc719404 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/metadata/KlibMetadataSerializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/metadata/KlibMetadataSerializer.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter +import org.jetbrains.kotlin.serialization.ApproximatingStringTable import org.jetbrains.kotlin.serialization.DescriptorSerializer import org.jetbrains.kotlin.serialization.StringTableImpl import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor @@ -51,7 +52,7 @@ abstract class KlibMetadataSerializer( val extension = KlibMetadataSerializerExtension( languageVersionSettings, metadataVersion, - KlibMetadataStringTable(), + ApproximatingStringTable(), allowErrorTypes ) return SerializerContext( diff --git a/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt b/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt deleted file mode 100644 index 6c4b3005076..00000000000 --- a/compiler/util-klib-metadata/src/org/jetbrains/kotlin/library/metadata/KlibMetadataStringTable.kt +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.backend.common.serialization.metadata - -import org.jetbrains.kotlin.serialization.ApproximatingStringTable - -typealias KlibMetadataStringTable = ApproximatingStringTable diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt deleted file mode 100644 index 3988e110008..00000000000 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/JavaScriptStringTable.kt +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.serialization.js - -import org.jetbrains.kotlin.serialization.ApproximatingStringTable - -typealias JavaScriptStringTable = ApproximatingStringTable diff --git a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt index 8b27bec57fc..daefb222c79 100644 --- a/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt +++ b/js/js.serializer/src/org/jetbrains/kotlin/serialization/js/KotlinJavascriptSerializerExtension.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.metadata.serialization.MutableVersionRequirementTabl import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.source.PsiSourceFile +import org.jetbrains.kotlin.serialization.ApproximatingStringTable import org.jetbrains.kotlin.serialization.DescriptorSerializer import org.jetbrains.kotlin.serialization.KotlinSerializerExtensionBase import org.jetbrains.kotlin.types.FlexibleType @@ -35,7 +36,7 @@ class KotlinJavascriptSerializerExtension( private val languageVersionSettings: LanguageVersionSettings, override val metadataVersion: BinaryVersion ) : KotlinSerializerExtensionBase(JsSerializerProtocol) { - override val stringTable = JavaScriptStringTable() + override val stringTable = ApproximatingStringTable() override fun serializeFlexibleType(flexibleType: FlexibleType, lowerProto: ProtoBuf.Type.Builder, upperProto: ProtoBuf.Type.Builder) { lowerProto.flexibleTypeCapabilitiesId = stringTable.getStringIndex(DynamicTypeDeserializer.id) diff --git a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/KlibModuleMetadata.kt b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/KlibModuleMetadata.kt index 2dd76f0bb15..b5cd8c4ee3f 100644 --- a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/KlibModuleMetadata.kt +++ b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/KlibModuleMetadata.kt @@ -10,11 +10,11 @@ import kotlinx.metadata.KmModuleFragment import kotlinx.metadata.impl.WriteContext import kotlinx.metadata.impl.accept import kotlinx.metadata.klib.impl.* -import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataStringTable import org.jetbrains.kotlin.library.metadata.parseModuleHeader import org.jetbrains.kotlin.library.metadata.parsePackageFragment import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl +import org.jetbrains.kotlin.serialization.ApproximatingStringTable /** * Allows to modify the way fragments of the single package are read by [KlibModuleMetadata.read]. @@ -120,12 +120,12 @@ class KlibModuleMetadata( ) val groupedProtos = groupedFragments.mapValues { (_, fragments) -> fragments.map { - val c = WriteContext(KlibMetadataStringTable(), listOf(reverseIndex)) - KlibModuleFragmentWriter(c.strings as KlibMetadataStringTable, c.contextExtensions).also(it::accept).write() + val c = WriteContext(ApproximatingStringTable(), listOf(reverseIndex)) + KlibModuleFragmentWriter(c.strings as ApproximatingStringTable, c.contextExtensions).also(it::accept).write() } } // This context and string table is only required for module-level annotations. - val c = WriteContext(KlibMetadataStringTable(), listOf(reverseIndex)) + val c = WriteContext(ApproximatingStringTable(), listOf(reverseIndex)) return SerializedKlibMetadata( header.writeHeader(c).build().toByteArray(), groupedProtos.map { it.value.map(ProtoBuf.PackageFragment::toByteArray) }, diff --git a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibWriters.kt b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibWriters.kt index 813fe46bb3a..289e6376446 100644 --- a/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibWriters.kt +++ b/libraries/kotlinx-metadata/klib/src/kotlinx/metadata/klib/impl/klibWriters.kt @@ -7,9 +7,9 @@ package kotlinx.metadata.klib.impl import kotlinx.metadata.impl.* import kotlinx.metadata.klib.KlibSourceFile -import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataStringTable import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf import org.jetbrains.kotlin.metadata.ProtoBuf +import org.jetbrains.kotlin.serialization.ApproximatingStringTable class ReverseSourceFileIndexWriteExtension : WriteContextExtension { private val filesReverseIndex = mutableMapOf() @@ -26,7 +26,7 @@ class ReverseSourceFileIndexWriteExtension : WriteContextExtension { } class KlibModuleFragmentWriter( - stringTable: KlibMetadataStringTable, + stringTable: ApproximatingStringTable, contextExtensions: List = emptyList() ) : ModuleFragmentWriter(stringTable, contextExtensions) { @@ -36,7 +36,7 @@ class KlibModuleFragmentWriter( override fun visitEnd() { // TODO: This should be moved to ModuleFragmentWriter. - val (strings, qualifiedNames) = (c.strings as KlibMetadataStringTable).buildProto() + val (strings, qualifiedNames) = (c.strings as ApproximatingStringTable).buildProto() t.strings = strings t.qualifiedNames = qualifiedNames From 5c28762c02de7cca22371285320ce1e09b0dd3ad Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Mon, 18 Jan 2021 19:52:15 +0300 Subject: [PATCH 029/122] Fix check for local classes in approximating string table Take local/anonymous classes and their inner classes into account. Simplify approximation: use first available super classifier instead of first super class. This approximation should only happen for private declarations that were not previously approximated by frontend. So basically the only requirement for the approximated types is to be denotable. Note that this only works if the types are not used later. JVM uses a different string table implementatin as it needs exact types of private members for reflection. ^KT-20996 Fixed --- .../serialization/ApproximatingStringTable.kt | 16 +++------- .../library/privateObjects.kt | 29 +++++++++++++++++ .../testsWithJsStdLib/localClassMetadata.kt | 31 ++++++++++++++++++- .../testsWithJsStdLib/localClassMetadata.txt | 3 ++ .../CompileKotlinAgainstCustomBinariesTest.kt | 12 +++++++ .../box/multiModule/localClassMetadata.kt | 30 ++++++++++++++++-- 6 files changed, 106 insertions(+), 15 deletions(-) diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt index 1e2f3aa2029..74cc59903b4 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/ApproximatingStringTable.kt @@ -13,19 +13,11 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers -open class ApproximatingStringTable : StringTableImpl() { +class ApproximatingStringTable : StringTableImpl() { override fun getLocalClassIdReplacement(descriptor: ClassifierDescriptorWithTypeParameters): ClassId? { - return if (descriptor.containingDeclaration is CallableMemberDescriptor) { - val superClassifiers = descriptor.getAllSuperClassifiers() - .mapNotNull { it as ClassifierDescriptorWithTypeParameters } - .filter { it != descriptor } - .toList() - if (superClassifiers.size == 1) { - superClassifiers[0].classId - } else { - val superClass = superClassifiers.find { !DescriptorUtils.isInterface(it) } - superClass?.classId ?: ClassId.topLevel(StandardNames.FqNames.any.toSafe()) - } + return if (DescriptorUtils.isLocal(descriptor)) { + descriptor.getAllSuperClassifiers().firstOrNull()?.classId + ?: ClassId.topLevel(StandardNames.FqNames.any.toSafe()) } else { super.getLocalClassIdReplacement(descriptor) } diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt index 39a6c985e45..55d262d7c5b 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/anonymousObjectTypeMetadata/library/privateObjects.kt @@ -29,6 +29,32 @@ private val o8 = object : G() {} private val o9 = object : G(), I1, I2 {} private val o10 = object : G(), I3 {} +private val o11 = object { + inner class D { + fun df() {} + } + fun d(): D = D() +}.d() + +private val o12 = { + class L { + fun l() {} + } + L() +}() + +private val o13 = { + class L { + inner class L1 { + inner class L2 { + fun l2() {} + } + } + } + + L().L1().L2() +}() + fun fn() { o1.foo() o2.i1() @@ -50,6 +76,9 @@ fun fn() { o10.g() o10.i1() o10.i2() + o11.df() + o12.l() + o13.l2() } class W { diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.kt b/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.kt index a39f6766b27..1c4b22865c7 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.kt @@ -39,6 +39,32 @@ class C { fun x() = "OK" } + + private val propOI = object { + inner class D { + fun df() {} + } + fun d(): D = D() + }.d() + + private val propL = run { + class L { + fun l() = "propL.l" + } + L() + } + + private val propL2 = run { + class L { + inner class L1 { + inner class L2 { + fun l2() = "propL2.l2" + } + } + } + + L().L1().L2() + } } // MODULE: main(lib) @@ -48,4 +74,7 @@ fun test() { println(C().propI.x()) println(C().propAI.x()) println(C().propG.x()) -} \ No newline at end of file + println(C().propOI.df()) + println(C().propL.l()) + println(C().propL2.l2()) +} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.txt b/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.txt index eeb8d79f136..33feed2c9e3 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.txt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/localClassMetadata.txt @@ -15,6 +15,9 @@ public final class C { private final val propAI: C.propAI. private final val propG: C.propG. private final val propI: C.propI. + private final val propL: C.propL..L + private final val propL2: C.propL2..L.L1.L2 + private final val propOI: C.propOI..D public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt index b9cc2e1570e..cc10adc2fac 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstCustomBinariesTest.kt @@ -735,6 +735,18 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration listOf(library), K2MetadataCompiler(), ) + + val klibLibrary = compileCommonLibrary( + libraryName = "library", + listOf("-Xexpect-actual-linker"), + ) + compileKotlin( + "anonymousObjectTypeMetadata.kt", + tmpdir, + listOf(klibLibrary), + K2MetadataCompiler(), + listOf("-Xexpect-actual-linker") + ) } private fun loadClassFile(className: String, dir: File, library: File) { diff --git a/js/js.translator/testData/box/multiModule/localClassMetadata.kt b/js/js.translator/testData/box/multiModule/localClassMetadata.kt index 7d42e42e487..0e509b1e350 100644 --- a/js/js.translator/testData/box/multiModule/localClassMetadata.kt +++ b/js/js.translator/testData/box/multiModule/localClassMetadata.kt @@ -34,14 +34,40 @@ class C { override fun baz() = "propG.baz" } - fun test() = "${propA.bar()};${propI.foo()};${propAI.foo()};${propAI.bar()};${propG.baz()}" + private val propInner = object { + inner class D { + fun df() = "propInner.df" + } + fun d(): D = D() + }.d() + + private val propL = run { + class L { + fun l() = "propL.l" + } + L() + } + + private val propL2 = run { + class L { + inner class L1 { + inner class L2 { + fun l2() = "propL2.l2" + } + } + } + + L().L1().L2() + } + + fun test() = "${propA.bar()};${propI.foo()};${propAI.foo()};${propAI.bar()};${propG.baz()};${propInner.df()};${propL.l()};${propL2.l2()}" } // MODULE: main(lib) // FILE: main.kt fun box(): String { val result = C().test() - if (result != "propA.bar;propI.foo;propAI.foo;propAI.bar;propG.baz") return "fail: $result" + if (result != "propA.bar;propI.foo;propAI.foo;propAI.bar;propG.baz;propInner.df;propL.l;propL2.l2") return "fail: $result" return "OK" } \ No newline at end of file From 50ab9ed0545f3f17963a1c935d752f0a4fcb3e76 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Mon, 18 Jan 2021 18:24:19 +0300 Subject: [PATCH 030/122] [JS IR] Add test on interface with default method calling extension method on super-interface ^KT-42176 fixed --- .../FirBlackBoxCodegenTestGenerated.java | 12 ++++++++++ .../classMethodCallExtensionSuper.kt | 22 +++++++++++++++++++ ...efaultMethodInterfaceCallExtensionSuper.kt | 22 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 12 ++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 12 ++++++++++ .../LightAnalysisModeTestGenerated.java | 10 +++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 10 +++++++++ .../IrJsCodegenBoxTestGenerated.java | 10 +++++++++ .../semantics/JsCodegenBoxTestGenerated.java | 10 +++++++++ .../IrCodegenBoxWasmTestGenerated.java | 10 +++++++++ 10 files changed, 130 insertions(+) create mode 100644 compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt create mode 100644 compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index de0b42c680a..9265d1e9baa 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -13178,6 +13178,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @Test + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @Test @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { diff --git a/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt b/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt new file mode 100644 index 00000000000..a39f14547d8 --- /dev/null +++ b/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt @@ -0,0 +1,22 @@ +// KT-42176 +interface Top{ + fun getData(): D + fun toString(data: D): String +} + +fun Top.getString() = toString(getData()) + +abstract class DefaultImpl: Top{ + override fun toString(data: Int): String = data.toString() +} + +class Bottom(val data: Int): DefaultImpl { + override fun getData(): Int = data +} + +fun box(): String { + val bottom = Bottom(10).getString() + if (bottom != "10") return "fail: $bottom" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt b/compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt new file mode 100644 index 00000000000..b4e6e62859e --- /dev/null +++ b/compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt @@ -0,0 +1,22 @@ +// KT-42176 +interface Top{ + fun getData(): D + fun toString(data: D): String +} + +fun Top.getString() = toString(getData()) + +interface DefaultImpl: Top{ + override fun toString(data: Int): String = data.toString() +} + +class Bottom(val data: Int): DefaultImpl { + override fun getData(): Int = data +} + +fun box(): String { + val bottom = Bottom(10).getString() + if (bottom != "10") return "fail: $bottom" + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index c3cde334b81..e2495707331 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -13178,6 +13178,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @Test + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @Test @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 32ae79fcaa3..e95f851c205 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -13178,6 +13178,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @Test + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @Test @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 1a47a345c07..2cc1f93b185 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11574,6 +11574,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/executionOrder.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 1e5498a872d..c89e44e6a11 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -9874,6 +9874,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/executionOrder.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 89da10b535e..ac238d412d0 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -9874,6 +9874,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/executionOrder.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 92459f39fae..253db10582e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -9874,6 +9874,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/executionOrder.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index db3a9539a99..39e49415d6b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -4913,6 +4913,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/extensionFunctions"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } + @TestMetadata("classMethodCallExtensionSuper.kt") + public void testClassMethodCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt"); + } + + @TestMetadata("defaultMethodInterfaceCallExtensionSuper.kt") + public void testDefaultMethodInterfaceCallExtensionSuper() throws Exception { + runTest("compiler/testData/codegen/box/extensionFunctions/defaultMethodInterfaceCallExtensionSuper.kt"); + } + @TestMetadata("executionOrder.kt") public void testExecutionOrder() throws Exception { runTest("compiler/testData/codegen/box/extensionFunctions/executionOrder.kt"); From 147d60523df9f8165bc1ecf57905a2f6795d13db Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 20 Jan 2021 07:01:19 +0100 Subject: [PATCH 031/122] Generate inline function arguments with parameters types #KT-44429 Fixed --- .../ir/FirBlackBoxInlineCodegenTestGenerated.java | 5 +++++ .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 6 +++--- .../kotlin/backend/jvm/codegen/IrInlineCodegen.kt | 4 ++-- .../testData/codegen/boxInline/complex/kt44429.kt | 13 +++++++++++++ .../codegen/BlackBoxInlineCodegenTestGenerated.java | 5 +++++ ...mpileKotlinAgainstInlineKotlinTestGenerated.java | 5 +++++ .../ir/IrBlackBoxInlineCodegenTestGenerated.java | 5 +++++ ...mpileKotlinAgainstInlineKotlinTestGenerated.java | 5 +++++ .../ir/JvmIrAgainstOldBoxInlineTestGenerated.java | 5 +++++ .../ir/JvmOldAgainstIrBoxInlineTestGenerated.java | 5 +++++ .../IrJsCodegenInlineES6TestGenerated.java | 5 +++++ .../semantics/IrJsCodegenInlineTestGenerated.java | 5 +++++ .../semantics/JsCodegenInlineTestGenerated.java | 5 +++++ 13 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 compiler/testData/codegen/boxInline/complex/kt44429.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java index 106e47b9d0e..735807fe896 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java @@ -1099,6 +1099,11 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index e81ea9f9a90..e461e454fbf 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -198,13 +198,13 @@ class ExpressionCodegen( return StackValue.onStack(type, irType.toIrBasedKotlinType()) } - internal fun genOrGetLocal(expression: IrExpression, data: BlockInfo): StackValue { + internal fun genOrGetLocal(expression: IrExpression, type: Type, parameterType: IrType, data: BlockInfo): StackValue { if (irFunction.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) { if (expression is IrTypeOperatorCall && expression.operator == IrTypeOperator.IMPLICIT_CAST) { // inline lambda parameters are passed from `foo$default` to `foo` call with implicit cast, // we need return pure StackValue.local value to be able proper inline this parameter later if (expression.type.makeNullable() == expression.argument.type) { - return genOrGetLocal(expression.argument, data) + return genOrGetLocal(expression.argument, type, parameterType, data) } } } @@ -212,7 +212,7 @@ class ExpressionCodegen( return if (expression is IrGetValue) StackValue.local(findLocalIndex(expression.symbol), frameMap.typeOf(expression.symbol), expression.type.toIrBasedKotlinType()) else - gen(expression, typeMapper.mapType(expression.type), expression.type, data) + gen(expression, type, parameterType, data) } fun generate() { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt index 7a3212d9e24..8cf6c637b0b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt @@ -110,7 +110,7 @@ class IrInlineCodegen( // Reuse an existing local if possible. NOTE: when stopping at a breakpoint placed // in an inline function, arguments which reuse an existing local will not be visible // in the debugger. - -> codegen.genOrGetLocal(argumentExpression, blockInfo) + -> codegen.genOrGetLocal(argumentExpression, parameterType, irValueParameter.type, blockInfo) else // Do not reuse locals for receivers. While it's actually completely fine, the non-IR // backend does not do it for internal reasons, and here we replicate the debugging @@ -128,7 +128,7 @@ class IrInlineCodegen( } private fun putCapturedValueOnStack(argumentExpression: IrExpression, valueType: Type, capturedParamIndex: Int) { - val onStack = codegen.genOrGetLocal(argumentExpression, BlockInfo()) + val onStack = codegen.genOrGetLocal(argumentExpression, valueType, argumentExpression.type, BlockInfo()) val expectedType = JvmKotlinType(valueType, argumentExpression.type.toIrBasedKotlinType()) putArgumentOrCapturedToLocalVal(expectedType, onStack, capturedParamIndex, capturedParamIndex, ValueKind.CAPTURED) } diff --git a/compiler/testData/codegen/boxInline/complex/kt44429.kt b/compiler/testData/codegen/boxInline/complex/kt44429.kt new file mode 100644 index 00000000000..4e3b2dfde39 --- /dev/null +++ b/compiler/testData/codegen/boxInline/complex/kt44429.kt @@ -0,0 +1,13 @@ +// FILE: 1.kt +package test + +inline fun takeT(t: T) {} + +// FILE: 2.kt +import test.* + +fun box(): String { + val f = { null } as () -> Int + takeT(f()) + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index c79d66772ad..08768c1d393 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -1099,6 +1099,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 53008f9e117..cdc6c658f5b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -1099,6 +1099,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 3c42ebbeebc..a63eb5652e1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -1099,6 +1099,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index b96c4df39fe..057a0ec17ef 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -1099,6 +1099,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java index 9f91c2e3c1c..e53ac975c9e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -1099,6 +1099,11 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java index 22c4b5bc1cd..0833aee391a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -1099,6 +1099,11 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index baf319def9c..588bcf36a64 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -949,6 +949,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/complex/closureChain.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("swapAndWith.kt") public void testSwapAndWith() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/swapAndWith.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 3ae0f317bbf..4e068f7f7f6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -949,6 +949,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/complex/closureChain.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("swapAndWith.kt") public void testSwapAndWith() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/swapAndWith.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 1453d0bc88d..e928f203178 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -949,6 +949,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/complex/closureChain.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("swapAndWith.kt") public void testSwapAndWith() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/swapAndWith.kt"); From 216b775095aab59fec36f38bdc16e16eec0d5852 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 20 Jan 2021 07:07:04 +0100 Subject: [PATCH 032/122] Remove obsolete code --- .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index e461e454fbf..060a3a19e84 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -199,16 +199,6 @@ class ExpressionCodegen( } internal fun genOrGetLocal(expression: IrExpression, type: Type, parameterType: IrType, data: BlockInfo): StackValue { - if (irFunction.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) { - if (expression is IrTypeOperatorCall && expression.operator == IrTypeOperator.IMPLICIT_CAST) { - // inline lambda parameters are passed from `foo$default` to `foo` call with implicit cast, - // we need return pure StackValue.local value to be able proper inline this parameter later - if (expression.type.makeNullable() == expression.argument.type) { - return genOrGetLocal(expression.argument, type, parameterType, data) - } - } - } - return if (expression is IrGetValue) StackValue.local(findLocalIndex(expression.symbol), frameMap.typeOf(expression.symbol), expression.type.toIrBasedKotlinType()) else From 91717cdcdd3c44d923ca3bc41f515e3966f95a6a Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 20 Jan 2021 08:07:07 +0100 Subject: [PATCH 033/122] Perform inline checks in IR tests --- compiler/testData/codegen/boxInline/complex/kt44429.kt | 1 + .../codegen/boxInline/reified/dontSubstituteNonReified.kt | 4 +--- .../boxInline/smap/anonymous/lambdaOnInlineCallSite.kt | 4 ++-- .../boxInline/smap/anonymous/objectOnInlineCallSite.kt | 4 ++-- compiler/testData/codegen/boxInline/smap/crossroutines.kt | 2 +- .../kotlin/codegen/ir/AbstractIrBlackBoxInlineCodegenTest.kt | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/compiler/testData/codegen/boxInline/complex/kt44429.kt b/compiler/testData/codegen/boxInline/complex/kt44429.kt index 4e3b2dfde39..ad0f79ce0d9 100644 --- a/compiler/testData/codegen/boxInline/complex/kt44429.kt +++ b/compiler/testData/codegen/boxInline/complex/kt44429.kt @@ -4,6 +4,7 @@ package test inline fun takeT(t: T) {} // FILE: 2.kt +// NO_CHECK_LAMBDA_INLINING import test.* fun box(): String { diff --git a/compiler/testData/codegen/boxInline/reified/dontSubstituteNonReified.kt b/compiler/testData/codegen/boxInline/reified/dontSubstituteNonReified.kt index a25932d9c79..0d7dc844be6 100644 --- a/compiler/testData/codegen/boxInline/reified/dontSubstituteNonReified.kt +++ b/compiler/testData/codegen/boxInline/reified/dontSubstituteNonReified.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND: JVM -// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD, JVM_MULTI_MODULE_OLD_AGAINST_IR // FILE: 1.kt package test @@ -9,7 +7,7 @@ class B : A inline fun foo(a: Any) = (a as? T != null).toString()[0] // FILE: 2.kt - +// NO_CHECK_LAMBDA_INLINING import test.* fun box(): String { diff --git a/compiler/testData/codegen/boxInline/smap/anonymous/lambdaOnInlineCallSite.kt b/compiler/testData/codegen/boxInline/smap/anonymous/lambdaOnInlineCallSite.kt index d7f7708ea70..c2d46b18725 100644 --- a/compiler/testData/codegen/boxInline/smap/anonymous/lambdaOnInlineCallSite.kt +++ b/compiler/testData/codegen/boxInline/smap/anonymous/lambdaOnInlineCallSite.kt @@ -1,8 +1,8 @@ // IGNORE_BACKEND_MULTI_MODULE: JVM_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD // FILE: 1.kt - +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR package builders - inline fun call(crossinline init: () -> Unit) { return init() } diff --git a/compiler/testData/codegen/boxInline/smap/anonymous/objectOnInlineCallSite.kt b/compiler/testData/codegen/boxInline/smap/anonymous/objectOnInlineCallSite.kt index aa075edbced..003692af4e2 100644 --- a/compiler/testData/codegen/boxInline/smap/anonymous/objectOnInlineCallSite.kt +++ b/compiler/testData/codegen/boxInline/smap/anonymous/objectOnInlineCallSite.kt @@ -1,8 +1,8 @@ // IGNORE_BACKEND_MULTI_MODULE: JVM_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD // FILE: 1.kt - +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR package builders - inline fun call(crossinline init: () -> Unit) { return init() } diff --git a/compiler/testData/codegen/boxInline/smap/crossroutines.kt b/compiler/testData/codegen/boxInline/smap/crossroutines.kt index f4e570713e2..787edabc791 100644 --- a/compiler/testData/codegen/boxInline/smap/crossroutines.kt +++ b/compiler/testData/codegen/boxInline/smap/crossroutines.kt @@ -1,7 +1,7 @@ // This test depends on line numbers // WITH_RUNTIME // FILE: 1.kt - +// IGNORE_BACKEND_FIR: JVM_IR package test interface SuspendRunnable { diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxInlineCodegenTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxInlineCodegenTest.kt index 46b128c0f2d..8fa8deae248 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxInlineCodegenTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBlackBoxInlineCodegenTest.kt @@ -17,10 +17,10 @@ package org.jetbrains.kotlin.codegen.ir import org.jetbrains.kotlin.ObsoleteTestInfrastructure -import org.jetbrains.kotlin.codegen.AbstractBlackBoxCodegenTest +import org.jetbrains.kotlin.codegen.AbstractBlackBoxInlineCodegenTest import org.jetbrains.kotlin.test.TargetBackend @OptIn(ObsoleteTestInfrastructure::class) -abstract class AbstractIrBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest() { +abstract class AbstractIrBlackBoxInlineCodegenTest : AbstractBlackBoxInlineCodegenTest() { override val backend = TargetBackend.JVM_IR } From 9c4f8f7e54209a8c4d890b7ae3be5cb39e5ea19f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Wed, 20 Jan 2021 12:57:18 +0100 Subject: [PATCH 034/122] JVM IR: Fix signature mapping for inline classes using new mangling When resolving inline class methods in binary dependencies we look for methods matching both the new and the old mangling scheme. On the IR backend the method signature has to be computed for the inline class replacement, since the logic for signature mangling is not contained in the method signature mapping, unlike in the old backend. --- ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ .../backend/jvm/codegen/irCodegenUtils.kt | 5 ++-- .../MemoizedInlineClassReplacements.kt | 30 ++++++++++++++----- .../inlineClassInlineFunctionCall.kt | 11 +++++++ ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ ...mpileKotlinAgainstKotlinTestGenerated.java | 5 ++++ .../ir/JvmIrAgainstOldBoxTestGenerated.java | 5 ++++ .../ir/JvmOldAgainstIrBoxTestGenerated.java | 5 ++++ 8 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/FirCompileKotlinAgainstKotlinTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/FirCompileKotlinAgainstKotlinTestGenerated.java index 58b13168908..0de6b68c39a 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/FirCompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/FirCompileKotlinAgainstKotlinTestGenerated.java @@ -165,6 +165,11 @@ public class FirCompileKotlinAgainstKotlinTestGenerated extends AbstractFirCompi runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt"); } + @TestMetadata("inlineClassInlineFunctionCall.kt") + public void testInlineClassInlineFunctionCall() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt"); + } + @TestMetadata("inlineClassInlineProperty.kt") public void testInlineClassInlineProperty() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineProperty.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt index b15d89c81ff..1dcae594b3d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/irCodegenUtils.kt @@ -382,14 +382,13 @@ val IrMemberAccessExpression<*>.psiElement: PsiElement? fun IrSimpleType.isRawType(): Boolean = hasAnnotation(JvmGeneratorExtensions.RAW_TYPE_ANNOTATION_FQ_NAME) -internal fun classFileContainsMethod(function: IrFunction, context: JvmBackendContext, name: String): Boolean? { - val classId = function.parentClassId ?: return null +internal fun classFileContainsMethod(classId: ClassId, function: IrFunction, context: JvmBackendContext): Boolean? { val originalDescriptor = context.methodSignatureMapper.mapSignatureWithGeneric(function).asmMethod.descriptor val descriptor = if (function.isSuspend) listOf(*Type.getArgumentTypes(originalDescriptor), Type.getObjectType("kotlin/coroutines/Continuation")) .joinToString(prefix = "(", postfix = ")", separator = "") + AsmTypes.OBJECT_TYPE else originalDescriptor - return classFileContainsMethod(classId, context.state, Method(name, descriptor)) + return classFileContainsMethod(classId, context.state, Method(function.name.asString(), descriptor)) } val IrMemberWithContainerSource.parentClassId: ClassId? diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt index 275c1d664ad..629179bf7c9 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmBackendContext import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin import org.jetbrains.kotlin.backend.jvm.codegen.classFileContainsMethod import org.jetbrains.kotlin.backend.jvm.codegen.isJvmInterface +import org.jetbrains.kotlin.backend.jvm.codegen.parentClassId import org.jetbrains.kotlin.backend.jvm.ir.isCompiledToJvmDefault import org.jetbrains.kotlin.backend.jvm.ir.isFromJava import org.jetbrains.kotlin.backend.jvm.ir.isStaticInlineClassReplacement @@ -226,6 +227,27 @@ class MemoizedInlineClassReplacements( replacementOrigin: IrDeclarationOrigin, noFakeOverride: Boolean = false, body: IrFunction.() -> Unit + ): IrSimpleFunction { + val useOldManglingScheme = context.state.useOldManglingSchemeForFunctionsWithInlineClassesInSignatures + val replacement = buildReplacementInner(function, replacementOrigin, noFakeOverride, useOldManglingScheme, body) + // When using the new mangling scheme we might run into dependencies using the old scheme + // for which we will fall back to the old mangling scheme as well. + if ( + !useOldManglingScheme && + replacement.name.asString().contains("-") && + function.parentClassId?.let { classFileContainsMethod(it, replacement, context) } == false + ) { + return buildReplacementInner(function, replacementOrigin, noFakeOverride, true, body) + } + return replacement + } + + private fun buildReplacementInner( + function: IrFunction, + replacementOrigin: IrDeclarationOrigin, + noFakeOverride: Boolean, + useOldManglingScheme: Boolean, + body: IrFunction.() -> Unit, ): IrSimpleFunction = irFactory.buildFun { updateFrom(function) if (function is IrConstructor) { @@ -243,15 +265,7 @@ class MemoizedInlineClassReplacements( if (noFakeOverride) { isFakeOverride = false } - val useOldManglingScheme = context.state.useOldManglingSchemeForFunctionsWithInlineClassesInSignatures name = mangledNameFor(function, mangleReturnTypes, useOldManglingScheme) - if ( - !useOldManglingScheme && - name.asString().contains("-") && - classFileContainsMethod(function, context, name.asString()) == false - ) { - name = mangledNameFor(function, mangleReturnTypes, true) - } returnType = function.returnType }.apply { parent = function.parent diff --git a/compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt b/compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt new file mode 100644 index 00000000000..d3e0401dfb0 --- /dev/null +++ b/compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt @@ -0,0 +1,11 @@ +// FILE: A.kt + +inline class A(val x: String) { + inline fun f(other: A): A = other +} + +// FILE: B.kt + +fun box(): String { + return A("Fail").f(A("OK")).x +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java index 2d276cffd97..d9f5dee2663 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstKotlinTestGenerated.java @@ -164,6 +164,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt"); } + @TestMetadata("inlineClassInlineFunctionCall.kt") + public void testInlineClassInlineFunctionCall() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt"); + } + @TestMetadata("inlineClassInlineProperty.kt") public void testInlineClassInlineProperty() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineProperty.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java index ce8d71d23cb..cd49136a2cb 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstKotlinTestGenerated.java @@ -165,6 +165,11 @@ public class IrCompileKotlinAgainstKotlinTestGenerated extends AbstractIrCompile runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt"); } + @TestMetadata("inlineClassInlineFunctionCall.kt") + public void testInlineClassInlineFunctionCall() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt"); + } + @TestMetadata("inlineClassInlineProperty.kt") public void testInlineClassInlineProperty() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineProperty.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxTestGenerated.java index bc6896c17b6..1e15624f388 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxTestGenerated.java @@ -165,6 +165,11 @@ public class JvmIrAgainstOldBoxTestGenerated extends AbstractJvmIrAgainstOldBoxT runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt"); } + @TestMetadata("inlineClassInlineFunctionCall.kt") + public void testInlineClassInlineFunctionCall() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt"); + } + @TestMetadata("inlineClassInlineProperty.kt") public void testInlineClassInlineProperty() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineProperty.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxTestGenerated.java index 726aa293ae4..e8b8722bf95 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxTestGenerated.java @@ -165,6 +165,11 @@ public class JvmOldAgainstIrBoxTestGenerated extends AbstractJvmOldAgainstIrBoxT runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassFromBinaryDependencies.kt"); } + @TestMetadata("inlineClassInlineFunctionCall.kt") + public void testInlineClassInlineFunctionCall() throws Exception { + runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineFunctionCall.kt"); + } + @TestMetadata("inlineClassInlineProperty.kt") public void testInlineClassInlineProperty() throws Exception { runTest("compiler/testData/compileKotlinAgainstKotlin/inlineClassInlineProperty.kt"); From 0ddb603eaa438d208078c0b936b0aad30ac11293 Mon Sep 17 00:00:00 2001 From: Ilya Goncharov Date: Wed, 20 Jan 2021 20:01:09 +0300 Subject: [PATCH 035/122] [JS IR] Fix of test with method in abstract class calling extension on super type --- .../box/extensionFunctions/classMethodCallExtensionSuper.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt b/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt index a39f14547d8..2964795fcc5 100644 --- a/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt +++ b/compiler/testData/codegen/box/extensionFunctions/classMethodCallExtensionSuper.kt @@ -10,7 +10,7 @@ abstract class DefaultImpl: Top{ override fun toString(data: Int): String = data.toString() } -class Bottom(val data: Int): DefaultImpl { +class Bottom(val data: Int): DefaultImpl() { override fun getData(): Int = data } From d48f92775bdbba8952a5935b1a0c59850ef103c9 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Wed, 20 Jan 2021 09:09:42 +0100 Subject: [PATCH 036/122] JVM_IR: Do not unbox Result parameter in invoke if there is a bridge since the bridge unboxes it. #KT-44141 Fixed --- .../codegen/FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../backend/jvm/codegen/ExpressionCodegen.kt | 11 ++++++++++- .../testData/codegen/box/inlineClasses/kt44141.kt | 14 ++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 5 +++++ .../semantics/IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../ir/semantics/IrJsCodegenBoxTestGenerated.java | 5 +++++ .../test/semantics/JsCodegenBoxTestGenerated.java | 5 +++++ .../semantics/IrCodegenBoxWasmTestGenerated.java | 5 +++++ 10 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/box/inlineClasses/kt44141.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 9265d1e9baa..cfb34ee8155 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -16226,6 +16226,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @Test + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @Test @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 060a3a19e84..4456f37dbf6 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -629,6 +629,8 @@ class ExpressionCodegen( if (irFunction !is IrSimpleFunction) return // Skip Result's methods if (irFunction.parentAsClass.fqNameWhenAvailable == StandardNames.RESULT_FQ_NAME) return + // Do not unbox, if there is a bridge, which unboxes for us + if (hasBridge()) return val index = (arg.symbol as? IrValueParameterSymbol)?.owner?.index ?: return val genericOrAnyOverride = irFunction.overriddenSymbols.any { @@ -637,7 +639,14 @@ class ExpressionCodegen( } || irFunction.parentAsClass.origin == JvmLoweredDeclarationOrigin.LAMBDA_IMPL if (!genericOrAnyOverride) return - StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.toIrBasedKotlinType(), mv) + StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.erasedUpperBound.defaultType.toIrBasedKotlinType(), mv) + } + + private fun hasBridge(): Boolean = irFunction.parentAsClass.declarations.any { function -> + function is IrFunction && function != irFunction && + context.methodSignatureMapper.mapSignatureSkipGeneric(function).let { + it.asmMethod.name == signature.asmMethod.name && it.valueParameters == signature.valueParameters + } } override fun visitFieldAccess(expression: IrFieldAccessExpression, data: BlockInfo): PromisedValue { diff --git a/compiler/testData/codegen/box/inlineClasses/kt44141.kt b/compiler/testData/codegen/box/inlineClasses/kt44141.kt new file mode 100644 index 00000000000..57aeb62ff46 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/kt44141.kt @@ -0,0 +1,14 @@ +// WITH_RUNTIME +// KJS_FULL_RUNTIME + +fun > isSuccess(a: A): String = + a.go { + it.isSuccess + } + +class A { + fun go(f: (T) -> Boolean): String = + if (f(Result.success(1) as T)) "OK" else "Fail" +} + +fun box(): String = isSuccess(A>()) diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index e2495707331..05b37087af6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -16226,6 +16226,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @Test + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @Test @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index e95f851c205..7b04d136da1 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -16226,6 +16226,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @Test + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @Test @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 2cc1f93b185..8e2ffa8dc16 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -14222,6 +14222,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index c89e44e6a11..ac716696f64 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -12177,6 +12177,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index ac238d412d0..ee7f3c8c69a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -12177,6 +12177,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 253db10582e..4e954e3625b 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -12242,6 +12242,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 39e49415d6b..c31ba15face 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -6648,6 +6648,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt"); } + @TestMetadata("kt44141.kt") + public void testKt44141() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt44141.kt"); + } + @TestMetadata("mangledDefaultParameterFunction.kt") public void testMangledDefaultParameterFunction() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt"); From 952576e98f4cbbdf80d0352b4d2af25a596fc6c7 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Wed, 20 Jan 2021 17:06:10 +0100 Subject: [PATCH 037/122] JVM_IR: Do not unbox Result parameter if it not only one inline class parameter, since in this case, the compiler generates a bridge, where the result is unboxed. --- .../FirBlackBoxCodegenTestGenerated.java | 18 +++++++++++++++ .../backend/jvm/codegen/ExpressionCodegen.kt | 5 +++++ .../funInterface/resultAny.kt | 22 +++++++++++++++++++ .../unboxGenericParameter/lambda/resultAny.kt | 16 ++++++++++++++ .../objectLiteral/resultAny.kt | 20 +++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 18 +++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 18 +++++++++++++++ .../LightAnalysisModeTestGenerated.java | 15 +++++++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 15 +++++++++++++ .../IrJsCodegenBoxTestGenerated.java | 15 +++++++++++++ .../semantics/JsCodegenBoxTestGenerated.java | 15 +++++++++++++ .../IrCodegenBoxWasmTestGenerated.java | 10 +++++++++ 12 files changed, 187 insertions(+) create mode 100644 compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt create mode 100644 compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index cfb34ee8155..17bce302afb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -17684,6 +17684,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { @@ -17736,6 +17742,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { @@ -17788,6 +17800,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index 4456f37dbf6..67d2bdb3462 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -626,6 +626,7 @@ class ExpressionCodegen( // bridge to unbox it. Instead, we unbox it in the non-mangled function manually. private fun unboxResultIfNeeded(arg: IrGetValue) { if (arg.type.erasedUpperBound.fqNameWhenAvailable != StandardNames.RESULT_FQ_NAME) return + if (!onlyResultInlineClassParameters()) return if (irFunction !is IrSimpleFunction) return // Skip Result's methods if (irFunction.parentAsClass.fqNameWhenAvailable == StandardNames.RESULT_FQ_NAME) return @@ -642,6 +643,10 @@ class ExpressionCodegen( StackValue.unboxInlineClass(OBJECT_TYPE, arg.type.erasedUpperBound.defaultType.toIrBasedKotlinType(), mv) } + private fun onlyResultInlineClassParameters(): Boolean = irFunction.valueParameters.all { + !it.type.erasedUpperBound.isInline || it.type.erasedUpperBound.fqNameWhenAvailable == StandardNames.RESULT_FQ_NAME + } + private fun hasBridge(): Boolean = irFunction.parentAsClass.declarations.any { function -> function is IrFunction && function != irFunction && context.methodSignatureMapper.mapSignatureSkipGeneric(function).let { diff --git a/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt b/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt new file mode 100644 index 00000000000..f58537aab59 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt @@ -0,0 +1,22 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// WASM_MUTE_REASON: SAM_CONVERSIONS +// !LANGUAGE: +InlineClasses +// WITH_RUNTIME + +inline class IC(val value: Any) + +fun foo(a: Result, ic: IC): Pair = bar(a, ic) { a, ic -> + a.getOrThrow() to ic.value +} + +fun interface FunIFace { + fun call(t1: T1, t2: T2): R +} + +fun bar(t1: T1, t2: T2, f: FunIFace): R { + return f.call(t1, t2) +} + +fun Pair.join(): String = "$first$second" + +fun box(): String = foo(Result.success("O"), IC("K")).join() \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt b/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt new file mode 100644 index 00000000000..7743341b618 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt @@ -0,0 +1,16 @@ +// !LANGUAGE: +InlineClasses +// WITH_RUNTIME + +inline class IC(val value: Any) + +fun foo(a: Result, ic: IC): Pair = bar(a, ic) { a, ic -> + a.getOrThrow() to ic.value +} + +fun bar(t1: T1, t2: T2, f: (T1, T2) -> R): R { + return f(t1, t2) +} + +fun Pair.join(): String = "$first$second" + +fun box(): String = foo(Result.success("O"), IC("K")).join() \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt b/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt new file mode 100644 index 00000000000..07c6d7404e6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +InlineClasses +// WITH_RUNTIME + +inline class IC(val value: Any) + +fun foo(a: Result, ic: IC): Pair = bar(a, ic, object : IFace, IC, Pair> { + override fun call(a: Result, ic: IC): Pair = a.getOrThrow() to ic.value +}) + +interface IFace { + fun call(t1: T1, t2: T2): R +} + +fun bar(t1: T1, t2: T2, f: IFace): R { + return f.call(t1, t2) +} + +fun Pair.join(): String = "$first$second" + +fun box(): String = foo(Result.success("O"), IC("K")).join() \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 05b37087af6..0961403bd71 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -17684,6 +17684,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { @@ -17736,6 +17742,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { @@ -17788,6 +17800,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 7b04d136da1..2c7e979804b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -17684,6 +17684,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { @@ -17736,6 +17742,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { @@ -17788,6 +17800,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @Test + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @Test @TestMetadata("string.kt") public void testString() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 8e2ffa8dc16..e572900f046 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -15492,6 +15492,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/string.kt"); @@ -15540,6 +15545,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/string.kt"); @@ -15588,6 +15598,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/string.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index ac716696f64..fb684cfdbdf 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -13342,6 +13342,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/string.kt"); @@ -13390,6 +13395,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/string.kt"); @@ -13438,6 +13448,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/string.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index ee7f3c8c69a..3e25c2bbef6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -13342,6 +13342,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/string.kt"); @@ -13390,6 +13395,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/string.kt"); @@ -13438,6 +13448,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/string.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 4e954e3625b..b44695e942a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -13407,6 +13407,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/funInterface/string.kt"); @@ -13455,6 +13460,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/string.kt"); @@ -13503,6 +13513,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/string.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index c31ba15face..ad33bfcffb5 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -7591,6 +7591,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/lambda/string.kt"); @@ -7639,6 +7644,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/result.kt"); } + @TestMetadata("resultAny.kt") + public void testResultAny() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/resultAny.kt"); + } + @TestMetadata("string.kt") public void testString() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxGenericParameter/objectLiteral/string.kt"); From 35093e0958f5b97532fcf7996111993dff10bed8 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Wed, 20 Jan 2021 12:20:29 -0800 Subject: [PATCH 038/122] FIR checker: error messages for properties/accessors diagnostics Also, update error inputs to conform to old FE's These should have been part of commit 5167d69b7ce7 --- .../declaration/FirMemberPropertyChecker.kt | 20 +++++------ .../diagnostics/FirDefaultErrorMessages.kt | 35 +++++++++++++++++++ .../fir/analysis/diagnostics/FirErrors.kt | 22 ++++++------ 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberPropertyChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberPropertyChecker.kt index b9918582b4e..db2bc0b6df7 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberPropertyChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberPropertyChecker.kt @@ -52,7 +52,7 @@ object FirMemberPropertyChecker : FirRegularClassChecker() { if (isAbstract) { if (!containingDeclaration.canHaveAbstractDeclaration) { property.source?.let { - reporter.report(it, FirErrors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS) + reporter.report(FirErrors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS.on(it, property, containingDeclaration)) return } } @@ -60,21 +60,21 @@ object FirMemberPropertyChecker : FirRegularClassChecker() { if (property.delegate != null) { property.delegate!!.source?.let { if (containingDeclaration.isInterface) { - reporter.report(FirErrors.DELEGATED_PROPERTY_IN_INTERFACE.on(it, property.delegate!!)) + reporter.report(it, FirErrors.DELEGATED_PROPERTY_IN_INTERFACE) } else { - reporter.report(FirErrors.ABSTRACT_DELEGATED_PROPERTY.on(it, property.delegate!!)) + reporter.report(it, FirErrors.ABSTRACT_DELEGATED_PROPERTY) } } } checkAccessor(property.getter, property.delegate) { src, symbol -> - reporter.report(FirErrors.ABSTRACT_PROPERTY_WITH_GETTER.on(src, symbol)) + reporter.report(src, FirErrors.ABSTRACT_PROPERTY_WITH_GETTER) } checkAccessor(property.setter, property.delegate) { src, symbol -> if (symbol.fir.visibility == Visibilities.Private && property.visibility != Visibilities.Private) { - reporter.report(FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY.on(src, symbol)) + reporter.report(src, FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY) } else { - reporter.report(FirErrors.ABSTRACT_PROPERTY_WITH_SETTER.on(src, symbol)) + reporter.report(src, FirErrors.ABSTRACT_PROPERTY_WITH_SETTER) } } } @@ -96,7 +96,7 @@ object FirMemberPropertyChecker : FirRegularClassChecker() { if (isOpen) { checkAccessor(property.setter, property.delegate) { src, symbol -> if (symbol.fir.visibility == Visibilities.Private && property.visibility != Visibilities.Private) { - reporter.report(FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY.on(src, symbol)) + reporter.report(src, FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY) } } } @@ -110,15 +110,15 @@ object FirMemberPropertyChecker : FirRegularClassChecker() { ) { property.initializer?.source?.let { if (propertyIsAbstract) { - reporter.report(FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER.on(it, property.initializer!!)) + reporter.report(it, FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER) } else if (containingDeclaration.isInterface) { - reporter.report(FirErrors.PROPERTY_INITIALIZER_IN_INTERFACE.on(it, property.initializer!!)) + reporter.report(it, FirErrors.PROPERTY_INITIALIZER_IN_INTERFACE) } } if (propertyIsAbstract) { if (property.initializer == null && property.delegate == null && property.returnTypeRef is FirImplicitTypeRef) { property.source?.let { - reporter.report(FirErrors.PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(it, property.symbol)) + reporter.report(it, FirErrors.PROPERTY_WITH_NO_TYPE_NO_INITIALIZER) } } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index cf74faad14e..aad8fce9798 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -13,6 +13,11 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.PROP import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.TO_STRING +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_DELEGATED_PROPERTY +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_WITH_GETTER +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_WITH_SETTER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_SUPER_CALL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.AMBIGUITY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ANNOTATION_CLASS_MEMBER @@ -30,6 +35,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_PROJE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_OBJECT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CYCLIC_CONSTRUCTOR_DELEGATION_CALL +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATED_PROPERTY_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATION_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.DEPRECATED_MODIFIER_PAIR @@ -75,8 +81,13 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NULLABLE_TYPE_OF_ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.OTHER_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_PROPERTY_IN_INTERFACE +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_INITIALIZER_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_TYPE_MISMATCH_ON_OVERRIDE +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PROPERTY_WITH_NO_TYPE_NO_INITIALIZER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_IMPLICIT_TYPES import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.RECURSION_IN_SUPERTYPES @@ -324,6 +335,30 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { TO_STRING ) + // Properties & accessors + map.put( + ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS, + "Abstract property ''{0}'' in non-abstract class ''{1}''", + DECLARATION_NAME, + DECLARATION_NAME + ) + map.put(PRIVATE_PROPERTY_IN_INTERFACE, "Abstract property in an interface cannot be private") + + map.put(ABSTRACT_PROPERTY_WITH_INITIALIZER, "Property with initializer cannot be abstract") + map.put(PROPERTY_INITIALIZER_IN_INTERFACE, "Property initializers are not allowed in interfaces") + map.put( + PROPERTY_WITH_NO_TYPE_NO_INITIALIZER, + "This property must either have a type annotation, be initialized or be delegated" + ) + + map.put(ABSTRACT_DELEGATED_PROPERTY, "Delegated property cannot be abstract") + map.put(DELEGATED_PROPERTY_IN_INTERFACE, "Delegated properties are not allowed in interfaces") + + map.put(ABSTRACT_PROPERTY_WITH_GETTER, "Property with getter implementation cannot be abstract") + map.put(ABSTRACT_PROPERTY_WITH_SETTER, "Property with setter implementation cannot be abstract") + map.put(PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY, "Private setters are not allowed for abstract properties") + map.put(PRIVATE_SETTER_FOR_OPEN_PROPERTY, "Private setters are not allowed for open properties") + // Control flow diagnostics map.put(UNINITIALIZED_VARIABLE, "{0} must be initialized before access", PROPERTY_NAME) map.put( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 1933753b53d..6b7f951772b 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -154,21 +154,21 @@ object FirErrors { val PRIVATE_FUNCTION_WITH_NO_BODY by error0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) // Properties & accessors - val ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS by error0(SourceElementPositioningStrategies.MODALITY_MODIFIER) - val PRIVATE_PROPERTY_IN_INTERFACE by error0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) + val ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS by error2(SourceElementPositioningStrategies.MODALITY_MODIFIER) + val PRIVATE_PROPERTY_IN_INTERFACE by error0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) - val ABSTRACT_PROPERTY_WITH_INITIALIZER by error1() - val PROPERTY_INITIALIZER_IN_INTERFACE by error1() - val PROPERTY_WITH_NO_TYPE_NO_INITIALIZER by error1() + val ABSTRACT_PROPERTY_WITH_INITIALIZER by error0() + val PROPERTY_INITIALIZER_IN_INTERFACE by error0() + val PROPERTY_WITH_NO_TYPE_NO_INITIALIZER by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) - val ABSTRACT_DELEGATED_PROPERTY by error1() - val DELEGATED_PROPERTY_IN_INTERFACE by error1() + val ABSTRACT_DELEGATED_PROPERTY by error0() + val DELEGATED_PROPERTY_IN_INTERFACE by error0() // TODO: val ACCESSOR_FOR_DELEGATED_PROPERTY by error1() - val ABSTRACT_PROPERTY_WITH_GETTER by error1() - val ABSTRACT_PROPERTY_WITH_SETTER by error1() - val PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY by error1() - val PRIVATE_SETTER_FOR_OPEN_PROPERTY by error1() + val ABSTRACT_PROPERTY_WITH_GETTER by error0() + val ABSTRACT_PROPERTY_WITH_SETTER by error0() + val PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY by error0() + val PRIVATE_SETTER_FOR_OPEN_PROPERTY by error0() // Destructuring declaration val INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION by error0() From 021395ce397991b0118e17c44372116113333175 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Wed, 20 Jan 2021 14:08:38 -0800 Subject: [PATCH 039/122] FIR checker: error message for destructuring declaration diagnostic Also, update error inputs to conform to old FE's This should have been part of commit 03cb0c3cd184a --- .../fir/analysis/diagnostics/FirDefaultErrorMessages.kt | 4 ++++ .../jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index aad8fce9798..c254376d305 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -60,6 +60,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_INFI import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INAPPLICABLE_LATEINIT_MODIFIER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INCOMPATIBLE_MODIFIERS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INFERENCE_ERROR +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INTERFACE_WITH_SUPERCLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER @@ -359,6 +360,9 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY, "Private setters are not allowed for abstract properties") map.put(PRIVATE_SETTER_FOR_OPEN_PROPERTY, "Private setters are not allowed for open properties") + // Destructuring declaration + map.put(INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION, "Initializer required for destructuring declaration") + // Control flow diagnostics map.put(UNINITIALIZED_VARIABLE, "{0} must be initialized before access", PROPERTY_NAME) map.put( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 6b7f951772b..4fa70ac8702 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -171,7 +171,7 @@ object FirErrors { val PRIVATE_SETTER_FOR_OPEN_PROPERTY by error0() // Destructuring declaration - val INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION by error0() + val INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION by error0() // Control flow diagnostics val UNINITIALIZED_VARIABLE by error1() From b99f1a1512cb0cb0a01a88602892906868e9433c Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Wed, 20 Jan 2021 14:28:59 -0800 Subject: [PATCH 040/122] FIR checker: error messages for function diagnostics Also, update error inputs to conform to old FE's These should have been part of commit 39df3e2b0adb --- .../declaration/FirMemberFunctionChecker.kt | 8 ++++---- .../diagnostics/FirDefaultErrorMessages.kt | 17 +++++++++++++++++ .../fir/analysis/diagnostics/FirErrors.kt | 8 ++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberFunctionChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberFunctionChecker.kt index 7596902d254..7046416221f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberFunctionChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMemberFunctionChecker.kt @@ -39,10 +39,10 @@ object FirMemberFunctionChecker : FirRegularClassChecker() { val isAbstract = function.isAbstract || hasAbstractModifier if (isAbstract) { if (!containingDeclaration.canHaveAbstractDeclaration) { - reporter.report(source, FirErrors.ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS) + reporter.report(FirErrors.ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS.on(source, function, containingDeclaration)) } if (function.hasBody) { - reporter.report(source, FirErrors.ABSTRACT_FUNCTION_WITH_BODY) + reporter.report(FirErrors.ABSTRACT_FUNCTION_WITH_BODY.on(source, function)) } } val isInsideExpectClass = isInsideExpectClass(containingDeclaration, context) @@ -51,13 +51,13 @@ object FirMemberFunctionChecker : FirRegularClassChecker() { if (!function.hasBody) { if (containingDeclaration.isInterface) { if (Visibilities.isPrivate(function.visibility)) { - reporter.report(source, FirErrors.PRIVATE_FUNCTION_WITH_NO_BODY) + reporter.report(FirErrors.PRIVATE_FUNCTION_WITH_NO_BODY.on(source, function)) } if (!isInsideExpectClass && !hasAbstractModifier && hasOpenModifier) { reporter.report(source, FirErrors.REDUNDANT_OPEN_IN_INTERFACE) } } else if (!isInsideExpectClass && !hasAbstractModifier && !isExternal) { - reporter.report(FirErrors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY.on(source, function.symbol)) + reporter.report(FirErrors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY.on(source, function)) } } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index c254376d305..4b3e444d388 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -14,6 +14,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMB import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.TO_STRING import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_DELEGATED_PROPERTY +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_FUNCTION_WITH_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_WITH_GETTER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER @@ -71,6 +73,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.LOCAL_OBJECT_NOT_ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MANY_COMPANION_OBJECTS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.MISSING_VAL_ON_ANNOTATION_PARAMETER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NONE_APPLICABLE +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_ENUM import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NOT_AN_ANNOTATION_CLASS @@ -82,6 +85,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.NULLABLE_TYPE_OF_ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.OTHER_ERROR import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_FUNCTION_WITH_NO_BODY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_PROPERTY_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY @@ -97,6 +101,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_CALL_OF import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_EXPLICIT_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_MODALITY_MODIFIER import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_MODIFIER +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_OPEN_IN_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_RETURN_UNIT_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_SETTER_PARAMETER_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE @@ -263,6 +268,7 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING) map.put(DEPRECATED_MODIFIER_PAIR, "Modifier ''{0}'' is deprecated in presence of ''{1}''", TO_STRING, TO_STRING) map.put(INCOMPATIBLE_MODIFIERS, "Modifier ''{0}'' is incompatible with ''{1}''", TO_STRING, TO_STRING) + map.put(REDUNDANT_OPEN_IN_INTERFACE, "Modifier 'open' is redundant for abstract interface members") // Applicability map.put(NONE_APPLICABLE, "None of the following functions are applicable: {0}", SYMBOLS) @@ -336,6 +342,17 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { TO_STRING ) + // Functions + map.put( + ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, + "Abstract function ''{0}'' in non-abstract class ''{1}''", + DECLARATION_NAME, + DECLARATION_NAME + ) + map.put(ABSTRACT_FUNCTION_WITH_BODY, "A function ''{0}'' with body cannot be abstract", DECLARATION_NAME) + map.put(NON_ABSTRACT_FUNCTION_WITH_NO_BODY, "Function ''{0}'' without a body must be abstract", DECLARATION_NAME) + map.put(PRIVATE_FUNCTION_WITH_NO_BODY, "Function ''{0}'' without body cannot be private", DECLARATION_NAME) + // Properties & accessors map.put( ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS, diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 4fa70ac8702..dd95a824702 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -148,10 +148,10 @@ object FirErrors { val LOCAL_INTERFACE_NOT_ALLOWED by error1(SourceElementPositioningStrategies.DECLARATION_NAME) // Functions - val ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS by error0(SourceElementPositioningStrategies.MODALITY_MODIFIER) - val ABSTRACT_FUNCTION_WITH_BODY by error0(SourceElementPositioningStrategies.MODALITY_MODIFIER) - val NON_ABSTRACT_FUNCTION_WITH_NO_BODY by error1>() - val PRIVATE_FUNCTION_WITH_NO_BODY by error0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) + val ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS by error2(SourceElementPositioningStrategies.MODALITY_MODIFIER) + val ABSTRACT_FUNCTION_WITH_BODY by error1(SourceElementPositioningStrategies.MODALITY_MODIFIER) + val NON_ABSTRACT_FUNCTION_WITH_NO_BODY by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) + val PRIVATE_FUNCTION_WITH_NO_BODY by error1(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) // Properties & accessors val ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS by error2(SourceElementPositioningStrategies.MODALITY_MODIFIER) From 14108011eefff320696313a9972c54e8d083627c Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 14:03:14 +0300 Subject: [PATCH 041/122] [FIR] Fix inferring arguments of bare types in different situations - argument type is flexible - supertype has flexible type argument - type of expression is more specific than bare type --- ...TouchedTilContractsPhaseTestGenerated.java | 10 ++++++ .../testData/resolve/bareTypes2.fir.txt | 32 +++++++++++++++++++ .../testData/resolve/bareTypes2.kt | 25 +++++++++++++++ .../bareTypesWithFlexibleArguments.fir.txt | 11 +++++++ .../resolve/bareTypesWithFlexibleArguments.kt | 10 ++++++ .../runners/FirDiagnosticTestGenerated.java | 12 +++++++ ...DiagnosticsWithLightTreeTestGenerated.java | 12 +++++++ .../FirExpressionsResolveTransformer.kt | 25 +++++++++++---- 8 files changed, 131 insertions(+), 6 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/bareTypes2.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt create mode 100644 compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 8520639a6dc..cf7e0629eb3 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -39,6 +39,16 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/bareTypes.kt"); } + @TestMetadata("bareTypes2.kt") + public void testBareTypes2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt"); + } + + @TestMetadata("bareTypesWithFlexibleArguments.kt") + public void testBareTypesWithFlexibleArguments() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt"); + } + @TestMetadata("cast.kt") public void testCast() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/cast.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/bareTypes2.fir.txt b/compiler/fir/analysis-tests/testData/resolve/bareTypes2.fir.txt new file mode 100644 index 00000000000..bbec9d8c0e3 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/bareTypes2.fir.txt @@ -0,0 +1,32 @@ +FILE: bareTypes2.kt + public abstract interface A|> : R|kotlin/Any| { + public abstract fun foo(): R|kotlin/Any| + + public abstract val cond: R|kotlin/Boolean| + public get(): R|kotlin/Boolean| + + public abstract val field: R|kotlin/Any| + public get(): R|kotlin/Any| + + } + public abstract interface B|> : R|A| { + public abstract override fun foo(): R|kotlin/CharSequence| + + } + public abstract interface C : R|B| { + public abstract override fun foo(): R|kotlin/String| + + } + public final fun test(x: R|A<*>|): R|kotlin/Unit| { + when ((R|/x| as? R|C|)?.{ $subj$.R|/A.field| }) { + ($subj$ is R|kotlin/String|) -> { + when () { + ==((R|/x| as? R|B|)?.{ $subj$.R|/A.cond| }, Boolean(true)) -> { + R|/x|.R|/C.foo|() + } + } + + } + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt b/compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt new file mode 100644 index 00000000000..4193632c6b6 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt @@ -0,0 +1,25 @@ +interface A> { + fun foo(): Any + + val cond: Boolean + val field: Any +} + +interface B> : A { + override fun foo(): CharSequence +} + +interface C : B { + override fun foo(): String +} + +fun test(x: A<*>) { + when ((x as? C)?.field) { + is String -> { + if ((x as? B)?.cond == true) { + x.foo() + } + } + } + +} diff --git a/compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.fir.txt b/compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.fir.txt new file mode 100644 index 00000000000..e941ae5c122 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.fir.txt @@ -0,0 +1,11 @@ +FILE: bareTypesWithFlexibleArguments.kt + public final fun R|kotlin/collections/Collection?|.concat(collection: R|kotlin/collections/Collection|): R|kotlin/collections/Collection?| { + when () { + (this@R|/concat| is R|kotlin/collections/LinkedHashSet|) -> { + this@R|/concat|.R|SubstitutionOverride|(R|/collection|) + ^concat this@R|/concat| + } + } + + ^concat this@R|/concat| + } diff --git a/compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt b/compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt new file mode 100644 index 00000000000..837d08fc8ad --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt @@ -0,0 +1,10 @@ +// WITH_STDLIB +// FULL_JDK + +fun Collection?.concat(collection: Collection): Collection? { + if (this is LinkedHashSet) { + addAll(collection) + return this + } + return this +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index adb9a067766..64a33e4f967 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -38,6 +38,18 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/bareTypes.kt"); } + @Test + @TestMetadata("bareTypes2.kt") + public void testBareTypes2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt"); + } + + @Test + @TestMetadata("bareTypesWithFlexibleArguments.kt") + public void testBareTypesWithFlexibleArguments() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt"); + } + @Test @TestMetadata("cast.kt") public void testCast() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index d4e136ce4e9..a53aadfc92c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -39,6 +39,18 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/bareTypes.kt"); } + @Test + @TestMetadata("bareTypes2.kt") + public void testBareTypes2() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/bareTypes2.kt"); + } + + @Test + @TestMetadata("bareTypesWithFlexibleArguments.kt") + public void testBareTypesWithFlexibleArguments() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/bareTypesWithFlexibleArguments.kt"); + } + @Test @TestMetadata("cast.kt") public void testCast() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 0f18e0da2d8..2c35bf21862 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.fir.types.builder.* import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability +import org.jetbrains.kotlin.types.AbstractTypeChecker import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.types.TypeApproximatorConfiguration @@ -473,7 +474,10 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform val type = typeRef.coneTypeSafe() ?: return null val indexMapping = typeParameters.map { parameter -> // TODO: if many, check consistency of the result - type.typeArguments.indexOfFirst { it is ConeTypeParameterType && it.lookupTag.typeParameterSymbol == parameter.symbol } + type.typeArguments.indexOfFirst { + val argument = (it as? ConeKotlinType)?.lowerBoundIfFlexible() + argument is ConeTypeParameterType && argument.lookupTag.typeParameterSymbol == parameter.symbol + } } if (indexMapping.any { it == -1 }) return null @@ -488,14 +492,23 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform val firClass = type.lookupTag.toSymbol(session)?.fir ?: return this if (firClass !is FirTypeParameterRefsOwner || firClass.typeParameters.isEmpty()) return this - val baseType = argument.typeRef.coneTypeSafe()?.fullyExpandedType(session) ?: return this + val baseType = argument.typeRef.coneTypeSafe()?.lowerBoundIfFlexible()?.fullyExpandedType(session) ?: return this + if (baseType !is ConeClassLikeType) return this val baseFirClass = baseType.lookupTag.toSymbol(session)?.fir ?: return this - val newArguments = type.inheritTypeArguments(baseFirClass, baseType.typeArguments) - ?: return buildErrorTypeRef { - source = this@withTypeArgumentsForBareType.source - diagnostic = ConeWrongNumberOfTypeArgumentsError(firClass.typeParameters.size, firClass.symbol) + val newArguments = if (AbstractTypeChecker.isSubtypeOfClass(session.typeCheckerContext, baseType.lookupTag, type.lookupTag)) { + // If actual type of declaration is more specific than bare type then we should just find + // corresponding supertype with proper arguments + with(session.typeContext) { + val superType = baseType.fastCorrespondingSupertypes(type.lookupTag)?.firstOrNull() as? ConeKotlinType? + superType?.typeArguments } + } else { + type.inheritTypeArguments(baseFirClass, baseType.typeArguments) + } ?: return buildErrorTypeRef { + source = this@withTypeArgumentsForBareType.source + diagnostic = ConeWrongNumberOfTypeArgumentsError(firClass.typeParameters.size, firClass.symbol) + } return if (newArguments.isEmpty()) this else withReplacedConeType(type.withArguments(newArguments)) } From 77ffc318f2c2b9cbfa2dbae8d8e6d7c1dde77c88 Mon Sep 17 00:00:00 2001 From: Andrei Klunnyi Date: Mon, 18 Jan 2021 15:55:38 +0100 Subject: [PATCH 042/122] KT-44250 [Sealed interfaces]: completion fails for 'when' with sealed --- .../idea/compiler/IdeSealedClassInheritorsProvider.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IdeSealedClassInheritorsProvider.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IdeSealedClassInheritorsProvider.kt index 7f0268cd7c8..13fdb4c15d7 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IdeSealedClassInheritorsProvider.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/IdeSealedClassInheritorsProvider.kt @@ -31,7 +31,7 @@ object IdeSealedClassInheritorsProvider : SealedClassInheritorsProvider() { val module = sealedKtClass.module ?: return emptyList() val moduleSourceScope = GlobalSearchScope.moduleScope(module) val containingPackage = sealedClass.containingPackage() ?: return emptyList() - val psiPackage = JavaDirectoryService.getInstance().getPackage(sealedKtClass.containingFile.containingDirectory) + val psiPackage = getPackageViaDirectoryService(sealedKtClass) ?: JavaPsiFacade.getInstance(sealedKtClass.project).findPackage(containingPackage.asString()) ?: return emptyList() val packageScope = PackageScope(psiPackage, false, false) @@ -50,4 +50,9 @@ object IdeSealedClassInheritorsProvider : SealedClassInheritorsProvider() { }.filterNotNull() .sortedBy(ClassDescriptor::getName) // order needs to be stable (at least for tests) } + + private fun getPackageViaDirectoryService(ktClass: KtClass): PsiPackage? { + val directory = ktClass.containingFile.containingDirectory ?: return null + return JavaDirectoryService.getInstance().getPackage(directory) + } } \ No newline at end of file From 17b71555e0d05502a9b32c0636190ac69c8cbc64 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Wed, 13 Jan 2021 15:25:35 +0400 Subject: [PATCH 043/122] KT-43944: Don't access Android test source sets' API configurations When dependencies are added to our corresponding configurations, report errors, as there's no proper way to add those dependencies. Issue #KT-43944 Fixed --- .../AbstractKotlinAndroidGradleTests.kt | 57 +++++++++++++++++-- .../kotlin/gradle/util/AGPVersion.kt | 1 + .../new-mpp-android/app/build.gradle | 2 +- .../new-mpp-android/lib/build.gradle | 2 +- .../kotlin/gradle/plugin/KotlinPlugin.kt | 12 +++- 5 files changed, 65 insertions(+), 9 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt index 56b5f2dd6ce..247e3ab8714 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt @@ -75,7 +75,7 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { } @Test - fun testAndroidWithNewMppApp() = with(Project("new-mpp-android", GradleVersionRequired.FOR_MPP_SUPPORT)) { + fun testAndroidWithNewMppApp() = with(Project("new-mpp-android")) { build("assemble", "compileDebugUnitTestJavaWithJavac", "printCompilerPluginOptions") { assertSuccessful() @@ -114,7 +114,10 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { compilerPluginArgsRegex.findAll(output).associate { it.groupValues[1] to it.groupValues[2] } compilerPluginOptionsBySourceSet.entries.forEach { (sourceSetName, argsString) -> - val shouldHaveAndroidExtensionArgs = sourceSetName.startsWith("androidApp") + val shouldHaveAndroidExtensionArgs = + sourceSetName.startsWith("androidApp") && ( + androidGradlePluginVersion < AGPVersion.v7_0_0 || !sourceSetName.contains("AndroidTestRelease") + ) if (shouldHaveAndroidExtensionArgs) assertTrue("$sourceSetName is an Android source set and should have Android Extensions in the args") { "plugin:org.jetbrains.kotlin.android" in argsString @@ -260,7 +263,7 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { } @Test - fun testAndroidMppProductionDependenciesInTests() = with(Project("new-mpp-android", GradleVersionRequired.FOR_MPP_SUPPORT)) { + fun testAndroidMppProductionDependenciesInTests() = with(Project("new-mpp-android")) { // Test the fix for KT-29343 setupWorkingDir() @@ -314,7 +317,7 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { } @Test - fun testCustomAttributesInAndroidTargets() = with(Project("new-mpp-android", GradleVersionRequired.FOR_MPP_SUPPORT)) { + fun testCustomAttributesInAndroidTargets() = with(Project("new-mpp-android")) { // Test the fix for KT-27714 setupWorkingDir() @@ -346,6 +349,16 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { run { val appBuildScriptBackup = gradleBuildScript("app").readText() + gradleBuildScript("lib").appendText( + "\n" + """ + kotlin.targets.all { + attributes.attribute( + Attribute.of("com.example.target", String), + targetName + ) + } + """.trimIndent() + ) gradleBuildScript("app").appendText( "\n" + """ kotlin.targets.androidApp.attributes.attribute( @@ -357,9 +370,24 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { build(":app:compileDebugKotlinAndroidApp") { assertFailed() // dependency resolution should fail - assertContains("Required com.example.target 'notAndroidLib'") + assertTrue( + "Required com.example.target 'notAndroidLib'" in output || + "attribute 'com.example.target' with value 'notAndroidLib'" in output + ) } + gradleBuildScript("lib").writeText( + appBuildScriptBackup + "\n" + """ + kotlin.targets.all { + compilations.all { + attributes.attribute( + Attribute.of("com.example.compilation", String), + targetName + compilationName.capitalize() + ) + } + } + """.trimIndent() + ) gradleBuildScript("app").writeText( appBuildScriptBackup + "\n" + """ kotlin.targets.androidApp.compilations.all { @@ -373,7 +401,10 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { build(":app:compileDebugKotlinAndroidApp") { assertFailed() - assertContains("Required com.example.compilation 'notDebug'") + assertTrue( + "Required com.example.compilation 'notDebug'" in output || + "attribute 'com.example.compilation' with value 'notDebug'" in output + ) } } } @@ -405,6 +436,20 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { } } +open class KotlinAndroid70GradleIT : KotlinAndroid36GradleIT() { + override val androidGradlePluginVersion: AGPVersion + get() = AGPVersion.v7_0_0 + + override val defaultGradleVersion: GradleVersionRequired + get() = GradleVersionRequired.AtLeast("6.8") + + override fun defaultBuildOptions(): BuildOptions { + val javaHome = File(System.getProperty("jdk11Home")!!) + Assume.assumeTrue("JDK 11 should be available", javaHome.isDirectory) + return super.defaultBuildOptions().copy(javaHome = javaHome, warningMode = WarningMode.Summary) + } +} + open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() { override val androidGradlePluginVersion: AGPVersion get() = AGPVersion.v3_2_0 diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/AGPVersion.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/AGPVersion.kt index 75b04c88c68..0fba0bacefc 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/AGPVersion.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/AGPVersion.kt @@ -26,5 +26,6 @@ class AGPVersion private constructor(private val versionNumber: VersionNumber) { val v3_6_0 = fromString("3.6.0") val v4_1_0 = fromString("4.1.0-beta02") val v4_2_0 = fromString("4.2.0-alpha10") + val v7_0_0 = fromString("7.0.0-alpha03") } } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle index a53f35cae83..19fae98ebd1 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/app/build.gradle @@ -10,7 +10,7 @@ android { defaultConfig { applicationId "app.example.com.app_sample" minSdkVersion 21 - targetSdkVersion 27 + targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle index ca9a42518bd..d9d555d50c1 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/new-mpp-android/lib/build.gradle @@ -10,7 +10,7 @@ android { defaultConfig { minSdkVersion 21 - targetSdkVersion 27 + targetSdkVersion 29 versionCode 1 versionName "1.0" diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt index 288ea2be08f..6d28b3110eb 100755 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinPlugin.kt @@ -855,7 +855,17 @@ abstract class AbstractAndroidProjectHandler(private val kotlinConfigurationTool compileOnlyConfigurationName: String, runtimeOnlyConfigurationName: String ) { - project.addExtendsFromRelation(androidSourceSet.apiConfigurationName, apiConfigurationName) + if (project.configurations.findByName(androidSourceSet.apiConfigurationName) != null) { + project.addExtendsFromRelation(androidSourceSet.apiConfigurationName, apiConfigurationName) + } else { + // If any dependency is added to this configuration, report an error: + project.configurations.getByName(apiConfigurationName).dependencies.all { dependency -> + throw InvalidUserCodeException( + "API dependencies are not allowed for Android source set ${androidSourceSet.name}. " + + "Please use an implementation dependency instead." + ) + } + } project.addExtendsFromRelation(androidSourceSet.implementationConfigurationName, implementationConfigurationName) project.addExtendsFromRelation(androidSourceSet.compileOnlyConfigurationName, compileOnlyConfigurationName) project.addExtendsFromRelation(androidSourceSet.runtimeOnlyConfigurationName, runtimeOnlyConfigurationName) From 341b87fad0db8de4a17dc2085556580e92255486 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Wed, 13 Jan 2021 15:21:20 +0400 Subject: [PATCH 044/122] Use `implementation` instead of `compile` in GradleIT, fix versions --- .../AbstractKotlinAndroidGradleTests.kt | 55 ++++--------------- .../AndroidDaggerProject/app/build.gradle | 10 ++-- .../app/build.gradle | 4 +- .../AndroidExtensionsProject/app/build.gradle | 4 +- .../app/build.gradle | 4 +- .../AndroidIcepickProject/app/build.gradle | 6 +- .../app/build.gradle | 8 +-- .../libAndroid/build.gradle | 2 +- .../libAndroidClassesOnly/build.gradle | 2 +- .../libJvmClassesOnly/build.gradle | 2 +- .../app/build.gradle | 4 +- .../AndroidJackProject/Android/build.gradle | 6 +- .../AndroidJackProject/Lib/build.gradle | 6 +- .../aaa/build.gradle | 2 +- .../app/build.gradle | 2 +- .../lib-a/build.gradle | 2 +- .../AndroidLibraryKotlinProject/build.gradle | 2 +- .../AndroidParcelizeProject/app/build.gradle | 6 +- .../AndroidProject/Android/build.gradle | 6 +- .../AndroidProject/Lib/build.gradle | 8 +-- .../AndroidProject/Test/build.gradle | 2 +- .../additionalJavaSrc/build.gradle | 6 +- .../a/b/build.gradle | 2 +- .../allOpenFromScript/kotlin.gradle | 2 +- .../testProject/allOpenSimple/build.gradle | 2 +- .../testProject/allOpenSpring/build.gradle | 2 +- .../coroutinesProjectDSL/build.gradle | 2 +- .../testProject/customJdk/build.gradle | 2 +- .../testProject/customSrcDir/build.gradle | 6 +- .../build.gradle | 4 +- .../testProject/groovyInterop/build.gradle | 2 +- .../interopWithProguarded/build.gradle | 8 +-- .../android-butterknife/app/build.gradle | 8 +-- .../kapt2/android-dagger/app/build.gradle | 10 ++-- .../android-databinding/app/build.gradle | 8 +-- .../kapt2/android-dbflow/app/build.gradle | 14 ++--- .../android-inter-project-ic/app/build.gradle | 12 ++-- .../lib-android/build.gradle | 2 +- .../lib-jvm/build.gradle | 2 +- .../kapt2/android-realm/build.gradle | 6 +- .../annotationProcessorAsFqName/build.gradle | 4 +- .../testProject/kapt2/arguments/build.gradle | 4 +- .../kapt2/autoService/build.gradle | 4 +- .../kapt2/autoService/processor/build.gradle | 4 +- .../kapt2/generatedDirUpToDate/build.gradle | 4 +- .../kapt2/icAnonymousTypes/build.gradle | 2 +- .../kapt2/incrementalRebuild/build.gradle | 4 +- .../kapt2/inheritedAnnotations/build.gradle | 4 +- .../javacIsLoadedOnce/module1/build.gradle | 4 +- .../javacIsLoadedOnce/module2/build.gradle | 6 +- .../kapt2/kaptOutputKotlinCode/build.gradle | 4 +- .../kapt2/kaptSkipped/build.gradle | 2 +- .../kapt2/kt15001/app/build.gradle | 8 +-- .../kapt2/kt18799/app/build.gradle | 4 +- .../kapt2/kt19179/api/build.gradle | 2 +- .../kapt2/kt19179/app/build.gradle | 4 +- .../kapt2/kt19179/processor/build.gradle | 6 +- .../annotation-processor/build.gradle | 4 +- .../example/build.gradle | 8 +-- .../kapt2/locationMapping/build.gradle | 6 +- .../kapt2/mpp-kapt-presence/dac/build.gradle | 2 +- .../testProject/kapt2/nokapt/build.gradle | 6 +- .../kotlin2JsICProject/app/build.gradle | 4 +- .../kotlin2JsICProject/lib/build.gradle | 2 +- .../kotlin2JsInternalTest/build.gradle | 6 +- .../kotlin2JsIrDtsGeneration/build.gradle | 2 +- .../kotlin2JsModuleKind/build.gradle | 6 +- .../libraryProject/build.gradle | 4 +- .../kotlin2JsProject/mainProject/build.gradle | 4 +- .../build.gradle | 4 +- .../build.gradle | 4 +- .../kotlin2JsProjectWithTests/build.gradle | 6 +- .../kotlinGradleSubplugin/build.gradle | 2 +- .../testProject/moduleName/build.gradle | 2 +- .../multiplatformAndroidProject/build.gradle | 20 ------- .../lib/build.gradle | 5 -- .../lib/src/main/kotlin/PlatformClass.kt | 7 --- .../lib/src/test/kotlin/PlatformTest.kt | 7 --- .../libAndroid/build.gradle | 20 ------- .../libAndroid/src/main/AndroidManifest.xml | 8 --- .../src/main/kotlin/PlatformClass.kt | 5 -- .../src/main/kotlin/androidSdkUse.kt | 8 --- .../src/test/kotlin/PlatformTest.kt | 5 -- .../libJvm/build.gradle | 7 --- .../libJvm/src/main/kotlin/PlatformClass.kt | 5 -- .../libJvm/src/main/kotlin/javaLibUse.kt | 7 --- .../libJvm/src/test/kotlin/PlatformTest.kt | 5 -- .../settings.gradle | 1 - .../libJvm/build.gradle | 4 +- .../testProject/noArgJpa/build.gradle | 2 +- .../testProject/noArgKt18668/build.gradle | 2 +- .../samWithReceiverSimple/build.gradle | 2 +- .../testProject/scalaInterop/build.gradle | 8 +-- .../testProject/scripting/app/build.gradle | 2 +- .../scripting/script-template/build.gradle | 4 +- .../scriptingCustomExtension/app/build.gradle | 2 +- .../script-template/build.gradle | 4 +- .../testProject/suppressWarnings/build.gradle | 2 +- 98 files changed, 192 insertions(+), 335 deletions(-) delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/build.gradle delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/build.gradle delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/main/kotlin/PlatformClass.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/test/kotlin/PlatformTest.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/build.gradle delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/AndroidManifest.xml delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/PlatformClass.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/androidSdkUse.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/test/kotlin/PlatformTest.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/build.gradle delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/PlatformClass.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/javaLibUse.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/test/kotlin/PlatformTest.kt delete mode 100644 libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/settings.gradle diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt index 247e3ab8714..a7bf583801c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/AbstractKotlinAndroidGradleTests.kt @@ -1,6 +1,7 @@ package org.jetbrains.kotlin.gradle import org.gradle.api.logging.LogLevel +import org.gradle.api.logging.configuration.WarningMode import org.jetbrains.kotlin.gradle.util.* import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.util.KtTestUtil @@ -23,7 +24,7 @@ open class KotlinAndroid36GradleIT : KotlinAndroid33GradleIT() { get() = GradleVersionRequired.AtLeast("6.0") @Test - fun testAndroidMppSourceSets(): Unit = with(Project("new-mpp-android-source-sets", GradleVersionRequired.FOR_MPP_SUPPORT)) { + fun testAndroidMppSourceSets(): Unit = with(Project("new-mpp-android-source-sets")) { build("sourceSets") { assertSuccessful() @@ -473,7 +474,6 @@ open class KotlinAndroid32GradleIT : KotlinAndroid3GradleIT() { File inputFile = null @Override - @Internal Iterable asArguments() { // Read the arguments from a file, because changing them in a build script is treated as an // implementation change by Gradle: @@ -863,54 +863,21 @@ fun getSomething() = 10 } } - @Test - fun testMultiplatformAndroidCompile() = with(Project("multiplatformAndroidProject")) { - setupWorkingDir() - - if (androidGradlePluginVersion >= AGPVersion.v3_6_0) { - - } - - // Check that the common module is not added to the deprecated configuration 'compile' (KT-23719): - gradleBuildScript("libAndroid").appendText( - """${'\n'} - configurations.compile.dependencies.all { aDependencyExists -> - throw GradleException("Check failed") - } - """.trimIndent() - ) - - build("build") { - assertSuccessful() - assertTasksExecuted( - ":lib:compileKotlinCommon", - ":lib:compileTestKotlinCommon", - ":libJvm:compileKotlin", - ":libJvm:compileTestKotlin", - ":libAndroid:compileDebugKotlin", - ":libAndroid:compileReleaseKotlin", - ":libAndroid:compileDebugUnitTestKotlin", - ":libAndroid:compileReleaseUnitTestKotlin" - ) - - assertFileExists("lib/build/classes/kotlin/main/foo/PlatformClass.kotlin_metadata") - assertFileExists("lib/build/classes/kotlin/test/foo/PlatformTest.kotlin_metadata") - assertFileExists("libJvm/build/classes/kotlin/main/foo/PlatformClass.class") - assertFileExists("libJvm/build/classes/kotlin/test/foo/PlatformTest.class") - - assertFileExists("libAndroid/build/tmp/kotlin-classes/debug/foo/PlatformClass.class") - assertFileExists("libAndroid/build/tmp/kotlin-classes/release/foo/PlatformClass.class") - assertFileExists("libAndroid/build/tmp/kotlin-classes/debugUnitTest/foo/PlatformTest.class") - assertFileExists("libAndroid/build/tmp/kotlin-classes/debugUnitTest/foo/PlatformTest.class") - } - } - @Test fun testDetectAndroidJava8() = with(Project("AndroidProject")) { setupWorkingDir() val kotlinJvmTarget18Regex = Regex("Kotlin compiler args: .* -jvm-target 1.8") + gradleBuildScript("Lib").appendText( + "\n" + """ + android.compileOptions { + sourceCompatibility JavaVersion.VERSION_1_6 + targetCompatibility JavaVersion.VERSION_1_6 + } + """.trimIndent() + ) + build(":Lib:assembleDebug", "-Pkotlin.setJvmTargetFromAndroidCompileOptions=true") { assertSuccessful() assertNotContains(kotlinJvmTarget18Regex) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidDaggerProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidDaggerProject/app/build.gradle index d3944ff72ca..a506bcd8edd 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidDaggerProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidDaggerProject/app/build.gradle @@ -40,11 +40,11 @@ repositories { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.1.1' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:23.1.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.dagger:dagger:2.0.1' + implementation 'com.google.dagger:dagger:2.0.1' kapt 'com.google.dagger:dagger-compiler:2.0' - provided 'org.glassfish:javax.annotation:10.0-b28' + compileOnly 'org.glassfish:javax.annotation:10.0-b28' } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsManyVariants/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsManyVariants/app/build.gradle index 25c740436c7..b0c457b94ae 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsManyVariants/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsManyVariants/app/build.gradle @@ -45,6 +45,6 @@ androidExtensions { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsProject/app/build.gradle index a1bce8d11f1..83a09ec6c55 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsProject/app/build.gradle @@ -19,6 +19,6 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsSpecificFeatures/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsSpecificFeatures/app/build.gradle index 0bf1a4325c8..6aa8b7391a3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsSpecificFeatures/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidExtensionsSpecificFeatures/app/build.gradle @@ -24,8 +24,8 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } androidExtensions { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIcepickProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIcepickProject/app/build.gradle index 59232eb989d..4dfc329a0b1 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIcepickProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIcepickProject/app/build.gradle @@ -3,13 +3,13 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' dependencies { - compile "frankiesardo:icepick:3.2.0" + implementation "frankiesardo:icepick:3.2.0" kapt "frankiesardo:icepick-processor:3.2.0" - compile 'org.parceler:parceler-api:1.1.5' + implementation 'org.parceler:parceler-api:1.1.5' kapt 'org.parceler:parceler:1.1.5' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } android { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/app/build.gradle index a2c0d217733..faefb4e7ca0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/app/build.gradle @@ -17,8 +17,8 @@ android { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile project(":libJvmClassesOnly") - compile project(":libAndroid") - compile project(":libAndroidClassesOnly") + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation project(":libJvmClassesOnly") + implementation project(":libAndroid") + implementation project(":libAndroidClassesOnly") } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroid/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroid/build.gradle index 87353a02404..1e9fbb4b874 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroid/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroid/build.gradle @@ -16,5 +16,5 @@ android { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroidClassesOnly/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroidClassesOnly/build.gradle index e2279e8f90d..934e9ad5044 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroidClassesOnly/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libAndroidClassesOnly/build.gradle @@ -16,5 +16,5 @@ android { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libJvmClassesOnly/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libJvmClassesOnly/build.gradle index 94c8ab22d92..c27bc6f3fc0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libJvmClassesOnly/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalMultiModule/libJvmClassesOnly/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'kotlin' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalSingleModuleProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalSingleModuleProject/app/build.gradle index fd030fc7763..26cd64d047b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalSingleModuleProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidIncrementalSingleModuleProject/app/build.gradle @@ -44,6 +44,6 @@ repositories { } dependencies { - compile 'com.android.support:appcompat-v7:23.1.1' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.android.support:appcompat-v7:23.1.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Android/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Android/build.gradle index 210f315a5c9..c78faf5564a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Android/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Android/build.gradle @@ -2,9 +2,9 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' dependencies { - compile project(':Lib') - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - testCompile 'junit:junit:4.12' + implementation project(':Lib') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testImplementation'junit:junit:4.12' } android { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Lib/build.gradle index 4180f60cf40..a1f94c14583 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidJackProject/Lib/build.gradle @@ -2,10 +2,10 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' dependencies { - compile files('libs/android-support-v4.jar') + implementation files('libs/android-support-v4.jar') // unused but needed for IncrementalCompilationMultiProjectIT.testAndroid to check if non-local dependency affects IC - compile 'io.reactivex:rxjava:1.1.9' - compile 'com.loopj.android:android-async-http:1.4.9' + implementation 'io.reactivex:rxjava:1.1.9' + implementation 'com.loopj.android:android-async-http:1.4.9' } android { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/aaa/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/aaa/build.gradle index 90480dd6356..74d691a688e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/aaa/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/aaa/build.gradle @@ -14,7 +14,7 @@ android { } dependencies { - compile project(':lib-a') + implementation project(':lib-a') kapt "com.squareup.dagger:dagger-compiler:$dagger_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/app/build.gradle index a402ff6d2a9..eb740335924 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/app/build.gradle @@ -18,7 +18,7 @@ android { } dependencies { - compile project(':aaa') + implementation project(':aaa') kapt "com.squareup.dagger:dagger-compiler:$dagger_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/lib-a/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/lib-a/build.gradle index 9b6cfaa9d00..36db4a1b55c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/lib-a/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidKaptChangingDependencies/lib-a/build.gradle @@ -14,7 +14,7 @@ android { } dependencies { - compile "com.android.support:appcompat-v7:$support_lib_version" + implementation "com.android.support:appcompat-v7:$support_lib_version" kapt "com.squareup.dagger:dagger-compiler:$dagger_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidLibraryKotlinProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidLibraryKotlinProject/build.gradle index 463e39d4b86..67a3ddee160 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidLibraryKotlinProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidLibraryKotlinProject/build.gradle @@ -25,5 +25,5 @@ android { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidParcelizeProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidParcelizeProject/app/build.gradle index 9ad20318610..ee94896eee3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidParcelizeProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidParcelizeProject/app/build.gradle @@ -24,7 +24,7 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-android-extensions-runtime:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Android/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Android/build.gradle index 569cc883c54..28abf49d10b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Android/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Android/build.gradle @@ -58,11 +58,11 @@ if (VersionNumber.parse(android_tools_version) < VersionNumber.parse("3.0.0-alph } else { dependencies { - compile project(":Lib") + implementation project(":Lib") } } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - testCompile 'junit:junit:4.12' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testImplementation'junit:junit:4.12' } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Lib/build.gradle index 0d2984e811a..34e95b00953 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Lib/build.gradle @@ -2,11 +2,11 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile files('libs/android-support-v4.jar') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation files('libs/android-support-v4.jar') // unused but needed for IncrementalCompilationMultiProjectIT.testAndroid to check if non-local dependency affects IC - compile 'io.reactivex:rxjava:1.1.9' - compile 'com.loopj.android:android-async-http:1.4.9' + implementation 'io.reactivex:rxjava:1.1.9' + implementation 'com.loopj.android:android-async-http:1.4.9' } android { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Test/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Test/build.gradle index 6e7de7d357a..23dda290031 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Test/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/AndroidProject/Test/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'com.android.test' apply plugin: 'kotlin-android' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } android { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/additionalJavaSrc/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/additionalJavaSrc/build.gradle index b055a8fa9b9..5292c079d16 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/additionalJavaSrc/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/additionalJavaSrc/build.gradle @@ -25,9 +25,9 @@ sourceSets { } dependencies { - compile 'com.google.guava:guava:12.0' - testCompile 'org.testng:testng:6.8' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.google.guava:guava:12.0' + testImplementation'org.testng:testng:6.8' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } test { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromNestedBuildscript/a/b/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromNestedBuildscript/a/b/build.gradle index 4676cfddfd8..8600c7d7d0f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromNestedBuildscript/a/b/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromNestedBuildscript/a/b/build.gradle @@ -11,5 +11,5 @@ allOpen { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromScript/kotlin.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromScript/kotlin.gradle index 9d37fc4159d..d2d4e25c898 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromScript/kotlin.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenFromScript/kotlin.gradle @@ -22,5 +22,5 @@ allOpen { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle index a31e3907aae..c1099b81770 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSimple/build.gradle @@ -26,5 +26,5 @@ allOpen { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle index 2239e8cc243..5c2023831e9 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/allOpenSpring/build.gradle @@ -22,5 +22,5 @@ sourceSets { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/coroutinesProjectDSL/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/coroutinesProjectDSL/build.gradle index 72503d73aeb..41cb1240a3f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/coroutinesProjectDSL/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/coroutinesProjectDSL/build.gradle @@ -22,5 +22,5 @@ kotlin { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customJdk/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customJdk/build.gradle index 8579a03e25a..fadc0850e11 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customJdk/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customJdk/build.gradle @@ -24,7 +24,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } compileKotlin { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customSrcDir/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customSrcDir/build.gradle index 3ac0dd2e688..07a79985887 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customSrcDir/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/customSrcDir/build.gradle @@ -26,9 +26,9 @@ repositories { } dependencies { - compile 'com.google.guava:guava:12.0' - testCompile 'org.testng:testng:6.8' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.google.guava:guava:12.0' + testImplementation'org.testng:testng:6.8' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } test { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/destinationDirReferencedDuringEvaluation/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/destinationDirReferencedDuringEvaluation/build.gradle index 2098ae0d9e8..a13a9f3f677 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/destinationDirReferencedDuringEvaluation/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/destinationDirReferencedDuringEvaluation/build.gradle @@ -17,8 +17,8 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - testCompile 'junit:junit:4.12' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + testImplementation'junit:junit:4.12' } // important to test that destinationDir is configured before evaluation diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyInterop/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyInterop/build.gradle index bb76dbcce7b..c4b843f693f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyInterop/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/groovyInterop/build.gradle @@ -19,7 +19,7 @@ repositories { dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testCompile 'junit:junit:4.12' + testImplementation'junit:junit:4.12' compile project(":lib") } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/interopWithProguarded/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/interopWithProguarded/build.gradle index a610154c434..ec1d850c36e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/interopWithProguarded/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/interopWithProguarded/build.gradle @@ -17,10 +17,10 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testCompile 'junit:junit:4.12' - compile project(path: ":lib", configuration: "proguarded") + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testImplementation'junit:junit:4.12' + implementation project(path: ":lib", configuration: "proguarded") } compileKotlin { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-butterknife/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-butterknife/app/build.gradle index ccc952639bb..0a09830ebe5 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-butterknife/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-butterknife/app/build.gradle @@ -27,10 +27,10 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.3.0' - compile 'com.jakewharton:butterknife:8.0.1' + implementation 'com.android.support:appcompat-v7:23.3.0' + implementation 'com.jakewharton:butterknife:8.0.1' kapt 'com.jakewharton:butterknife-compiler:8.0.1' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dagger/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dagger/app/build.gradle index f9f8a5254b1..d13de145205 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dagger/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dagger/app/build.gradle @@ -26,11 +26,11 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.3.0' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:appcompat-v7:23.3.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.dagger:dagger:2.6.1' + implementation 'com.google.dagger:dagger:2.6.1' kapt 'com.google.dagger:dagger-compiler:2.6.1' - provided 'org.glassfish:javax.annotation:10.0-b28' + compileOnly 'org.glassfish:javax.annotation:10.0-b28' } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-databinding/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-databinding/app/build.gradle index 905af95d3a5..9b0ca4c359c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-databinding/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-databinding/app/build.gradle @@ -25,10 +25,10 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" kapt "com.android.databinding:compiler:$android_tools_version" kaptAndroidTest "junit:junit:4.12" - compile 'com.android.support.constraint:constraint-layout:1.0.2' - testCompile 'junit:junit:4.12' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' + testImplementation'junit:junit:4.12' } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dbflow/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dbflow/app/build.gradle index c1726d5b8f6..b15ce741c65 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dbflow/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-dbflow/app/build.gradle @@ -22,17 +22,17 @@ def dbflow_version = "3.1.1" dependencies { // Android Support Libraries - compile 'com.android.support:appcompat-v7:23.3.0' - compile 'com.android.support:cardview-v7:23.3.0' - compile 'com.android.support:recyclerview-v7:23.3.0' + implementation 'com.android.support:appcompat-v7:23.3.0' + implementation 'com.android.support:cardview-v7:23.3.0' + implementation 'com.android.support:recyclerview-v7:23.3.0' // DBFlow kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}" - compile "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}" - compile "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}" - compile "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${dbflow_version}" + implementation "com.github.Raizlabs.DBFlow:dbflow-core:${dbflow_version}" + implementation "com.github.Raizlabs.DBFlow:dbflow:${dbflow_version}" + implementation "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${dbflow_version}" // Kotlin - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/app/build.gradle index 9c107be68b2..45d459d6f61 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/app/build.gradle @@ -17,12 +17,12 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + implementation fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.3.0' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile project(':lib-android') - compile project(':lib-jvm') - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation 'com.android.support:appcompat-v7:23.3.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation project(':lib-android') + implementation project(':lib-jvm') + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-android/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-android/build.gradle index 144a8f25025..21e04d4ea32 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-android/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-android/build.gradle @@ -14,5 +14,5 @@ android { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-jvm/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-jvm/build.gradle index 94c8ab22d92..c27bc6f3fc0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-jvm/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-inter-project-ic/lib-jvm/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'kotlin' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-realm/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-realm/build.gradle index 4123e604254..d589ce522d1 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-realm/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/android-realm/build.gradle @@ -66,7 +66,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - compile 'org.jetbrains.anko:anko-common:0.9' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + implementation 'org.jetbrains.anko:anko-common:0.9' } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/annotationProcessorAsFqName/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/annotationProcessorAsFqName/build.gradle index 60ca5218d8d..c8f7a91b48e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/annotationProcessorAsFqName/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/annotationProcessorAsFqName/build.gradle @@ -22,7 +22,7 @@ kapt { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" kapt "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/arguments/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/arguments/build.gradle index 455654bfba7..887a944f1a3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/arguments/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/arguments/build.gradle @@ -17,8 +17,8 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/build.gradle index da590eadb56..8a7682ed77c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/build.gradle @@ -19,7 +19,7 @@ allprojects { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile project(":processor") + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation project(":processor") kapt project(":processor") } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/processor/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/processor/build.gradle index 5edd5035436..2a8bec13a8a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/processor/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/autoService/processor/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'kotlin' dependencies { ext.autoServiceVersion = '1.0-rc2' - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "com.google.auto.service:auto-service:$autoServiceVersion" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "com.google.auto.service:auto-service:$autoServiceVersion" kapt "com.google.auto.service:auto-service:$autoServiceVersion" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/generatedDirUpToDate/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/generatedDirUpToDate/build.gradle index f276cd40603..1fd631c588a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/generatedDirUpToDate/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/generatedDirUpToDate/build.gradle @@ -18,7 +18,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/icAnonymousTypes/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/icAnonymousTypes/build.gradle index 6437c69238e..164a65d623c 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/icAnonymousTypes/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/icAnonymousTypes/build.gradle @@ -41,6 +41,6 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" kapt "com.android.databinding:compiler:$android_tools_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/incrementalRebuild/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/incrementalRebuild/build.gradle index 042cd12474a..61d62a5db5b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/incrementalRebuild/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/incrementalRebuild/build.gradle @@ -18,7 +18,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.dagger:dagger:2.14.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.google.dagger:dagger:2.14.1' kapt 'com.google.dagger:dagger-compiler:2.14.1' } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/inheritedAnnotations/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/inheritedAnnotations/build.gradle index f276cd40603..1fd631c588a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/inheritedAnnotations/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/inheritedAnnotations/build.gradle @@ -18,7 +18,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module1/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module1/build.gradle index 76311bd4dc3..ed7870af24f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module1/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module1/build.gradle @@ -2,7 +2,7 @@ apply plugin: "kotlin" apply plugin: "kotlin-kapt" dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module2/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module2/build.gradle index c0d6a83114f..b19935abe56 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module2/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/javacIsLoadedOnce/module2/build.gradle @@ -2,8 +2,8 @@ apply plugin: "kotlin" apply plugin: "kotlin-kapt" dependencies { - compile project(":module1") - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation project(":module1") + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptOutputKotlinCode/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptOutputKotlinCode/build.gradle index 1b3dc5d680c..b4dee3f1929 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptOutputKotlinCode/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptOutputKotlinCode/build.gradle @@ -17,8 +17,8 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptSkipped/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptSkipped/build.gradle index 2dd5423eced..6dadebe737d 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptSkipped/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kaptSkipped/build.gradle @@ -18,5 +18,5 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle index 25fbe77b60a..4fb7e01dbe0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle @@ -23,11 +23,11 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.dagger:dagger:2.8' + implementation 'com.google.dagger:dagger:2.8' kapt 'com.google.dagger:dagger-compiler:2.8' - compile 'com.android.support:appcompat-v7:23.3.0' + implementation 'com.android.support:appcompat-v7:23.3.0' } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt18799/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt18799/app/build.gradle index e634ff94502..ef169b56aa4 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt18799/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt18799/app/build.gradle @@ -2,8 +2,8 @@ apply plugin: 'kotlin' apply plugin: 'kotlin-kapt' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - compile 'com.google.dagger:dagger:2.9' + implementation 'com.google.dagger:dagger:2.9' kapt 'com.google.dagger:dagger-compiler:2.9' } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/api/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/api/build.gradle index 0a21010a664..ec4d9520028 100755 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/api/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/api/build.gradle @@ -2,5 +2,5 @@ apply plugin: 'kotlin' apply plugin: 'java-library' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/app/build.gradle index 9f2cc286714..b8dcf98ba89 100755 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'kotlin' apply plugin: 'kotlin-kapt' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile project(':api') + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation project(':api') kapt project(':processor') } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/processor/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/processor/build.gradle index 5e68fcbb023..cf7cbe94884 100755 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/processor/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt19179/processor/build.gradle @@ -2,8 +2,8 @@ apply plugin: 'kotlin' apply plugin: 'kotlin-kapt' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.auto.service:auto-service:1.0-rc3' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.google.auto.service:auto-service:1.0-rc3' kapt 'com.google.auto.service:auto-service:1.0-rc3' - compile project(':api') + implementation project(':api') } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/annotation-processor/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/annotation-processor/build.gradle index b1e6d0bae10..997529b1808 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/annotation-processor/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/annotation-processor/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'kotlin' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.github.yanex:takenoko:0.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.github.yanex:takenoko:0.1' } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/example/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/example/build.gradle index ed0bb8750a4..d025536c09e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/example/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/localAnnotationProcessor/example/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'kotlin' apply plugin: 'kotlin-kapt' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile project(":annotation-processor") + implementation project(":annotation-processor") kapt project(":annotation-processor") - compile files("a") + implementation files("a") - testCompile 'junit:junit:4.12' + testImplementation'junit:junit:4.12' } apply plugin: 'idea' diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/locationMapping/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/locationMapping/build.gradle index 9e07222662c..84c74041bee 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/locationMapping/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/locationMapping/build.gradle @@ -18,10 +18,10 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" - testCompile 'junit:junit:4.12' + testImplementation'junit:junit:4.12' } kapt { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/mpp-kapt-presence/dac/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/mpp-kapt-presence/dac/build.gradle index f011d28696d..6d1b81f5189 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/mpp-kapt-presence/dac/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/mpp-kapt-presence/dac/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'org.jetbrains.kotlin.platform.common' dependencies { - compile deps.kotlin.stdlib.common + implementation deps.kotlin.stdlib.common } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/nokapt/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/nokapt/build.gradle index d9015c5f19b..91f617f0b35 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/nokapt/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/nokapt/build.gradle @@ -17,10 +17,10 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version" - testCompile 'junit:junit:4.12' + testImplementation'junit:junit:4.12' } compileKotlin.kotlinOptions.allWarningsAsErrors = true \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle index 56f9300dd03..4fdfb3c4dd9 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/app/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'kotlin2js' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" - compile project(":lib") + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation project(":lib") } def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() ?: false diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle index 16e015a7919..294a85a5996 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsICProject/lib/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'kotlin2js' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } def isIrBackend = project.findProperty("kotlin.js.useIrBackend")?.toBoolean() ?: false diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle index b40f68fbe44..6ca04058e5e 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsInternalTest/build.gradle @@ -16,8 +16,8 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" - compile "org.mozilla:rhino:1.7.7.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.mozilla:rhino:1.7.7.1" } def classesDir = "${buildDir}/classes/kotlin" @@ -41,7 +41,7 @@ task runRhino(type: JavaExec) { } build.doLast { - configurations.compile.each { File file -> + configurations.compileClasspath.each { File file -> copy { includeEmptyDirs = false diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsIrDtsGeneration/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsIrDtsGeneration/build.gradle index e701bdd8e12..1676dcaebbc 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsIrDtsGeneration/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsIrDtsGeneration/build.gradle @@ -23,5 +23,5 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle index 585e007f11a..5f0c7ad58c2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsModuleKind/build.gradle @@ -26,8 +26,8 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" - compile "org.mozilla:rhino:1.7.7.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.mozilla:rhino:1.7.7.1" } task runRhino(type: JavaExec) { @@ -38,7 +38,7 @@ task runRhino(type: JavaExec) { } build.doLast { - configurations.compile.each { File file -> + configurations.compileClasspath.each { File file -> copy { includeEmptyDirs = false diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle index aa8b99e1877..9a41de983c2 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/libraryProject/build.gradle @@ -16,7 +16,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } task jarSources(type: Jar) { @@ -24,7 +24,7 @@ task jarSources(type: Jar) { classifier = 'source' } artifacts { - compile jarSources + implementation jarSources } def outDir = "${buildDir}/kotlin2js/main/" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle index 7ea73eeb83e..af2f511691a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProject/mainProject/build.gradle @@ -16,8 +16,8 @@ repositories { } dependencies { - compile project(":libraryProject") - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation project(":libraryProject") + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } compileKotlin2Js.kotlinOptions.sourceMap = true diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithCustomSourceset/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithCustomSourceset/build.gradle index 10ec6b59fc2..836f71db154 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithCustomSourceset/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithCustomSourceset/build.gradle @@ -36,7 +36,7 @@ if (isIrBackend) { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" integrationTestCompile files(file(compileKotlin2Js.kotlinOptions.outputFile).parent) integrationTestCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" } @@ -53,5 +53,5 @@ task jarSources(type: Jar) { classifier = 'source' } artifacts { - compile jarSources + implementation jarSources } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMapInline/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMapInline/build.gradle index 68acb9258b8..782e1478c60 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMapInline/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithSourceMapInline/build.gradle @@ -18,7 +18,7 @@ allprojects { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" } compileKotlin2Js { @@ -31,7 +31,7 @@ allprojects { project("app") { dependencies { - compile project(":lib") + implementation project(":lib") } } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle index 1d91521eb23..3f579c0d8e3 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlin2JsProjectWithTests/build.gradle @@ -16,8 +16,8 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" - testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version" + testImplementation"org.jetbrains.kotlin:kotlin-test-js:$kotlin_version" } task jarSources(type: Jar) { @@ -25,7 +25,7 @@ task jarSources(type: Jar) { classifier = 'source' } artifacts { - compile jarSources + implementation jarSources } compileKotlin2Js.kotlinOptions.outputFile = "${buildDir}/kotlin2js/main/module.js" diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlinGradleSubplugin/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlinGradleSubplugin/build.gradle index 6fee132288e..47ab074dc08 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlinGradleSubplugin/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kotlinGradleSubplugin/build.gradle @@ -18,5 +18,5 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/moduleName/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/moduleName/build.gradle index a716e5864a3..2b3aff3d16a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/moduleName/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/moduleName/build.gradle @@ -24,7 +24,7 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } compileKotlin { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/build.gradle deleted file mode 100644 index 78fb261acac..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -buildscript { - repositories { - mavenLocal() - maven { url 'https://maven.google.com' } - jcenter() - } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "com.android.tools.build:gradle:$android_tools_version" - } -} - -allprojects { - repositories { - mavenLocal() - maven { url 'https://maven.google.com' } - jcenter() - } -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/build.gradle deleted file mode 100644 index bd07e135b4a..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -apply plugin: 'kotlin-platform-common' - -dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/main/kotlin/PlatformClass.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/main/kotlin/PlatformClass.kt deleted file mode 100644 index 526586c399e..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/main/kotlin/PlatformClass.kt +++ /dev/null @@ -1,7 +0,0 @@ -package foo - -expect class PlatformClass { - val value: String -} - -class CommonClass \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/test/kotlin/PlatformTest.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/test/kotlin/PlatformTest.kt deleted file mode 100644 index 2688286a168..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/lib/src/test/kotlin/PlatformTest.kt +++ /dev/null @@ -1,7 +0,0 @@ -package foo - -expect class PlatformTest { - val value: PlatformClass -} - -class CommonTest(val commonClass: CommonClass) \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/build.gradle deleted file mode 100644 index 10377b9e07f..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-platform-android' - -dependencies { - expectedBy project(":lib") -} - -android { - compileSdkVersion 23 - buildToolsVersion "25.0.2" - - defaultConfig { - minSdkVersion 19 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" - } - - lintOptions.abortOnError = false -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/AndroidManifest.xml b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/AndroidManifest.xml deleted file mode 100644 index 98b903c90e2..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/AndroidManifest.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/PlatformClass.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/PlatformClass.kt deleted file mode 100644 index 30645e27340..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/PlatformClass.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -actual class PlatformClass { - actual val value: String = "Android" -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/androidSdkUse.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/androidSdkUse.kt deleted file mode 100644 index 6db4293f3e5..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/main/kotlin/androidSdkUse.kt +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package platform.kotlin.android.test - -class MyActivity: android.app.Activity() \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/test/kotlin/PlatformTest.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/test/kotlin/PlatformTest.kt deleted file mode 100644 index 38a6198f0bd..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libAndroid/src/test/kotlin/PlatformTest.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -actual class PlatformTest { - actual val value: PlatformClass = PlatformClass() -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/build.gradle deleted file mode 100644 index 9f694bbd6a1..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/build.gradle +++ /dev/null @@ -1,7 +0,0 @@ -apply plugin: 'kotlin-platform-jvm' - -dependencies { - expectedBy project(":lib") - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.guava:guava:20.0' -} diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/PlatformClass.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/PlatformClass.kt deleted file mode 100644 index 21783c3a136..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/PlatformClass.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -actual class PlatformClass { - actual val value: String = "JVM" -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/javaLibUse.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/javaLibUse.kt deleted file mode 100644 index c48348ed34e..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/main/kotlin/javaLibUse.kt +++ /dev/null @@ -1,7 +0,0 @@ -package foo - -import com.google.common.collect.ImmutableSet - -fun main(args: Array) { - val colors = ImmutableSet.of("red", "orange", "yellow") -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/test/kotlin/PlatformTest.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/test/kotlin/PlatformTest.kt deleted file mode 100644 index 38a6198f0bd..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/libJvm/src/test/kotlin/PlatformTest.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -actual class PlatformTest { - actual val value: PlatformClass = PlatformClass() -} \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/settings.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/settings.gradle deleted file mode 100644 index f2ad2a2219e..00000000000 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformAndroidProject/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':lib', ':libJvm', ':libAndroid' \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformMultipleCommonModules/libJvm/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformMultipleCommonModules/libJvm/build.gradle index 92e8632acdb..1646db865b0 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformMultipleCommonModules/libJvm/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiplatformMultipleCommonModules/libJvm/build.gradle @@ -3,6 +3,6 @@ apply plugin: 'kotlin-platform-jvm' dependencies { expectedBy project(":libA") expectedBy project(":libB") - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile 'com.google.guava:guava:20.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation 'com.google.guava:guava:20.0' } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgJpa/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgJpa/build.gradle index fe06de104a2..e142900f88a 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgJpa/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgJpa/build.gradle @@ -22,5 +22,5 @@ sourceSets { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgKt18668/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgKt18668/build.gradle index 586c814300a..c6899911273 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgKt18668/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/noArgKt18668/build.gradle @@ -26,5 +26,5 @@ sourceSets { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/samWithReceiverSimple/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/samWithReceiverSimple/build.gradle index ca6d92361b2..5ade6d2ec88 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/samWithReceiverSimple/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/samWithReceiverSimple/build.gradle @@ -26,5 +26,5 @@ samWithReceiver { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scalaInterop/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scalaInterop/build.gradle index bb76dbcce7b..69e97456ef9 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scalaInterop/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scalaInterop/build.gradle @@ -17,10 +17,10 @@ repositories { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testCompile 'junit:junit:4.12' - compile project(":lib") + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testImplementation'junit:junit:4.12' + implementation project(":lib") } compileKotlin { diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/app/build.gradle index 6c8499756db..3fb738d5103 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/app/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'kotlin' dependencies { - compile project(':script-template') + implementation project(':script-template') } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/script-template/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/script-template/build.gradle index a66ada1ae01..e2aac26b489 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/script-template/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scripting/script-template/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'kotlin' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-scripting-common:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-scripting-common:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/app/build.gradle index 3db99c8b6ab..8058699ef16 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/app/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'kotlin' dependencies { - compile project(':script-template') + implementation project(':script-template') kotlinScriptDef project(':script-template') } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/script-template/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/script-template/build.gradle index a66ada1ae01..e2aac26b489 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/script-template/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/scriptingCustomExtension/script-template/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'kotlin' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-scripting-common:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-scripting-common:$kotlin_version" } \ No newline at end of file diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/suppressWarnings/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/suppressWarnings/build.gradle index c673dfc03ed..339331362a7 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/suppressWarnings/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/suppressWarnings/build.gradle @@ -21,7 +21,7 @@ sourceSets { } dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } repositories { From 6e913e16adb7b489f9016de78df1b8dd7963c02e Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Wed, 13 Jan 2021 15:44:15 +0400 Subject: [PATCH 045/122] Add integration tests for Kapt + Android Gradle plugin 7.0 --- .../jetbrains/kotlin/gradle/Kapt3AndroidIT.kt | 37 +++++++++++++++++-- .../kapt2/kt15001/app/build.gradle | 1 + 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3AndroidIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3AndroidIT.kt index 63317eb13e5..5427d326480 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3AndroidIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/Kapt3AndroidIT.kt @@ -1,8 +1,11 @@ package org.jetbrains.kotlin.gradle +import org.gradle.api.logging.configuration.WarningMode import org.jetbrains.kotlin.gradle.util.* import org.jetbrains.kotlin.test.util.KtTestUtil import org.junit.Assert +import org.junit.Assume +import org.junit.Ignore import org.junit.Test import java.io.File @@ -90,6 +93,32 @@ class Kapt3Android34IT : Kapt3AndroidIT() { get() = GradleVersionRequired.Until("5.4.1") } +class Kapt3Android70IT : Kapt3AndroidIT() { + override val androidGradlePluginVersion: AGPVersion + get() = AGPVersion.v7_0_0 + + override val defaultGradleVersion: GradleVersionRequired + get() = GradleVersionRequired.AtLeast("6.8") + + override fun defaultBuildOptions(): BuildOptions { + val javaHome = File(System.getProperty("jdk11Home")!!) + Assume.assumeTrue("JDK 11 should be available", javaHome.isDirectory) + return super.defaultBuildOptions().copy(javaHome = javaHome, warningMode = WarningMode.Summary) + } + + @Ignore("KT-44350") + override fun testRealm() = Unit + + @Ignore("KT-44350") + override fun testDatabinding() = Unit + + @Ignore("KT-44350") + override fun testDagger() = Unit + + @Ignore("KT-44350") + override fun testButterKnife() = Unit +} + class Kapt3Android42IT : Kapt3BaseIT() { override val defaultGradleVersion: GradleVersionRequired get() = GradleVersionRequired.AtLeast("6.7") @@ -119,7 +148,7 @@ abstract class Kapt3AndroidIT : Kapt3BaseIT() { ) @Test - fun testButterKnife() { + open fun testButterKnife() { val project = Project("android-butterknife", directoryPrefix = "kapt2") project.build("assembleDebug") { @@ -141,7 +170,7 @@ abstract class Kapt3AndroidIT : Kapt3BaseIT() { } @Test - fun testDagger() { + open fun testDagger() { val project = Project("android-dagger", directoryPrefix = "kapt2") project.build("assembleDebug") { @@ -184,7 +213,7 @@ abstract class Kapt3AndroidIT : Kapt3BaseIT() { } @Test - fun testRealm() { + open fun testRealm() { val project = Project("android-realm", directoryPrefix = "kapt2") project.build("assembleDebug") { @@ -247,7 +276,7 @@ abstract class Kapt3AndroidIT : Kapt3BaseIT() { } @Test - fun testDatabinding() { + open fun testDatabinding() { val project = Project("android-databinding", directoryPrefix = "kapt2") setupDataBinding(project) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle index 4fb7e01dbe0..c720c5be65f 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/kapt2/kt15001/app/build.gradle @@ -28,6 +28,7 @@ dependencies { implementation 'com.google.dagger:dagger:2.8' kapt 'com.google.dagger:dagger-compiler:2.8' + kapt 'javax.annotation:javax.annotation-api:1.3.2' implementation 'com.android.support:appcompat-v7:23.3.0' } \ No newline at end of file From dfacccf84fde33eb8d49a31ae1447aaa5aa83586 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Thu, 14 Jan 2021 16:05:10 +0400 Subject: [PATCH 046/122] Set canBeConsumed = false on the deprecated configurations like compile This leads to cleaner error messages in Gradle variant-aware dependency resolution failures. Gradle has deprecated those configurations since long ago, and we didn't see much use of them as variant-aware dependency resolution entities either. So this commits sets `canBeConsumed` to false on these configuratons: * compile (+ testCompile, fooCompile in MPP) * runtime (+ testRuntime, fooRuntime, ...) * compileOnly (+ testCompileOnly, fooCompileOnly, ...) * default (+ fooDefault in MPP) This change replaces the PR #3995 --- .../org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt | 4 ++++ .../kotlin/gradle/plugin/ProjectLocalConfigurations.kt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt index 159771ba539..d001e18345b 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt @@ -187,6 +187,10 @@ class VariantAwareDependenciesIT : BaseGradleIT() { with(outerProject) { embedProject(innerProject) + gradleBuildScript().appendText( + "\nconfigurations['jvm6TestRuntime'].canBeConsumed = true" + ) + gradleBuildScript(innerProject.projectName).appendText( "\ndependencies { testCompile project(path: ':', configuration: 'jvm6TestRuntime') }" ) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt index 201e7aa46d2..7b5fa05b352 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt @@ -38,6 +38,8 @@ object ProjectLocalConfigurations { } internal fun Configuration.setupAsLocalTargetSpecificConfigurationIfSupported(target: KotlinTarget) { + isCanBeConsumed = false + // don't setup in old MPP common modules, as their output configurations with KotlinPlatformType attribute would // fail to resolve as transitive dependencies of the platform modules, just as we don't mark their // `api/RuntimeElements` with the KotlinPlatformType From de00f72fa31cf6f9e6d0e41098db7e35aa74baa4 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Wed, 20 Jan 2021 16:53:57 +0100 Subject: [PATCH 047/122] Generate linenumber for inline call site in case of implicit iterator/hasNext/next calls in for loop Otherwise -1 is generated in smap --- .../kotlin/codegen/ExpressionCodegen.java | 4 ++ ...FirBlackBoxInlineCodegenTestGenerated.java | 5 ++ .../codegen/boxInline/smap/forInline.kt | 61 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 5 ++ ...otlinAgainstInlineKotlinTestGenerated.java | 5 ++ .../IrBlackBoxInlineCodegenTestGenerated.java | 5 ++ ...otlinAgainstInlineKotlinTestGenerated.java | 5 ++ ...JvmIrAgainstOldBoxInlineTestGenerated.java | 5 ++ ...JvmOldAgainstIrBoxInlineTestGenerated.java | 5 ++ .../IrJsCodegenInlineES6TestGenerated.java | 5 ++ .../IrJsCodegenInlineTestGenerated.java | 5 ++ .../JsCodegenInlineTestGenerated.java | 5 ++ 12 files changed, 115 insertions(+) create mode 100644 compiler/testData/codegen/boxInline/smap/forInline.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 0f6f65eb51a..7abf69564b4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -742,7 +742,11 @@ public class ExpressionCodegen extends KtVisitor impleme // Some forms of for-loop can be optimized as post-condition loops. PseudoInsnsKt.fakeAlwaysFalseIfeq(v, continueLabel); + // Renew line number cause it could be reset by inline (resetLastLineNumber) in generator.checkPreCondition(loopExit). + markStartLineNumber(generator.getForExpression()); + v.nop(); generator.beforeBody(); + blockStackElements.push(new LoopBlockStackElement(loopExit, continueLabel, targetLabel(generator.getForExpression()))); generator.body(); blockStackElements.pop(); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java index 735807fe896..765f6d542d7 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java @@ -3551,6 +3551,11 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/testData/codegen/boxInline/smap/forInline.kt b/compiler/testData/codegen/boxInline/smap/forInline.kt new file mode 100644 index 00000000000..67840ef676f --- /dev/null +++ b/compiler/testData/codegen/boxInline/smap/forInline.kt @@ -0,0 +1,61 @@ +// !LANGUAGE: +CorrectSourceMappingSyntax +// WITH_RUNTIME +// FILE: 1.kt +package test + +inline fun stub() { + +} + +// FILE: 2.kt + +fun box(): String { + //Breakpoint! + for (element in Some()) { // No inlining visible on this string + return nonInline(element) + } + return "fail" +} + +fun nonInline(p: T): T = p + +class Some() { + operator fun iterator() = SomeIterator() +} + +class SomeIterator { + var result = "OK" + + inline operator fun hasNext() : Boolean { + return result == "OK" + } + + inline operator fun next(): String { + result = "fail" + return "OK" + } +} + + +// FILE: 1.smap + +// FILE: 2.smap +SMAP +2.kt +Kotlin +*S Kotlin +*F ++ 1 2.kt +_2Kt ++ 2 2.kt +SomeIterator +*L +1#1,31:1 +21#2,6:32 +*S KotlinDebug +*F ++ 1 2.kt +_2Kt +*L +5#1:32,6 +*E \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 08768c1d393..8452fce8d1b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -3551,6 +3551,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index cdc6c658f5b..84f33fa5110 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3551,6 +3551,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index a63eb5652e1..64d54213a38 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -3551,6 +3551,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 057a0ec17ef..e3e8f6f2da4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3551,6 +3551,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java index e53ac975c9e..9e053a8c5dc 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -3551,6 +3551,11 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java index 0833aee391a..b3298bf657d 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -3551,6 +3551,11 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 588bcf36a64..a1d8520d3d9 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -3151,6 +3151,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 4e068f7f7f6..8e2b513129f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -3151,6 +3151,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index e928f203178..11821520f20 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -3151,6 +3151,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/smap/defaultFunctionWithInlineCall.kt"); } + @TestMetadata("forInline.kt") + public void testForInline() throws Exception { + runTest("compiler/testData/codegen/boxInline/smap/forInline.kt"); + } + @TestMetadata("interleavedFiles.kt") public void testInterleavedFiles() throws Exception { runTest("compiler/testData/codegen/boxInline/smap/interleavedFiles.kt"); From 704366e53127e4ef764f92a0ef0df0b7a64862aa Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Thu, 21 Jan 2021 10:55:15 +0100 Subject: [PATCH 048/122] JVM: Mark suspend lambda receiver as used if callable reference accesses it. #KT-44131 Fixed --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++ .../cfg/ControlFlowInformationProvider.kt | 51 +++++++++++-------- .../callableReference/lambdaParameterUsed.kt | 20 ++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++ .../LightAnalysisModeTestGenerated.java | 5 ++ .../IrJsCodegenBoxES6TestGenerated.java | 5 ++ .../IrJsCodegenBoxTestGenerated.java | 5 ++ .../semantics/JsCodegenBoxTestGenerated.java | 5 ++ 9 files changed, 87 insertions(+), 22 deletions(-) create mode 100644 compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 17bce302afb..e45be44ded4 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -8562,6 +8562,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt"); } + @Test + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @Test @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt index bc28565c318..90d6504893c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -864,7 +864,9 @@ class ControlFlowInformationProvider private constructor( } private fun markImplicitReceiverOfSuspendLambda(instruction: Instruction) { - if (instruction !is MagicInstruction || instruction.kind != MagicKind.IMPLICIT_RECEIVER) return + if (instruction !is MagicInstruction || + (instruction.kind != MagicKind.IMPLICIT_RECEIVER && instruction.kind != MagicKind.UNBOUND_CALLABLE_REFERENCE) + ) return fun CallableDescriptor?.markIfNeeded() { if (this is AnonymousFunctionDescriptor && isSuspend) { @@ -872,31 +874,36 @@ class ControlFlowInformationProvider private constructor( } } - if (instruction.element is KtDestructuringDeclarationEntry || instruction.element is KtCallExpression) { - val visited = mutableSetOf() - fun dfs(insn: Instruction) { - if (!visited.add(insn)) return - if (insn is CallInstruction && insn.element == instruction.element) { - for ((_, receiver) in insn.receiverValues) { - (receiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + when (val element = instruction.element) { + is KtDestructuringDeclarationEntry, is KtCallExpression -> { + val visited = mutableSetOf() + fun dfs(insn: Instruction) { + if (!visited.add(insn)) return + if (insn is CallInstruction && insn.element == element) { + for ((_, receiver) in insn.receiverValues) { + (receiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + } + } + for (next in insn.nextInstructions) { + dfs(next) } } - for (next in insn.nextInstructions) { - dfs(next) - } - } - instruction.next?.let { dfs(it) } - } else if (instruction.element is KtNameReferenceExpression || instruction.element is KtBinaryExpression || - instruction.element is KtUnaryExpression - ) { - val call = instruction.element.getResolvedCall(trace.bindingContext) - if (call is VariableAsFunctionResolvedCall) { - (call.variableCall.dispatchReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } - (call.variableCall.extensionReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + instruction.next?.let { dfs(it) } + } + is KtNameReferenceExpression, is KtBinaryExpression, is KtUnaryExpression -> { + val call = element.getResolvedCall(trace.bindingContext) + if (call is VariableAsFunctionResolvedCall) { + (call.variableCall.dispatchReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + (call.variableCall.extensionReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + } + (call?.dispatchReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + (call?.extensionReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } + } + is KtCallableReferenceExpression -> { + val resolvedCall = element.callableReference.getResolvedCall(trace.bindingContext) + (resolvedCall?.dispatchReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } } - (call?.dispatchReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } - (call?.extensionReceiver as? ExtensionReceiver)?.declarationDescriptor?.apply { markIfNeeded() } } } diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt new file mode 100644 index 00000000000..a29fdaff363 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt @@ -0,0 +1,20 @@ +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME + +import kotlin.coroutines.* + +fun box(): String = a { (::write)() } + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(Continuation(EmptyCoroutineContext) {}) +} + +fun a(a: suspend Writer.() -> String): String { + var res = "" + builder { res = Writer().a() } + return res +} + +class Writer { + fun write(): String = "OK" +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 0961403bd71..de0bf7c0340 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -8562,6 +8562,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt"); } + @Test + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @Test @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 2c7e979804b..1d4fcac0785 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -8562,6 +8562,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt"); } + @Test + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @Test @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index e572900f046..8d42b316610 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -7461,6 +7461,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/fromJava.kt"); } + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index fb684cfdbdf..0ffa287b7ea 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -6196,6 +6196,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt"); } + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 3e25c2bbef6..24990b3bda6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -6196,6 +6196,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt"); } + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index b44695e942a..b0b919405af 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -6196,6 +6196,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/bigArity.kt"); } + @TestMetadata("lambdaParameterUsed.kt") + public void testLambdaParameterUsed() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/lambdaParameterUsed.kt"); + } + @TestMetadata("longArgs.kt") public void testLongArgs() throws Exception { runTest("compiler/testData/codegen/box/coroutines/featureIntersection/callableReference/longArgs.kt"); From 243f85a4d69751f3f54098af735f51d5a6767c86 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Thu, 14 Jan 2021 00:31:50 +0300 Subject: [PATCH 049/122] [FIR IDE] Add base support for FIR incomplete types resolve --- .../FirSpecificTypeResolverTransformer.kt | 2 ++ .../fir/declarations/impl/FirErrorFunctionImpl.kt | 2 +- .../fir/declarations/impl/FirErrorPropertyImpl.kt | 2 +- .../fir/expressions/impl/FirErrorExpressionImpl.kt | 2 +- .../fir/types/builder/FirErrorTypeRefBuilder.kt | 3 +++ .../kotlin/fir/types/impl/FirErrorTypeRefImpl.kt | 4 +++- .../fir/tree/generator/ImplementationConfigurator.kt | 10 +++------- .../level/api/file/structure/FirElementsRecorder.kt | 12 +++++++++++- .../idea/references/FirReferenceResolveHelper.kt | 7 +++++-- .../references/TypeArgumentUnresolvedClass.kt | 1 - .../references/TypeArgumentUnresolvedConstructor.kt | 1 - .../resolve/references/TypeArgumentWrongNumber.kt | 1 - .../resolve/references/WrongNumberOfTypeArguments.kt | 2 -- .../references/WrongNumberOfTypeArguments2.kt | 2 -- .../WrongNumberOfTypeArgumentsInSupertype.kt | 1 - 15 files changed, 30 insertions(+), 22 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt index 3ed05afb15a..dde33c42004 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirSpecificTypeResolverTransformer.kt @@ -86,6 +86,8 @@ class FirSpecificTypeResolverTransformer( typeRef.source } + delegatedTypeRef = typeRef + diagnostic = resolvedType.diagnostic } }.compose() diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt index 7c5147f53dd..4c29b705a0a 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorFunctionImpl.kt @@ -39,7 +39,7 @@ internal class FirErrorFunctionImpl( override val symbol: FirErrorFunctionSymbol, override val typeParameters: MutableList, ) : FirErrorFunction() { - override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, diagnostic) + override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, null, diagnostic) override val receiverTypeRef: FirTypeRef? get() = null override var controlFlowGraphReference: FirControlFlowGraphReference? = null override val body: FirBlock? get() = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt index e85bcf49249..532a3a6a3ba 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/declarations/impl/FirErrorPropertyImpl.kt @@ -40,7 +40,7 @@ internal class FirErrorPropertyImpl( override val typeParameters: MutableList, override val symbol: FirErrorPropertySymbol, ) : FirErrorProperty() { - override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, diagnostic) + override var returnTypeRef: FirTypeRef = FirErrorTypeRefImpl(null, null, diagnostic) override val receiverTypeRef: FirTypeRef? get() = null override val initializer: FirExpression? get() = null override val delegate: FirExpression? get() = null diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt index 2df4a84c90f..afe92ff17cf 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirErrorExpressionImpl.kt @@ -23,7 +23,7 @@ internal class FirErrorExpressionImpl( override val source: FirSourceElement?, override val diagnostic: ConeDiagnostic, ) : FirErrorExpression() { - override var typeRef: FirTypeRef = FirErrorTypeRefImpl(source, ConeStubDiagnostic(diagnostic)) + override var typeRef: FirTypeRef = FirErrorTypeRefImpl(source, null, ConeStubDiagnostic(diagnostic)) override val annotations: List get() = emptyList() override fun acceptChildren(visitor: FirVisitor, data: D) { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt index 07cb6c3276d..5b967ddfdd4 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/builder/FirErrorTypeRefBuilder.kt @@ -26,11 +26,13 @@ import org.jetbrains.kotlin.fir.visitors.* @FirBuilderDsl class FirErrorTypeRefBuilder : FirAnnotationContainerBuilder { override var source: FirSourceElement? = null + var delegatedTypeRef: FirTypeRef? = null lateinit var diagnostic: ConeDiagnostic override fun build(): FirErrorTypeRef { return FirErrorTypeRefImpl( source, + delegatedTypeRef, diagnostic, ) } @@ -55,6 +57,7 @@ inline fun buildErrorTypeRefCopy(original: FirErrorTypeRef, init: FirErrorTypeRe } val copyBuilder = FirErrorTypeRefBuilder() copyBuilder.source = original.source + copyBuilder.delegatedTypeRef = original.delegatedTypeRef copyBuilder.diagnostic = original.diagnostic return copyBuilder.apply(init).build() } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt index 567903e36a4..c376e7c25e3 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt @@ -21,18 +21,20 @@ import org.jetbrains.kotlin.fir.visitors.* internal class FirErrorTypeRefImpl( override val source: FirSourceElement?, + override var delegatedTypeRef: FirTypeRef?, override val diagnostic: ConeDiagnostic, ) : FirErrorTypeRef() { override val annotations: MutableList = mutableListOf() override val type: ConeKotlinType = ConeClassErrorType(diagnostic) - override val delegatedTypeRef: FirTypeRef? get() = null override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } + delegatedTypeRef?.accept(visitor, data) } override fun transformChildren(transformer: FirTransformer, data: D): FirErrorTypeRefImpl { transformAnnotations(transformer, data) + delegatedTypeRef = delegatedTypeRef?.transformSingle(transformer, data) return this } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index 11dfd0a1501..992324f0fa1 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -170,10 +170,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() val errorTypeRefImpl = impl(errorTypeRef) { default("type", "ConeClassErrorType(diagnostic)") - default("delegatedTypeRef") { - value = "null" - withGetter = true - } default("annotations", "mutableListOf()") useTypes(coneClassErrorTypeType) } @@ -201,7 +197,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() "getter", "setter", withGetter = true ) - default("returnTypeRef", "FirErrorTypeRefImpl(null, diagnostic)") + default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic)") useTypes(errorTypeRefImpl) } @@ -396,13 +392,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(errorExpression) { defaultEmptyList("annotations") - default("typeRef", "FirErrorTypeRefImpl(source, ConeStubDiagnostic(diagnostic))") + default("typeRef", "FirErrorTypeRefImpl(source, null, ConeStubDiagnostic(diagnostic))") useTypes(errorTypeRefImpl, coneStubDiagnosticType) } impl(errorFunction) { defaultNull("receiverTypeRef", "body", withGetter = true) - default("returnTypeRef", "FirErrorTypeRefImpl(null, diagnostic)") + default("returnTypeRef", "FirErrorTypeRefImpl(null, null, diagnostic)") useTypes(errorTypeRefImpl) } diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FirElementsRecorder.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FirElementsRecorder.kt index 67a27e3825c..dd9694b6a7d 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FirElementsRecorder.kt +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/file/structure/FirElementsRecorder.kt @@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.realPsi import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.types.FirErrorTypeRef +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirUserTypeRef import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl @@ -68,9 +69,18 @@ internal open class FirElementsRecorder : FirVisitor) {} override fun visitSuperReference(superReference: FirSuperReference, data: MutableMap) {} override fun visitThisReference(thisReference: FirThisReference, data: MutableMap) {} - override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: MutableMap) {} //@formatter:on + override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: MutableMap) { + super.visitResolvedTypeRef(errorTypeRef, data) + errorTypeRef.delegatedTypeRef?.accept(this, data) + } + + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: MutableMap) { + super.visitResolvedTypeRef(resolvedTypeRef, data) + resolvedTypeRef.delegatedTypeRef?.accept(this, data) + } + override fun visitUserTypeRef(userTypeRef: FirUserTypeRef, data: MutableMap) { userTypeRef.acceptChildren(this, data) } diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt index 91ca1f4e53c..c0928b8f1d6 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/references/FirReferenceResolveHelper.kt @@ -388,8 +388,11 @@ internal object FirReferenceResolveHelper { ): ClassId? { val qualifierToResolve = qualifier.parent as KtUserType // FIXME make it work with generics in functional types (like () -> AA.BB) - val wholeType = - (wholeTypeFir.psi as KtTypeReference).typeElement?.unwrapNullable() as? KtUserType ?: return null + val wholeType = when (val psi = wholeTypeFir.psi) { + is KtUserType -> psi + is KtTypeReference -> psi.typeElement?.unwrapNullable() as? KtUserType + else -> null + } ?: return null val qualifiersToDrop = countQualifiersToDrop(wholeType, qualifierToResolve) return wholeTypeFir.type.classId?.dropLastNestedClasses(qualifiersToDrop) diff --git a/idea/testData/resolve/references/TypeArgumentUnresolvedClass.kt b/idea/testData/resolve/references/TypeArgumentUnresolvedClass.kt index 7b6b02313ca..e71361f94d8 100644 --- a/idea/testData/resolve/references/TypeArgumentUnresolvedClass.kt +++ b/idea/testData/resolve/references/TypeArgumentUnresolvedClass.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR val v: UnknownClass<String> // REF: (kotlin).String diff --git a/idea/testData/resolve/references/TypeArgumentUnresolvedConstructor.kt b/idea/testData/resolve/references/TypeArgumentUnresolvedConstructor.kt index c3074edbab5..52f75931936 100644 --- a/idea/testData/resolve/references/TypeArgumentUnresolvedConstructor.kt +++ b/idea/testData/resolve/references/TypeArgumentUnresolvedConstructor.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR val v: UnknownClass<String>() // REF: (kotlin).String diff --git a/idea/testData/resolve/references/TypeArgumentWrongNumber.kt b/idea/testData/resolve/references/TypeArgumentWrongNumber.kt index a3df1c630cb..232ee88a284 100644 --- a/idea/testData/resolve/references/TypeArgumentWrongNumber.kt +++ b/idea/testData/resolve/references/TypeArgumentWrongNumber.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR class Foo class Bar: Foo<String diff --git a/idea/testData/resolve/references/WrongNumberOfTypeArguments.kt b/idea/testData/resolve/references/WrongNumberOfTypeArguments.kt index 098725b1a63..fca2ff6eaf0 100644 --- a/idea/testData/resolve/references/WrongNumberOfTypeArguments.kt +++ b/idea/testData/resolve/references/WrongNumberOfTypeArguments.kt @@ -1,5 +1,3 @@ -// IGNORE_FIR - package foo class A diff --git a/idea/testData/resolve/references/WrongNumberOfTypeArguments2.kt b/idea/testData/resolve/references/WrongNumberOfTypeArguments2.kt index c328ab5c241..22647bdbf99 100644 --- a/idea/testData/resolve/references/WrongNumberOfTypeArguments2.kt +++ b/idea/testData/resolve/references/WrongNumberOfTypeArguments2.kt @@ -1,5 +1,3 @@ -// IGNORE_FIR - package foo class A diff --git a/idea/testData/resolve/references/WrongNumberOfTypeArgumentsInSupertype.kt b/idea/testData/resolve/references/WrongNumberOfTypeArgumentsInSupertype.kt index 9934b6c0d82..0e8071fd19c 100644 --- a/idea/testData/resolve/references/WrongNumberOfTypeArgumentsInSupertype.kt +++ b/idea/testData/resolve/references/WrongNumberOfTypeArgumentsInSupertype.kt @@ -1,4 +1,3 @@ -// IGNORE_FIR package foo class A From b7d3469819a1ef5831a06cbfc158a1ca15f120ea Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 18 Jan 2021 19:59:12 +0300 Subject: [PATCH 050/122] [FIR] Remove transform/accept from FirResolvedTypeRef.delegateTypeRef --- .../fir/analysis/collectors/AbstractDiagnosticCollector.kt | 6 ++++++ .../fir/resolve/transformers/FirTypeResolveTransformer.kt | 2 +- .../kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt | 2 -- .../kotlin/fir/tree/generator/ImplementationConfigurator.kt | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt index 6c1315998fe..79cbafe8f2d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/AbstractDiagnosticCollector.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorForFullBodyResolve import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.coneTypeSafe @@ -160,6 +161,11 @@ abstract class AbstractDiagnosticCollector( } } + override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: Nothing?) { + super.visitResolvedTypeRef(resolvedTypeRef, data) + resolvedTypeRef.delegatedTypeRef?.accept(this, data) + } + private inline fun visitWithDeclaration( declaration: FirDeclaration, block: () -> Unit = { declaration.acceptChildren(this, null) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt index 6a2d16597c6..426637818ff 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirTypeResolveTransformer.kt @@ -158,7 +158,7 @@ class FirTypeResolveTransformer( } override fun transformTypeRef(typeRef: FirTypeRef, data: Nothing?): CompositeTransformResult { - return typeResolverTransformer.transformTypeRef(typeRef, towerScope) + return typeRef.transform(typeResolverTransformer, towerScope) } override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult { diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt index 6a24a618234..640f811ff4f 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirResolvedTypeRefImpl.kt @@ -26,12 +26,10 @@ class FirResolvedTypeRefImpl @FirImplementationDetail constructor( ) : FirResolvedTypeRef() { override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } - delegatedTypeRef?.accept(visitor, data) } override fun transformChildren(transformer: FirTransformer, data: D): FirResolvedTypeRefImpl { transformAnnotations(transformer, data) - delegatedTypeRef = delegatedTypeRef?.transformSingle(transformer, data) return this } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index 992324f0fa1..ca0129fa92d 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -388,6 +388,9 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() impl(resolvedTypeRef) { publicImplementation() + default("delegatedTypeRef") { + needAcceptAndTransform = false + } } impl(errorExpression) { From 2e4daee1d460665381f6243094a2ad6d19e202b8 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Mon, 18 Jan 2021 22:39:41 +0300 Subject: [PATCH 051/122] [FIR] Fix invalid diagnostic fir node sites and improved invalid type parameters count diagnostic report --- .../typeArgumentsNotAllowed.fir.txt | 8 +++---- .../diagnostics/upperBoundViolated.fir.txt | 2 +- .../resolve/diagnostics/upperBoundViolated.kt | 2 +- .../resolve/typeParameterVsNested.fir.txt | 8 +++---- .../testData/resolve/typeParameterVsNested.kt | 4 ++-- .../capturedParametersOfInnerClasses.fir.txt | 2 +- .../types/capturedParametersOfInnerClasses.kt | 2 +- .../providers/impl/FirTypeResolverImpl.kt | 22 ++++++++++++------- .../jetbrains/kotlin/fir/types/TypeUtils.kt | 1 + .../fir/types/impl/FirErrorTypeRefImpl.kt | 2 -- .../org/jetbrains/kotlin/fir/FirRenderer.kt | 2 +- .../kotlin/fir/resolve/TreeResolveUtils.kt | 9 +------- .../generator/ImplementationConfigurator.kt | 3 +++ .../diagnostics/tests/EnumEntryAsType.fir.kt | 8 +++---- .../diagnostics/tests/Unresolved.fir.kt | 4 ++-- .../cast/bare/ErrorsInSubstitution.fir.kt | 2 +- .../tests/cast/bare/UnrelatedColon.fir.kt | 2 +- .../tests/classLiteral/arrays.fir.kt | 9 -------- .../diagnostics/tests/classLiteral/arrays.kt | 1 + .../generics/RawTypeInIsExpression.fir.kt | 2 +- .../tests/generics/RawTypeInIsPattern.fir.kt | 4 ++-- .../finalUpperBoundWithoutOverride.fir.kt | 2 +- .../tests/generics/genericsInType.fir.kt | 6 ++--- .../generics/innerClasses/bareTypes.fir.kt | 4 ++-- .../fromSuperClassesLocal.fir.kt | 4 ++-- .../fromSuperClassesLocalInsideInner.fir.kt | 4 ++-- .../innerClasses/importedInner.fir.kt | 2 +- .../outerArgumentsRequired.fir.kt | 6 ++--- .../innerClasses/qualifiedOuter.fir.kt | 2 +- .../qualifiedTypesResolution.fir.kt | 2 +- .../invalidArgumentsNumberInWhere.fir.kt | 20 ++++++++--------- .../controlStructuresErrors.fir.kt | 2 +- .../commonSuperTypeOfErrorTypes.fir.kt | 10 ++++----- .../tests/inner/deepInnerClass.fir.kt | 6 ++--- .../genericArgumentNumberMismatch.fir.kt | 4 ++-- .../extensionOnErrorType.fir.kt | 4 ++-- .../regressions/OrphanStarProjection.fir.kt | 2 +- .../tests/resolve/CycleInTypeArgs.fir.kt | 4 ++-- .../scopes/classHeader/classParents.fir.kt | 2 +- .../scopes/classHeader/objectParents.fir.kt | 2 +- .../diagnostics/tests/subtyping/kt304.fir.kt | 2 +- .../tests/thisAndSuper/Super.fir.kt | 2 +- ...pturingTypeParametersFromOuterClass.fir.kt | 8 +++---- .../javaStaticMembersViaTypeAlias.fir.kt | 10 ++++----- .../typealias/localTypeAliasRecursive.fir.kt | 4 ++-- .../tests/variance/InPosition.fir.kt | 8 +++---- .../tests/variance/InvariantPosition.fir.kt | 8 +++---- .../tests/variance/OutPosition.fir.kt | 8 +++---- .../InaccessibleInternalClass.fir.kt | 2 +- .../testsWithStdLib/regression/kt37727.fir.kt | 4 ++-- 50 files changed, 118 insertions(+), 125 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt index 40bcc35998d..aedd7069035 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeArgumentsNotAllowed.fir.txt @@ -12,7 +12,7 @@ FILE: typeArgumentsNotAllowed.kt } public final fun foo(): R|kotlin/Unit| { R|rest/bar|<>() - R|rest/bar|<>() + R|rest/bar|>|>() } public final fun bar(): R|kotlin/Unit| { } @@ -41,9 +41,9 @@ FILE: typeArgumentsNotAllowed.kt public final fun gest(): R|kotlin/Unit| { } public final fun fest(): R|kotlin/Unit| { - lval b: + lval b: R|kotlin/collections/List| R|rest/gest|<>() R|rest/gest|() - lval c: - R|rest/gest|<>() + lval c: R|kotlin/collections/List>>| + R|rest/gest|>|>() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt index f0c353ed66f..9845330a969 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.fir.txt @@ -23,7 +23,7 @@ FILE: upperBoundViolated.kt lval b2: R|B| = R|/B.B|() lval b3: R|B| = R|/B.B|() lval b4: R|B| = R|/B.B|<>() - lval b5: R|B| = R|/B.B|<>() + lval b5: R|B>| = R|/B.B||>() R|/fest|() R|/fest|() R|/fest|() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt index d1596c5afda..9e0ce9dcbfc 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/upperBoundViolated.kt @@ -15,7 +15,7 @@ fun test() { val b2 = B() val b3 = B<Any?>() val b4 = B<UnexistingType>() - val b5 = B<B>() + val b5 = B<B<UnexistingType>>() fest<Boolean>() fest() fest() diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt index 76a5371a0bd..3f336035ba4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.fir.txt @@ -18,11 +18,11 @@ FILE: typeParameterVsNested.kt public abstract fun foo(arg: R|test/My.T|): R|kotlin/Unit| - public abstract val y: - public get(): + public abstract val y: + public get(): - public abstract val z: - public get(): + public abstract val z: + public get(): public final class Some : { public constructor(): R|test/My.Some| { diff --git a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt index 5181ec7b24e..ded00ddec29 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt +++ b/compiler/fir/analysis-tests/testData/resolve/typeParameterVsNested.kt @@ -9,9 +9,9 @@ abstract class My { abstract fun foo(arg: T) - abstract val y: My.T + abstract val y: My.T - abstract val z: test.My.T + abstract val z: test.My.T class Some : T() } diff --git a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt index 459c37e8e6e..75eb3f942f9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.fir.txt @@ -27,5 +27,5 @@ FILE: capturedParametersOfInnerClasses.kt } public final fun foo(c: R|A.B.C|): R|kotlin/Unit| { } - public final fun foo(c: ): R|kotlin/Unit| { + public final fun foo(c: ): R|kotlin/Unit| { } diff --git a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt index a6e88678f95..87bfbb31db0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt +++ b/compiler/fir/analysis-tests/testData/resolve/types/capturedParametersOfInnerClasses.kt @@ -10,4 +10,4 @@ class A { fun foo(c: A.B.C) {} -fun foo(c: A.B.C) {} +fun foo(c: A.B.C) {} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt index 1a788330f45..232e6ec133c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirTypeResolverImpl.kt @@ -114,23 +114,29 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver() { val isPossibleBareType = areBareTypesAllowed && typeArguments.isEmpty() if (typeArguments.size != symbol.fir.typeParameters.size && !isPossibleBareType) { @Suppress("NAME_SHADOWING") - val substitutor = substitutor ?: ConeSubstitutor.Empty - val n = symbol.fir.typeParameters.size - typeArguments.size - if (n < 0) { - typeArguments = (1..symbol.fir.typeParameters.size).map { - ConeClassErrorType(ConeWrongNumberOfTypeArgumentsError(typeArguments.size, symbol)) - }.toTypedArray() + if (symbol.fir.typeParameters.size < typeArguments.size) { + return ConeClassErrorType(ConeWrongNumberOfTypeArgumentsError(symbol.fir.typeParameters.size, symbol)) } else { - val argumentsFromOuterClassesAndParents = symbol.fir.typeParameters.takeLast(n).map { + val substitutor = substitutor ?: ConeSubstitutor.Empty + val argumentsFromOuterClassesAndParents = symbol.fir.typeParameters.drop(typeArguments.size).mapNotNull { val type = ConeTypeParameterTypeImpl(ConeTypeParameterLookupTag(it.symbol), isNullable = false) // we should report ConeSimpleDiagnostic(..., WrongNumberOfTypeArguments) // but genericArgumentNumberMismatch.kt test fails with // index out of bounds exception for start offset of // the source substitutor.substituteOrNull(type) - ?: ConeClassErrorType(ConeIntermediateDiagnostic("Type argument not defined")) + }.toTypedArray() typeArguments += argumentsFromOuterClassesAndParents + + if (typeArguments.size != symbol.fir.typeParameters.size) { + return ConeClassErrorType( + ConeWrongNumberOfTypeArgumentsError( + desiredCount = symbol.fir.typeParameters.size - argumentsFromOuterClassesAndParents.size, + type = symbol + ) + ) + } } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index cf0f97ff074..5faf26003be 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -236,6 +236,7 @@ fun FirTypeRef.withReplacedConeType( this@withReplacedConeType.source type = newType annotations += this@withReplacedConeType.annotations + delegatedTypeRef = this@withReplacedConeType.delegatedTypeRef } } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt index c376e7c25e3..0a1f8d570cd 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/types/impl/FirErrorTypeRefImpl.kt @@ -29,12 +29,10 @@ internal class FirErrorTypeRefImpl( override fun acceptChildren(visitor: FirVisitor, data: D) { annotations.forEach { it.accept(visitor, data) } - delegatedTypeRef?.accept(visitor, data) } override fun transformChildren(transformer: FirTransformer, data: D): FirErrorTypeRefImpl { transformAnnotations(transformer, data) - delegatedTypeRef = delegatedTypeRef?.transformSingle(transformer, data) return this } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 9223ab2c694..587da9cc36c 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -859,7 +859,7 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM } override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef) { - visitTypeRef(errorTypeRef) + errorTypeRef.annotations.renderAnnotations() print("") } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt index bab010fe8b2..d6fdbd030c3 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/resolve/TreeResolveUtils.kt @@ -26,14 +26,7 @@ fun FirClassifierSymbol<*>.constructType( ConeTypeParameterTypeImpl(this.toLookupTag(), isNullable, attributes) } is FirClassSymbol -> { - val errorTypeRef = typeArguments.find { - it is ConeClassErrorType - } - if (errorTypeRef is ConeClassErrorType) { - ConeClassErrorType(errorTypeRef.diagnostic) - } else { - ConeClassLikeTypeImpl(this.toLookupTag(), typeArguments, isNullable, attributes) - } + ConeClassLikeTypeImpl(this.toLookupTag(), typeArguments, isNullable, attributes) } is FirTypeAliasSymbol -> { ConeClassLikeTypeImpl( diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt index ca0129fa92d..c51fe91e63c 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/ImplementationConfigurator.kt @@ -172,6 +172,9 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator() default("type", "ConeClassErrorType(diagnostic)") default("annotations", "mutableListOf()") useTypes(coneClassErrorTypeType) + default("delegatedTypeRef") { + needAcceptAndTransform = false + } } diff --git a/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt b/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt index 88ac6c4adcd..c51d4d4acf2 100644 --- a/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt +++ b/compiler/testData/diagnostics/tests/EnumEntryAsType.fir.kt @@ -30,17 +30,17 @@ class MyColor(val x: Color.RED, y: Array? = null +fun create(): Array<Color.RED>? = null interface YourColor.RED> -class His : Your +class His : Your<Color.RED> fun Color.RED> otherCreate(): Array? = null typealias RedAlias = Color.RED -typealias ArrayOfEnumEntry = Array +typealias ArrayOfEnumEntry = Array<Color.RED> typealias ArrayOfEnumEntryAlias = Array @@ -52,4 +52,4 @@ fun foo() { bar<Color.RED>(Color.RED) } -fun Array.foo(entries: Array): Array = null!! \ No newline at end of file +fun Array<Color.RED>.foo(entries: Array<Color.RED>): Array<Color.RED> = null!! \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/Unresolved.fir.kt b/compiler/testData/diagnostics/tests/Unresolved.fir.kt index d4133613353..ce9319e4fe7 100644 --- a/compiler/testData/diagnostics/tests/Unresolved.fir.kt +++ b/compiler/testData/diagnostics/tests/Unresolved.fir.kt @@ -3,8 +3,8 @@ package unresolved class Pair(val a: A, val b: B) fun testGenericArgumentsCount() { - val p1: Pair = Pair(2, 2) - val p2: Pair = Pair(2, 2) + val p1: Pair = Pair(2, 2) + val p2: Pair = Pair(2, 2) } fun testUnresolved() { diff --git a/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt index 5b5c799c707..c36ceb82b82 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/ErrorsInSubstitution.fir.kt @@ -3,7 +3,7 @@ interface B interface G: B -fun f(p: B): Any { +fun f(p: B<Foo>): Any { val v = p as G return checkSubtype>(v) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt index b63ed2cd2b1..10a098124b5 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/UnrelatedColon.fir.kt @@ -4,4 +4,4 @@ interface Tr interface G -fun test(tr: Tr) = checkSubtype(tr) \ No newline at end of file +fun test(tr: Tr) = checkSubtype<G>(tr) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt b/compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt deleted file mode 100644 index 8b87530bb2a..00000000000 --- a/compiler/testData/diagnostics/tests/classLiteral/arrays.fir.kt +++ /dev/null @@ -1,9 +0,0 @@ -// !LANGUAGE: +BareArrayClassLiteral - -val a01 = Array::class -val a02 = Array::class -val a03 = Array::class -val a04 = Array?>::class -val a05 = Array::class -val a06 = kotlin.Array::class -val a07 = kotlin.Array::class diff --git a/compiler/testData/diagnostics/tests/classLiteral/arrays.kt b/compiler/testData/diagnostics/tests/classLiteral/arrays.kt index 64cdf231d0d..1b19014d41f 100644 --- a/compiler/testData/diagnostics/tests/classLiteral/arrays.kt +++ b/compiler/testData/diagnostics/tests/classLiteral/arrays.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +BareArrayClassLiteral val a01 = Array::class diff --git a/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt b/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt index dd9049258b6..08648c657fb 100644 --- a/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/RawTypeInIsExpression.fir.kt @@ -1,7 +1,7 @@ package p public fun foo(a: Any) { - a is Map + a is Map a is Map a is Map a is Map<*, *> diff --git a/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt b/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt index bfca3e37219..167c86b8c8e 100644 --- a/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/RawTypeInIsPattern.fir.kt @@ -1,6 +1,6 @@ -public fun foo(a: Any, b: Map) { +public fun foo(a: Any, b: Map) { when (a) { - is Map -> {} + is Map -> {} is Map -> {} is Map -> {} is Map<*, *> -> {} diff --git a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt index 45cb5777982..d6c18a73b49 100644 --- a/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/finalUpperBoundWithoutOverride.fir.kt @@ -55,7 +55,7 @@ object MessageManager10 : Message5() { fun execute() {} } -class MessageManager11 : Message5>() { +class MessageManager11 : Message5<Message5>() { fun Message5> execute() {} } diff --git a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt index c7e6f18acd4..03a6774fddb 100644 --- a/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/genericsInType.fir.kt @@ -23,13 +23,13 @@ fun test() { Foo.Bar.Baz::class a.Bar>() - a.Bar.Baz>() + a<Foo.Bar.Baz>() a>() - a.Baz>() + a<Foo.Bar.Baz>() } -fun Foo> x() {} +fun String.Bar>> x() {} fun Foo.Bar.ext() {} fun ex1(a: Foo.Bar): Foo.Bar { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt index b88ad364875..c25f3d45412 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/bareTypes.fir.kt @@ -15,6 +15,6 @@ class Outer { fun bare(x: Outer<*>.Inner<*, *>.Inner2Base, y: Outer<*>.Inner<*, *>.Inner3Base) { if (x is Outer.Inner.Inner2) return if (y is Outer.Inner.Inner3) return - if (y is Outer.Inner.Inner3) return - if (y is Outer.Inner.Inner3) return + if (y is Outer.Inner.Inner3) return + if (y is Outer.Inner.Inner3) return } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt index 56416b2ca57..603d640167d 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocal.fir.kt @@ -10,7 +10,7 @@ private fun foobar() = { fun a() = A() } - typealias LocalAlias = A + typealias LocalAlias = A<E, X, Y, W> } class Derived : LocalOuter() { @@ -27,7 +27,7 @@ private fun noParameters() = { fun a() = A() } - typealias LocalAlias2 = A + typealias LocalAlias2 = A<Any, X, Y, W> } class Derived2 : LocalOuter2() { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt index 75447981b2f..9f0071189a5 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromSuperClassesLocalInsideInner.fir.kt @@ -12,7 +12,7 @@ class Outer { fun a() = A() } - typealias LocalAlias = A + typealias LocalAlias = A<T, F, E, X, Y, W> } class Derived : LocalOuter() { @@ -29,7 +29,7 @@ class Outer { fun a() = A() } - typealias LocalAlias2 = A + typealias LocalAlias2 = A<T, F, Any, X, Y, W> } class Derived2 : LocalOuter2() { diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt index 5246f574368..131b56d7afc 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/importedInner.fir.kt @@ -17,4 +17,4 @@ class Outer { class E -fun bar(x: Inner) {} +fun bar(x: Inner) {} diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt index a26cddf1a78..259d8335b9d 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/outerArgumentsRequired.fir.kt @@ -15,9 +15,9 @@ class A { val y: B.C? = null val z: B.D? = null - val c: C? = null - val d: D? = null + val c: C? = null + val d: D? = null - val innerMost: Innermost? = null + val innerMost: Innermost? = null } } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt index e365762a123..680ac81cc21 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedOuter.fir.kt @@ -4,7 +4,7 @@ class Outer { inner class Inner - fun foo(x: Outer.Inner, y: Outer.Inner, z: Inner) { + fun foo(x: Outer.Inner, y: Outer.Inner, z: Inner) { var inner = Inner() x.checkType { _() } x.checkType { _.Inner>() } diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt index 6e0cefa3c49..58fd1618b6d 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/qualifiedTypesResolution.fir.kt @@ -42,7 +42,7 @@ fun errorTypeWithArguments(): Q.W.R.M = n fun error1(): Outer.Inner.Inner3 = null!! fun error2(): Outer.Inner.Inner2 = null!! -fun error3(): Outer.Inner.Inner3 = null!! +fun error3(): Outer.Inner.Inner3 = null!! fun error4(): Outer.Nested.Inner4 = null!! fun error5(): Outer.Obj.Nested2.Inner5 = null!! diff --git a/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt b/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt index 4225780a004..ea3c40512f7 100644 --- a/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.fir.kt @@ -1,19 +1,19 @@ class A -interface I0> -interface I1 where T : A -interface I2> where T : A +interface I0A> +interface I1 where T : A +interface I2A> where T : A -fun > foo0() {} -fun foo1() where E : A {} -fun > foo2() where E : A {} +fun A> foo0() {} +fun foo1() where E : A {} +fun A> foo2() where E : A {} -val > E.p1: Int +val A> E.p1: Int get() = 1 -val E.p2: Int where E : A +val E.p2: Int where E : A get() = 1 -val > E.p3: Int where E : A +val A> E.p3: Int where E : A get() = 1 // See KT-8200 interface X -public class EnumAttribute>(val klass: Class) where T : Enum +public class EnumAttributeX>(val klass: Class) where T : Enum diff --git a/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt index 08b91385fad..06718ca85dc 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/controlStructuresErrors.fir.kt @@ -19,7 +19,7 @@ fun test1() { } } -fun test2(l: List) { +fun test2(l: List<AA>) { l.map { it!! } diff --git a/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt b/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt index 38f020fede2..c1c3e279798 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSuperTypeOfErrorTypes.fir.kt @@ -8,14 +8,14 @@ fun consume(x: Foo, y: Foo) {} fun materialize() = null as T fun test() { - consume( - materialize<Foo>>(), - materialize<Foo>>() + consume( + materializeErrorType>>>(), + materializeErrorType>>>() ) consume( - materialize<Foo>>(), - materialize<Foo>() + materializeErrorType>>>(), + materializeErrorType>>() ) } diff --git a/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt b/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt index 35335a385c6..bacd454df96 100644 --- a/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt +++ b/compiler/testData/diagnostics/tests/inner/deepInnerClass.fir.kt @@ -3,11 +3,11 @@ interface P class A { class B { fun test() { - class C() : P { - companion object : P { + class C() : PT> { + companion object : PT> { } - inner class D : P + inner class D : PT> } } } diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt index 830ca995ebf..d7184e68c6f 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/genericArgumentNumberMismatch.fir.kt @@ -6,7 +6,7 @@ package p public class A public class M1 { - public val a: A = A() + public val a: A = A() } // MODULE: m2 @@ -16,7 +16,7 @@ package p public class A -public fun foo(a: A) { +public fun foo(a: A) { } // MODULE: m3(m1, m2) diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt index 10292f79764..03781e5adfa 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.fir.kt @@ -3,5 +3,5 @@ interface G { val bar: Int } -fun G.foo() {} -val G.bar: Int get() = 42 \ No newline at end of file +fun G.foo() {} +val G.bar: Int get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt b/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt index a7e6c9f79df..2ec70721ce6 100644 --- a/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt +++ b/compiler/testData/diagnostics/tests/regressions/OrphanStarProjection.fir.kt @@ -1,3 +1,3 @@ class B {} -val b : B<*> = 1 +val b : B<*> = 1 diff --git a/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt b/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt index b6f853123b3..d8ef905f937 100644 --- a/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/CycleInTypeArgs.fir.kt @@ -1,3 +1,3 @@ -class Class1Class2>> +class Class1X>>> -class Class2Class1>> \ No newline at end of file +class Class2X>>> \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt index e7d485328fc..c3b8fec0203 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/classParents.fir.kt @@ -2,7 +2,7 @@ interface I -class A(impl: Interface) : Nested(), Interface by impl, Inner, I { +class A(impl: Interface) : Nested(), Interface by impl, Inner, I<Nested, Interface, Inner> { class Nested diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt index c86b87fca24..d3a1ec33824 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/objectParents.fir.kt @@ -3,7 +3,7 @@ interface I val aImpl: A.Interface get() = null!! -object A : Nested(), Interface by aImpl, I { +object A : Nested(), Interface by aImpl, I<Nested, Interface> { class Nested diff --git a/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt b/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt index aab7fe69d26..95b34f3a56a 100644 --- a/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt +++ b/compiler/testData/diagnostics/tests/subtyping/kt304.fir.kt @@ -1,6 +1,6 @@ //KT-304: Resolve supertype reference to class anyway -open class Foo() : Bar() { +open class Foo() : Bar() { } open class Bar() { diff --git a/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt b/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt index a391a2d06ac..6cc779c744b 100644 --- a/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt +++ b/compiler/testData/diagnostics/tests/thisAndSuper/Super.fir.kt @@ -50,7 +50,7 @@ class CG : G { fun test() { super.foo() // OK super>.foo() // Warning - super>.foo() // Error + super>.foo() // Error super>.foo() // Error } } diff --git a/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt index 7f0daa5bcc7..bcbf49d0c3b 100644 --- a/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.fir.kt @@ -17,13 +17,13 @@ class Outer { fun foo() { class Local { - typealias LTF = List - typealias LTL = List + typealias LTF = List<TF> + typealias LTL = List<TL> } fun localfun() = object { - typealias LTF = List - typealias LTLF = List + typealias LTF = List<TF> + typealias LTLF = List<TLF> } } diff --git a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt index 06f1590bb1a..f35abf68cc9 100644 --- a/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/javaStaticMembersViaTypeAlias.fir.kt @@ -38,9 +38,9 @@ val testNested2: KT.Nested = KT.IT.Nested = IT.Nested() val testInner1: JT.Inner = JT.Inner() val testInner2: KT.Inner = KT.Inner() -fun testNestedAsTypeArgument1(x: List) {} -fun testNestedAsTypeArgument2(x: List) {} -fun testNestedAsTypeArgument3(x: List) {} -fun testInnerAsTypeArgument1(x: List) {} -fun testInnerAsTypeArgument2(x: List) {} +fun testNestedAsTypeArgument1(x: List<JT.Nested>) {} +fun testNestedAsTypeArgument2(x: List<KT.Nested>) {} +fun testNestedAsTypeArgument3(x: List<IT.Nested>) {} +fun testInnerAsTypeArgument1(x: List<JT.Inner>) {} +fun testInnerAsTypeArgument2(x: List<KT.Inner>) {} diff --git a/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt b/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt index 52a4006e8cf..4c0d7226f3d 100644 --- a/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/localTypeAliasRecursive.fir.kt @@ -2,6 +2,6 @@ fun outer() { typealias Test1 = Test1 - typealias Test2 = List - typealias Test3 = List> + typealias Test2 = List<Test2> + typealias Test3 = List<Test3<T>> } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt index 8a8b8171ec3..041174eefa2 100644 --- a/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/InPosition.fir.kt @@ -41,10 +41,10 @@ interface Test { fun neOk11(i: Inv) fun neOk12(i: Inv) - fun neOk30(i: Pair) - fun neOk31(i: Pair) - fun neOk32(i: Inv) + fun neOk30(i: Pair) + fun neOk31(i: PairInv>) + fun neOk32(i: Inv) fun neOk33(i: Inv<>) - fun neOk34(i: Inv) + fun neOk34(i: Inv<C>) fun neOk35(i: Inv) } diff --git a/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt index 4b0754eeb12..9fb72696400 100644 --- a/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/InvariantPosition.fir.kt @@ -38,10 +38,10 @@ interface Test { var neOk22: Inv var neOk23: Inv - var neOk30: Pair - var neOk31: Pair - var neOk32: Inv + var neOk30: Pair + var neOk31: PairInv> + var neOk32: Inv var neOk33: Inv<> - var neOk34: Inv + var neOk34: Inv<C> var neOk35: Inv } diff --git a/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt b/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt index 7fa171d1429..a9d19182389 100644 --- a/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt +++ b/compiler/testData/diagnostics/tests/variance/OutPosition.fir.kt @@ -33,10 +33,10 @@ interface Test { fun neOk10(): Inv fun neOk11(): Inv - fun neOk30(): Pair - fun neOk31(): Pair - fun neOk32(): Inv + fun neOk30(): Pair + fun neOk31(): PairInv> + fun neOk32(): Inv fun neOk33(): Inv<> - fun neOk34(): Inv + fun neOk34(): Inv<C> fun neOk35(): Inv } diff --git a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt index 99a7d664c06..379189d3aef 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt @@ -10,6 +10,6 @@ package kotlin.sequences import p.* interface I { - val v1: FilteringSequence + val v1: FilteringSequence val v2: IndexingSequence } diff --git a/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt index 72ea6639c4f..110550f7e97 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/regression/kt37727.fir.kt @@ -1,5 +1,5 @@ -data class A(val x: Set = setOf()) { - fun with(x: Set? = null) { +data class A(val x: Set<CLassNotFound> = setOf()) { + fun with(x: Set<CLassNotFound>? = null) { A(x ?: this.x) } } From f1d8a6e5d1caec1fbeadd74c2d90cef43130cc44 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Tue, 19 Jan 2021 16:46:06 -0800 Subject: [PATCH 052/122] FIR checker: introduce DECLARATION_SIGNATURE_OR_DEFAULT positioning strategy and fix CONFLICTING_OVERLOADS to use it --- .../diagnostics/conflictingOverloads.kt | 12 ++--- .../mixingImplicitAndExplicitReceivers.kt | 4 +- .../smartcasts/safeCalls/assignSafeCall.kt | 4 +- .../testData/resolve/whenElse.kt | 4 +- .../callableReferences/beyoundCalls.kt | 4 +- .../lowPriorityInResolution.kt | 6 +-- .../fir/analysis/diagnostics/FirErrors.kt | 2 +- .../LightTreePositioningStrategies.kt | 24 +++++++++ .../SourceElementPositioningStrategies.kt | 5 ++ .../conflictingCopyOverloads.fir.kt | 4 +- .../MultiDeclarationErrors.fir.kt | 4 +- .../ForLoopComponentFunctionAmbiguity.fir.kt | 4 +- .../conflictingImplDeclarations.fir.kt | 8 +-- .../headerDeclarationWithBody.fir.kt | 2 +- ...OverloadsFunsDifferentReturnInClass.fir.kt | 6 +-- ...erloadsFunsDifferentReturnInPackage.fir.kt | 8 +-- ...gOverloadsIdenticalExtFunsInPackage.fir.kt | 4 +- ...ictingOverloadsIdenticalFunsInClass.fir.kt | 7 --- ...onflictingOverloadsIdenticalFunsInClass.kt | 1 + .../TypeParameterMultipleBounds.fir.kt | 15 ------ .../overload/TypeParameterMultipleBounds.kt | 1 + .../tests/override/DuplicateMethod.fir.kt | 8 --- .../tests/override/DuplicateMethod.kt | 1 + .../RedeclarationMainInFile.fir.kt | 5 -- .../redeclarations/RedeclarationMainInFile.kt | 1 + .../RedeclaringPrivateToFile.fir.kt | 12 ++--- .../tests/redeclarations/kt470.fir.kt | 28 +++++----- .../resolveWithRedeclarationError.fir.kt | 54 +++++++++---------- .../suspendConflictsWithNoSuspend.fir.kt | 8 +-- .../noInferAndLowPriority.fir.kt | 4 +- .../onlyInputTypesAndLowPriority.fir.kt | 4 +- 31 files changed, 126 insertions(+), 128 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt index a5e75c40091..43bd1d7e656 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt @@ -1,6 +1,6 @@ -fun test(x: Int) {} +fun test(x: Int) {} -fun test(y: Int) {} +fun test(y: Int) {} fun test() {} @@ -17,9 +17,9 @@ fun test(z: Int, c: Char) {} } class B : A { - override fun rest(s: String) {} + override fun rest(s: String) {} - fun rest(s: String) {} + fun rest(s: String) {} fun rest(l: Long) {} @@ -45,8 +45,8 @@ fun kek(t: T) {} fun lol(a: Array) {} fun lol(a: Array) {} -fun mem(t: T) where T : () -> Boolean, T : String {} -fun mem(t: T) where T : String, T : () -> Boolean {} +fun mem(t: T) where T : () -> Boolean, T : String {} +fun mem(t: T) where T : String, T : () -> Boolean {} class M { companion object {} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt index ca70aec69ce..4220436053e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt @@ -1,4 +1,4 @@ -fun takeString(s: String) {} +fun takeString(s: String) {} class Wrapper(val s: String?) { fun withThis() { @@ -11,4 +11,4 @@ class Wrapper(val s: String?) { } } -fun takeString(s: String) {} +fun takeString(s: String) {} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt index 2ab10f63a19..c48cdff0f54 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt @@ -23,7 +23,7 @@ fun test_2(a: A?) { } } -fun test_3(x: Any?) { +fun test_3(x: Any?) { val a = x as? A ?: return a.foo() // Should be OK x.foo() // Should be OK @@ -53,7 +53,7 @@ fun test_2(a: B?) { } } -fun test_3(x: Any?) { +fun test_3(x: Any?) { val a = x as? B ?: return a.foo() // Should be OK x.foo() // Should be OK diff --git a/compiler/fir/analysis-tests/testData/resolve/whenElse.kt b/compiler/fir/analysis-tests/testData/resolve/whenElse.kt index d217e230760..e3340f5c092 100644 --- a/compiler/fir/analysis-tests/testData/resolve/whenElse.kt +++ b/compiler/fir/analysis-tests/testData/resolve/whenElse.kt @@ -13,7 +13,7 @@ class B() class C(val b : B) fun get(f: Boolean) = if (f) {A.A1} else {""} -fun case2() { +fun case2() { val flag: Any = get(false) //string val l1 = when (flag!!) { // should be NO_ELSE_IN_WHEN @@ -27,7 +27,7 @@ fun get(f: Boolean) = if (f) {A.A1} else {""} } } -fun case2() { +fun case2() { val flag: Any = get(true) //A val l1 = when (flag!!) {// should be NO_ELSE_IN_WHEN diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt index 51dd56f6405..93336ccf18e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/beyoundCalls.kt @@ -1,5 +1,5 @@ -fun bar(x: String): Int = 1 -fun bar(x: String): Double = 1 +fun bar(x: String): Int = 1 +fun bar(x: String): Double = 1 fun baz(x: String): Int = 1 fun foobaz(x: T): R = TODO() diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt index dfbc77b8778..bfda7fa1285 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/lowPriorityInResolution.kt @@ -1,8 +1,8 @@ -@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.internal.LowPriorityInOverloadResolution -fun foo(): Int = 1 +fun foo(): Int = 1 -fun foo(): String = "" +fun foo(): String = "" fun test() { val s = foo() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index dd95a824702..9b15b3505e6 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -139,7 +139,7 @@ object FirErrors { // Redeclarations val MANY_COMPANION_OBJECTS by error0() - val CONFLICTING_OVERLOADS by error1() + val CONFLICTING_OVERLOADS by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT) val REDECLARATION by error1() val ANY_METHOD_IMPLEMENTED_IN_INTERFACE by error0() diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index 78863350667..f0a296ea3ea 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -145,6 +145,30 @@ object LightTreePositioningStrategies { } } + val DECLARATION_SIGNATURE_OR_DEFAULT: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { + override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List = + if (node.isDeclaration) { + DECLARATION_SIGNATURE.mark(node, tree) + } else { + DEFAULT.mark(node, tree) + } + + private val LighterASTNode.isDeclaration: Boolean + get() = + when (tokenType) { + KtNodeTypes.PRIMARY_CONSTRUCTOR, KtNodeTypes.SECONDARY_CONSTRUCTOR, + KtNodeTypes.FUN, KtNodeTypes.FUNCTION_LITERAL, + KtNodeTypes.PROPERTY, + KtNodeTypes.PROPERTY_ACCESSOR, + KtNodeTypes.CLASS, + KtNodeTypes.OBJECT_DECLARATION, + KtNodeTypes.CLASS_INITIALIZER -> + true + else -> + false + } + } + private class ModifierSetBasedLightTreePositioningStrategy(private val modifierSet: TokenSet) : LightTreePositioningStrategy() { override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { tree.findChildByType(node, modifierSet)?.let { return markElement(it, tree) } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt index f5eb8792cea..97d1c6e463e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategies.kt @@ -33,6 +33,11 @@ object SourceElementPositioningStrategies { PositioningStrategies.DECLARATION_SIGNATURE ) + val DECLARATION_SIGNATURE_OR_DEFAULT = SourceElementPositioningStrategy( + LightTreePositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT, + PositioningStrategies.DECLARATION_SIGNATURE_OR_DEFAULT + ) + val VISIBILITY_MODIFIER = SourceElementPositioningStrategy( LightTreePositioningStrategies.VISIBILITY_MODIFIER, PositioningStrategies.VISIBILITY_MODIFIER diff --git a/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt b/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt index 5eccbe99833..6433094e08a 100644 --- a/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt +++ b/compiler/testData/diagnostics/tests/dataClasses/conflictingCopyOverloads.fir.kt @@ -1,6 +1,6 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER data class A(val x: Int, val y: String) { - fun copy(x: Int, y: String) = x - fun copy(x: Int, y: String) = A(x, y) + fun copy(x: Int, y: String) = x + fun copy(x: Int, y: String) = A(x, y) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt index 321146b1b63..e311960423f 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt @@ -7,8 +7,8 @@ class MyClass { class MyClass2 {} -fun MyClass2.component1() = 1.2 -fun MyClass2.component1() = 1.3 +fun MyClass2.component1() = 1.2 +fun MyClass2.component1() = 1.3 fun test(mc1: MyClass, mc2: MyClass2) { val (a, b) = mc1 diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt index 11046074966..e845fef30e1 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt @@ -1,6 +1,6 @@ class A { - operator fun component1() = 1 - operator fun component1() = 1 + operator fun component1() = 1 + operator fun component1() = 1 operator fun component2() = 1 } diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt index 3fc939f994e..f7be9406549 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingImplDeclarations.fir.kt @@ -7,11 +7,11 @@ expect fun foo() // MODULE: m2-jvm(m1-common) // FILE: jvm.kt -actual fun foo() {} -actual fun foo() {} +actual fun foo() {} +actual fun foo() {} // MODULE: m3-js(m1-common) // FILE: js.kt -actual fun foo() {} -actual fun foo() {} +actual fun foo() {} +actual fun foo() {} diff --git a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt index 354cb79554c..b7917046dff 100644 --- a/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt +++ b/compiler/testData/diagnostics/tests/multiplatform/topLevelFun/headerDeclarationWithBody.fir.kt @@ -4,6 +4,6 @@ expect fun foo() -expect fun foo() {} +expect fun foo() {} expect fun bar() {} diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt index 7ab306aa4ba..753ddd6221b 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt @@ -1,6 +1,6 @@ class A { - fun a(a: Int): Int = 0 + fun a(a: Int): Int = 0 - fun a(a: Int) { - } + fun a(a: Int) { + } } diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt index ccecc8e1f00..e785dc5bebb 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt @@ -1,7 +1,7 @@ package qwertyuiop -fun c(s: String) { -} +fun c(s: String) { +} -fun c(s: String) { -} +fun c(s: String) { +} diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt index a7fa2b5bc69..aaee8c77bfe 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt @@ -1,5 +1,5 @@ package extensionFunctions -fun Int.qwe(a: Float) = 1 +fun Int.qwe(a: Float) = 1 -fun Int.qwe(a: Float) = 2 +fun Int.qwe(a: Float) = 2 diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt deleted file mode 100644 index 756a107d8fd..00000000000 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.fir.kt +++ /dev/null @@ -1,7 +0,0 @@ -class A() { - fun b() { - } - - fun b() { - } -} diff --git a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.kt b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.kt index a0f0a29a765..5603c19cc0f 100644 --- a/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.kt +++ b/compiler/testData/diagnostics/tests/overload/ConflictingOverloadsIdenticalFunsInClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class A() { fun b() { } diff --git a/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt b/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt deleted file mode 100644 index 1aef2b3ca48..00000000000 --- a/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -import java.io.Serializable - -interface Test1 { - fun foo(t: T) where T : Cloneable, T : Serializable - fun foo(t: T) where T : Serializable, T : Cloneable -} - - -interface I1 -interface I2 : I1 - -interface Test2 { - fun foo(t: T) where T : I1, T : I2 - fun foo(t: T) where T : I2, T : I1 -} diff --git a/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.kt b/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.kt index e6e1d985c79..a6498f1027e 100644 --- a/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.kt +++ b/compiler/testData/diagnostics/tests/overload/TypeParameterMultipleBounds.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import java.io.Serializable interface Test1 { diff --git a/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt b/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt deleted file mode 100644 index be33444fcb7..00000000000 --- a/compiler/testData/diagnostics/tests/override/DuplicateMethod.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -interface Some { - fun test() -} - -class SomeImpl : Some { - override fun test() {} - override fun test() {} -} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/DuplicateMethod.kt b/compiler/testData/diagnostics/tests/override/DuplicateMethod.kt index 15a21f53ec4..8b6649cd6e6 100644 --- a/compiler/testData/diagnostics/tests/override/DuplicateMethod.kt +++ b/compiler/testData/diagnostics/tests/override/DuplicateMethod.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface Some { fun test() } diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt deleted file mode 100644 index fa478cd835d..00000000000 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.fir.kt +++ /dev/null @@ -1,5 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER -// KT-9733 No error shown for 2 "main" functions in the same file - -fun main(args: Array) {} -fun main(args: Array) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.kt index 648c51dc73c..3de04fac6c1 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/RedeclarationMainInFile.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_PARAMETER // KT-9733 No error shown for 2 "main" functions in the same file diff --git a/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt index faa8c989be2..0d4d6ac0d36 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/RedeclaringPrivateToFile.fir.kt @@ -14,16 +14,16 @@ private val invalidProp0 = 1 fun useInvalidFun0() = invalidFun0() fun useInvalidProp0() = invalidProp0 -private fun invalidFun1() {} -private fun invalidFun1() {} +private fun invalidFun1() {} +private fun invalidFun1() {} -private fun invalidFun2() {} -public fun invalidFun2() {} +private fun invalidFun2() {} +public fun invalidFun2() {} public fun invalidFun3() {} -private fun invalidFun4() {} -public fun invalidFun4() {} +private fun invalidFun4() {} +public fun invalidFun4() {} public fun validFun2(a: A) = a public fun validFun2(b: B) = b diff --git a/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt b/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt index d5c756feafe..b8732450a9e 100644 --- a/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt +++ b/compiler/testData/diagnostics/tests/redeclarations/kt470.fir.kt @@ -7,14 +7,14 @@ val b : Int = 1 val b : Int = 1 -fun foo() {} // and here too -fun foo() {} // and here -fun foo() {} // and here -fun foo() {} // and here +fun foo() {} // and here too +fun foo() {} // and here +fun foo() {} // and here +fun foo() {} // and here -fun bar() {} // and here -fun bar() {} // and here -fun bar() {} // and here +fun bar() {} // and here +fun bar() {} // and here +fun bar() {} // and here class A { val a : Int = 1 @@ -26,12 +26,12 @@ class A { val b : Int = 1 val b : Int = 1 - fun foo() {} // and here too - fun foo() {} // and here - fun foo() {} // and here - fun foo() {} // and here + fun foo() {} // and here too + fun foo() {} // and here + fun foo() {} // and here + fun foo() {} // and here - fun bar() {} // and here - fun bar() {} // and here - fun bar() {} // and here + fun bar() {} // and here + fun bar() {} // and here + fun bar() {} // and here } diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt index e19700c8231..342ef2b152c 100644 --- a/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.fir.kt @@ -3,32 +3,32 @@ package c fun z(view: () -> Unit) {} -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } -fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } class x() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt index 93b532a59ec..05c30d2900e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/suspendConflictsWithNoSuspend.fir.kt @@ -5,11 +5,11 @@ interface A { } interface B : A { - suspend override fun foo() { + suspend override fun foo() { - } + } - override fun foo() { + override fun foo() { - } + } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt index acb58ed66d0..e7b0720908d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.fir.kt @@ -4,10 +4,10 @@ @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @kotlin.internal.LowPriorityInOverloadResolution -public fun Iterable.contains1(element: T): Int = null!! +public fun Iterable.contains1(element: T): Int = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boolean = null!! +public fun Iterable.contains1(element: @kotlin.internal.NoInfer T): Boolean = null!! fun test() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt index 68afa34a75e..e3f188fd452 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesAndLowPriority.fir.kt @@ -5,10 +5,10 @@ @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @kotlin.jvm.JvmName("containsAny") @kotlin.internal.LowPriorityInOverloadResolution -public fun Iterable.contains1(element: T): Int = null!! +public fun Iterable.contains1(element: T): Int = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") -public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! +public fun <@kotlin.internal.OnlyInputTypes T> Iterable.contains1(element: T): Boolean = null!! @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @JvmName("getAny") From 40bec30393dea6462ba2548da88296a80d99f15a Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 21 Jan 2021 13:47:07 +0300 Subject: [PATCH 053/122] FIR: implement LT positioning in diagnostic tests, fix LT strategies --- .../diagnostics/annotationClassMember.kt | 2 +- .../diagnostics/conflictingOverloads.kt | 14 +- .../diagnostics/constructorInInterface.kt | 6 +- .../cyclicConstructorDelegationCall.kt | 30 ++-- .../delegationSuperCallInEnumConstructor.kt | 2 +- .../explicitDelegationCallRequired.kt | 6 +- .../instanceAccessBeforeSuperCall.kt | 4 +- .../diagnostics/localEntitytNotAllowed.kt | 8 +- .../diagnostics/manyCompanionObjects.kt | 12 +- .../resolve/diagnostics/sealedSupertype.kt | 4 +- .../diagnostics/typeParametersInObject.kt | 14 +- .../diagnostics/valOnAnnotationParameter.kt | 2 +- .../resolve/expresssions/localObjects.kt | 4 +- .../ArrayEqualityCanBeReplacedWithEquals.kt | 6 +- .../extendedCheckers/CanBeValChecker.kt | 22 +-- .../RedundantExplicitTypeChecker.kt | 2 +- .../RedundantModalityModifierChecker.kt | 58 +++---- .../RedundantVisibilityModifierChecker.kt | 28 ++-- .../BasicTest.kt | 4 +- .../multipleOperators.kt | 4 +- .../multipleOperatorsRightSideRepeat.kt | 4 +- .../nonCommutativeRepeat.kt | 6 +- .../rightSideRepeat.kt | 2 +- .../simpleAssign.kt | 2 +- .../validAddition.kt | 2 +- .../validSubtraction.kt | 2 +- .../unused/manyLocalVariables.kt | 2 +- .../testData/resolve/openInInterface.kt | 6 +- .../mixingImplicitAndExplicitReceivers.kt | 4 +- .../smartcasts/safeCalls/assignSafeCall.kt | 8 +- .../resolve/typeAliasWithTypeArguments.kt | 4 +- .../testData/resolve/whenElse.kt | 8 +- .../LightTreePositioningStrategies.kt | 145 ++++++++++++------ .../LightTreePositioningStrategy.kt | 40 +++-- .../SourceElementPositioningStrategy.kt | 2 +- .../fir/handlers/FirDiagnosticCodeMetaInfo.kt | 16 +- 36 files changed, 275 insertions(+), 210 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationClassMember.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationClassMember.kt index 99c7f132257..4c459a52221 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationClassMember.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/annotationClassMember.kt @@ -1,5 +1,5 @@ annotation class A() { - constructor(s: Nothing?) {} + constructor(s: Nothing?) {} init {} fun foo() {} val bar: Nothing? diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt index 43bd1d7e656..48bf6e25af2 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt @@ -1,6 +1,6 @@ -fun test(x: Int) {} +fun test(x: Int) {} -fun test(y: Int) {} +fun test(y: Int) {} fun test() {} @@ -17,9 +17,9 @@ fun test(z: Int, c: Char) {} } class B : A { - override fun rest(s: String) {} + override fun rest(s: String) {} - fun rest(s: String) {} + fun rest(s: String) {} fun rest(l: Long) {} @@ -45,11 +45,11 @@ fun kek(t: T) {} fun lol(a: Array) {} fun lol(a: Array) {} -fun mem(t: T) where T : () -> Boolean, T : String {} -fun mem(t: T) where T : String, T : () -> Boolean {} +fun mem(t: T) where T : () -> Boolean, T : String {} +fun mem(t: T) where T : String, T : () -> Boolean {} class M { - companion object {} + companion object {} val Companion = object : Any {} } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/constructorInInterface.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/constructorInInterface.kt index fed72540136..0431d3a915f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/constructorInInterface.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/constructorInInterface.kt @@ -1,7 +1,7 @@ -interface A(val s: String) +interface A(val s: String) -interface B constructor(val s: String) +interface B constructor(val s: String) interface C { - constructor(val s: String) {} + constructor(val s: String) {} } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt index 6af1dea3d24..3e0bcb593bf 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/cyclicConstructorDelegationCall.kt @@ -2,14 +2,14 @@ class B class C class A() { - constructor(a: Int) : this("test") {} - constructor(a: String) : this(10) {} + constructor(a: Int) : this("test") {} + constructor(a: String) : this(10) {} - constructor(a: Boolean) : this('\n') {} - constructor(a: Char) : this(0.0) {} - constructor(a: Double) : this(false) {} + constructor(a: Boolean) : this('\n') {} + constructor(a: Char) : this(0.0) {} + constructor(a: Double) : this(false) {} - constructor(b: B) : this(3.14159265) {} + constructor(b: B) : this(3.14159265) {} constructor(c: C) : this() {} constructor(a: List) : this(C()) {} @@ -17,7 +17,7 @@ class A() { class D { constructor(i: Boolean) {} - constructor(i: Int) : this(3) {} + constructor(i: Int) : this(3) {} } class E { @@ -25,7 +25,7 @@ class E { // selection of the proper constructor // but a type mismatch for the first // argument - constructor(e: T, i: Int) : this(i, 10) {} + constructor(e: T, i: Int) : this(i, 10) {} } class I { @@ -33,7 +33,7 @@ class I { // selection of the proper constructor // but a type mismatch for the first // argument - constructor(e: T, i: Int) : this(i, 10) + constructor(e: T, i: Int) : this(i, 10) } class J { @@ -42,20 +42,20 @@ class J { } class F(s: String) { - constructor(i: Boolean) {} - constructor(i: Int) : this(3) {} + constructor(i: Boolean) {} + constructor(i: Int) : this(3) {} } class G(x: Int) { - constructor() {} + constructor() {} } class H(x: Int) { - constructor() + constructor() } class K(x: Int) { - constructor() : this() {} + constructor() : this() {} } class M { @@ -63,5 +63,5 @@ class M { } class U : M { - constructor() + constructor() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/delegationSuperCallInEnumConstructor.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/delegationSuperCallInEnumConstructor.kt index de3e2fca1f5..f647d95b892 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/delegationSuperCallInEnumConstructor.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/delegationSuperCallInEnumConstructor.kt @@ -1,6 +1,6 @@ enum class A { A(1), B(2), C("test"); - constructor(x: Int) : super() + constructor(x: Int) : super() constructor(t: String) : this(10) } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt index 8a943818747..89391c3f554 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/explicitDelegationCallRequired.kt @@ -3,16 +3,16 @@ class A(x: Int) { } class B : A { - constructor() + constructor() constructor(z: String) : this() } class C : A(20) { - constructor() + constructor() constructor(z: String) : this() } class D() : A(20) { - constructor(x: Int) + constructor(x: Int) constructor(z: String) : this() } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt index 5af0cecc5ce..ecc452d60ca 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/instanceAccessBeforeSuperCall.kt @@ -7,10 +7,10 @@ class A { class B(other: B = this) class C() { - constructor(x: Int) : this({ + constructor(x: Int) : this({ val a = 10 this - }) {} + }) {} } class D { diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt index 93261d8df5c..b419ca218d9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/localEntitytNotAllowed.kt @@ -6,19 +6,19 @@ object A { interface X val a = object : Any() { - object D { + object D { object G interface Z - } + } interface Y } fun b() { - object E { + object E { object F interface M - } + } interface N diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt index 0b81df7cd10..56cc10963e7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/manyCompanionObjects.kt @@ -1,11 +1,11 @@ class A { - companion object { + companion object { - } + } - companion object { + companion object { - } + } } class B { @@ -13,7 +13,7 @@ class B { } - companion object B { + companion object B { - } + } } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt index 63562f91132..6bd11376197 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt @@ -28,9 +28,9 @@ sealed class P { class K : P() -object B { +object B { class I : P() -} +} fun test() { class L : P() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt index 53e38a047bc..cce8b4d04bc 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/typeParametersInObject.kt @@ -1,15 +1,15 @@ -object A { - object B -} +object A { + object B +} class N { - companion object { + companion object { - } + } } fun test() { - object M { + object M { - } + } } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/valOnAnnotationParameter.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/valOnAnnotationParameter.kt index 03c8a353964..11a2a5ce1a9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/valOnAnnotationParameter.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/valOnAnnotationParameter.kt @@ -1,4 +1,4 @@ annotation class A( - var a: Int, + var a: Int, b: String ) diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt index f82f0ba51de..cf10589374f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/localObjects.kt @@ -12,9 +12,9 @@ fun test() { } b.foo() - object B { + object B { fun foo() {} - } + } B.foo() } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/ArrayEqualityCanBeReplacedWithEquals.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/ArrayEqualityCanBeReplacedWithEquals.kt index 48ee3140b41..1a9b3677c68 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/ArrayEqualityCanBeReplacedWithEquals.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/ArrayEqualityCanBeReplacedWithEquals.kt @@ -4,14 +4,14 @@ fun foo(p: Int) { val a = arrayOf(1, 2, 3) val b = arrayOf(3, 2, 1) - if (a == b) { } + if (a == b) { } } fun testsFromIdea() { val a = arrayOf("a") val b = a val c: Any? = null - a == b + a == b a == c - a != b + a != b } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.kt index 5265bf5f52c..908fed80c3f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/CanBeValChecker.kt @@ -23,7 +23,7 @@ operator fun C.plusAssign(a: Any) {} fun testOperatorAssignment() { val c = C() c += "" - var c1 = C() + var c1 = C() c1 += "" var a = 1 @@ -33,7 +33,7 @@ fun testOperatorAssignment() { fun destructuringDeclaration() { - var (v1, v2) = getPair() + var (v1, v2) = getPair() print(v1) var (v3, v4) = getPair() @@ -49,11 +49,11 @@ fun destructuringDeclaration() { val (a, b, c) = Triple(1, 1, 1) - var (x, y, z) = Triple(1, 1, 1) + var (x, y, z) = Triple(1, 1, 1) } fun stackOverflowBug() { - var a: Int + var a: Int a = 1 for (i in 1..10) print(i) @@ -71,8 +71,8 @@ fun smth(flag: Boolean) { } fun withAnnotation(p: List) { - @Suppress("UNCHECKED_CAST") - var v = p as List + @Suppress("UNCHECKED_CAST") + var v = p as List print(v) } @@ -88,7 +88,7 @@ fun listReceiver(p: List) {} fun withInitializer() { var v1 = 1 var v2 = 2 - var v3 = 3 + var v3 = 3 v1 = 1 v2++ // todo mark this UNUSED_CHANGED_VALUES print(v3) @@ -102,7 +102,7 @@ fun test() { } fun foo() { - var a: Int + var a: Int val bool = true if (bool) a = 4 else a = 42 val b: String @@ -130,7 +130,7 @@ fun assignedTwice(p: Int) { } fun main(args: Array) { - var a: String? + var a: String? val unused = 0 if (args.size == 1) { @@ -153,7 +153,7 @@ fun lambda() { } fun lambdaInitialization() { - var a: Int + var a: Int run { a = 20 @@ -161,7 +161,7 @@ fun lambdaInitialization() { } fun notAssignedWhenNotUsed(p: Int) { - var v: Int + var v: Int if (p > 0) { v = 1 print(v) diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantExplicitTypeChecker.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantExplicitTypeChecker.kt index 033dc08beeb..1639a7f6634 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantExplicitTypeChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantExplicitTypeChecker.kt @@ -52,7 +52,7 @@ fun foo() { val piFloat: Float = 3.14f val piDouble: Double = 3.14 val charZ: Char = 'z' - var alpha: Int = 0 + var alpha: Int = 0 } fun test(boolean: Boolean) { diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt index 0489203b341..29ef5c58d94 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantModalityModifierChecker.kt @@ -4,23 +4,23 @@ object O { // Interface interface Interface { - // Questionable cuz compiler reports warning here in FE 1.0 - open val gav: Int - get() = 42 - // Redundant - abstract fun foo() - // error - private final fun bar() + // Questionable cuz compiler reports warning here in FE 1.0 + open val gav: Int + get() = 42 + // Redundant + abstract fun foo() + // error + private final fun bar() - open fun goo() {} - abstract fun tar() + open fun goo() {} + abstract fun tar() - // error - abstract fun too() {} + // error + abstract fun too() {} } interface B { - abstract var bar: Unit - abstract fun foo() + abstract var bar: Unit + abstract fun foo() } interface Foo @@ -35,8 +35,8 @@ expect abstract class AbstractClass : Foo { // Abstract abstract class Base { - // Redundant final - final fun foo() {} + // Redundant final + final fun foo() {} // Abstract abstract fun bar() // Open @@ -44,8 +44,8 @@ abstract class Base { } class FinalDerived : Base() { - // Redundant final - override final fun bar() {} + // Redundant final + override final fun bar() {} // Non-final member in final class override open val gav = 13 } @@ -53,33 +53,33 @@ class FinalDerived : Base() { open class OpenDerived : Base() { // Final override final fun bar() {} - // Redundant open - override open val gav = 13 + // Redundant open + override open val gav = 13 } -// Redundant final -final class Final +// Redundant final +final class Final // Derived interface interface Derived : Interface { - // Redundant - override open fun foo() {} + // Redundant + override open fun foo() {} // error final class Nested } // Derived abstract class abstract class AbstractDerived1(override final val gav: Int) : Interface { - // Redundant - override open fun foo() {} + // Redundant + override open fun foo() {} } // Derived abstract class abstract class AbstractDerived2 : Interface { // Final override final fun foo() {} - // Redundant - override open val gav = 13 + // Redundant + override open val gav = 13 } // Redundant abstract interface abstract interface AbstractInterface -// Redundant final object -final object FinalObject +// Redundant final object +final object FinalObject // Open interface open interface OpenInterface diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.kt index 9bd5d5fab2b..d1ac4a133b3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantVisibilityModifierChecker.kt @@ -1,7 +1,7 @@ fun f() { - public var baz = 0 + public var baz = 0 class LocalClass { - internal var foo = 0 + internal var foo = 0 } LocalClass().foo = 1 } @@ -26,10 +26,10 @@ class Foo2< internal inner class B } -public class C { - public val foo: Int = 0 +public class C { + public val foo: Int = 0 - public fun bar() {} + public fun bar() {} } @@ -42,19 +42,19 @@ open class D { } class E : D() { - protected override fun willRemainProtected() { - } + protected override fun willRemainProtected() { + } public override fun willBecomePublic() { } } -enum class F private constructor(val x: Int) { +enum class F private constructor(val x: Int) { FIRST(42) } sealed class G constructor(val y: Int) { - private constructor(): this(42) + private constructor(): this(42) object H : G() } @@ -63,16 +63,16 @@ interface I { fun bar() } -public var baz = 0 +public var baz = 0 open class J { protected val baz = 0 - protected get() = field * 2 + protected get() = field * 2 var baf = 0 - public get() = 1 - public set(value) { + public get() = 1 + public set(value) { field = value - } + } var buf = 0 private get() = 42 diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/BasicTest.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/BasicTest.kt index 912b9269c91..e218c599d57 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/BasicTest.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/BasicTest.kt @@ -1,7 +1,7 @@ fun goo() { var a = 2 val b = 4 - a = a + 1 + b - a = (a + 1) + a = a + 1 + b + a = (a + 1) a = a * b + 1 } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperators.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperators.kt index 11f1bca71de..9d171517e9c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperators.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperators.kt @@ -1,5 +1,5 @@ fun foo() { var x = 0 - var y = 0 - x = x + y + 5 + var y = 0 + x = x + y + 5 } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperatorsRightSideRepeat.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperatorsRightSideRepeat.kt index 96977f2be0e..a93064495f9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperatorsRightSideRepeat.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/multipleOperatorsRightSideRepeat.kt @@ -1,5 +1,5 @@ fun foo() { var x = 0 - var y = 0 - x = y + x + 5 + var y = 0 + x = y + x + 5 } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/nonCommutativeRepeat.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/nonCommutativeRepeat.kt index dcc6e3c00c3..2208ebf69b3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/nonCommutativeRepeat.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/nonCommutativeRepeat.kt @@ -1,8 +1,8 @@ fun foo() { var x = 0 - x = x - 1 - 1 + x = x - 1 - 1 - x = x / 1 + x = x / 1 x = 1 / x - x = -1 + x + x = -1 + x } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/rightSideRepeat.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/rightSideRepeat.kt index adde06044e7..43f50dd8c40 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/rightSideRepeat.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/rightSideRepeat.kt @@ -1,4 +1,4 @@ fun foo() { var x = 0 - x = 1 + x + x = 1 + x } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/simpleAssign.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/simpleAssign.kt index cb9f57e7075..ba5108a3cc6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/simpleAssign.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/simpleAssign.kt @@ -1,5 +1,5 @@ fun foo() { var y = 0 val x = 0 - y = y + x + y = y + x } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validAddition.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validAddition.kt index d77084bd75a..191b05aebd9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validAddition.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validAddition.kt @@ -1,4 +1,4 @@ fun foo() { var x = 0 - x = x + 1 + x = x + 1 } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validSubtraction.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validSubtraction.kt index a474c593fa1..41407233e65 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validSubtraction.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/canBeReplacedWithOperatorAssignment/validSubtraction.kt @@ -1,4 +1,4 @@ fun foo() { var x = 0 - x = x - 1 + x = x - 1 } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/manyLocalVariables.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/manyLocalVariables.kt index d95d419335f..dd1e7085692 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/manyLocalVariables.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/unused/manyLocalVariables.kt @@ -1,5 +1,5 @@ fun foo() { - var a = 1 + var a = 1 var b = 2 var c = 3 diff --git a/compiler/fir/analysis-tests/testData/resolve/openInInterface.kt b/compiler/fir/analysis-tests/testData/resolve/openInInterface.kt index fdd553a0018..863e2cf7e4f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/openInInterface.kt +++ b/compiler/fir/analysis-tests/testData/resolve/openInInterface.kt @@ -1,12 +1,12 @@ interface Some { - open fun foo() + open fun foo() open fun bar() {} - open val x: Int + open val x: Int open val y = 1 open val z get() = 1 - open var xx: Int + open var xx: Int open var yy = 1 open var zz: Int set(value) { diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt index 4220436053e..9cd0660a7a9 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/receivers/mixingImplicitAndExplicitReceivers.kt @@ -1,4 +1,4 @@ -fun takeString(s: String) {} +fun takeString(s: String) {} class Wrapper(val s: String?) { fun withThis() { @@ -11,4 +11,4 @@ class Wrapper(val s: String?) { } } -fun takeString(s: String) {} +fun takeString(s: String) {} diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt index c48cdff0f54..8e51020f74a 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/safeCalls/assignSafeCall.kt @@ -23,11 +23,11 @@ fun test_2(a: A?) { } } -fun test_3(x: Any?) { +fun test_3(x: Any?) { val a = x as? A ?: return a.foo() // Should be OK x.foo() // Should be OK -} +} // ----------------- Unstable ----------------- @@ -53,8 +53,8 @@ fun test_2(a: B?) { } } -fun test_3(x: Any?) { +fun test_3(x: Any?) { val a = x as? B ?: return a.foo() // Should be OK x.foo() // Should be OK -} +} diff --git a/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt b/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt index 065f9741152..997d46d1aaa 100644 --- a/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt +++ b/compiler/fir/analysis-tests/testData/resolve/typeAliasWithTypeArguments.kt @@ -10,10 +10,10 @@ interface C { fun baz() } -interface Inv() { +interface Inv() { fun k(): K fun t(): T -} +} typealias Inv0 = Inv typealias Inv1 = Inv diff --git a/compiler/fir/analysis-tests/testData/resolve/whenElse.kt b/compiler/fir/analysis-tests/testData/resolve/whenElse.kt index e3340f5c092..831c7f173ab 100644 --- a/compiler/fir/analysis-tests/testData/resolve/whenElse.kt +++ b/compiler/fir/analysis-tests/testData/resolve/whenElse.kt @@ -13,7 +13,7 @@ class B() class C(val b : B) fun get(f: Boolean) = if (f) {A.A1} else {""} -fun case2() { +fun case2() { val flag: Any = get(false) //string val l1 = when (flag!!) { // should be NO_ELSE_IN_WHEN @@ -25,9 +25,9 @@ fun get(f: Boolean) = if (f) {A.A1} else {""} A.A1 -> B() A.A2 -> B() } -} +} -fun case2() { +fun case2() { val flag: Any = get(true) //A val l1 = when (flag!!) {// should be NO_ELSE_IN_WHEN @@ -39,7 +39,7 @@ fun get(f: Boolean) = if (f) {A.A1} else {""} A.A1 -> B() A.A2 -> B() } -} +} fun case3() { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt index f0a296ea3ea..f288784a41e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategies.kt @@ -20,39 +20,56 @@ import org.jetbrains.kotlin.psi.KtParameter.VAL_VAR_TOKEN_SET object LightTreePositioningStrategies { val DEFAULT = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { when (node.tokenType) { KtNodeTypes.OBJECT_DECLARATION -> { val objectKeyword = tree.objectKeyword(node)!! return markRange( from = objectKeyword, to = tree.nameIdentifier(node) ?: objectKeyword, - tree + startOffset, endOffset, tree, node ) } KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> { - return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(node, tree) + return SECONDARY_CONSTRUCTOR_DELEGATION_CALL.mark(node, startOffset, endOffset, tree) } } - return super.mark(node, tree) + return super.mark(node, startOffset, endOffset, tree) } } val VAL_OR_VAR_NODE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { val target = tree.valOrVarKeyword(node) ?: node - return markElement(target, tree) + return markElement(target, startOffset, endOffset, tree, node) } } val SECONDARY_CONSTRUCTOR_DELEGATION_CALL: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { when (node.tokenType) { KtNodeTypes.SECONDARY_CONSTRUCTOR -> { - val valueParameterList = tree.valueParameterList(node) ?: return markElement(node, tree) + val valueParameterList = tree.valueParameterList(node) + ?: return markElement(node, startOffset, endOffset, tree) return markRange( tree.constructorKeyword(node)!!, - tree.lastChild(valueParameterList)!!, tree + tree.lastChild(valueParameterList) ?: valueParameterList, + startOffset, endOffset, tree, node ) } KtNodeTypes.CONSTRUCTOR_DELEGATION_CALL -> { @@ -60,13 +77,14 @@ object LightTreePositioningStrategies { if (delegationReference != null && tree.firstChild(delegationReference) == null) { val constructor = tree.findParentOfType(node, KtNodeTypes.SECONDARY_CONSTRUCTOR)!! val valueParameterList = tree.valueParameterList(constructor) - ?: return markElement(constructor, tree) + ?: return markElement(constructor, startOffset, endOffset, tree, node) return markRange( tree.constructorKeyword(constructor)!!, - tree.lastChild(valueParameterList)!!, tree + tree.lastChild(valueParameterList) ?: valueParameterList, + startOffset, endOffset, tree, node ) } - return markElement(delegationReference ?: node, tree) + return markElement(delegationReference ?: node, startOffset, endOffset, tree, node) } else -> error("unexpected element $node") } @@ -74,7 +92,12 @@ object LightTreePositioningStrategies { } val DECLARATION_NAME: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { val nameIdentifier = tree.nameIdentifier(node) if (nameIdentifier != null) { if (node.tokenType == KtNodeTypes.CLASS || node.tokenType == KtNodeTypes.OBJECT_DECLARATION) { @@ -83,24 +106,31 @@ object LightTreePositioningStrategies { ?: tree.findChildByType(node, TokenSet.create(KtTokens.CLASS_KEYWORD, KtTokens.OBJECT_KEYWORD)) ?: node - return markRange(startElement, nameIdentifier, tree) + return markRange(startElement, nameIdentifier, startOffset, endOffset, tree, node) } - return markElement(nameIdentifier, tree) + return markElement(node, startOffset, endOffset, tree) } if (node.tokenType == KtNodeTypes.FUN) { - return DECLARATION_SIGNATURE.mark(node, tree) + return DECLARATION_SIGNATURE.mark(node, startOffset, endOffset, tree) } - return DEFAULT.mark(node, tree) + return DEFAULT.mark(node, startOffset, endOffset, tree) } } val DECLARATION_SIGNATURE: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { when (node.tokenType) { KtNodeTypes.PRIMARY_CONSTRUCTOR, KtNodeTypes.SECONDARY_CONSTRUCTOR -> { - val begin = tree.constructorKeyword(node) ?: tree.valueParameterList(node) ?: return markElement(node, tree) - val end = tree.valueParameterList(node) ?: tree.constructorKeyword(node) ?: return markElement(node, tree) - return markRange(begin, end, tree) + val begin = tree.constructorKeyword(node) ?: tree.valueParameterList(node) + ?: return markElement(node, startOffset, endOffset, tree) + val end = tree.valueParameterList(node) ?: tree.constructorKeyword(node) + ?: return markElement(node, startOffset, endOffset, tree) + return markRange(begin, end, startOffset, endOffset, tree, node) } KtNodeTypes.FUN, KtNodeTypes.FUNCTION_LITERAL -> { val endOfSignatureElement = @@ -113,11 +143,11 @@ object LightTreePositioningStrategies { ?: tree.valueParameterList(node) ?: node } else node - return markRange(startElement, endOfSignatureElement, tree) + return markRange(startElement, endOfSignatureElement, startOffset, endOffset, tree, node) } KtNodeTypes.PROPERTY -> { val endOfSignatureElement = tree.typeReference(node) ?: tree.nameIdentifier(node) ?: node - return markRange(node, endOfSignatureElement, tree) + return markRange(node, endOfSignatureElement, startOffset, endOffset, tree, node) } KtNodeTypes.PROPERTY_ACCESSOR -> { val endOfSignatureElement = @@ -125,32 +155,38 @@ object LightTreePositioningStrategies { ?: tree.rightParenthesis(node) ?: tree.accessorNamePlaceholder(node) - return markRange(node, endOfSignatureElement, tree) + return markRange(node, endOfSignatureElement, startOffset, endOffset, tree, node) } KtNodeTypes.CLASS -> { - val nameAsDeclaration = tree.nameIdentifier(node) ?: return markElement(node, tree) + val nameAsDeclaration = tree.nameIdentifier(node) + ?: return markElement(node, startOffset, endOffset, tree) val primaryConstructorParameterList = tree.primaryConstructor(node)?.let { constructor -> tree.valueParameterList(constructor) - } ?: return markElement(nameAsDeclaration, tree) - return markRange(nameAsDeclaration, primaryConstructorParameterList, tree) + } ?: return markElement(nameAsDeclaration, startOffset, endOffset, tree, node) + return markRange(nameAsDeclaration, primaryConstructorParameterList, startOffset, endOffset, tree, node) } KtNodeTypes.OBJECT_DECLARATION -> { - return DECLARATION_NAME.mark(node, tree) + return DECLARATION_NAME.mark(node, startOffset, endOffset, tree) } KtNodeTypes.CLASS_INITIALIZER -> { - return markElement(tree.initKeyword(node)!!, tree) + return markElement(tree.initKeyword(node)!!, startOffset, endOffset, tree, node) } } - return super.mark(node, tree) + return super.mark(node, startOffset, endOffset, tree) } } val DECLARATION_SIGNATURE_OR_DEFAULT: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List = + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List = if (node.isDeclaration) { - DECLARATION_SIGNATURE.mark(node, tree) + DECLARATION_SIGNATURE.mark(node, startOffset, endOffset, tree) } else { - DEFAULT.mark(node, tree) + DEFAULT.mark(node, startOffset, endOffset, tree) } private val LighterASTNode.isDeclaration: Boolean @@ -170,17 +206,29 @@ object LightTreePositioningStrategies { } private class ModifierSetBasedLightTreePositioningStrategy(private val modifierSet: TokenSet) : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { - tree.findChildByType(node, modifierSet)?.let { return markElement(it, tree) } - tree.nameIdentifier(node)?.let { return markElement(it, tree) } + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + val modifierList = tree.modifierList(node) + if (modifierList != null) { + tree.findChildByType(modifierList, modifierSet)?.let { + return markElement(it, startOffset, endOffset, tree, node) + } + } + tree.nameIdentifier(node)?.let { + return markElement(it, startOffset, endOffset, tree, node) + } return when (node.tokenType) { KtNodeTypes.OBJECT_DECLARATION -> { - markElement(tree.objectKeyword(node)!!, tree) + markElement(tree.objectKeyword(node)!!, startOffset, endOffset, tree, node) } KtNodeTypes.PROPERTY_ACCESSOR -> { - markElement(tree.accessorNamePlaceholder(node), tree) + markElement(tree.accessorNamePlaceholder(node), startOffset, endOffset, tree, node) } - else -> markElement(node, tree) + else -> markElement(node, startOffset, endOffset, tree) } } } @@ -190,8 +238,13 @@ object LightTreePositioningStrategies { val MODALITY_MODIFIER: LightTreePositioningStrategy = ModifierSetBasedLightTreePositioningStrategy(MODALITY_MODIFIERS) val OPERATOR: LightTreePositioningStrategy = object : LightTreePositioningStrategy() { - override fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { - return markElement(tree.operationReference(node) ?: node, tree) + override fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + return markElement(tree.operationReference(node) ?: node, startOffset, endOffset, tree, node) } } } @@ -248,15 +301,17 @@ private fun FlyweightCapableTreeStructure.valueParameterList(nod findChildByType(node, KtNodeTypes.VALUE_PARAMETER_LIST) private fun FlyweightCapableTreeStructure.typeReference(node: LighterASTNode): LighterASTNode? { - val childrenRef = Ref>() + val childrenRef = Ref>() getChildren(node, childrenRef) - return childrenRef.get()?.dropWhile { it.tokenType != KtTokens.COLON }?.firstOrNull { it.tokenType == KtNodeTypes.TYPE_REFERENCE } + return childrenRef.get()?.filterNotNull()?.dropWhile { it.tokenType != KtTokens.COLON }?.firstOrNull { + it.tokenType == KtNodeTypes.TYPE_REFERENCE + } } private fun FlyweightCapableTreeStructure.receiverTypeReference(node: LighterASTNode): LighterASTNode? { - val childrenRef = Ref>() + val childrenRef = Ref>() getChildren(node, childrenRef) - return childrenRef.get()?.firstOrNull { + return childrenRef.get()?.filterNotNull()?.firstOrNull { if (it.tokenType == KtTokens.COLON || it.tokenType == KtTokens.LPAR) return null it.tokenType == KtNodeTypes.TYPE_REFERENCE } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategy.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategy.kt index 5c0db8b0dea..2d76d410168 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategy.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/LightTreePositioningStrategy.kt @@ -15,13 +15,13 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens.WHITE_SPACE open class LightTreePositioningStrategy { - open fun markDiagnostic(diagnostic: FirDiagnostic<*>): List { - val element = diagnostic.element - return mark(element.lighterASTNode, element.treeStructure) - } - - open fun mark(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { - return markElement(node, tree) + open fun mark( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure + ): List { + return markElement(node, startOffset, endOffset, tree) } open fun isValid(node: LighterASTNode, tree: FlyweightCapableTreeStructure): Boolean { @@ -29,12 +29,30 @@ open class LightTreePositioningStrategy { } } -fun markElement(node: LighterASTNode, tree: FlyweightCapableTreeStructure): List { - return listOf(TextRange(tree.getStartOffset(node), tree.getEndOffset(node))) +fun markElement( + node: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure, + originalNode: LighterASTNode = node, +): List { + if (node === originalNode) return listOf(TextRange(startOffset, endOffset)) + val startDelta = tree.getStartOffset(node) - tree.getStartOffset(originalNode) + val endDelta = tree.getEndOffset(node) - tree.getEndOffset(originalNode) + return listOf(TextRange(startDelta + startOffset, endDelta + endOffset)) } -fun markRange(from: LighterASTNode, to: LighterASTNode, tree: FlyweightCapableTreeStructure): List { - return listOf(TextRange(tree.getStartOffset(from), tree.getEndOffset(to))) +fun markRange( + from: LighterASTNode, + to: LighterASTNode, + startOffset: Int, + endOffset: Int, + tree: FlyweightCapableTreeStructure, + originalNode: LighterASTNode +): List { + val startDelta = tree.getStartOffset(from) - tree.getStartOffset(originalNode) + val endDelta = tree.getEndOffset(to) - tree.getEndOffset(originalNode) + return listOf(TextRange(startDelta + startOffset, endDelta + endOffset)) } private val DOC_AND_COMMENT_TOKENS = setOf( diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategy.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategy.kt index aef575700a9..f628d09d93a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategy.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/SourceElementPositioningStrategy.kt @@ -21,7 +21,7 @@ open class SourceElementPositioningStrategy( @Suppress("UNCHECKED_CAST") return psiStrategy.mark(element.psi as E) } - return lightTreeStrategy.mark(element.lighterASTNode, element.treeStructure) + return lightTreeStrategy.mark(element.lighterASTNode, element.startOffset, element.endOffset, element.treeStructure) } fun isValid(element: FirSourceElement): Boolean { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticCodeMetaInfo.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticCodeMetaInfo.kt index bfd591e42c8..cab0787fcd0 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticCodeMetaInfo.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticCodeMetaInfo.kt @@ -6,14 +6,11 @@ package org.jetbrains.kotlin.test.frontend.fir.handlers import com.intellij.openapi.util.TextRange -import com.intellij.psi.PsiElement import org.jetbrains.kotlin.codeMetaInfo.model.CodeMetaInfo import org.jetbrains.kotlin.codeMetaInfo.renderConfigurations.AbstractCodeMetaInfoRenderConfiguration -import org.jetbrains.kotlin.diagnostics.PositioningStrategy import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderer -import org.jetbrains.kotlin.fir.psi object FirMetaInfoUtils { val renderDiagnosticNoArgs = FirDiagnosticCodeMetaRenderConfiguration().apply { renderParams = false } @@ -24,23 +21,18 @@ class FirDiagnosticCodeMetaInfo( val diagnostic: FirDiagnostic<*>, renderConfiguration: FirDiagnosticCodeMetaRenderConfiguration ) : CodeMetaInfo { - // TODO: this implementation is hacky and doesn't support proper ranges for light tree diagnostics - private val textRangeFromClassicDiagnostic: TextRange? = run { - val psi = diagnostic.element.psi ?: return@run null - - @Suppress("UNCHECKED_CAST") - val positioningStrategy = diagnostic.factory.positioningStrategy.psiStrategy as PositioningStrategy - positioningStrategy.mark(psi).first() + private val textRangeFromClassicDiagnostic: TextRange = run { + diagnostic.factory.positioningStrategy.markDiagnostic(diagnostic).first() } override var renderConfiguration: FirDiagnosticCodeMetaRenderConfiguration = renderConfiguration private set override val start: Int - get() = textRangeFromClassicDiagnostic?.startOffset ?: diagnostic.element.startOffset + get() = textRangeFromClassicDiagnostic.startOffset override val end: Int - get() = textRangeFromClassicDiagnostic?.endOffset ?: diagnostic.element.endOffset + get() = textRangeFromClassicDiagnostic.endOffset override val tag: String get() = renderConfiguration.getTag(this) From de592f4f676e2c33eba55d97ad2803ffec3e1b45 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Fri, 15 Jan 2021 23:21:24 -0800 Subject: [PATCH 054/122] FIR checker: introduce FunctionChecker alias and use it to add support diagnostic FUNCTION_DECLARATION_WITH_NO_NAME --- .../diagnostics/conflictingOverloads.kt | 4 +-- .../kotlin/fir/checkers/generator/Main.kt | 1 + .../ComposedDeclarationCheckers.kt | 4 +++ .../declaration/DeclarationCheckers.kt | 4 ++- .../FirDeclarationCheckerAliases.kt | 2 ++ .../declaration/FirFunctionNameChecker.kt | 29 +++++++++++++++++++ .../DeclarationCheckersDiagnosticComponent.kt | 4 +-- .../diagnostics/FirDefaultErrorMessages.kt | 3 ++ .../fir/analysis/diagnostics/FirErrors.kt | 2 ++ .../fir/checkers/CommonDeclarationCheckers.kt | 4 +++ .../FunctionWithMissingNames.fir.kt | 16 +++++----- .../duplicateJvmSignature/missingNames.fir.kt | 6 ++-- .../tests/recovery/namelessInJava.fir.kt | 18 ------------ .../tests/recovery/namelessInJava.kt | 1 + .../tests/recovery/namelessMembers.fir.kt | 17 ----------- .../tests/recovery/namelessMembers.kt | 1 + .../namelessToplevelDeclarations.fir.kt | 2 +- 17 files changed, 66 insertions(+), 52 deletions(-) create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionNameChecker.kt delete mode 100644 compiler/testData/diagnostics/tests/recovery/namelessInJava.fir.kt delete mode 100644 compiler/testData/diagnostics/tests/recovery/namelessMembers.fir.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt index 48bf6e25af2..d123aa55763 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt @@ -63,6 +63,6 @@ fun mest() class mest -fun() {} +fun() {} -private fun() {} +private fun() {} diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt index 1eadb1b7186..41ec1d4a3a1 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/Main.kt @@ -27,6 +27,7 @@ fun main(args: Array) { generateCheckersComponents(generationPath, declarationPackage, "FirDeclarationChecker") { alias("BasicDeclarationChecker") alias("MemberDeclarationChecker") + alias>("FunctionChecker") alias("PropertyChecker") alias("RegularClassChecker") alias("ConstructorChecker") diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt index 8080f5c677b..0298aabbea9 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/ComposedDeclarationCheckers.kt @@ -19,6 +19,8 @@ internal class ComposedDeclarationCheckers : DeclarationCheckers() { get() = _basicDeclarationCheckers override val memberDeclarationCheckers: Set get() = _memberDeclarationCheckers + override val functionCheckers: Set + get() = _functionCheckers override val propertyCheckers: Set get() = _propertyCheckers override val regularClassCheckers: Set @@ -34,6 +36,7 @@ internal class ComposedDeclarationCheckers : DeclarationCheckers() { private val _basicDeclarationCheckers: MutableSet = mutableSetOf() private val _memberDeclarationCheckers: MutableSet = mutableSetOf() + private val _functionCheckers: MutableSet = mutableSetOf() private val _propertyCheckers: MutableSet = mutableSetOf() private val _regularClassCheckers: MutableSet = mutableSetOf() private val _constructorCheckers: MutableSet = mutableSetOf() @@ -45,6 +48,7 @@ internal class ComposedDeclarationCheckers : DeclarationCheckers() { internal fun register(checkers: DeclarationCheckers) { _basicDeclarationCheckers += checkers.allBasicDeclarationCheckers _memberDeclarationCheckers += checkers.allMemberDeclarationCheckers + _functionCheckers += checkers.allFunctionCheckers _propertyCheckers += checkers.allPropertyCheckers _regularClassCheckers += checkers.allRegularClassCheckers _constructorCheckers += checkers.allConstructorCheckers diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt index 56a62ef5153..f96ece8dbe5 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/DeclarationCheckers.kt @@ -21,6 +21,7 @@ abstract class DeclarationCheckers { open val basicDeclarationCheckers: Set = emptySet() open val memberDeclarationCheckers: Set = emptySet() + open val functionCheckers: Set = emptySet() open val propertyCheckers: Set = emptySet() open val regularClassCheckers: Set = emptySet() open val constructorCheckers: Set = emptySet() @@ -31,8 +32,9 @@ abstract class DeclarationCheckers { @CheckersComponentInternal internal val allBasicDeclarationCheckers: Set get() = basicDeclarationCheckers @CheckersComponentInternal internal val allMemberDeclarationCheckers: Set get() = memberDeclarationCheckers + allBasicDeclarationCheckers + @CheckersComponentInternal internal val allFunctionCheckers: Set get() = functionCheckers + allBasicDeclarationCheckers @CheckersComponentInternal internal val allPropertyCheckers: Set get() = propertyCheckers + allMemberDeclarationCheckers @CheckersComponentInternal internal val allRegularClassCheckers: Set get() = regularClassCheckers + allMemberDeclarationCheckers - @CheckersComponentInternal internal val allConstructorCheckers: Set get() = constructorCheckers + allMemberDeclarationCheckers + @CheckersComponentInternal internal val allConstructorCheckers: Set get() = constructorCheckers + allFunctionCheckers @CheckersComponentInternal internal val allFileCheckers: Set get() = fileCheckers + allBasicDeclarationCheckers } diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt index 4b680e2445c..ef4ca66ed49 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDeclarationCheckerAliases.kt @@ -13,12 +13,14 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.declarations.FirRegularClass typealias FirBasicDeclarationChecker = FirDeclarationChecker typealias FirMemberDeclarationChecker = FirDeclarationChecker +typealias FirFunctionChecker = FirDeclarationChecker> typealias FirPropertyChecker = FirDeclarationChecker typealias FirRegularClassChecker = FirDeclarationChecker typealias FirConstructorChecker = FirDeclarationChecker diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionNameChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionNameChecker.kt new file mode 100644 index 00000000000..63b7a9d3508 --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirFunctionNameChecker.kt @@ -0,0 +1,29 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.fir.FirFakeSourceElementKind +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.extended.report +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.declarations.FirFunction +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.name.SpecialNames + +object FirFunctionNameChecker : FirFunctionChecker() { + override fun check(declaration: FirFunction<*>, context: CheckerContext, reporter: DiagnosticReporter) { + val source = declaration.source + if (source == null || source.kind is FirFakeSourceElementKind) return + val containingDeclaration = context.containingDeclarations.lastOrNull() + val isNonLocal = containingDeclaration is FirFile || containingDeclaration is FirClass<*> + if (declaration is FirSimpleFunction && declaration.name == SpecialNames.NO_NAME_PROVIDED && isNonLocal) { + reporter.report(source, FirErrors.FUNCTION_DECLARATION_WITH_NO_NAME) + } + } +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt index 513153297fe..a89ec402aa4 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt @@ -30,7 +30,7 @@ class DeclarationCheckersDiagnosticComponent( } override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: CheckerContext) { - checkers.memberDeclarationCheckers.check(simpleFunction, data, reporter) + (checkers.memberDeclarationCheckers + checkers.functionCheckers).check(simpleFunction, data, reporter) } override fun visitTypeAlias(typeAlias: FirTypeAlias, data: CheckerContext) { @@ -38,7 +38,7 @@ class DeclarationCheckersDiagnosticComponent( } override fun visitConstructor(constructor: FirConstructor, data: CheckerContext) { - checkers.constructorCheckers.check(constructor, data, reporter) + (checkers.memberDeclarationCheckers + checkers.constructorCheckers).check(constructor, data, reporter) } override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: CheckerContext) { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index 4b3e444d388..a038eb8dd01 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -54,6 +54,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPOSED_SUPER_CLA import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPOSED_SUPER_INTERFACE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPOSED_TYPEALIAS_EXPANDED_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.EXPOSED_TYPE_PARAMETER_BOUND +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.FUNCTION_DECLARATION_WITH_NO_NAME import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.HIDDEN import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ILLEGAL_CONST_EXPRESSION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.ILLEGAL_UNDERSCORE @@ -353,6 +354,8 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { map.put(NON_ABSTRACT_FUNCTION_WITH_NO_BODY, "Function ''{0}'' without a body must be abstract", DECLARATION_NAME) map.put(PRIVATE_FUNCTION_WITH_NO_BODY, "Function ''{0}'' without body cannot be private", DECLARATION_NAME) + map.put(FUNCTION_DECLARATION_WITH_NO_NAME, "Function declaration must have a name") + // Properties & accessors map.put( ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS, diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index 9b15b3505e6..c8c56ec913f 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -153,6 +153,8 @@ object FirErrors { val NON_ABSTRACT_FUNCTION_WITH_NO_BODY by error1(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) val PRIVATE_FUNCTION_WITH_NO_BODY by error1(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) + val FUNCTION_DECLARATION_WITH_NO_NAME by error0(SourceElementPositioningStrategies.DECLARATION_SIGNATURE) + // Properties & accessors val ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS by error2(SourceElementPositioningStrategies.MODALITY_MODIFIER) val PRIVATE_PROPERTY_IN_INTERFACE by error0(SourceElementPositioningStrategies.VISIBILITY_MODIFIER) diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index fd289afbdb5..673eb05c602 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -28,6 +28,10 @@ object CommonDeclarationCheckers : DeclarationCheckers() { FirSealedSupertypeChecker, ) + override val functionCheckers: Set = setOf( + FirFunctionNameChecker, + ) + override val propertyCheckers: Set = setOf( FirInapplicableLateinitChecker, FirDestructuringDeclarationInitializerChecker, diff --git a/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.fir.kt index 35f770556d9..2c30dfe864e 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/FunctionWithMissingNames.fir.kt @@ -3,18 +3,18 @@ annotation class a interface A interface B -fun () {} -fun A.() {} +fun () {} +fun A.() {} -@a fun () {} -fun @a A.() {} +@a fun () {} +fun @a A.() {} class Outer { - fun () {} - fun B.() {} + fun () {} + fun B.() {} - @a fun () {} - fun @a A.() {} + @a fun () {} + fun @a A.() {} } fun outerFun() { diff --git a/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.fir.kt b/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.fir.kt index 9bf897065b4..9f5dda53c4d 100644 --- a/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.fir.kt +++ b/compiler/testData/diagnostics/tests/duplicateJvmSignature/missingNames.fir.kt @@ -1,9 +1,9 @@ // !DIAGNOSTICS: -DUPLICATE_CLASS_NAMES -fun () { +fun () { } -fun Outer.() { +fun Outer.() { } @@ -30,7 +30,7 @@ annotation class { } class Outer { - fun () { + fun () { } diff --git a/compiler/testData/diagnostics/tests/recovery/namelessInJava.fir.kt b/compiler/testData/diagnostics/tests/recovery/namelessInJava.fir.kt deleted file mode 100644 index 7017eaced2e..00000000000 --- a/compiler/testData/diagnostics/tests/recovery/namelessInJava.fir.kt +++ /dev/null @@ -1,18 +0,0 @@ -// SKIP_JAVAC -// FILE: p/Nameless.java - -package p; - -public class Nameless { - void () {} - int ; -} - -// FILE: k.kt - -import p.* - -class K : Nameless() { - fun () {} - val : Int = 1 -} diff --git a/compiler/testData/diagnostics/tests/recovery/namelessInJava.kt b/compiler/testData/diagnostics/tests/recovery/namelessInJava.kt index 8028e9059db..33c382dbf9d 100644 --- a/compiler/testData/diagnostics/tests/recovery/namelessInJava.kt +++ b/compiler/testData/diagnostics/tests/recovery/namelessInJava.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // SKIP_JAVAC // FILE: p/Nameless.java diff --git a/compiler/testData/diagnostics/tests/recovery/namelessMembers.fir.kt b/compiler/testData/diagnostics/tests/recovery/namelessMembers.fir.kt deleted file mode 100644 index 6bd0aa7f1fe..00000000000 --- a/compiler/testData/diagnostics/tests/recovery/namelessMembers.fir.kt +++ /dev/null @@ -1,17 +0,0 @@ -// !DIAGNOSTICS: -REDECLARATION -DUPLICATE_CLASS_NAMES - -class C { - fun () { - - } - - val : Int = 1 - - class {} - - enum class {} -} - -class C1<in> {} - -class C2(val) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/recovery/namelessMembers.kt b/compiler/testData/diagnostics/tests/recovery/namelessMembers.kt index a11d5649f11..ca24786d62f 100644 --- a/compiler/testData/diagnostics/tests/recovery/namelessMembers.kt +++ b/compiler/testData/diagnostics/tests/recovery/namelessMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -REDECLARATION -DUPLICATE_CLASS_NAMES class C { diff --git a/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.fir.kt b/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.fir.kt index 4c13a3703b1..54973f749d1 100644 --- a/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.fir.kt +++ b/compiler/testData/diagnostics/tests/recovery/namelessToplevelDeclarations.fir.kt @@ -2,7 +2,7 @@ package -fun () { +fun () { } From be29b6d64d42d753a25855eaec9b301ed1b1fff8 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Fri, 15 Jan 2021 23:38:54 -0800 Subject: [PATCH 055/122] FIR checker: use aliased checker when possible (part 2) --- .../declaration/FirAnnotationClassDeclarationChecker.kt | 5 ++--- .../declaration/FirConstructorInInterfaceChecker.kt | 9 ++++----- .../FirSupertypeInitializedInInterfaceChecker.kt | 9 ++++----- .../kotlin/fir/checkers/CommonDeclarationCheckers.kt | 4 ++-- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationClassDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationClassDeclarationChecker.kt index e4c02cbe2ce..d040ea5648d 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationClassDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationClassDeclarationChecker.kt @@ -23,9 +23,8 @@ import org.jetbrains.kotlin.KtNodeTypes.VALUE_PARAMETER import org.jetbrains.kotlin.fir.analysis.diagnostics.* import org.jetbrains.kotlin.name.ClassId -object FirAnnotationClassDeclarationChecker : FirBasicDeclarationChecker() { - override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration !is FirRegularClass) return +object FirAnnotationClassDeclarationChecker : FirRegularClassChecker() { + override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { if (declaration.classKind != ANNOTATION_CLASS) return if (declaration.isLocal) reporter.report(declaration.source, FirErrors.LOCAL_ANNOTATION_CLASS_ERROR) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt index 87a397feedf..65530d9fea0 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt @@ -11,12 +11,11 @@ import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.hasPrimaryConstructor -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirRegularClass -object FirConstructorInInterfaceChecker : FirBasicDeclarationChecker() { - override fun check(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration !is FirClass<*> || declaration.classKind != ClassKind.INTERFACE) { +object FirConstructorInInterfaceChecker : FirRegularClassChecker() { + override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration.classKind != ClassKind.INTERFACE) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt index d81a167bab4..7478d2d5665 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt @@ -11,12 +11,11 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.fir.declarations.FirClass -import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration +import org.jetbrains.kotlin.fir.declarations.FirRegularClass -object FirSupertypeInitializedInInterfaceChecker : FirMemberDeclarationChecker() { - override fun check(declaration: FirMemberDeclaration, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration !is FirClass<*> || declaration.classKind != ClassKind.INTERFACE) { +object FirSupertypeInitializedInInterfaceChecker : FirRegularClassChecker() { + override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { + if (declaration.classKind != ClassKind.INTERFACE) { return } diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index 673eb05c602..61537e04d1f 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -15,10 +15,8 @@ import org.jetbrains.kotlin.fir.analysis.checkers.declaration.* object CommonDeclarationCheckers : DeclarationCheckers() { override val basicDeclarationCheckers: Set = setOf( FirAnnotationArgumentChecker, - FirAnnotationClassDeclarationChecker, FirModifierChecker, FirConflictsChecker, - FirConstructorInInterfaceChecker, FirConflictingProjectionChecker, ) @@ -38,7 +36,9 @@ object CommonDeclarationCheckers : DeclarationCheckers() { ) override val regularClassCheckers: Set = setOf( + FirAnnotationClassDeclarationChecker, FirCommonConstructorDelegationIssuesChecker, + FirConstructorInInterfaceChecker, FirDelegationSuperCallInEnumConstructorChecker, FirDelegationInInterfaceChecker, FirEnumClassSimpleChecker, From 5f0eb8a4012d9ce15e834c5a8100da08080f6862 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Fri, 15 Jan 2021 23:46:48 -0800 Subject: [PATCH 056/122] FIR checker: minor cleanups --- .../checkers/declaration/FirConstructorInInterfaceChecker.kt | 4 ++-- .../checkers/declaration/FirDelegationInInterfaceChecker.kt | 4 ++-- .../FirDelegationSuperCallInEnumConstructorChecker.kt | 4 ++-- .../checkers/declaration/FirEnumClassSimpleChecker.kt | 4 ++-- .../checkers/declaration/FirInterfaceWithSuperclassChecker.kt | 4 ++-- .../FirMethodOfAnyImplementedInInterfaceChecker.kt | 3 +-- .../declaration/FirSupertypeInitializedInInterfaceChecker.kt | 4 ++-- .../FirSupertypeInitializedWithoutPrimaryConstructor.kt | 4 ++-- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt index 65530d9fea0..0014a41ff4a 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirConstructorInInterfaceChecker.kt @@ -5,17 +5,17 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.analysis.diagnostics.hasPrimaryConstructor import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isInterface object FirConstructorInInterfaceChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.INTERFACE) { + if (!declaration.isInterface) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt index 8584567b06a..a30619b0675 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationInInterfaceChecker.kt @@ -6,16 +6,16 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration import org.jetbrains.kotlin.KtNodeTypes -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isInterface object FirDelegationInInterfaceChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.INTERFACE) { + if (!declaration.isInterface) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationSuperCallInEnumConstructorChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationSuperCallInEnumConstructorChecker.kt index a8da964e437..c4bab19cbda 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationSuperCallInEnumConstructorChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDelegationSuperCallInEnumConstructorChecker.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirFakeSourceElementKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext @@ -13,10 +12,11 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isEnumClass object FirDelegationSuperCallInEnumConstructorChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.ENUM_CLASS) { + if (!declaration.isEnumClass) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirEnumClassSimpleChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirEnumClassSimpleChecker.kt index cbac351329f..5670b872be6 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirEnumClassSimpleChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirEnumClassSimpleChecker.kt @@ -5,17 +5,17 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.findNonInterfaceSupertype import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isEnumClass object FirEnumClassSimpleChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.ENUM_CLASS) { + if (!declaration.isEnumClass) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInterfaceWithSuperclassChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInterfaceWithSuperclassChecker.kt index ebd188f3f44..24e69261a20 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInterfaceWithSuperclassChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirInterfaceWithSuperclassChecker.kt @@ -5,17 +5,17 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.findNonInterfaceSupertype import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isInterface object FirInterfaceWithSuperclassChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.INTERFACE) { + if (!declaration.isInterface) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMethodOfAnyImplementedInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMethodOfAnyImplementedInInterfaceChecker.kt index f52c3be8243..fcc41268fb6 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMethodOfAnyImplementedInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirMethodOfAnyImplementedInInterfaceChecker.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationInspector import org.jetbrains.kotlin.fir.analysis.checkers.FirDeclarationPresenter @@ -57,7 +56,7 @@ object FirMethodOfAnyImplementedInInterfaceChecker : FirRegularClassChecker(), F } override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.INTERFACE) { + if (!declaration.isInterface) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt index 7478d2d5665..3e4c655da9e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedInInterfaceChecker.kt @@ -6,16 +6,16 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration import org.jetbrains.kotlin.KtNodeTypes -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isInterface object FirSupertypeInitializedInInterfaceChecker : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind != ClassKind.INTERFACE) { + if (!declaration.isInterface) { return } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedWithoutPrimaryConstructor.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedWithoutPrimaryConstructor.kt index 9e31f99a1d6..fa9782af05e 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedWithoutPrimaryConstructor.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSupertypeInitializedWithoutPrimaryConstructor.kt @@ -6,17 +6,17 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration import org.jetbrains.kotlin.KtNodeTypes -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.isInterface object FirSupertypeInitializedWithoutPrimaryConstructor : FirRegularClassChecker() { override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) { - if (declaration.classKind == ClassKind.INTERFACE) { + if (declaration.isInterface) { return } From 83b9c29495b3821d61ff3d4b5d645e599124f171 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Fri, 15 Jan 2021 23:50:14 -0800 Subject: [PATCH 057/122] FIR checker: relocate sealed class ctor call checker --- .../FirSealedClassConstructorCallChecker.kt | 5 ++--- .../kotlin/fir/checkers/CommonExpressionCheckers.kt | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) rename compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/{declaration => expression}/FirSealedClassConstructorCallChecker.kt (89%) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSealedClassConstructorCallChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSealedClassConstructorCallChecker.kt similarity index 89% rename from compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSealedClassConstructorCallChecker.kt rename to compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSealedClassConstructorCallChecker.kt index 1a014103fec..f05dcfc06b5 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirSealedClassConstructorCallChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirSealedClassConstructorCallChecker.kt @@ -1,14 +1,13 @@ /* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.fir.analysis.checkers.declaration +package org.jetbrains.kotlin.fir.analysis.checkers.expression import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirQualifiedAccessChecker import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.declarations.FirConstructor diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt index cec00d6bee4..bde2a98848a 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonExpressionCheckers.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.checkers -import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirSealedClassConstructorCallChecker import org.jetbrains.kotlin.fir.analysis.checkers.expression.* object CommonExpressionCheckers : ExpressionCheckers() { From fa0b933bc818caacc89865e002557b90833ad913 Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Sun, 17 Jan 2021 23:51:08 -0800 Subject: [PATCH 058/122] FIR checker: add diagnostics for missing/ambiguous component calls --- .../FirDestructuringDeclarationChecker.kt | 122 ++++++++++++++++++ ...tructuringDeclarationInitializerChecker.kt | 35 ----- .../ErrorNodeDiagnosticCollectorComponent.kt | 8 ++ .../diagnostics/FirDefaultErrorMessages.kt | 16 +++ .../diagnostics/FirDiagnosticRenderers.kt | 12 ++ .../fir/analysis/diagnostics/FirErrors.kt | 7 + .../fir/checkers/CommonDeclarationCheckers.kt | 2 +- .../MultiDeclarationErrors.fir.kt | 2 +- .../ForLoopComponentFunctionAmbiguity.fir.kt | 2 +- .../ForLoopComponentFunctionMissing.fir.kt | 2 +- .../ForLoopMissingLoopParameter.fir.kt | 4 +- ...turingDeclarationAssignedUnresolved.fir.kt | 4 +- ...turingDeclarationMissingInitializer.fir.kt | 4 +- .../functionLiterals/DeprecatedSyntax.fir.kt | 6 +- .../complexInference.fir.kt | 2 +- .../noExpectedType.fir.kt | 8 +- .../valWithNoNameInBlock.fir.kt | 2 +- 17 files changed, 184 insertions(+), 54 deletions(-) create mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt delete mode 100644 compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationInitializerChecker.kt diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt new file mode 100644 index 00000000000..a16123ea4cd --- /dev/null +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationChecker.kt @@ -0,0 +1,122 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.analysis.checkers.declaration + +import org.jetbrains.kotlin.KtNodeTypes +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext +import org.jetbrains.kotlin.fir.analysis.checkers.extended.report +import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirValueParameter +import org.jetbrains.kotlin.fir.declarations.FirVariable +import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic +import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind +import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.references.FirErrorNamedReference +import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeAmbiguityError +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError +import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol + +object FirDestructuringDeclarationChecker : FirPropertyChecker() { + override fun check(declaration: FirProperty, context: CheckerContext, reporter: DiagnosticReporter) { + val source = declaration.source ?: return + // val (...) = `destructuring_declaration` + if (source.elementType == KtNodeTypes.DESTRUCTURING_DECLARATION) { + assert(declaration.name.isSpecial && declaration.name.asString() == "") { + "Unexpected name: ${declaration.name.asString()} for destructuring declaration" + } + checkInitializer(source, declaration.initializer, reporter) + return + } + + // val (`destructuring_declaration_entry`, ...) = ... + if (source.elementType != KtNodeTypes.DESTRUCTURING_DECLARATION_ENTRY) return + + val componentCall = declaration.initializer as? FirComponentCall ?: return + val reference = componentCall.calleeReference as? FirErrorNamedReference ?: return + + val originalExpression = componentCall.explicitReceiverOfQualifiedAccess ?: return + val originalDestructuringDeclaration = originalExpression.resolvedVariable ?: return + val originalDestructuringDeclarationOrInitializer = + when (originalDestructuringDeclaration) { + is FirProperty -> { + if (originalDestructuringDeclaration.initializer?.source?.elementType == KtNodeTypes.FOR) { + // for ((entry, ...) = `destructuring_declaration`) { ... } + // It will be wrapped as `next()` call whose explicit receiver is `iterator()` on the actual source. + val iterator = originalDestructuringDeclaration.initializer?.explicitReceiverOfQualifiedAccess + (iterator?.resolvedVariable as? FirProperty)?.initializer?.explicitReceiverOfQualifiedAccess + } else { + // val (entry, ...) = `destructuring_declaration` + originalDestructuringDeclaration.initializer + } + } + is FirValueParameter -> { + // ... = { `(entry, ...)` -> ... } // value parameter itself is a destructuring declaration + originalDestructuringDeclaration + } + else -> null + } ?: return + val originalDestructuringDeclarationOrInitializerSource = originalDestructuringDeclarationOrInitializer.source ?: return + val originalDestructuringDeclarationType = + when (originalDestructuringDeclarationOrInitializer) { + is FirVariable<*> -> originalDestructuringDeclarationOrInitializer.returnTypeRef + is FirExpression -> originalDestructuringDeclarationOrInitializer.typeRef + else -> null + } ?: return + + when (val diagnostic = reference.diagnostic) { + is ConeUnresolvedNameError -> { + reporter.report( + FirErrors.COMPONENT_FUNCTION_MISSING.on( + originalDestructuringDeclarationOrInitializerSource, + diagnostic.name, + originalDestructuringDeclarationType + ) + ) + } + is ConeAmbiguityError -> { + reporter.report( + FirErrors.COMPONENT_FUNCTION_AMBIGUITY.on( + originalDestructuringDeclarationOrInitializerSource, + diagnostic.name, + diagnostic.candidates + ) + ) + } + // TODO: COMPONENT_FUNCTION_ON_NULLABLE + // TODO: COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH + } + } + + private fun checkInitializer(source: FirSourceElement, initializer: FirExpression?, reporter: DiagnosticReporter) { + val needToReport = + when (initializer) { + null -> true + is FirErrorExpression -> (initializer.diagnostic as? ConeSimpleDiagnostic)?.kind == DiagnosticKind.Syntax + else -> false + } + if (needToReport) { + reporter.report(source, FirErrors.INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION) + } + } + + private val FirExpression.explicitReceiverOfQualifiedAccess: FirQualifiedAccessExpression? + get() = (this as? FirQualifiedAccess)?.explicitReceiver?.unwrapped as? FirQualifiedAccessExpression + + private val FirExpression.unwrapped: FirExpression + get() = + when (this) { + is FirExpressionWithSmartcast -> this.originalExpression + is FirWrappedExpression -> this.expression + else -> this + } + + private val FirQualifiedAccessExpression.resolvedVariable: FirVariable<*>? + get() = ((calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirVariableSymbol)?.fir as? FirVariable<*> +} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationInitializerChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationInitializerChecker.kt deleted file mode 100644 index a6d6e772892..00000000000 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirDestructuringDeclarationInitializerChecker.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir.analysis.checkers.declaration - -import org.jetbrains.kotlin.KtNodeTypes -import org.jetbrains.kotlin.fir.FirFakeSourceElementKind -import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext -import org.jetbrains.kotlin.fir.analysis.checkers.extended.report -import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic -import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind -import org.jetbrains.kotlin.fir.expressions.FirErrorExpression - -object FirDestructuringDeclarationInitializerChecker : FirPropertyChecker() { - override fun check(declaration: FirProperty, context: CheckerContext, reporter: DiagnosticReporter) { - if (!declaration.name.isSpecial || declaration.name.asString() != "") return - val source = declaration.source - if (source == null || source.kind is FirFakeSourceElementKind) return - if (source.elementType != KtNodeTypes.DESTRUCTURING_DECLARATION) return - val needToReport = - when (val initializer = declaration.initializer) { - null -> true - is FirErrorExpression -> (initializer.diagnostic as? ConeSimpleDiagnostic)?.kind == DiagnosticKind.Syntax - else -> false - } - if (needToReport) { - reporter.report(source, FirErrors.INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION) - } - } -} diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt index 4a154518f0c..33a800bf918 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/ErrorNodeDiagnosticCollectorComponent.kt @@ -59,6 +59,14 @@ class ErrorNodeDiagnosticCollectorComponent(collector: AbstractDiagnosticCollect } private fun reportFirDiagnostic(diagnostic: ConeDiagnostic, source: FirSourceElement, reporter: DiagnosticReporter) { + // Will be handled by [FirDestructuringDeclarationChecker] + if (source.elementType == KtNodeTypes.DESTRUCTURING_DECLARATION_ENTRY) { + // TODO: if all diagnostics are supported, we don't need the following check, and will bail out based on element type. + if (diagnostic is ConeUnresolvedNameError || diagnostic is ConeAmbiguityError) { + return + } + } + val coneDiagnostic = when (diagnostic) { is ConeUnresolvedReferenceError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.name?.asString() ?: "") is ConeUnresolvedSymbolError -> FirErrors.UNRESOLVED_REFERENCE.on(source, diagnostic.classId.asString()) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index a038eb8dd01..3b40846d9ae 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -7,9 +7,11 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.AMBIGUOUS_CALLS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.DECLARATION_NAME import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.NULLABLE_STRING import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.PROPERTY_NAME +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.RENDER_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.TO_STRING @@ -32,6 +34,8 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.BREAK_OR_CONTINUE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CAN_BE_VAL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CLASS_IN_SUPERTYPE_FOR_ENUM +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.COMPONENT_FUNCTION_AMBIGUITY +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.COMPONENT_FUNCTION_MISSING import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_OVERLOADS import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONFLICTING_PROJECTION import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.CONSTRUCTOR_IN_INTERFACE @@ -382,6 +386,18 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { // Destructuring declaration map.put(INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION, "Initializer required for destructuring declaration") + map.put( + COMPONENT_FUNCTION_MISSING, + "Destructuring declaration initializer of type {1} must have a ''{0}()'' function", + TO_STRING, + RENDER_TYPE + ) + map.put( + COMPONENT_FUNCTION_AMBIGUITY, + "Function ''{0}''() is ambiguous for this expression: {1}", + TO_STRING, + AMBIGUOUS_CALLS + ) // Control flow diagnostics map.put(UNINITIALIZED_VARIABLE, "{0} must be initialized before access", PROPERTY_NAME) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt index 906466b40e8..a06c569f83b 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDiagnosticRenderers.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.types.FirTypeRef object FirDiagnosticRenderers { val NULLABLE_STRING = Renderer { it ?: "null" } @@ -56,4 +57,15 @@ object FirDiagnosticRenderers { } name.asString() } + + val RENDER_TYPE = Renderer { typeRef: FirTypeRef -> + // TODO: need a way to tune granuality, e.g., without parameter names in functional types. + typeRef.render() + } + + val AMBIGUOUS_CALLS = Renderer { candidates: Collection> -> + candidates.joinToString(separator = "\n", prefix = "\n") { symbol -> + SYMBOL.render(symbol) + } + } } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index c8c56ec913f..6f9c6108c03 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -13,12 +13,15 @@ import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirStatement import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.lexer.KtModifierKeywordToken import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.types.KotlinType object FirErrors { // Miscellaneous @@ -174,6 +177,10 @@ object FirErrors { // Destructuring declaration val INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION by error0() + val COMPONENT_FUNCTION_MISSING by error2() + val COMPONENT_FUNCTION_AMBIGUITY by error2>>() + // TODO: val COMPONENT_FUNCTION_ON_NULLABLE by ... + // TODO: val COMPONENT_FUNCTION_RETURN_TYPE_MISMATCH by ... // Control flow diagnostics val UNINITIALIZED_VARIABLE by error1() diff --git a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt index 61537e04d1f..099f3ffbf0c 100644 --- a/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt +++ b/compiler/fir/entrypoint/src/org/jetbrains/kotlin/fir/checkers/CommonDeclarationCheckers.kt @@ -32,7 +32,7 @@ object CommonDeclarationCheckers : DeclarationCheckers() { override val propertyCheckers: Set = setOf( FirInapplicableLateinitChecker, - FirDestructuringDeclarationInitializerChecker, + FirDestructuringDeclarationChecker, ) override val regularClassCheckers: Set = setOf( diff --git a/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt index e311960423f..93b54cc4397 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/MultiDeclarationErrors.fir.kt @@ -11,7 +11,7 @@ class MyClass2 {} fun MyClass2.component1() = 1.3 fun test(mc1: MyClass, mc2: MyClass2) { - val (a, b) = mc1 + val (a, b) = mc1 val (c) = mc2 //a,b,c are error types diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt index e845fef30e1..fddfd72aaca 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionAmbiguity.fir.kt @@ -9,7 +9,7 @@ class C { } fun test() { - for ((x, y) in C()) { + for ((x, y) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.fir.kt index 068be345d66..95924e4c839 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopComponentFunctionMissing.fir.kt @@ -7,7 +7,7 @@ class C { } fun test() { - for ((x, y) in C()) { + for ((x, y) in C()) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt index 0bc48dd8f5b..27d22aa856c 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/ForLoopMissingLoopParameter.fir.kt @@ -1,13 +1,13 @@ // !WITH_NEW_INFERENCE fun useDeclaredVariables() { - for ((a, b)) { + for ((a, b)) { a b } } fun checkersShouldRun() { - for ((@A a, _)) { + for ((@A a, _)) { } } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt index da599329974..2a5ec373b5a 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationAssignedUnresolved.fir.kt @@ -1,11 +1,11 @@ fun useDeclaredVariables() { - val (a, b) = unresolved + val (a, b) = unresolved a b } fun checkersShouldRun() { - val (@A a, _) = unresolved + val (@A a, _) = unresolved } annotation class A diff --git a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt index 307dc46e555..3b11c44915f 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/destructuringDeclarations/destructuringDeclarationMissingInitializer.fir.kt @@ -1,11 +1,11 @@ fun useDeclaredVariables() { - val (a, b) + val (a, b) a b } fun checkersShouldRun() { - val (@A a, _) + val (@A a, _) } annotation class A diff --git a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt index dac5ccb52fb..8111b18415b 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/DeprecatedSyntax.fir.kt @@ -6,12 +6,12 @@ val receiverAndReturnType = { Int.(): Int -> 5 } val receiverAndReturnTypeWithParameter = { Int.(a: Int): Int -> 5 } val returnType = { (): Int -> 5 } -val returnTypeWithParameter = { (b: Int): Int -> 5 } +val returnTypeWithParameter = { (b: Int): Int -> 5 } val receiverWithFunctionType = { ((Int) -> Int).() -> } -val parenthesizedParameters = { (a: Int) -> } -val parenthesizedParameters2 = { (b) -> } +val parenthesizedParameters = { (a: Int) -> } +val parenthesizedParameters2 = { (b) -> } val none = { -> } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt index 5a90d6d1d9e..b12e1a7dcd1 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt @@ -9,7 +9,7 @@ fun foo(y: Y, x: (X, Y) -> Unit) {} fun bar(aInstance: A, bInstance: B) { foo("") { - (a, b): A, c -> + (a, b): A, c -> a checkType { _() } b checkType { _() } c checkType { _() } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt index d7af54b0415..270d1deee1d 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt @@ -4,28 +4,28 @@ data class A(val x: Int, val y: String) fun bar() { - val x = { (a, b): A -> + val x = { (a, b): A -> a checkType { _() } b checkType { _() } } x checkType { _<(A) -> Unit>() } - val y = { (a: Int, b): A -> + val y = { (a: Int, b): A -> a checkType { _() } b checkType { _() } } y checkType { _<(A) -> Unit>() } - val y2 = { (a: Number, b): A -> + val y2 = { (a: Number, b): A -> a checkType { _() } b checkType { _() } } y2 checkType { _<(A) -> Unit>() } - val z = { (a: Int, b: String) -> + val z = { (a: Int, b: String) -> a checkType { _() } b checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt index 9818e905979..26b87f01991 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/valWithNoNameInBlock.fir.kt @@ -46,5 +46,5 @@ fun foo() { propertyWithType: Int val - (a, b) = 1 + (a, b) = 1 } From 2e660ef62aa988fbb23ef5e9dc56528ee84ed01b Mon Sep 17 00:00:00 2001 From: Jinseong Jeon Date: Mon, 18 Jan 2021 00:18:38 -0800 Subject: [PATCH 059/122] Raw FIR: use lambda parameter type if available --- .../lightTree/converter/ExpressionsConverter.kt | 3 +-- .../jetbrains/kotlin/fir/builder/RawFirBuilder.kt | 4 ++-- .../destructuringInLambdas/complexInference.fir.kt | 6 +++--- .../inferredFunctionalType.fir.kt | 2 +- .../destructuringInLambdas/noExpectedType.fir.kt | 14 +++++++------- .../destructuringInLambdas/simple.fir.kt | 6 +++--- .../destructuringInLambdas/underscore.fir.kt | 4 ++-- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt index 670c637fe09..d95bd4e607c 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/ExpressionsConverter.kt @@ -38,7 +38,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef -import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.stubs.elements.KtConstantExpressionElementType @@ -155,7 +154,7 @@ class ExpressionsConverter( val multiParameter = buildValueParameter { session = baseSession origin = FirDeclarationOrigin.Source - returnTypeRef = buildImplicitTypeRef() + returnTypeRef = valueParameter.firValueParameter.returnTypeRef this.name = name symbol = FirVariableSymbol(name) defaultValue = null diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 6b70d454b89..7c23143efdb 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1106,7 +1106,7 @@ class RawFirBuilder( source = valueParameter.toFirSourceElement() session = baseSession origin = FirDeclarationOrigin.Source - returnTypeRef = buildImplicitTypeRef { + returnTypeRef = valueParameter.typeReference?.convertSafe() ?: buildImplicitTypeRef { source = multiDeclaration.toFirSourceElement(FirFakeSourceElementKind.ImplicitTypeRef) } this.name = name @@ -1124,7 +1124,7 @@ class RawFirBuilder( ) { toFirOrImplicitType() } multiParameter } else { - val typeRef = buildImplicitTypeRef { + val typeRef = valueParameter.typeReference?.convertSafe() ?: buildImplicitTypeRef { source = implicitTypeRefSource } valueParameter.toFirValueParameter(typeRef) diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt index b12e1a7dcd1..e9d09e341af 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/complexInference.fir.kt @@ -9,9 +9,9 @@ fun foo(y: Y, x: (X, Y) -> Unit) {} fun bar(aInstance: A, bInstance: B) { foo("") { - (a, b): A, c -> - a checkType { _() } - b checkType { _() } + (a, b): A, c -> + a checkType { _() } + b checkType { _() } c checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/inferredFunctionalType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/inferredFunctionalType.fir.kt index 43835ece222..0fcfc1b4a2d 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/inferredFunctionalType.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/inferredFunctionalType.fir.kt @@ -27,7 +27,7 @@ fun bar(aList: List) { b checkType { _() } } - aList.foo { (a, b): B -> + aList.foo { (a, b): B -> b checkType { _() } a checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt index 270d1deee1d..4fec1861ca3 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/noExpectedType.fir.kt @@ -4,23 +4,23 @@ data class A(val x: Int, val y: String) fun bar() { - val x = { (a, b): A -> - a checkType { _() } - b checkType { _() } + val x = { (a, b): A -> + a checkType { _() } + b checkType { _() } } x checkType { _<(A) -> Unit>() } - val y = { (a: Int, b): A -> + val y = { (a: Int, b): A -> a checkType { _() } - b checkType { _() } + b checkType { _() } } y checkType { _<(A) -> Unit>() } - val y2 = { (a: Number, b): A -> + val y2 = { (a: Number, b): A -> a checkType { _() } - b checkType { _() } + b checkType { _() } } y2 checkType { _<(A) -> Unit>() } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/simple.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/simple.fir.kt index 41783ca7cee..1115485d97c 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/simple.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/simple.fir.kt @@ -47,8 +47,8 @@ fun bar() { b checkType { _() } } - foo { (a, b): B -> - a checkType { _() } - b checkType { _() } + foo { (a, b): B -> + a checkType { _() } + b checkType { _() } } } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt index 0dda6673162..afdf43b95f5 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/underscore.fir.kt @@ -56,8 +56,8 @@ fun bar() { b checkType { _() } } - foo { (_, b): B -> + foo { (_, b): B -> _.hashCode() - b checkType { _() } + b checkType { _() } } } From 87c6b6bffceb465e2cff80abca624447bbb8db53 Mon Sep 17 00:00:00 2001 From: Sergey Igushkin Date: Thu, 21 Jan 2021 16:39:00 +0300 Subject: [PATCH 060/122] Revert "Set canBeConsumed = false on the deprecated configurations like compile" This reverts commit dfacccf8 --- .../org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt | 4 ---- .../kotlin/gradle/plugin/ProjectLocalConfigurations.kt | 2 -- 2 files changed, 6 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt index d001e18345b..159771ba539 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/VariantAwareDependenciesIT.kt @@ -187,10 +187,6 @@ class VariantAwareDependenciesIT : BaseGradleIT() { with(outerProject) { embedProject(innerProject) - gradleBuildScript().appendText( - "\nconfigurations['jvm6TestRuntime'].canBeConsumed = true" - ) - gradleBuildScript(innerProject.projectName).appendText( "\ndependencies { testCompile project(path: ':', configuration: 'jvm6TestRuntime') }" ) diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt index 7b5fa05b352..201e7aa46d2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/ProjectLocalConfigurations.kt @@ -38,8 +38,6 @@ object ProjectLocalConfigurations { } internal fun Configuration.setupAsLocalTargetSpecificConfigurationIfSupported(target: KotlinTarget) { - isCanBeConsumed = false - // don't setup in old MPP common modules, as their output configurations with KotlinPlatformType attribute would // fail to resolve as transitive dependencies of the platform modules, just as we don't mark their // `api/RuntimeElements` with the KotlinPlatformType From 5003738d29c78b7ffa6fdcdfd9598e812887de9d Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Thu, 21 Jan 2021 14:33:07 +0300 Subject: [PATCH 061/122] Fix: use idea caches correctly Instead of using value from cache the first created value was being saved to field and not invalidated later. --- .../idea/caches/project/KotlinStdlibCache.kt | 14 ++++++++------ .../caches/resolve/ResolutionAnchorCacheService.kt | 9 ++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/KotlinStdlibCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/KotlinStdlibCache.kt index dde135a3188..da61c5691c5 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/KotlinStdlibCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/project/KotlinStdlibCache.kt @@ -40,13 +40,15 @@ interface KotlinStdlibCache { } class KotlinStdlibCacheImpl(val project: Project) : KotlinStdlibCache { - private val stdlibCache = project.cacheInvalidatingOnRootModifications { - ConcurrentHashMap() - } + private val stdlibCache + get() = project.cacheInvalidatingOnRootModifications { + ConcurrentHashMap() + } - private val stdlibDependencyCache = project.cacheInvalidatingOnRootModifications { - ConcurrentHashMap() - } + private val stdlibDependencyCache + get() = project.cacheInvalidatingOnRootModifications { + ConcurrentHashMap() + } private class LibraryScope( project: Project, diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt index 0b39cd2f301..7fc139458f6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt @@ -65,14 +65,13 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) : object ResolutionAnchorMappingCacheKey object ResolutionAnchorDependenciesCacheKey - override val resolutionAnchorsForLibraries: Map by lazy { - project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorMappingCacheKey::class.java) { + override val resolutionAnchorsForLibraries: Map + get() = project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorMappingCacheKey::class.java) { mapResolutionAnchorForLibraries() } - } - private val resolutionAnchorDependenciesCache: MutableMap> = - project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorDependenciesCacheKey::class.java) { + private val resolutionAnchorDependenciesCache: MutableMap> + get() = project.cacheByClassInvalidatingOnRootModifications(ResolutionAnchorDependenciesCacheKey::class.java) { ContainerUtil.createConcurrentWeakMap() } From 628d6a9c30a0c6083662cdd28a46742e2c60743d Mon Sep 17 00:00:00 2001 From: Pavel Kirpichenkov Date: Thu, 21 Jan 2021 14:41:34 +0300 Subject: [PATCH 062/122] Don't store logger in instance field --- .../idea/caches/resolve/ResolutionAnchorCacheService.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt index 7fc139458f6..269c9dcbcea 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/resolve/ResolutionAnchorCacheService.kt @@ -50,8 +50,6 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) : var moduleNameToAnchorName: Map = emptyMap() ) - private val logger = logger() - @JvmField @Volatile var myState: State = State() @@ -117,4 +115,8 @@ class ResolutionAnchorCacheServiceImpl(val project: Project) : library to anchor }.toMap() } + + companion object { + private val logger = logger() + } } From 20843b6894700a9e5b4cd044b3bf2715a3fc928b Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 21 Jan 2021 16:15:08 +0300 Subject: [PATCH 063/122] Remove error suppression in KotlinChangeSignatureDialog --- .../changeSignature/ui/KotlinChangeSignatureDialog.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt index e6f611c1f05..f354260797a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinChangeSignatureDialog.kt @@ -245,7 +245,7 @@ class KotlinChangeSignatureDialog( when { KotlinPrimaryConstructorParameterTableModel.isValVarColumn(columnInfo) -> - (components[column] as @Suppress("NO_TYPE_ARGUMENTS_ON_RHS") JComboBox).selectedItem + (components[column] as JComboBox<*>).selectedItem KotlinCallableParameterTableModel.isTypeColumn(columnInfo) -> item.typeCodeFragment KotlinCallableParameterTableModel.isNameColumn(columnInfo) -> From 71e74497b55173a4c0c033cee95a6bf116c7acf0 Mon Sep 17 00:00:00 2001 From: Alexander Dudinsky Date: Wed, 20 Jan 2021 09:46:03 +0300 Subject: [PATCH 064/122] Use `addTestJdk`&`removeTestJdk` methods instead `addJdk`&`removeJdk` --- .../idea/codeInsight/gradle/GradleFacetImportTest.kt | 8 ++++++-- .../idea/codeInsight/gradle/GradleImportingTestCase.kt | 7 +++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt index a4ac279f0f4..7e318a4ba72 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt @@ -250,7 +250,7 @@ class GradleFacetImportTest : GradleImportingTestCase() { @Test fun testJsImportTransitive() { configureByFiles() - importProject() + importProject(false) with(facetSettings) { Assert.assertEquals("1.3", languageLevel!!.versionString) @@ -867,10 +867,14 @@ class GradleFacetImportTest : GradleImportingTestCase() { } override fun importProject() { + importProject(true) + } + + fun importProject(skipIndexing: Boolean = true) { val isCreateEmptyContentRootDirectories = currentExternalProjectSettings.isCreateEmptyContentRootDirectories try { currentExternalProjectSettings.isCreateEmptyContentRootDirectories = true - super.importProject(true) + super.importProject(skipIndexing) } finally { currentExternalProjectSettings.isCreateEmptyContentRootDirectories = isCreateEmptyContentRootDirectories } diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt index 9de10e2d445..6cb59a93fed 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt @@ -31,6 +31,7 @@ import com.intellij.openapi.fileTypes.FileTypeManager import com.intellij.openapi.projectRoots.JavaSdk import com.intellij.openapi.projectRoots.ProjectJdkTable import com.intellij.openapi.projectRoots.Sdk +import com.intellij.openapi.projectRoots.impl.ProjectJdkTableImpl import com.intellij.openapi.projectRoots.impl.SdkConfigurationUtil import com.intellij.openapi.roots.ProjectRootManager import com.intellij.openapi.ui.Messages @@ -140,7 +141,8 @@ abstract class GradleImportingTestCase : ExternalSystemImportingTestCase() { val jdk = SdkConfigurationUtil.setupSdk(arrayOfNulls(0), jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME) TestCase.assertNotNull("Cannot create JDK for $myJdkHome", jdk) if (!jdkTable.allJdks.contains(jdk)) { - jdkTable.addJdk(jdk!!, testRootDisposable) +// jdkTable.addJdk(jdk!!, testRootDisposable) + (jdkTable as ProjectJdkTableImpl).addTestJdk(jdk!!, testRootDisposable) ProjectRootManager.getInstance(myProject).projectSdk = jdk } FileTypeManager.getInstance().associateExtension(GroovyFileType.GROOVY_FILE_TYPE, "gradle") @@ -176,7 +178,8 @@ abstract class GradleImportingTestCase : ExternalSystemImportingTestCase() { ThrowableRunnable { runWrite { Arrays.stream(ProjectJdkTable.getInstance().allJdks).forEach { jdk: Sdk -> - ProjectJdkTable.getInstance().removeJdk(jdk) + (ProjectJdkTable.getInstance() as ProjectJdkTableImpl).removeTestJdk(jdk) +// ProjectJdkTable.getInstance().removeJdk(jdk) } for (sdk in removedSdks) { SdkConfigurationUtil.addSdk(sdk) From 6dc0440cd00e4ea6b977c2627e2c97797b63fdb8 Mon Sep 17 00:00:00 2001 From: Alexander Dudinsky Date: Thu, 21 Jan 2021 18:47:48 +0300 Subject: [PATCH 065/122] Remove commented code in previous commit --- .../kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt index 6cb59a93fed..cdee509f01a 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleImportingTestCase.kt @@ -141,7 +141,6 @@ abstract class GradleImportingTestCase : ExternalSystemImportingTestCase() { val jdk = SdkConfigurationUtil.setupSdk(arrayOfNulls(0), jdkHomeDir, JavaSdk.getInstance(), true, null, GRADLE_JDK_NAME) TestCase.assertNotNull("Cannot create JDK for $myJdkHome", jdk) if (!jdkTable.allJdks.contains(jdk)) { -// jdkTable.addJdk(jdk!!, testRootDisposable) (jdkTable as ProjectJdkTableImpl).addTestJdk(jdk!!, testRootDisposable) ProjectRootManager.getInstance(myProject).projectSdk = jdk } @@ -179,7 +178,6 @@ abstract class GradleImportingTestCase : ExternalSystemImportingTestCase() { runWrite { Arrays.stream(ProjectJdkTable.getInstance().allJdks).forEach { jdk: Sdk -> (ProjectJdkTable.getInstance() as ProjectJdkTableImpl).removeTestJdk(jdk) -// ProjectJdkTable.getInstance().removeJdk(jdk) } for (sdk in removedSdks) { SdkConfigurationUtil.addSdk(sdk) From 5e83e10a72d83889360e6c1a80a4de5d00f15276 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 13 Jan 2021 12:16:03 +0300 Subject: [PATCH 066/122] FIR: Add callable references nodes to CFG Otherwise, they are not being considered as return expressions from lambdas --- .../kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt | 6 ++++++ .../jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt | 10 ++++++++++ .../kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt | 4 +++- .../fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt | 6 ++++++ .../fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt | 5 ++++- .../fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt | 4 ++++ .../body/resolve/FirExpressionsResolveTransformer.kt | 2 ++ 7 files changed, 35 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index 7c3acdd6da6..b18d5c3f97f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -1112,6 +1112,12 @@ abstract class FirDataFlowAnalyzer( graphBuilder.exitElvis().mergeIncomingFlow() } + // Callable reference + + fun exitCallableReference(callableReferenceAccess: FirCallableReferenceAccess) { + graphBuilder.exitCallableReference(callableReferenceAccess).mergeIncomingFlow() + } + // ------------------------------------------------------ Utils ------------------------------------------------------ private var CFGNode<*>.flow: FLOW diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt index a48fe395aa7..2a81173d62d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNode.kt @@ -564,6 +564,16 @@ class FunctionCallNode( } } +class CallableReferenceNode( + owner: ControlFlowGraph, + override val fir: FirCallableReferenceAccess, + level: Int, id: Int +) : CFGNode(owner, level, id) { + override fun accept(visitor: ControlFlowGraphVisitor, data: D): R { + return visitor.visitCallableReferenceNode(this, data) + } +} + class DelegatedConstructorCallNode( owner: ControlFlowGraph, override val fir: FirDelegatedConstructorCall, diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt index ceccaf39958..7caba7c1e9d 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/CFGNodeRenderer.kt @@ -116,6 +116,8 @@ fun CFGNode<*>.render(): String = is ElvisRhsEnterNode -> "Enter rhs of ?:" is ElvisExitNode -> "Exit ?:" + is CallableReferenceNode -> "Callable reference: ${fir.render(CfgRenderMode)}" + is AbstractBinaryExitNode -> throw IllegalStateException() }, ) @@ -141,4 +143,4 @@ private fun FirLoop.type(): String = when (this) { is FirWhileLoop -> "while" is FirDoWhileLoop -> "do-while" else -> throw IllegalArgumentException() -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index 5446b6ffedb..864bd9c0f44 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -1039,6 +1039,12 @@ class ControlFlowGraphBuilder { return node } + // ----------------------------------- Callable references ----------------------------------- + + fun exitCallableReference(callableReferenceAccess: FirCallableReferenceAccess): CallableReferenceNode { + return createCallableReferenceNode(callableReferenceAccess).also { addNewSimpleNode(it) } + } + // ----------------------------------- Block ----------------------------------- fun enterInitBlock(initBlock: FirAnonymousInitializer): Pair?> { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt index 64cd282844f..2d8a69826d3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphNodeBuilder.kt @@ -119,6 +119,9 @@ fun ControlFlowGraphBuilder.createLoopBlockExitNode(fir: FirLoop): LoopBlockExit fun ControlFlowGraphBuilder.createFunctionCallNode(fir: FirFunctionCall): FunctionCallNode = FunctionCallNode(currentGraph, fir, levelCounter, createId()) +fun ControlFlowGraphBuilder.createCallableReferenceNode(fir: FirCallableReferenceAccess): CallableReferenceNode = + CallableReferenceNode(currentGraph, fir, levelCounter, createId()) + fun ControlFlowGraphBuilder.createDelegatedConstructorCallNode(fir: FirDelegatedConstructorCall): DelegatedConstructorCallNode = DelegatedConstructorCallNode(currentGraph, fir, levelCounter, createId()) @@ -231,4 +234,4 @@ fun ControlFlowGraphBuilder.createExitDefaultArgumentsNode(fir: FirValueParamete ExitDefaultArgumentsNode(currentGraph, fir, levelCounter, createId()) fun ControlFlowGraphBuilder.createComparisonExpressionNode(fir: FirComparisonExpression): ComparisonExpressionNode = - ComparisonExpressionNode(currentGraph, fir, levelCounter, createId()) \ No newline at end of file + ComparisonExpressionNode(currentGraph, fir, levelCounter, createId()) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt index e8d8bd1752c..cb5fc522cc6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphVisitor.kt @@ -277,6 +277,10 @@ abstract class ControlFlowGraphVisitor { return visitNode(node, data) } + open fun visitCallableReferenceNode(node: CallableReferenceNode, data: D): R { + return visitNode(node, data) + } + open fun visitDelegatedConstructorCallNode(node: DelegatedConstructorCallNode, data: D): R { return visitNode(node, data) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 2c35bf21862..88f497176af 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -660,9 +660,11 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform callableReferenceAccess, data.expectedType, resolutionContext, ) ?: callableReferenceAccess + dataFlowAnalyzer.exitCallableReference(resolvedReference) return resolvedReference.compose() } + dataFlowAnalyzer.exitCallableReference(callableReferenceAccessWithTransformedLHS) return callableReferenceAccessWithTransformedLHS.compose() } From 0e368cc23721cde39df80c28a0542bd915fc7df1 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 13 Jan 2021 21:13:48 +0300 Subject: [PATCH 067/122] FIR: Analyze return statements for implicit lambda with independent context --- .../body/resolve/BodyResolveContext.kt | 14 ++++++++++ .../body/resolve/FirBodyResolveTransformer.kt | 7 +++++ ...ControlFlowStatementsResolveTransformer.kt | 28 +++++++++++++------ .../FirDeclarationsResolveTransformer.kt | 6 +++- .../constraints/returnLambdaFromLambda.fir.kt | 2 +- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt index e9254f795bb..8246c99fbc5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.utils.sure @@ -56,6 +57,8 @@ class BodyResolveContext( @set:PrivateForInline var inferenceSession: FirInferenceSession = FirInferenceSession.DEFAULT + val anonymousFunctionsAnalyzedInDependentContext: MutableSet> = mutableSetOf() + @OptIn(PrivateForInline::class) inline fun withInferenceSession(inferenceSession: FirInferenceSession, block: () -> R): R { val oldSession = this.inferenceSession @@ -125,6 +128,16 @@ class BodyResolveContext( } } + @OptIn(PrivateForInline::class) + inline fun withLambdaBeingAnalyzedInDependentContext(lambda: FirAnonymousFunctionSymbol, l: () -> R): R { + anonymousFunctionsAnalyzedInDependentContext.add(lambda) + return try { + l() + } finally { + anonymousFunctionsAnalyzedInDependentContext.remove(lambda) + } + } + @OptIn(PrivateForInline::class) fun replaceTowerDataContext(newContext: FirTowerDataContext) { towerDataContext = newContext @@ -189,5 +202,6 @@ class BodyResolveContext( towerDataContextForAnonymousFunctions.putAll(this@BodyResolveContext.towerDataContextForAnonymousFunctions) containers = this@BodyResolveContext.containers towerDataContext = this@BodyResolveContext.towerDataContext + anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt index 3243455d96b..ea09b540c33 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt @@ -342,6 +342,13 @@ open class FirBodyResolveTransformer( return controlFlowStatementsTransformer.transformJump(jump, data) } + override fun transformReturnExpression( + returnExpression: FirReturnExpression, + data: ResolutionMode + ): CompositeTransformResult { + return controlFlowStatementsTransformer.transformReturnExpression(returnExpression, data) + } + override fun transformThrowExpression( throwExpression: FirThrowExpression, data: ResolutionMode diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt index 3618d271e6c..3864150cf6e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirControlFlowStatementsResolveTransformer.kt @@ -187,18 +187,30 @@ class FirControlFlowStatementsResolveTransformer(transformer: FirBodyResolveTran // ------------------------------- Jumps ------------------------------- override fun transformJump(jump: FirJump, data: ResolutionMode): CompositeTransformResult { - val expectedTypeRef = (jump as? FirReturnExpression)?.target?.labeledElement?.returnTypeRef - - val mode = if (expectedTypeRef != null) { - ResolutionMode.WithExpectedType(expectedTypeRef) - } else { - ResolutionMode.ContextIndependent - } - val result = transformer.transformExpression(jump, mode).single + val result = transformer.transformExpression(jump, data).single dataFlowAnalyzer.exitJump(jump) return result.compose() } + override fun transformReturnExpression( + returnExpression: FirReturnExpression, + data: ResolutionMode + ): CompositeTransformResult { + val labeledElement = returnExpression.target.labeledElement + val expectedTypeRef = labeledElement.returnTypeRef + @Suppress("IntroduceWhenSubject") + val mode = when { + labeledElement.symbol in context.anonymousFunctionsAnalyzedInDependentContext -> { + ResolutionMode.ContextDependent + } + else -> { + ResolutionMode.WithExpectedType(expectedTypeRef) + } + } + + return transformJump(returnExpression, mode) + } + override fun transformThrowExpression( throwExpression: FirThrowExpression, data: ResolutionMode diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index b160becbf98..557eff9e2a3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -435,7 +435,11 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor fun transform(): FirAnonymousFunction { val expectedReturnType = lambdaResolution.expectedReturnTypeRef ?: anonymousFunction.returnTypeRef.takeUnless { it is FirImplicitTypeRef } - val result = transformFunction(anonymousFunction, withExpectedType(expectedReturnType)).single as FirAnonymousFunction + + val result = context.withLambdaBeingAnalyzedInDependentContext(anonymousFunction.symbol) { + transformFunction(anonymousFunction, withExpectedType(expectedReturnType)).single as FirAnonymousFunction + } + val body = result.body if (result.returnTypeRef is FirImplicitTypeRef && body != null) { result.transformReturnTypeRef(transformer, withExpectedType(body.resultType)) diff --git a/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.fir.kt b/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.fir.kt index 0f100c7b735..f79f1fa6a01 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/returnLambdaFromLambda.fir.kt @@ -3,7 +3,7 @@ fun testLambda() { val basicTest: (Int) -> Int = myRun { val x: Any? = null - if (x is String) return@myRun { it -> x.length + it } + if (x is String) return@myRun { it -> x.length + it } if (x !is Int) return@myRun { it -> it } { it -> x + it } From ad30c6c3802fc39fa9fefef766546802c7111d73 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 13 Jan 2021 21:28:23 +0300 Subject: [PATCH 068/122] FIR: Fix callable references resolution when they're being returned from lambdas --- .../jetbrains/kotlin/fir/FirCallResolver.kt | 6 ++- .../inference/ConstraintSystemCompleter.kt | 3 +- .../inference/PostponedArgumentsAnalyzer.kt | 2 +- .../fir/resolve/inference/PostponedAtoms.kt | 17 +++++--- .../boxInline/callableReference/kt15449.kt | 3 +- .../callableReference/lambdaResult.fir.kt | 43 ------------------- .../tests/callableReference/lambdaResult.kt | 1 + 7 files changed, 19 insertions(+), 56 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/callableReference/lambdaResult.fir.kt diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 655c3f8994e..a4f740ade2f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -263,13 +263,15 @@ class FirCallResolver( conflictResolver.chooseMaximallySpecificCandidates(bestCandidates, discriminateGenerics = false) } + resolvedCallableReferenceAtom.hasBeenResolvedOnce = true + when { noSuccessfulCandidates -> { return false } reducedCandidates.size > 1 -> { - if (resolvedCallableReferenceAtom.postponed) return false - resolvedCallableReferenceAtom.postponed = true + if (resolvedCallableReferenceAtom.hasBeenPostponed) return false + resolvedCallableReferenceAtom.hasBeenPostponed = true return true } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt index 3a5f00f7cdf..4a0d282d8de 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/ConstraintSystemCompleter.kt @@ -291,8 +291,9 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) { postponedAtom.collectNotFixedVariables() } postponedAtom is ResolvedCallableReferenceAtom -> { - if (postponedAtom.postponed) + if (postponedAtom.mightNeedAdditionalResolution) { postponedAtom.collectNotFixedVariables() + } } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt index 56c5d4aa1bc..ec55504908f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt @@ -68,7 +68,7 @@ class PostponedArgumentsAnalyzer( } private fun processCallableReference(atom: ResolvedCallableReferenceAtom, candidate: Candidate) { - if (atom.postponed) { + if (atom.mightNeedAdditionalResolution) { callResolver.resolveCallableReference(candidate.csBuilder, atom) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt index c7f1ab6bfc8..823544c872e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedAtoms.kt @@ -116,35 +116,38 @@ class ResolvedCallableReferenceAtom( val lhs: DoubleColonLHS?, private val session: FirSession ) : PostponedResolvedAtom(), PostponedCallableReferenceMarker { - // TODO: in several places atoms are filtered by the marker interface - potential overhead/errors - var postponed: Boolean = false + + var hasBeenResolvedOnce: Boolean = false + var hasBeenPostponed: Boolean = false + + val mightNeedAdditionalResolution get() = !hasBeenResolvedOnce || hasBeenPostponed var resultingCandidate: Pair? = null override val inputTypes: Collection get() { - if (!postponed) return emptyList() + if (!hasBeenPostponed) return emptyList() return extractInputOutputTypesFromCallableReferenceExpectedType(expectedType, session)?.inputTypes ?: listOfNotNull(expectedType) } override val outputType: ConeKotlinType? get() { - if (!postponed) return null + if (!hasBeenPostponed) return null return extractInputOutputTypesFromCallableReferenceExpectedType(expectedType, session)?.outputType } override val expectedType: ConeKotlinType? - get() = if (!postponed) + get() = if (!hasBeenPostponed) initialExpectedType else revisedExpectedType ?: initialExpectedType override var revisedExpectedType: ConeKotlinType? = null - get() = if (postponed) field else expectedType + get() = if (hasBeenPostponed) field else expectedType private set override fun reviseExpectedType(expectedType: KotlinTypeMarker) { - if (!postponed) return + if (!mightNeedAdditionalResolution) return require(expectedType is ConeKotlinType) revisedExpectedType = expectedType } diff --git a/compiler/testData/codegen/boxInline/callableReference/kt15449.kt b/compiler/testData/codegen/boxInline/callableReference/kt15449.kt index eb591ffe6b8..265fe026478 100644 --- a/compiler/testData/codegen/boxInline/callableReference/kt15449.kt +++ b/compiler/testData/codegen/boxInline/callableReference/kt15449.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // FILE: 1.kt package test @@ -38,4 +37,4 @@ class A { fun box(): String { A().test() return result -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/callableReference/lambdaResult.fir.kt b/compiler/testData/diagnostics/tests/callableReference/lambdaResult.fir.kt deleted file mode 100644 index 00b7794fa25..00000000000 --- a/compiler/testData/diagnostics/tests/callableReference/lambdaResult.fir.kt +++ /dev/null @@ -1,43 +0,0 @@ -// SKIP_TXT -// !DIAGNOSTICS: -UNUSED_PARAMETER -// !LANGUAGE: +NewInference - -interface Inv - -fun Inv.foo( - handler: () -> ((command: E) -> Unit) -) {} - -fun bar(x: Int) {} -fun bar(x: String) {} - -fun bar1(arg: Int) {} -fun foo1(f: () -> (Int) -> Unit) = "" - -fun main(x: Inv) { - x.foo { - if (x.hashCode() == 0) return@foo ::bar - - ::bar - } - - x.foo { - if (x.hashCode() == 0) return@foo ::bar - - ::bar - } - - foo1 { - ::bar1 - } - - foo1 { - return@foo1 ::bar1 - } - - foo1 { - if (x.hashCode() == 0) return@foo1 ::bar - - ::bar - } -} diff --git a/compiler/testData/diagnostics/tests/callableReference/lambdaResult.kt b/compiler/testData/diagnostics/tests/callableReference/lambdaResult.kt index 1391ebe2b86..4b9b62cc8e4 100644 --- a/compiler/testData/diagnostics/tests/callableReference/lambdaResult.kt +++ b/compiler/testData/diagnostics/tests/callableReference/lambdaResult.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // SKIP_TXT // !DIAGNOSTICS: -UNUSED_PARAMETER // !LANGUAGE: +NewInference From 5f0d00a83f9ac4d7ea6ba670059178688e7fd3c4 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 13 Jan 2021 21:30:15 +0300 Subject: [PATCH 069/122] FIR: Use proper tower data contexts for postponed callable references E.g., it should contain local scopes of containing lambdas --- .../jetbrains/kotlin/fir/FirCallResolver.kt | 18 ++++++++++++------ .../inference/PostponedArgumentsAnalyzer.kt | 3 +++ .../body/resolve/BodyResolveContext.kt | 3 +++ .../body/resolve/FirBodyResolveTransformer.kt | 1 + .../FirExpressionsResolveTransformer.kt | 2 ++ .../notNullAssertions/localEntities.kt | 1 - 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index a4f740ade2f..4c4821fd24b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -249,12 +249,18 @@ class FirCallResolver( ) // No reset here! val localCollector = CandidateCollector(components, components.resolutionStageRunner) - val result = towerResolver.runResolver( - info, - transformer.resolutionContext, - collector = localCollector, - manager = TowerResolveManager(localCollector), - ) + + val towerDataContext = + transformer.context.towerDataContextForCallableReferences[callableReferenceAccess] ?: transformer.context.towerDataContext + + val result = transformer.context.withTowerDataContext(towerDataContext) { + towerResolver.runResolver( + info, + transformer.resolutionContext, + collector = localCollector, + manager = TowerResolveManager(localCollector), + ) + } val bestCandidates = result.bestCandidates() val noSuccessfulCandidates = !result.currentApplicability.isSuccess val reducedCandidates = if (noSuccessfulCandidates) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt index ec55504908f..6b3ff053b84 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt @@ -74,6 +74,9 @@ class PostponedArgumentsAnalyzer( val callableReferenceAccess = atom.reference atom.analyzed = true + + resolutionContext.bodyResolveContext.towerDataContextForCallableReferences.remove(callableReferenceAccess) + val (resultingCandidate, applicability) = atom.resultingCandidate ?: Pair(null, CandidateApplicability.INAPPLICABLE) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt index 8246c99fbc5..ff6c54ebcc8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt @@ -9,6 +9,7 @@ import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf import org.jetbrains.kotlin.fir.PrivateForInline import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess import org.jetbrains.kotlin.fir.resolve.FirTowerDataContext import org.jetbrains.kotlin.fir.resolve.FirTowerDataContextsForClassParts import org.jetbrains.kotlin.fir.resolve.FirTowerDataElement @@ -53,6 +54,7 @@ class BodyResolveContext( var containers: PersistentList = persistentListOf() val towerDataContextForAnonymousFunctions: MutableMap = mutableMapOf() + val towerDataContextForCallableReferences: MutableMap = mutableMapOf() @set:PrivateForInline var inferenceSession: FirInferenceSession = FirInferenceSession.DEFAULT @@ -200,6 +202,7 @@ class BodyResolveContext( ): BodyResolveContext = BodyResolveContext(returnTypeCalculator, dataFlowAnalyzerContext, targetedLocalClasses, outerLocalClassForNested).apply { file = this@BodyResolveContext.file towerDataContextForAnonymousFunctions.putAll(this@BodyResolveContext.towerDataContextForAnonymousFunctions) + towerDataContextForCallableReferences.putAll(this@BodyResolveContext.towerDataContextForCallableReferences) containers = this@BodyResolveContext.containers towerDataContext = this@BodyResolveContext.towerDataContext anonymousFunctionsAnalyzedInDependentContext.addAll(this@BodyResolveContext.anonymousFunctionsAnalyzedInDependentContext) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt index ea09b540c33..d127e062ea9 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirBodyResolveTransformer.kt @@ -51,6 +51,7 @@ open class FirBodyResolveTransformer( override fun transformFile(file: FirFile, data: ResolutionMode): CompositeTransformResult { checkSessionConsistency(file) context.cleanContextForAnonymousFunction() + context.towerDataContextForCallableReferences.clear() context.cleanDataFlowContext() @OptIn(PrivateForInline::class) context.file = file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 88f497176af..786b7c061d2 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -664,6 +664,8 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform return resolvedReference.compose() } + context.towerDataContextForCallableReferences[callableReferenceAccess] = context.towerDataContext + dataFlowAnalyzer.exitCallableReference(callableReferenceAccessWithTransformedLHS) return callableReferenceAccessWithTransformedLHS.compose() } diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/localEntities.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/localEntities.kt index 0788277d7b0..95de17765a3 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/localEntities.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/localEntities.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // SKIP_JDK6 // TARGET_BACKEND: JVM // WITH_RUNTIME From 5afebb4e789607109ffc18942f747b73fbdb3a9d Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Thu, 14 Jan 2021 16:26:35 +0300 Subject: [PATCH 070/122] FIR: Transform synthetic calls children even without incomplete candidate It might be necessary for cases like run @l1{ run { if (...) return@l1 1 } } "if" is a synthetic call, but without candidate since there's just one branch But return@l1 1 is incomplete because it's resolved in dependent context and "1" is hang incomplete integer literal --- .../FirCallCompletionResultsWriterTransformer.kt | 11 +++++++++-- .../tests/inference/regressions/kt36342_2.fir.kt | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 63e080d5868..e801a3062b0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -534,9 +534,16 @@ class FirCallCompletionResultsWriterTransformer( syntheticCall: D, data: ExpectedArgumentType?, ): CompositeTransformResult where D : FirResolvable, D : FirExpression { - val calleeReference = syntheticCall.calleeReference as? FirNamedReferenceWithCandidate ?: return syntheticCall.compose() + val calleeReference = syntheticCall.calleeReference as? FirNamedReferenceWithCandidate + val declaration = calleeReference?.candidate?.symbol?.fir as? FirSimpleFunction - val declaration = calleeReference.candidate.symbol.fir as? FirSimpleFunction ?: return syntheticCall.compose() + if (calleeReference == null || declaration == null) { + syntheticCall.transformChildren( + this, + data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() + ) + return syntheticCall.compose() + } val typeRef = typeCalculator.tryCalculateReturnType(declaration) syntheticCall.replaceTypeRefWithSubstituted(calleeReference, typeRef) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt index 4657de5aa65..5e8254c4013 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.fir.kt @@ -5,7 +5,7 @@ fun materialize(): M = TODO() fun test(b: Boolean) { id(if (b) { - id(unresolved) + id(unresolved) } else { id( materialize() From 9493e685843c53544f3f3dc71bd88d69192e5e90 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Fri, 15 Jan 2021 18:54:36 +0300 Subject: [PATCH 071/122] FIR: Do not run completion for lambda's explicit return too early See the test case Completion for synthetic call: x ?: return@myRun materialize() makes `materialize()` while it's obviously too early for that --- ...TouchedTilContractsPhaseTestGenerated.java | 5 ++++ .../resolve/inference/lambdasReturns.fir.txt | 15 +++++++++++ .../resolve/inference/lambdasReturns.kt | 15 +++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 +++++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 +++++ .../fir/resolve/inference/FirCallCompleter.kt | 4 ++- ...rCallCompletionResultsWriterTransformer.kt | 25 ++++++++++++++++--- .../FirDeclarationsResolveTransformer.kt | 1 + 8 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index cf7e0629eb3..633632c5704 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -2223,6 +2223,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.kt"); } + @TestMetadata("lambdasReturns.kt") + public void testLambdasReturns() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt"); + } + @TestMetadata("nestedExtensionFunctionType.kt") public void testNestedExtensionFunctionType() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/inference/nestedExtensionFunctionType.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt new file mode 100644 index 00000000000..41ca1d4fa2d --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt @@ -0,0 +1,15 @@ +FILE: lambdasReturns.kt + public final fun myRun(b: R|() -> R|): R|R| { + ^myRun R|/b|.R|SubstitutionOverride|() + } + public final fun materialize(): R|T| { + ^materialize R|kotlin/TODO|() + } + public final fun foo(x: R|kotlin/String?|): R|kotlin/Unit| { + lval r: R|kotlin/Int| = R|/myRun|( = myRun@fun (): R|kotlin/Int| { + lval y: R|kotlin/String| = R|/x| ?: ^@myRun R?C|/materialize|() + ^ R|/y|.R|kotlin/String.length| + } + ) + R|/r|.R|kotlin/Int.minus|(Int(1)) + } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt b/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt new file mode 100644 index 00000000000..665e02bed0b --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt @@ -0,0 +1,15 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + +fun myRun(b: () -> R): R = b() + +fun materialize(): T = TODO() + +fun foo(x: String?) { + val r = myRun { + val y = x ?: return@myRun materialize() + y.length + } + + r.minus(1) +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 64a33e4f967..be352eaf06c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -2547,6 +2547,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.kt"); } + @Test + @TestMetadata("lambdasReturns.kt") + public void testLambdasReturns() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt"); + } + @Test @TestMetadata("nestedExtensionFunctionType.kt") public void testNestedExtensionFunctionType() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index a53aadfc92c..d89ea750310 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -2568,6 +2568,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdaInElvis.kt"); } + @Test + @TestMetadata("lambdasReturns.kt") + public void testLambdasReturns() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.kt"); + } + @Test @TestMetadata("nestedExtensionFunctionType.kt") public void testNestedExtensionFunctionType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt index f3dc5091520..d6a37a5f596 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt @@ -83,7 +83,8 @@ class FirCallCompleter( val completedCall = call.transformSingle( FirCallCompletionResultsWriterTransformer( session, finalSubstitutor, components.returnTypeCalculator, - session.inferenceComponents.approximator + session.inferenceComponents.approximator, + components.dataFlowAnalyzer, ), null ) @@ -153,6 +154,7 @@ class FirCallCompleter( return FirCallCompletionResultsWriterTransformer( session, substitutor, components.returnTypeCalculator, session.inferenceComponents.approximator, + components.dataFlowAnalyzer, mode ) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index e801a3062b0..07350b79d33 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -13,18 +13,16 @@ import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedCallableReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference +import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.Candidate import org.jetbrains.kotlin.fir.resolve.calls.FirErrorReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.varargElementType -import org.jetbrains.kotlin.fir.resolve.constructFunctionalTypeRef -import org.jetbrains.kotlin.fir.resolve.createFunctionalType -import org.jetbrains.kotlin.fir.resolve.firProvider +import org.jetbrains.kotlin.fir.resolve.dfa.FirDataFlowAnalyzer import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType import org.jetbrains.kotlin.fir.resolve.inference.returnType -import org.jetbrains.kotlin.fir.resolve.propagateTypeFromQualifiedAccessAfterNullCheck import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirArrayOfCallTransformer import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.remapArgumentsWithVararg @@ -48,6 +46,7 @@ class FirCallCompletionResultsWriterTransformer( private val finalSubstitutor: ConeSubstitutor, private val typeCalculator: ReturnTypeCalculator, private val typeApproximator: AbstractTypeApproximator, + private val dataFlowAnalyzer: FirDataFlowAnalyzer<*>, private val mode: Mode = Mode.Normal ) : FirAbstractTreeTransformer(phase = FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) { @@ -472,6 +471,7 @@ class FirCallCompletionResultsWriterTransformer( } val result = transformElement(anonymousFunction, null) + val resultFunction = result.single if (resultFunction.returnTypeRef.coneTypeSafe() != null) { val blockType = resultFunction.body?.typeRef?.coneTypeSafe() @@ -480,9 +480,26 @@ class FirCallCompletionResultsWriterTransformer( resultFunction.constructFunctionalTypeRef(isSuspend = expectedType?.isSuspendFunctionType(session) == true) ) } + + for (expression in dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(anonymousFunction)) { + expression.transform(this, null) + } + return result } + override fun transformReturnExpression( + returnExpression: FirReturnExpression, + data: ExpectedArgumentType? + ): CompositeTransformResult { + val labeledElement = returnExpression.target.labeledElement + if (labeledElement is FirAnonymousFunction) { + return returnExpression.compose() + } + + return super.transformReturnExpression(returnExpression, data) + } + override fun transformBlock(block: FirBlock, data: ExpectedArgumentType?): CompositeTransformResult { val initialType = block.resultType.coneTypeSafe() if (initialType != null) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 557eff9e2a3..0d59e01234a 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -759,6 +759,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor ConeSubstitutor.Empty, components.returnTypeCalculator, inferenceComponents.approximator, + dataFlowAnalyzer, ) lambda.transformSingle(writer, expectedTypeRef.coneTypeSafe()?.toExpectedType()) val returnTypes = dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(lambda) From 7df4f67f7cfad9570f2866f614684a254925d0fc Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 20 Jan 2021 13:11:01 +0300 Subject: [PATCH 072/122] FIR: Minor. Drop unused parameter --- .../jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt | 1 - .../kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt | 2 -- 2 files changed, 3 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt index d6a37a5f596..4b083f9634b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/FirCallCompleter.kt @@ -175,7 +175,6 @@ class FirCallCompleter( receiverType: ConeKotlinType?, parameters: List, expectedReturnType: ConeKotlinType?, - rawReturnType: ConeKotlinType, stubsForPostponedVariables: Map ): ReturnArgumentsAnalysisResult { val lambdaArgument: FirAnonymousFunction = lambdaAtom.atom diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt index 6b3ff053b84..5bba7ca49e6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/PostponedArgumentsAnalyzer.kt @@ -37,7 +37,6 @@ interface LambdaAnalyzer { receiverType: ConeKotlinType?, parameters: List, expectedReturnType: ConeKotlinType?, // null means, that return type is not proper i.e. it depends on some type variables - rawReturnType: ConeKotlinType, stubsForPostponedVariables: Map ): ReturnArgumentsAnalysisResult } @@ -129,7 +128,6 @@ class PostponedArgumentsAnalyzer( receiver, parameters, expectedTypeForReturnArguments, - rawReturnType, stubsForPostponedVariables ) applyResultsOfAnalyzedLambdaToCandidateSystem(c, lambda, candidate, results, expectedTypeForReturnArguments, ::substitute) From 4dc2653736efa904b4f2182868f0173b2b8bf32f Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Wed, 20 Jan 2021 15:50:50 +0300 Subject: [PATCH 073/122] FIR: Do not complete finally parts of try-finally It's been processed via Body transformer explicitly --- ...rCallCompletionResultsWriterTransformer.kt | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index 07350b79d33..f2f93c05862 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -555,19 +555,13 @@ class FirCallCompletionResultsWriterTransformer( val declaration = calleeReference?.candidate?.symbol?.fir as? FirSimpleFunction if (calleeReference == null || declaration == null) { - syntheticCall.transformChildren( - this, - data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() - ) + transformSyntheticCallChildren(syntheticCall, data) return syntheticCall.compose() } val typeRef = typeCalculator.tryCalculateReturnType(declaration) syntheticCall.replaceTypeRefWithSubstituted(calleeReference, typeRef) - syntheticCall.transformChildren( - this, - data = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() - ) + transformSyntheticCallChildren(syntheticCall, data) return (syntheticCall.transformCalleeReference( StoreCalleeReference, @@ -575,6 +569,25 @@ class FirCallCompletionResultsWriterTransformer( ) as D).compose() } + private inline fun transformSyntheticCallChildren( + syntheticCall: D, + data: ExpectedArgumentType? + ) where D : FirResolvable, D : FirExpression { + val newData = data?.getExpectedType(syntheticCall)?.toExpectedType() ?: syntheticCall.typeRef.coneType.toExpectedType() + + if (syntheticCall is FirTryExpression) { + syntheticCall.transformCalleeReference(this, newData) + syntheticCall.transformTryBlock(this, newData) + syntheticCall.transformCatches(this, newData) + return + } + + syntheticCall.transformChildren( + this, + data = newData + ) + } + override fun transformConstExpression( constExpression: FirConstExpression, data: ExpectedArgumentType?, From b0b7f39c75e9e4685125e44011585eb544a50ce1 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Mon, 18 Jan 2021 15:13:37 +0300 Subject: [PATCH 074/122] FIR: Do not use return statement for type of a block expression Type of a block is a kind of irrelevant for lambdas: their type is much more complicated and defined via FirDataFlowAnalyzer#returnExpressionsOfAnonymousFunction at at FirCallCompleter.LambdaAnalyzerImpl#analyzeAndGetLambdaReturnArguments --- .../arguments/integerLiteralTypes.fir.txt | 4 +- .../resolve/cfg/lambdaAsReturnOfLambda.dot | 55 ++++++++---------- .../resolve/expresssions/access.fir.txt | 2 +- .../resolve/inference/lambdasReturns.fir.txt | 2 +- .../samConstructors/genericSam.fir.txt | 4 +- .../genericSamInferenceFromExpectType.fir.txt | 10 ++-- .../resolve/samConversions/genericSam.fir.txt | 4 +- .../resolve/samConversions/kotlinSam.fir.txt | 4 +- .../notSamBecauseOfSupertype.fir.txt | 2 +- .../callableReferences/implicitTypes.fir.txt | 2 +- .../resolveWithStdlib/j+k/MyMap.fir.txt | 2 +- .../fir/resolve/dfa/FirDataFlowAnalyzer.kt | 3 + .../dfa/cfg/ControlFlowGraphBuilder.kt | 5 ++ ...rCallCompletionResultsWriterTransformer.kt | 57 +++++++++++++------ .../body/resolve/BodyResolveUtils.kt | 5 +- .../FirDeclarationsResolveTransformer.kt | 24 +++++++- .../sam/samConversionToGeneric.fir.kt.txt | 4 +- .../sam/samConversionToGeneric.fir.txt | 12 ++-- .../stringVsTXArray.fir.kt.txt | 3 +- .../stringVsTXArray.fir.txt | 6 +- 20 files changed, 127 insertions(+), 83 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.fir.txt b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.fir.txt index e2910694a10..7464269e561 100644 --- a/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/arguments/integerLiteralTypes.fir.txt @@ -30,11 +30,11 @@ FILE: integerLiteralTypes.kt } )) R|/takeByte|(R|kotlin/run|( = run@fun (): R|kotlin/Byte| { - ^ Int(1) + ^ Byte(1) } )) R|/takeLong|(R|kotlin/run|( = run@fun (): R|kotlin/Long| { - ^ Int(1) + ^ Long(1) } )) } diff --git a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot index ba85a36cc4b..5b40cbc0a17 100644 --- a/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot +++ b/compiler/fir/analysis-tests/testData/resolve/cfg/lambdaAsReturnOfLambda.dot @@ -44,21 +44,14 @@ digraph lambdaAsReturnOfLambda_kt { 7 [label="Exit function anonymousFunction" style="filled" fillcolor=red]; } 18 [label="Postponed exit from lambda"]; - subgraph cluster_6 { - color=blue - 19 [label="Enter block"]; - 20 [label="Exit block"]; - } - 21 [label="Function call: R|/run| kotlin/Unit|>(...)"]; - 22 [label="Exit property" style="filled" fillcolor=red]; + 19 [label="Function call: R|/run| kotlin/Unit|>(...)"]; + 20 [label="Exit property" style="filled" fillcolor=red]; } 16 -> {17}; 17 -> {18 0}; 17 -> {0} [style=dashed]; 18 -> {19}; 19 -> {20}; - 20 -> {21}; - 21 -> {22}; 0 -> {1}; 1 -> {2}; 2 -> {3 8}; @@ -74,39 +67,39 @@ digraph lambdaAsReturnOfLambda_kt { 11 -> {12}; 12 -> {13}; - subgraph cluster_7 { + subgraph cluster_6 { color=red - 23 [label="Enter function bar" style="filled" fillcolor=red]; - subgraph cluster_8 { + 21 [label="Enter function bar" style="filled" fillcolor=red]; + subgraph cluster_7 { color=blue - 24 [label="Enter block"]; - 25 [label="Exit block"]; + 22 [label="Enter block"]; + 23 [label="Exit block"]; } - 26 [label="Exit function bar" style="filled" fillcolor=red]; + 24 [label="Exit function bar" style="filled" fillcolor=red]; } + 21 -> {22}; + 22 -> {23}; 23 -> {24}; - 24 -> {25}; - 25 -> {26}; - subgraph cluster_9 { + subgraph cluster_8 { color=red - 27 [label="Enter function run" style="filled" fillcolor=red]; - subgraph cluster_10 { + 25 [label="Enter function run" style="filled" fillcolor=red]; + subgraph cluster_9 { color=blue - 28 [label="Enter block"]; - 29 [label="Function call: R|/block|.R|SubstitutionOverride|()"]; - 30 [label="Jump: ^run R|/block|.R|SubstitutionOverride|()"]; - 31 [label="Stub" style="filled" fillcolor=gray]; - 32 [label="Exit block" style="filled" fillcolor=gray]; + 26 [label="Enter block"]; + 27 [label="Function call: R|/block|.R|SubstitutionOverride|()"]; + 28 [label="Jump: ^run R|/block|.R|SubstitutionOverride|()"]; + 29 [label="Stub" style="filled" fillcolor=gray]; + 30 [label="Exit block" style="filled" fillcolor=gray]; } - 33 [label="Exit function run" style="filled" fillcolor=red]; + 31 [label="Exit function run" style="filled" fillcolor=red]; } + 25 -> {26}; + 26 -> {27}; 27 -> {28}; - 28 -> {29}; - 29 -> {30}; - 30 -> {33}; + 28 -> {31}; + 28 -> {29} [style=dotted]; + 29 -> {30} [style=dotted]; 30 -> {31} [style=dotted]; - 31 -> {32} [style=dotted]; - 32 -> {33} [style=dotted]; } diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/access.fir.txt b/compiler/fir/analysis-tests/testData/resolve/expresssions/access.fir.txt index e29e4aab883..5b203daae18 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/access.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/access.fir.txt @@ -36,7 +36,7 @@ FILE: access.kt ^plus String() } - public final fun R|Foo|.check(): R|ERROR CLASS: Ambiguity: plus, [kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus, kotlin/Int.plus]| { + public final fun R|Foo|.check(): { ^check this@R|/Bar.check|.R|/Foo.abc|().#(this@R|/Bar|.R|/Bar.bar|()) } diff --git a/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt b/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt index 41ca1d4fa2d..4f178aecddb 100644 --- a/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/inference/lambdasReturns.fir.txt @@ -7,7 +7,7 @@ FILE: lambdasReturns.kt } public final fun foo(x: R|kotlin/String?|): R|kotlin/Unit| { lval r: R|kotlin/Int| = R|/myRun|( = myRun@fun (): R|kotlin/Int| { - lval y: R|kotlin/String| = R|/x| ?: ^@myRun R?C|/materialize|() + lval y: R|kotlin/String| = R|/x| ?: ^@myRun R|/materialize|() ^ R|/y|.R|kotlin/String.length| } ) diff --git a/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSam.fir.txt b/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSam.fir.txt index 727a3c0f878..3b88a0aa9ec 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSam.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSam.fir.txt @@ -1,10 +1,10 @@ FILE: main.kt public final fun main(): R|kotlin/Unit| { - R|/MyFunction|!|, R|ft!|>( = MyFunction@fun (x: R|ft!|): R|kotlin/String| { + R|/MyFunction|!|, R|ft!|>( = MyFunction@fun (x: R|ft!|): R|ft!| { ^ R|/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|() } ) - R|/MyFunction|!|, R|ft!|>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + R|/MyFunction|!|, R|ft!|>( = MyFunction@fun (x: R|kotlin/Int|): R|ft!| { ^ R|/x|.R|kotlin/Any.toString|() } ) diff --git a/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.fir.txt b/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.fir.txt index ef1f2089c4a..3feb87eebc0 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/samConstructors/genericSamInferenceFromExpectType.fir.txt @@ -6,23 +6,23 @@ FILE: main.kt public final fun foo3(f: R|MyFunction|, x: R|X|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - R|/foo1|(R|/MyFunction|( = MyFunction@fun (x: R|ft!|): R|kotlin/String| { + R|/foo1|(R|/MyFunction|( = MyFunction@fun (x: R|ft!|): R|ft!| { ^ R|/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|() } )) - R|/foo2|(R|/MyFunction|!|>( = MyFunction@fun (x: R|ft!|): R|kotlin/String| { + R|/foo2|(R|/MyFunction|!|>( = MyFunction@fun (x: R|ft!|): R|ft!| { ^ R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } )) - #(R|/MyFunction|!|>( = MyFunction@fun (x: R|kotlin/Int|): R|kotlin/String| { + #(R|/MyFunction|!|>( = MyFunction@fun (x: R|kotlin/Int|): R|ft!| { ^ R|/x|.R|kotlin/Any.toString|() } )) - R|/foo3|!|>(R|/MyFunction|!|>( = MyFunction@fun (x: R|ft!|): R|kotlin/String| { + R|/foo3|!|>(R|/MyFunction|!|>( = MyFunction@fun (x: R|ft!|): R|ft!| { ^ R|/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|() } ), Int(1)) - R|/foo3|!|>(R|/MyFunction|!|>( = MyFunction@fun (x: R|kotlin/Number|): R|kotlin/String| { + R|/foo3|!|>(R|/MyFunction|!|>( = MyFunction@fun (x: R|kotlin/Number|): R|ft!| { ^ R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } ), Int(2)) diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.fir.txt b/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.fir.txt index 7df65bfaa24..65d8458fb85 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/genericSam.fir.txt @@ -12,11 +12,11 @@ FILE: main.kt ^ R|/x|.R|kotlin/Any.toString|() } ) - Q|JavaUsage|.R|/JavaUsage.foo3|!|, R|ft!|>(foo3@fun (x: R|ft!|): R|kotlin/String| { + Q|JavaUsage|.R|/JavaUsage.foo3|!|, R|ft!|>(foo3@fun (x: R|ft!|): R|ft!| { ^ R|/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|() } , Int(1)) - Q|JavaUsage|.R|/JavaUsage.foo3|!|, R|ft!|>(foo3@fun (x: R|kotlin/Number|): R|kotlin/String| { + Q|JavaUsage|.R|/JavaUsage.foo3|!|, R|ft!|>(foo3@fun (x: R|kotlin/Number|): R|ft!| { ^ R|/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|() } , Int(2)) diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.fir.txt b/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.fir.txt index b2161f7954e..04e92984f55 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/kotlinSam.fir.txt @@ -38,12 +38,12 @@ FILE: kotlinSam.kt } ) R|/foo1|(R|/f|) - #( = foo2@fun (x: R|kotlin/Nothing|): R|kotlin/Boolean| { + #( = foo2@fun (x: R|kotlin/Nothing|): R|kotlin/Nothing| { ^ CMP(>, R|/x|.#(Int(1))) } ) #(R|/f|) - #( = foo3@fun (x: R|kotlin/Nothing|): R|kotlin/Boolean| { + #( = foo3@fun (x: R|kotlin/Nothing|): R|kotlin/Nothing| { ^ CMP(>, R|/x|.#(Int(1))) } ) diff --git a/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.fir.txt b/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.fir.txt index d8145c5f91d..6bc71ae1046 100644 --- a/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/samConversions/notSamBecauseOfSupertype.fir.txt @@ -2,7 +2,7 @@ FILE: main.kt public final fun foo(m: R|MyRunnable|): R|kotlin/Unit| { } public final fun main(): R|kotlin/Unit| { - Q|JavaUsage|.#( = foo@fun (x: R|kotlin/Nothing|): R|kotlin/Boolean| { + Q|JavaUsage|.#( = foo@fun (x: R|kotlin/Nothing|): R|kotlin/Nothing| { ^ CMP(>, R|/x|.#(Int(1))) } ) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.fir.txt index 8ed1ac98753..a4aada100e8 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/implicitTypes.fir.txt @@ -11,6 +11,6 @@ FILE: implicitTypes.kt public final fun loop1(): R|(kotlin/Any?) -> kotlin/Nothing| { ^loop1 #(::#) } - public final fun loop2(): R|ERROR CLASS: cycle| { + public final fun loop2(): { ^loop2 R|/loop1|() } diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.fir.txt index 5b1e9a42bf7..f378e0039a4 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/MyMap.fir.txt @@ -1,6 +1,6 @@ FILE: test.kt public final fun test(map: R|MyMap|): R|kotlin/Unit| { - lval result: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = R|/map|.R|kotlin/collections/getOrPut|!|, R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|>(String(key), = getOrPut@fun (): R|kotlin/String| { + lval result: R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| = R|/map|.R|kotlin/collections/getOrPut|!|, R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!|>(String(key), = getOrPut@fun (): R|ft<@FlexibleNullability kotlin/String, kotlin/String?>!| { ^ String(value) } ) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index b18d5c3f97f..58e5d30c9b8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -143,6 +143,9 @@ abstract class FirDataFlowAnalyzer( return graphBuilder.returnExpressionsOfAnonymousFunction(function) } + fun isThereControlFlowInfoForAnonymousFunction(function: FirAnonymousFunction): Boolean = + graphBuilder.isThereControlFlowInfoForAnonymousFunction(function) + fun dropSubgraphFromCall(call: FirFunctionCall) { graphBuilder.dropSubgraphFromCall(call) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index 864bd9c0f44..3a3e2ac5653 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -120,6 +120,11 @@ class ControlFlowGraphBuilder { // ----------------------------------- Public API ----------------------------------- + fun isThereControlFlowInfoForAnonymousFunction(function: FirAnonymousFunction): Boolean = + function.controlFlowGraphReference?.controlFlowGraph != null || + exitsOfAnonymousFunctions.containsKey(function.symbol) + + // This function might throw exception if !isThereControlFlowInfoForAnonymousFunction(function) fun returnExpressionsOfAnonymousFunction(function: FirAnonymousFunction): Collection { fun FirElement.extractArgument(): FirElement = when { this is FirReturnExpression && target.labeledElement.symbol == function.symbol -> result.extractArgument() diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt index f2f93c05862..4ecdeb9444f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirCallCompletionResultsWriterTransformer.kt @@ -19,10 +19,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.FirErrorReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.varargElementType import org.jetbrains.kotlin.fir.resolve.dfa.FirDataFlowAnalyzer -import org.jetbrains.kotlin.fir.resolve.inference.inferenceComponents -import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType -import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType -import org.jetbrains.kotlin.fir.resolve.inference.returnType +import org.jetbrains.kotlin.fir.resolve.inference.* import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirArrayOfCallTransformer import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.remapArgumentsWithVararg @@ -340,14 +337,22 @@ class FirCallCompletionResultsWriterTransformer( .let { finalSubstitutor.substituteOrSelf(it) } private fun Candidate.createArgumentsMapping(): ExpectedArgumentType? { - return argumentMapping?.map { (argument, valueParameter) -> + val lambdasReturnType = postponedAtoms.filterIsInstance().associate { + Pair(it.atom, finalSubstitutor.substituteOrSelf(substitutor.substituteOrSelf(it.returnType))) + } + + val arguments = argumentMapping?.map { (argument, valueParameter) -> val expectedType = if (valueParameter.isVararg) { valueParameter.returnTypeRef.substitute(this).varargElementType() } else { valueParameter.returnTypeRef.substitute(this) } argument.unwrapArgument() to expectedType - }?.toMap()?.toExpectedType() + }?.toMap() + + + if (lambdasReturnType.isEmpty() && arguments.isNullOrEmpty()) return null + return ExpectedArgumentType.ArgumentsMap(arguments ?: emptyMap(), lambdasReturnType) } override fun transformDelegatedConstructorCall( @@ -425,6 +430,13 @@ class FirCallCompletionResultsWriterTransformer( anonymousFunction: FirAnonymousFunction, data: ExpectedArgumentType?, ): CompositeTransformResult { + // This case is not common, and happens when there are anonymous function arguments that aren't mapped to any parameter in the call + // So, we don't run body resolve transformation for them, thus there's no control flow info either + // Control flow info is necessary prerequisite because we collect return expressions in that function + // + // Example: second lambda in the call like list.filter({}, {}) + if (!dataFlowAnalyzer.isThereControlFlowInfoForAnonymousFunction(anonymousFunction)) return anonymousFunction.compose() + val expectedType = data?.getExpectedType(anonymousFunction)?.let { expectedArgumentType -> // From the argument mapping, the expected type of this anonymous function would be: when { @@ -455,10 +467,13 @@ class FirCallCompletionResultsWriterTransformer( needUpdateLambdaType = true } - val expectedReturnType = expectedType?.returnType(session) as? ConeClassLikeType val initialType = anonymousFunction.returnTypeRef.coneTypeSafe() - if (initialType != null) { - val finalType = expectedReturnType ?: finalSubstitutor.substituteOrNull(initialType) + val finalType = + expectedType?.returnType(session) as? ConeClassLikeType + ?: (data as? ExpectedArgumentType.ArgumentsMap)?.lambdasReturnTypes?.get(anonymousFunction) + ?: initialType?.let(finalSubstitutor::substituteOrSelf) + + if (finalType != null) { val resultType = anonymousFunction.returnTypeRef.withReplacedConeType(finalType) anonymousFunction.transformReturnTypeRef(StoreType, resultType) needUpdateLambdaType = true @@ -472,19 +487,24 @@ class FirCallCompletionResultsWriterTransformer( val result = transformElement(anonymousFunction, null) + val returnExpressionsOfAnonymousFunction: Collection = + dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(anonymousFunction) + for (expression in returnExpressionsOfAnonymousFunction) { + expression.transform(this, finalType?.toExpectedType()) + } + val resultFunction = result.single if (resultFunction.returnTypeRef.coneTypeSafe() != null) { - val blockType = resultFunction.body?.typeRef?.coneTypeSafe() - resultFunction.replaceReturnTypeRef(resultFunction.returnTypeRef.withReplacedConeType(blockType)) + val lastExpressionType = + (returnExpressionsOfAnonymousFunction.lastOrNull() as? FirExpression) + ?.typeRef?.coneTypeSafe() + + resultFunction.replaceReturnTypeRef(resultFunction.returnTypeRef.withReplacedConeType(lastExpressionType)) resultFunction.replaceTypeRef( resultFunction.constructFunctionalTypeRef(isSuspend = expectedType?.isSuspendFunctionType(session) == true) ) } - for (expression in dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(anonymousFunction)) { - expression.transform(this, null) - } - return result } @@ -622,7 +642,11 @@ class FirCallCompletionResultsWriterTransformer( } sealed class ExpectedArgumentType { - class ArgumentsMap(val map: Map) : ExpectedArgumentType() + class ArgumentsMap( + val map: Map, + val lambdasReturnTypes: Map + ) : ExpectedArgumentType() + class ExpectedType(val type: ConeKotlinType) : ExpectedArgumentType() object NoApproximation : ExpectedArgumentType() } @@ -633,7 +657,6 @@ private fun ExpectedArgumentType.getExpectedType(argument: FirExpression): ConeK ExpectedArgumentType.NoApproximation -> null } -private fun Map.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ArgumentsMap(this) fun ConeKotlinType.toExpectedType(): ExpectedArgumentType = ExpectedArgumentType.ExpectedType(this) private fun FirExpression.unwrapArgument(): FirExpression = when (this) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt index e4b3acf1a51..b2d3da6bd55 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt @@ -9,7 +9,9 @@ import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind -import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.FirBlock +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression import org.jetbrains.kotlin.fir.expressions.builder.buildVarargArgumentsExpression import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol @@ -83,7 +85,6 @@ internal fun remapArgumentsWithVararg( fun FirBlock.writeResultType(session: FirSession) { val resultExpression = when (val statement = statements.lastOrNull()) { - is FirReturnExpression -> statement.result is FirExpression -> statement else -> null } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index 0d59e01234a..6fc9b4397a9 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -37,6 +37,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildImplicitTypeRef import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult import org.jetbrains.kotlin.utils.addToStdlib.safeAs open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) { @@ -442,7 +443,23 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor val body = result.body if (result.returnTypeRef is FirImplicitTypeRef && body != null) { - result.transformReturnTypeRef(transformer, withExpectedType(body.resultType)) + // TODO: This part seems unnecessary because for lambdas in dependent context will be completed and their type + // should be replaced there properly + val returnType = + dataFlowAnalyzer.returnExpressionsOfAnonymousFunction(result) + .firstNotNullResult { (it as? FirExpression)?.resultType?.coneTypeSafe() } + + if (returnType != null) { + result.transformReturnTypeRef(transformer, withExpectedType(returnType)) + } else { + result.transformReturnTypeRef( + transformer, + withExpectedType(buildErrorTypeRef { + diagnostic = + ConeSimpleDiagnostic("Unresolved lambda return type", DiagnosticKind.InferenceError) + }) + ) + } } return result } @@ -506,11 +523,12 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor val body = result.body if (result.returnTypeRef is FirImplicitTypeRef) { val simpleFunction = function as? FirSimpleFunction - if (body != null) { + val returnExpression = (body?.statements?.single() as? FirReturnExpression)?.result + if (returnExpression != null && returnExpression.typeRef is FirResolvedTypeRef) { result.transformReturnTypeRef( transformer, withExpectedType( - body.resultType.approximatedIfNeededOrSelf( + returnExpression.resultType.approximatedIfNeededOrSelf( inferenceComponents.approximator, simpleFunction?.visibility, simpleFunction?.isInline == true ) ) diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt index a81462a07eb..d4621f45e1a 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.kt.txt @@ -6,14 +6,14 @@ fun test1(): J { } fun test2(): J { - return local fun (x: String): String { + return local fun (x: String): String? { return x } /*-> J */ } fun test3() { - return bar(j = local fun (x: String): String { + return bar(j = local fun (x: String): String? { return x } /*-> J? */) diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt index f42df5fa5fd..00e1e8586da 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.fir.txt @@ -13,11 +13,11 @@ FILE fqName: fileName:/samConversionToGeneric.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (): .J declared in ' TYPE_OP type=.J origin=SAM_CONVERSION typeOperand=.J - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String + FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String? VALUE_PARAMETER name:x index:0 type:kotlin.String BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (x: kotlin.String): kotlin.String declared in .test2' + RETURN type=kotlin.Nothing from='local final fun (x: kotlin.String): kotlin.String? declared in .test2' GET_VAR 'x: kotlin.String declared in .test2.' type=kotlin.String origin=null FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY @@ -25,11 +25,11 @@ FILE fqName: fileName:/samConversionToGeneric.kt CALL 'public open fun bar (j: .J.H.bar?>?): kotlin.Unit declared in .H' type=kotlin.Unit origin=null : kotlin.String? j: TYPE_OP type=.J.H.bar?>? origin=SAM_CONVERSION typeOperand=.J.H.bar?>? - FUN_EXPR type=kotlin.Function1 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String + FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String? VALUE_PARAMETER name:x index:0 type:kotlin.String BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (x: kotlin.String): kotlin.String declared in .test3' + RETURN type=kotlin.Nothing from='local final fun (x: kotlin.String): kotlin.String? declared in .test3' GET_VAR 'x: kotlin.String declared in .test3.' type=kotlin.String origin=null FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit VALUE_PARAMETER name:a index:0 type:kotlin.Any diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.kt.txt index ab0c1e2394d..a0f93bc18b4 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.kt.txt @@ -3,8 +3,9 @@ fun useTX(x: T, fn: Function0): T { } fun testNoNullCheck(xs: Array) { - useTX(x = xs, fn = local fun (): String? { + useTX(x = xs, fn = local fun (): Serializable? { return string() } ) /*~> Unit */ } + diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt index 09ed2f34a77..dda3f0be796 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt @@ -14,8 +14,8 @@ FILE fqName: fileName:/stringVsTXArray.kt CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=java.io.Serializable? origin=null : java.io.Serializable? x: GET_VAR 'xs: kotlin.Array declared in .testNoNullCheck' type=kotlin.Array origin=null - fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:java.io.Serializable? BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .testNoNullCheck' + RETURN type=kotlin.Nothing from='local final fun (): java.io.Serializable? declared in .testNoNullCheck' CALL 'public open fun string (): kotlin.String? declared in .J' type=kotlin.String? origin=null From a13eb4c8e622de0eedcc714a7fc9a7ea38b91b45 Mon Sep 17 00:00:00 2001 From: scaventz Date: Thu, 14 Jan 2021 00:04:48 +0800 Subject: [PATCH 075/122] Ant task: do not include runtime by default if destination is a jar --- .../jetbrains/kotlin/ant/Kotlin2JvmTask.kt | 2 +- .../build.log.expected | 16 ++++++++ .../doNotIncludeRuntimeByDefault/build.xml | 41 +++++++++++++++++++ .../jvm/doNotIncludeRuntimeByDefault/test.kt | 14 +++++++ .../integration/ant/jvm/kt11995/build.xml | 2 +- .../integration/AntTaskTestGenerated.java | 5 +++ 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.log.expected create mode 100644 compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.xml create mode 100644 compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt diff --git a/ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt b/ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt index 33f946e31f5..1765dfd15b2 100644 --- a/ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt +++ b/ant/src/org/jetbrains/kotlin/ant/Kotlin2JvmTask.kt @@ -26,7 +26,7 @@ import java.io.File.separator class Kotlin2JvmTask : KotlinCompilerBaseTask() { override val compilerFqName = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler" - var includeRuntime: Boolean = true + var includeRuntime: Boolean = false var moduleName: String? = null var noReflect: Boolean = false diff --git a/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.log.expected b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.log.expected new file mode 100644 index 00000000000..de2e3d06fa4 --- /dev/null +++ b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.log.expected @@ -0,0 +1,16 @@ +OUT: +Buildfile: [TestData]/build.xml + +test1: + [kotlinc] Compiling [[TestData]/test.kt] => [[Temp]/test.jar] + +test2: + [kotlinc] Compiling [[TestData]/test.kt] => [[Temp]/test.jar] + +test3: + [kotlinc] Compiling [[TestData]/test.kt] => [[Temp]/test.jar] + +BUILD SUCCESSFUL +Total time: [time] + +Return code: 0 diff --git a/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.xml b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.xml new file mode 100644 index 00000000000..11e264852f5 --- /dev/null +++ b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/build.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt new file mode 100644 index 00000000000..700dece245f --- /dev/null +++ b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt @@ -0,0 +1,14 @@ +import java.io.File +import java.util.jar.JarFile + +fun main(args: Array) { + val jar = File(args[0]) + // if "includeRuntime" is specified to be true + var specifiedBeTrue = args[1].toBoolean() + for (entry in JarFile(jar).entries()) { + if (!specifiedBeTrue && entry.name.startsWith("kotlin/")) { + println("Error: Kotlin runtime is expected to be excluded if the attribute \"includeRuntime\" is not specified to be true") + break; + } + } +} diff --git a/compiler/testData/integration/ant/jvm/kt11995/build.xml b/compiler/testData/integration/ant/jvm/kt11995/build.xml index 48b401de372..0ec394417e4 100644 --- a/compiler/testData/integration/ant/jvm/kt11995/build.xml +++ b/compiler/testData/integration/ant/jvm/kt11995/build.xml @@ -2,7 +2,7 @@ - + diff --git a/compiler/tests-gen/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java index 42359965240..6b1d770aa8c 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/integration/AntTaskTestGenerated.java @@ -39,6 +39,11 @@ public class AntTaskTestGenerated extends AbstractAntTaskTest { runTest("compiler/testData/integration/ant/jvm/doNotFailOnError/"); } + @TestMetadata("doNotIncludeRuntimeByDefault") + public void testDoNotIncludeRuntimeByDefault() throws Exception { + runTest("compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/"); + } + @TestMetadata("failOnErrorByDefault") public void testFailOnErrorByDefault() throws Exception { runTest("compiler/testData/integration/ant/jvm/failOnErrorByDefault/"); From e17153fab93ad961d0ec0be8e86675aa52e3d877 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 21 Jan 2021 18:25:49 +0100 Subject: [PATCH 076/122] Minor, improve Ant test on includeRuntime Also check that we _do_ include runtime if includeRuntime is true. --- .../ant/jvm/doNotIncludeRuntimeByDefault/test.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt index 700dece245f..4742e5b0fa3 100644 --- a/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt +++ b/compiler/testData/integration/ant/jvm/doNotIncludeRuntimeByDefault/test.kt @@ -4,11 +4,12 @@ import java.util.jar.JarFile fun main(args: Array) { val jar = File(args[0]) // if "includeRuntime" is specified to be true - var specifiedBeTrue = args[1].toBoolean() - for (entry in JarFile(jar).entries()) { - if (!specifiedBeTrue && entry.name.startsWith("kotlin/")) { - println("Error: Kotlin runtime is expected to be excluded if the attribute \"includeRuntime\" is not specified to be true") - break; - } + var shouldIncludeRuntime = args[1].toBoolean() + val hasKotlinPackage = JarFile(jar).entries().toList().any { it.name.startsWith("kotlin/") } + if (shouldIncludeRuntime != hasKotlinPackage) { + println( + "Error: Kotlin runtime is expected to be included only if the attribute \"includeRuntime\" is specified to be true\n" + + "includeRuntime = ${shouldIncludeRuntime}; hasKotlinPackage = $hasKotlinPackage" + ) } } From 28cff22cd0243d5c8bd8984c60e2baf95c13ea64 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 15 Jan 2021 14:01:42 +0300 Subject: [PATCH 077/122] [Test] Add ability to specify directive for test file Rules of directives resolving: - If no `MODULE` or `FILE` was declared in test then all directives belongs to module - If `FILE` is declared, then all directives after it will belong to file until next `FILE` or `MODULE` directive will be declared - All directives between `MODULE` and `FILE` directives belongs to module - All directives before first `MODULE` are global and belongs to each declared module --- .../jetbrains/kotlin/test/model/Modules.kt | 3 +- .../test/services/AdditionalSourceProvider.kt | 9 +++++- .../impl/ModuleStructureExtractorImpl.kt | 28 ++++++++++++++++--- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt index c2a02684c46..0996531b75b 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt @@ -43,7 +43,8 @@ class TestFile( * isAdditional means that this file provided as addition to sources of testdata * and there is no need to apply any handlers or preprocessors over it */ - val isAdditional: Boolean + val isAdditional: Boolean, + val directives: RegisteredDirectives ) { val name: String = relativePath.split("/").last() } diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/AdditionalSourceProvider.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/AdditionalSourceProvider.kt index 10a4548248f..22642e37ea5 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/AdditionalSourceProvider.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/AdditionalSourceProvider.kt @@ -26,7 +26,14 @@ abstract class AdditionalSourceProvider(val testServices: TestServices) { } protected fun File.toTestFile(): TestFile { - return TestFile(this.name, this.readText(), this, startLineNumberInOriginalFile = 0, isAdditional = true) + return TestFile( + this.name, + this.readText(), + originalFile = this, + startLineNumberInOriginalFile = 0, + isAdditional = true, + directives = RegisteredDirectives.Empty + ) } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt index b0af28598bc..ec63451a9d9 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt @@ -25,6 +25,14 @@ import org.jetbrains.kotlin.test.util.joinToArrayString import org.jetbrains.kotlin.utils.DFS import java.io.File +/* + * Rules of directives resolving: + * - If no `MODULE` or `FILE` was declared in test then all directives belongs to module + * - If `FILE` is declared, then all directives after it will belong to + * file until next `FILE` or `MODULE` directive will be declared + * - All directives between `MODULE` and `FILE` directives belongs to module + * - All directives before first `MODULE` are global and belongs to each declared module + */ class ModuleStructureExtractorImpl( testServices: TestServices, additionalSourceProviders: List, @@ -32,6 +40,7 @@ class ModuleStructureExtractorImpl( ) : ModuleStructureExtractor(testServices, additionalSourceProviders) { companion object { private val allowedExtensionsForFiles = listOf(".kt", ".kts", ".java") + /* * ([\w-]+) module name * \((.*?)\) module dependencies @@ -82,12 +91,14 @@ class ModuleStructureExtractorImpl( private var startLineNumberOfCurrentFile = 0 private var directivesBuilder = RegisteredDirectivesParser(directivesContainer, assertions) + private var moduleDirectivesBuilder: RegisteredDirectivesParser = directivesBuilder + private var fileDirectivesBuilder: RegisteredDirectivesParser? = null private var globalDirectives: RegisteredDirectives? = null private val modules = mutableListOf() - private val moduleDirectiveBuilder = RegisteredDirectivesParser(ModuleStructureDirectives, assertions) + private val moduleStructureDirectiveBuilder = RegisteredDirectivesParser(ModuleStructureDirectives, assertions) fun splitTestDataByModules(): TestModuleStructure { for (testDataFile in testDataFiles) { @@ -143,7 +154,7 @@ class ModuleStructureExtractorImpl( */ private fun tryParseStructureDirective(rawDirective: RegisteredDirectivesParser.RawDirective?, lineNumber: Int): Boolean { if (rawDirective == null) return false - val (directive, values) = moduleDirectiveBuilder.convertToRegisteredDirective(rawDirective) ?: return false + val (directive, values) = moduleStructureDirectiveBuilder.convertToRegisteredDirective(rawDirective) ?: return false when (directive) { ModuleStructureDirectives.MODULE -> { /* @@ -236,7 +247,7 @@ class ModuleStructureExtractorImpl( private fun finishModule() { finishFile() - val moduleDirectives = directivesBuilder.build() + testServices.defaultDirectives + globalDirectives + val moduleDirectives = moduleDirectivesBuilder.build() + testServices.defaultDirectives + globalDirectives currentModuleLanguageVersionSettingsBuilder.configureUsingDirectives(moduleDirectives, environmentConfigurators) val moduleName = currentModuleName ?: defaultModuleName val testModule = TestModule( @@ -293,7 +304,8 @@ class ModuleStructureExtractorImpl( originalContent = linesOfCurrentFile.joinToString(separator = "\n", postfix = "\n"), originalFile = currentTestDataFile, startLineNumberInOriginalFile = startLineNumberOfCurrentFile, - isAdditional = false + isAdditional = false, + directives = fileDirectivesBuilder?.build() ?: RegisteredDirectives.Empty ) ) firstFileInModule = false @@ -310,15 +322,23 @@ class ModuleStructureExtractorImpl( filesOfCurrentModule = mutableListOf() dependenciesOfCurrentModule = mutableListOf() friendsOfCurrentModule = mutableListOf() + resetDirectivesBuilder() + moduleDirectivesBuilder = directivesBuilder + } + + private fun resetDirectivesBuilder() { directivesBuilder = RegisteredDirectivesParser(directivesContainer, assertions) } private fun resetFileCaches() { if (!firstFileInModule) { linesOfCurrentFile = mutableListOf() + moduleDirectivesBuilder = directivesBuilder } currentFileName = null startLineNumberOfCurrentFile = 0 + resetDirectivesBuilder() + fileDirectivesBuilder = directivesBuilder } private fun tryParseRegularDirective(rawDirective: RegisteredDirectivesParser.RawDirective?) { From 6a7cd0c81141e78b477ffa6454ce707337c9860f Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 15 Jan 2021 14:54:05 +0300 Subject: [PATCH 078/122] [Test] Add ability to specify applicability of diagnostic to module or file --- .../resolve/expresssions/genericDescriptor.kt | 2 +- .../resolve/expresssions/genericDiagnostic.kt | 2 +- .../j+k/StaticGenericMethod.kt | 4 +- .../kotlin/test/directives/model/Directive.kt | 41 +++++++++++++++---- .../directives/model/DirectivesContainer.kt | 20 ++++++--- .../multiModule/inlineCrossModule.kt | 2 +- .../inlineFunctionWithOptionalParam.kt | 2 +- .../box/delegation/byMiddleInterface.kt | 2 +- .../codegen/box/delegation/defaultOverride.kt | 2 +- .../codegen/box/delegation/diamond.kt | 2 +- .../codegen/box/delegation/diamond2.kt | 2 +- .../box/delegation/inClassDeclaration.kt | 2 +- .../testData/codegen/box/delegation/mixed.kt | 2 +- .../testData/codegen/box/delegation/simple.kt | 2 +- .../codegen/box/delegation/simple1.0.kt | 2 +- .../box/fakeOverride/privateFakeOverrides0.kt | 2 +- .../box/fakeOverride/privateFakeOverrides1.kt | 2 +- .../box/javaInterop/generics/kt42824.kt | 8 ++-- .../box/javaInterop/generics/kt42825.kt | 8 ++-- .../notNullAssertions/functionAssertion.kt | 4 +- ...NullabilityAssertionOnExtensionReceiver.kt | 2 +- ...ionOnExtensionReceiverInPrivateOperator.kt | 2 +- .../jvm8/defaults/allCompatibility/bridge.kt | 4 +- .../jvm8/defaults/allCompatibility/bridge2.kt | 4 +- .../jvm8/defaults/allCompatibility/bridge3.kt | 4 +- .../allCompatibility/bridgeWithProperties.kt | 4 +- .../allCompatibility/bridgeWithProperties2.kt | 4 +- .../allCompatibility/bridgeWithProperties3.kt | 4 +- .../allCompatibility/callStackTrace.kt | 3 +- .../allCompatibility/inheritedJvmDefault.kt | 4 +- .../allCompatibility/simpleFunction.kt | 4 +- .../box/jvm8/defaults/compatibility/bridge.kt | 4 +- .../jvm8/defaults/compatibility/bridge2.kt | 4 +- .../jvm8/defaults/compatibility/bridge3.kt | 4 +- .../compatibility/bridgeWithProperties.kt | 4 +- .../compatibility/bridgeWithProperties2.kt | 4 +- .../compatibility/bridgeWithProperties3.kt | 4 +- .../compatibility/inheritedJvmDefault.kt | 4 +- .../defaults/compatibility/simpleFunction.kt | 4 +- .../codegen/box/jvm8/defaults/kt40920.kt | 4 +- .../jvm8/defaults/noDefaultImpls/bridge.kt | 4 +- .../jvm8/defaults/noDefaultImpls/bridge2.kt | 4 +- .../jvm8/defaults/noDefaultImpls/bridge3.kt | 4 +- .../noDefaultImpls/bridgeWithProperties.kt | 4 +- .../noDefaultImpls/bridgeWithProperties2.kt | 4 +- .../noDefaultImpls/bridgeWithProperties3.kt | 4 +- .../noDefaultImpls/inheritedJvmDefault.kt | 4 +- .../jvm8/defaults/noDefaultImpls/kt40920.kt | 4 +- .../defaults/noDefaultImpls/simpleFunction.kt | 4 +- .../box/jvm8/interfaceFlag/superCall.kt | 4 +- .../jvm8/interfaceFlag/superCallIndirect.kt | 4 +- .../jvm8/javaDefaults/capturedSuperCall.kt | 2 +- .../defaultMethodCallFromInterface.kt | 2 +- .../javaDefaults/defaultMethodCallViaClass.kt | 2 +- .../defaultMethodCallViaInterface.kt | 2 +- .../javaDefaults/defaultMethodOverride.kt | 2 +- .../dontDelegateToDefaultMethods.kt | 2 +- .../box/jvm8/javaDefaults/inheritKotlin.kt | 2 +- .../javaDefaults/invokeDefaultViaSuper.kt | 2 +- .../codegen/box/jvm8/javaDefaults/kt40920.kt | 2 +- .../box/jvm8/javaDefaults/kt40920_java.kt | 2 +- .../box/jvm8/javaDefaults/kt40920_java2.kt | 2 +- .../box/jvm8/javaDefaults/kt40920_map.kt | 4 +- ...ChainOfKotlinExtendsFromJavaWithDefault.kt | 2 +- .../samOnInterfaceWithDefaultMethod.kt | 2 +- ...ExtensionReceiverInPrivateOperator_lv11.kt | 4 +- ...bilityAssertionOnExtensionReceiver_lv11.kt | 2 +- .../defaultAndNamedCombination.kt | 2 +- .../signatureAnnotations/defaultBoxTypes.kt | 4 +- .../signatureAnnotations/defaultEnumType.kt | 2 +- .../defaultLongLiteral.kt | 2 +- .../defaultMultipleParams.kt | 2 +- .../box/signatureAnnotations/defaultNull.kt | 4 +- .../defaultNullableBoxTypes.kt | 4 +- .../signatureAnnotations/defaultOverrides.kt | 4 +- .../defaultPrimitiveTypes.kt | 2 +- .../defaultValueInConstructor.kt | 2 +- .../defaultWithJavaBase.kt | 2 +- .../reorderedParameterNames.kt | 4 +- .../box/traits/multipleImplFromJava.kt | 2 +- ...ntersectionTypesWithDifferentBounds.fir.kt | 2 +- ...bleIntersectionTypesWithDifferentBounds.kt | 2 +- .../signatureAnnotations/defaultEnum.fir.kt | 4 +- .../j+k/signatureAnnotations/defaultEnum.kt | 4 +- .../defaultLongLiteral.fir.kt | 2 +- .../defaultLongLiteral.kt | 2 +- .../signatureAnnotations/defaultNull.fir.kt | 4 +- .../j+k/signatureAnnotations/defaultNull.kt | 4 +- .../defaultNullAndParameter.kt | 2 +- .../defaultParameter.fir.kt | 2 +- .../signatureAnnotations/defaultParameter.kt | 2 +- .../emptyParameterName.fir.kt | 4 +- .../emptyParameterName.kt | 4 +- .../overridesDefaultValue.fir.kt | 2 +- .../overridesDefaultValue.kt | 2 +- .../overridesParameterName.fir.kt | 2 +- .../overridesParameterName.kt | 2 +- .../reorderedParameterNames.kt | 4 +- .../sameParameterName.fir.kt | 4 +- .../signatureAnnotations/sameParameterName.kt | 4 +- .../specialCharsParameterName.fir.kt | 4 +- .../specialCharsParameterName.kt | 4 +- .../stableParameterName.kt | 2 +- .../staticMethodWithDefaultValue.kt | 2 +- ...NullTypeParameterWithKotlinNullable.fir.kt | 2 +- .../notNullTypeParameterWithKotlinNullable.kt | 2 +- ...ParameterWithKotlinNullableWarnings.fir.kt | 2 +- ...TypeParameterWithKotlinNullableWarnings.kt | 2 +- .../duplicateClass/collectionMethodStub.kt | 4 +- .../InaccessibleInternalClass.fir.kt | 2 +- .../InaccessibleInternalClass.kt | 2 +- .../inference/performance/kt41741.kt | 2 +- .../testData/foreignAnnotations/tests/aosp.kt | 2 +- .../test/directives/CodegenTestDirectives.kt | 11 +++-- .../test/directives/DiagnosticsDirectives.kt | 3 ++ .../directives/FirDiagnosticsDirectives.kt | 13 ++++-- .../impl/ModuleStructureExtractorImpl.kt | 34 ++++++++++++++- 117 files changed, 266 insertions(+), 189 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDescriptor.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDescriptor.kt index 4f8e72981ba..8c23920ad8c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDescriptor.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDescriptor.kt @@ -1,5 +1,5 @@ -// FILE: Descriptor.java // FULL_JDK +// FILE: Descriptor.java public interface Descriptor diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDiagnostic.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDiagnostic.kt index 4a982f1cc1d..48b47cd69e4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDiagnostic.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/genericDiagnostic.kt @@ -1,5 +1,5 @@ -// FILE: Element.java // FULL_JDK +// FILE: Element.java public interface Element {} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/StaticGenericMethod.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/StaticGenericMethod.kt index bfc2106cbb7..0a6dfd93d20 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/StaticGenericMethod.kt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k/StaticGenericMethod.kt @@ -1,5 +1,5 @@ -// FILE: StaticOwner.java // FULL_JDK +// FILE: StaticOwner.java import org.jetbrains.annotations.NotNull; @@ -21,4 +21,4 @@ abstract class User { fun foo() { settings = StaticOwner.newInstance(settings.javaClass) } -} \ No newline at end of file +} diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/Directive.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/Directive.kt index 024bcd7bb0a..621eb3a88fd 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/Directive.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/Directive.kt @@ -9,7 +9,18 @@ import org.jetbrains.kotlin.test.util.joinToArrayString // --------------------------- Directive declaration --------------------------- -sealed class Directive(val name: String, val description: String) { +enum class DirectiveApplicability( + val forGlobal: Boolean = false, + val forModule: Boolean = false, + val forFile: Boolean = false +) { + Any(forGlobal = true, forModule = true, forFile = true), + Global(forGlobal = true, forModule = true), + Module(forModule = true), + File(forFile = true) +} + +sealed class Directive(val name: String, val description: String, val applicability: DirectiveApplicability) { override fun toString(): String { return name } @@ -17,23 +28,26 @@ sealed class Directive(val name: String, val description: String) { class SimpleDirective( name: String, - description: String -) : Directive(name, description) + description: String, + applicability: DirectiveApplicability +) : Directive(name, description, applicability) class StringDirective( name: String, - description: String -) : Directive(name, description) + description: String, + applicability: DirectiveApplicability +) : Directive(name, description, applicability) class ValueDirective( name: String, description: String, + applicability: DirectiveApplicability, val parser: (String) -> T? -) : Directive(name, description) +) : Directive(name, description, applicability) // --------------------------- Registered directive --------------------------- -abstract class RegisteredDirectives { +abstract class RegisteredDirectives : Iterable { companion object { val Empty = RegisteredDirectivesImpl(emptyList(), emptyMap(), emptyMap()) } @@ -78,6 +92,15 @@ class RegisteredDirectivesImpl( valueDirectives.forEach { (d, v) -> appendLine(" $d: ${v.joinToArrayString()}")} } } + + @OptIn(ExperimentalStdlibApi::class) + override fun iterator(): Iterator { + return buildList { + addAll(simpleDirectives) + addAll(stringDirectives.keys) + addAll(valueDirectives.keys) + }.iterator() + } } class ComposedRegisteredDirectives( @@ -109,6 +132,10 @@ class ComposedRegisteredDirectives( override fun isEmpty(): Boolean { return containers.all { it.isEmpty() } } + + override fun iterator(): Iterator { + return containers.flatten().iterator() + } } // --------------------------- Utils --------------------------- diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/DirectivesContainer.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/DirectivesContainer.kt index 00d6288a5f8..3446b5a60ca 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/DirectivesContainer.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/directives/model/DirectivesContainer.kt @@ -20,28 +20,36 @@ abstract class SimpleDirectivesContainer : DirectivesContainer() { override operator fun get(name: String): Directive? = registeredDirectives[name] - protected fun directive(description: String): DirectiveDelegateProvider { - return DirectiveDelegateProvider { SimpleDirective(it, description) } + protected fun directive( + description: String, + applicability: DirectiveApplicability = DirectiveApplicability.Global + ): DirectiveDelegateProvider { + return DirectiveDelegateProvider { SimpleDirective(it, description, applicability) } } - protected fun stringDirective(description: String): DirectiveDelegateProvider { - return DirectiveDelegateProvider { StringDirective(it, description) } + protected fun stringDirective( + description: String, + applicability: DirectiveApplicability = DirectiveApplicability.Global + ): DirectiveDelegateProvider { + return DirectiveDelegateProvider { StringDirective(it, description, applicability) } } protected inline fun > enumDirective( description: String, + applicability: DirectiveApplicability = DirectiveApplicability.Global, noinline additionalParser: ((String) -> T?)? = null ): DirectiveDelegateProvider> { val possibleValues = enumValues() val parser: (String) -> T? = { value -> possibleValues.firstOrNull { it.name == value } ?: additionalParser?.invoke(value) } - return DirectiveDelegateProvider { ValueDirective(it, description, parser) } + return DirectiveDelegateProvider { ValueDirective(it, description, applicability, parser) } } protected fun valueDirective( description: String, + applicability: DirectiveApplicability = DirectiveApplicability.Global, parser: (String) -> T? ): DirectiveDelegateProvider> { - return DirectiveDelegateProvider { ValueDirective(it, description, parser) } + return DirectiveDelegateProvider { ValueDirective(it, description, applicability, parser) } } protected fun registerDirective(directive: Directive) { diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt index dedd563e500..606a4962d8b 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineCrossModule.kt @@ -18,9 +18,9 @@ suspend fun notInlined( ): R = block() // MODULE: main(lib, support) -// FILE: main.kt // WITH_COROUTINES // WITH_RUNTIME +// FILE: main.kt import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt b/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt index 0988b122ce9..b8b2597b182 100644 --- a/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt +++ b/compiler/testData/codegen/box/coroutines/multiModule/inlineFunctionWithOptionalParam.kt @@ -8,9 +8,9 @@ inline fun foo(x: String = "OK"): String { } // MODULE: main(lib, support) -// FILE: main.kt // WITH_RUNTIME // WITH_COROUTINES +// FILE: main.kt import helpers.* import kotlin.coroutines.* import kotlin.coroutines.intrinsics.* diff --git a/compiler/testData/codegen/box/delegation/byMiddleInterface.kt b/compiler/testData/codegen/box/delegation/byMiddleInterface.kt index f4e61e75afa..9e316f9b5b8 100644 --- a/compiler/testData/codegen/box/delegation/byMiddleInterface.kt +++ b/compiler/testData/codegen/box/delegation/byMiddleInterface.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -10,7 +11,6 @@ public interface Base { } // FILE: main.kt -// JVM_TARGET: 1.8 public interface BaseKotlin : Base { } diff --git a/compiler/testData/codegen/box/delegation/defaultOverride.kt b/compiler/testData/codegen/box/delegation/defaultOverride.kt index 25bdbf7a7f2..4675849a849 100644 --- a/compiler/testData/codegen/box/delegation/defaultOverride.kt +++ b/compiler/testData/codegen/box/delegation/defaultOverride.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -10,7 +11,6 @@ public interface Base { } // FILE: main.kt -// JVM_TARGET: 1.8 public interface BaseKotlin : Base { override fun getValue() = "OK" diff --git a/compiler/testData/codegen/box/delegation/diamond.kt b/compiler/testData/codegen/box/delegation/diamond.kt index 7a539ee55bf..80172e13a7f 100644 --- a/compiler/testData/codegen/box/delegation/diamond.kt +++ b/compiler/testData/codegen/box/delegation/diamond.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -18,7 +19,6 @@ public interface Base2 extends Base { } // FILE: main.kt -// JVM_TARGET: 1.8 interface KBase : Base diff --git a/compiler/testData/codegen/box/delegation/diamond2.kt b/compiler/testData/codegen/box/delegation/diamond2.kt index 251670895cc..1a6d0ccc8c7 100644 --- a/compiler/testData/codegen/box/delegation/diamond2.kt +++ b/compiler/testData/codegen/box/delegation/diamond2.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -17,7 +18,6 @@ public interface Base2 extends Base { // FILE: main.kt -// JVM_TARGET: 1.8 interface KBase : Base { override fun test() = "O" + getValue() diff --git a/compiler/testData/codegen/box/delegation/inClassDeclaration.kt b/compiler/testData/codegen/box/delegation/inClassDeclaration.kt index e29eea6a650..541c697bae7 100644 --- a/compiler/testData/codegen/box/delegation/inClassDeclaration.kt +++ b/compiler/testData/codegen/box/delegation/inClassDeclaration.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -10,7 +11,6 @@ public interface Base { } // FILE: main.kt -// JVM_TARGET: 1.8 class Fail : Base { override fun getValue() = "Fail" diff --git a/compiler/testData/codegen/box/delegation/mixed.kt b/compiler/testData/codegen/box/delegation/mixed.kt index 091fdbfd6e3..f570d9a988b 100644 --- a/compiler/testData/codegen/box/delegation/mixed.kt +++ b/compiler/testData/codegen/box/delegation/mixed.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base extends KBase { @@ -10,7 +11,6 @@ public interface Base extends KBase { } // FILE: main.kt -// JVM_TARGET: 1.8 interface KBase { fun getValue(): String diff --git a/compiler/testData/codegen/box/delegation/simple.kt b/compiler/testData/codegen/box/delegation/simple.kt index 2f176b6a473..d10855a639f 100644 --- a/compiler/testData/codegen/box/delegation/simple.kt +++ b/compiler/testData/codegen/box/delegation/simple.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -10,7 +11,6 @@ public interface Base { } // FILE: main.kt -// JVM_TARGET: 1.8 class Fail : Base { override fun getValue() = "Fail" diff --git a/compiler/testData/codegen/box/delegation/simple1.0.kt b/compiler/testData/codegen/box/delegation/simple1.0.kt index 7d22a09f9ed..904157c6aa7 100644 --- a/compiler/testData/codegen/box/delegation/simple1.0.kt +++ b/compiler/testData/codegen/box/delegation/simple1.0.kt @@ -1,6 +1,7 @@ // !LANGUAGE: -NoDelegationToJavaDefaultInterfaceMembers // IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -12,7 +13,6 @@ public interface Base { } // FILE: main.kt -// JVM_TARGET: 1.8 class OK : Base { override fun getValue() = "OK" diff --git a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt index b4f805a0fe0..ada4c892a50 100644 --- a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt +++ b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides0.kt @@ -1,6 +1,6 @@ // MODULE: lib -// FILE: lib.kt // WITH_RUNTIME +// FILE: lib.kt import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt index b177cc918d0..6317714f618 100644 --- a/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt +++ b/compiler/testData/codegen/box/fakeOverride/privateFakeOverrides1.kt @@ -1,6 +1,6 @@ // MODULE: lib -// FILE: lib.kt // WITH_RUNTIME +// FILE: lib.kt import kotlin.test.assertEquals diff --git a/compiler/testData/codegen/box/javaInterop/generics/kt42824.kt b/compiler/testData/codegen/box/javaInterop/generics/kt42824.kt index c2bc5b7f38c..e79361962eb 100644 --- a/compiler/testData/codegen/box/javaInterop/generics/kt42824.kt +++ b/compiler/testData/codegen/box/javaInterop/generics/kt42824.kt @@ -1,3 +1,6 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS_IR // FILE: DiagnosticFactory0.java import org.jetbrains.annotations.NotNull; @@ -10,9 +13,6 @@ public class DiagnosticFactory0 { } // FILE: test.kt -// DONT_TARGET_EXACT_BACKEND: WASM -// IGNORE_BACKEND: JS -// IGNORE_BACKEND: JS_IR class SimpleDiagnostic(val element: E) interface KtAnnotationEntry @@ -21,4 +21,4 @@ fun foo(error: DiagnosticFactory0, entry: KtAnnotationEntr error.on(entry) // used to be INAPPLICABLE_CANDIDATE } -fun box() = "OK" \ No newline at end of file +fun box() = "OK" diff --git a/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt b/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt index deae821819a..70ade460cbe 100644 --- a/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt +++ b/compiler/testData/codegen/box/javaInterop/generics/kt42825.kt @@ -1,3 +1,6 @@ +// DONT_TARGET_EXACT_BACKEND: WASM +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS_IR // FILE: Processor.java public interface Processor { @@ -5,9 +8,6 @@ public interface Processor { } // FILE: test.kt -// DONT_TARGET_EXACT_BACKEND: WASM -// IGNORE_BACKEND: JS -// IGNORE_BACKEND: JS_IR interface PsiModifierListOwner interface KtClassOrObject { @@ -23,4 +23,4 @@ fun execute(declaration: Any, consumer: Processor) { } } -fun box(): String = "OK" \ No newline at end of file +fun box(): String = "OK" diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/functionAssertion.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/functionAssertion.kt index 3dee7701f44..5a39088ad03 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/functionAssertion.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/functionAssertion.kt @@ -1,5 +1,7 @@ // SKIP_JDK6 // TARGET_BACKEND: JVM +// WITH_RUNTIME +// FULL_JDK // FILE: F.java import java.util.function.Function; @@ -10,8 +12,6 @@ public class F { } // FILE: test.kt -// WITH_RUNTIME -// FULL_JDK fun test(f: (Int?) -> String): String { return F.passNull(f) } diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver.kt index 7eea297f2b7..056f1e429aa 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver.kt @@ -1,6 +1,6 @@ // TARGET_BACKEND: JVM -// FILE: test.kt // WITH_RUNTIME +// FILE: test.kt import kotlin.test.* diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator.kt index 5a1d1602d93..9c18cde65ee 100644 --- a/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator.kt +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator.kt @@ -1,6 +1,6 @@ // TARGET_BACKEND: JVM -// FILE: test.kt // WITH_RUNTIME +// FILE: test.kt import kotlin.test.* diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge.kt index dff26aa4fea..8b893cb39c9 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(p: T): T { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge2.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge2.kt index 2af4393c031..15bdaf20fa4 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge2.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(p: T): T { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt index 9b0580bc2a9..871b6b64213 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface3 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(p: T): T { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt index bfed4e6f0b8..704fc44cde0 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties2.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties2.kt index b61193b1e24..fe86ba1ba17 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties2.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties3.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties3.kt index b4be289cb7c..ef170cae8d8 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties3.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties3.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface3 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/callStackTrace.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/callStackTrace.kt index 66244c9597c..5f398116b70 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/callStackTrace.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/callStackTrace.kt @@ -2,6 +2,7 @@ // TARGET_BACKEND: JVM // FULL_JDK // WITH_RUNTIME +// JVM_TARGET: 1.8 // FILE: Simple.java public interface Simple extends KInterface { @@ -16,8 +17,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun call(): List { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/inheritedJvmDefault.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/inheritedJvmDefault.kt index 86f309e3d4b..ee52eb6b0cf 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/inheritedJvmDefault.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/inheritedJvmDefault.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(): String { diff --git a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/simpleFunction.kt b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/simpleFunction.kt index 829a302d7fc..27d58d78286 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/simpleFunction.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/allCompatibility/simpleFunction.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all-compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(): String { diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge.kt index 4d0b1343e1b..4b44ef3d22a 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { @JvmDefault diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge2.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge2.kt index 5e6b9ec3a41..cb0ce44550d 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge2.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { @JvmDefault diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge3.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge3.kt index e200ae225bf..c254900a5b7 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge3.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridge3.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface3 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { @JvmDefault diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties.kt index e39bc76d620..d90ec95d184 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties2.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties2.kt index eb72cc03ac2..4e2bdcdb094 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties2.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties3.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties3.kt index 55df395bf87..53e346cc884 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties3.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/bridgeWithProperties3.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface3 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedJvmDefault.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedJvmDefault.kt index f031ef38328..0e879b832fe 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedJvmDefault.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/inheritedJvmDefault.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { @JvmDefault diff --git a/compiler/testData/codegen/box/jvm8/defaults/compatibility/simpleFunction.kt b/compiler/testData/codegen/box/jvm8/defaults/compatibility/simpleFunction.kt index f5d9c43ba3c..db7ebb237de 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/compatibility/simpleFunction.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/compatibility/simpleFunction.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: compatibility // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { @JvmDefault diff --git a/compiler/testData/codegen/box/jvm8/defaults/kt40920.kt b/compiler/testData/codegen/box/jvm8/defaults/kt40920.kt index 42bc8c65933..cb9d348c3b0 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/kt40920.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/kt40920.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: enable // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: JBase.java public interface JBase extends Base { @@ -9,8 +11,6 @@ public interface JBase extends Base { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface Base { @JvmDefault diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge.kt index a47031c4e66..080f1da1955 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(p: T): T { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge2.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge2.kt index 32a7e78335d..790dc242ddb 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge2.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(p: T): T { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt index ab8518269a4..48847c91c42 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface3 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(p: T): T { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt index 501a8e65461..ebb2290eb4e 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties2.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties2.kt index 28d1c51cf35..4ddef56ed3f 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties2.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties2.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -16,8 +18,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties3.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties3.kt index cf5eecf6aa5..d7e1531654b 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties3.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties3.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface3 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/inheritedJvmDefault.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/inheritedJvmDefault.kt index 998353b6375..9fcb2f15971 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/inheritedJvmDefault.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/inheritedJvmDefault.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface2 { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(): String { diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt index dcd28bf5b6d..bc147b2f1a4 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: JBase.java public interface JBase extends Base { @@ -9,8 +11,6 @@ public interface JBase extends Base { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface Base { fun test(): String = "Base" diff --git a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/simpleFunction.kt b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/simpleFunction.kt index c3a1e9bbb59..9283a38072f 100644 --- a/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/simpleFunction.kt +++ b/compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/simpleFunction.kt @@ -1,5 +1,7 @@ // !JVM_DEFAULT_MODE: all // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 +// WITH_RUNTIME // FILE: Simple.java public interface Simple extends KInterface { @@ -14,8 +16,6 @@ public class Foo implements Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 -// WITH_RUNTIME interface KInterface { fun test2(): String { diff --git a/compiler/testData/codegen/box/jvm8/interfaceFlag/superCall.kt b/compiler/testData/codegen/box/jvm8/interfaceFlag/superCall.kt index ee22e95abfe..e7ea8f0ed2b 100644 --- a/compiler/testData/codegen/box/jvm8/interfaceFlag/superCall.kt +++ b/compiler/testData/codegen/box/jvm8/interfaceFlag/superCall.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java public interface Simple { @@ -12,7 +13,6 @@ public interface Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 class TestClass : Simple { override fun test(): String { return super.test() @@ -22,4 +22,4 @@ class TestClass : Simple { fun box(): String { return TestClass().test() + Simple.testStatic() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/jvm8/interfaceFlag/superCallIndirect.kt b/compiler/testData/codegen/box/jvm8/interfaceFlag/superCallIndirect.kt index 49d613352bd..ffcb988f250 100644 --- a/compiler/testData/codegen/box/jvm8/interfaceFlag/superCallIndirect.kt +++ b/compiler/testData/codegen/box/jvm8/interfaceFlag/superCallIndirect.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java public interface Simple { @@ -12,7 +13,6 @@ public interface Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 interface KSimple : Simple {} class TestClass : KSimple { @@ -24,4 +24,4 @@ class TestClass : KSimple { fun box(): String { return TestClass().test() + Simple.testStatic() -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/capturedSuperCall.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/capturedSuperCall.kt index 7a154be1009..5757ce97209 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/capturedSuperCall.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/capturedSuperCall.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: IBase.java interface IBase { @@ -8,7 +9,6 @@ interface IBase { } // FILE: Kotlin.kt -// JVM_TARGET: 1.8 open class Base { fun foo() = "OK" } diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallFromInterface.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallFromInterface.kt index df269e8e02a..e8fe1a07f58 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallFromInterface.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallFromInterface.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java public interface Simple { @@ -12,7 +13,6 @@ public interface Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 interface KInterface : Simple { fun bar(): String { return test("O") + Simple.testStatic("O") diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaClass.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaClass.kt index 306986ae137..be17d4985c5 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaClass.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaClass.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java interface Simple { @@ -12,7 +13,6 @@ interface Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 class Test : Simple {} fun box(): String { diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaInterface.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaInterface.kt index c26fb7dff0e..df42e6386de 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaInterface.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodCallViaInterface.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java public interface Simple { @@ -12,7 +13,6 @@ public interface Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 interface TestInterface : Simple {} class Test : TestInterface {} diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodOverride.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodOverride.kt index 6deb9b3d6e9..e6e2c314177 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodOverride.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/defaultMethodOverride.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java public interface Simple { @@ -8,7 +9,6 @@ public interface Simple { } // FILE: main.kt -// JVM_TARGET: 1.8 interface KInterface: Simple { override fun test(s: String): String { diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/dontDelegateToDefaultMethods.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/dontDelegateToDefaultMethods.kt index b1d313c5b4b..92fa0e23e4b 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/dontDelegateToDefaultMethods.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/dontDelegateToDefaultMethods.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Test.java interface Test { @@ -11,7 +12,6 @@ interface Test { } // FILE: main.kt -// JVM_TARGET: 1.8 class Child : Test { override fun call() : String { diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/inheritKotlin.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/inheritKotlin.kt index e1edf9d0269..b19732ba591 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/inheritKotlin.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/inheritKotlin.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Simple.java interface Simple extends KInterface { @@ -8,7 +9,6 @@ interface Simple extends KInterface { } // FILE: main.kt -// JVM_TARGET: 1.8 interface KInterface { fun test(): String { return "base"; diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/invokeDefaultViaSuper.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/invokeDefaultViaSuper.kt index 2c01176ff17..f3a71c44034 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/invokeDefaultViaSuper.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/invokeDefaultViaSuper.kt @@ -1,5 +1,6 @@ // SKIP_JDK6 // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Test.java public interface Test { @@ -9,7 +10,6 @@ public interface Test { } // FILE: test.kt -// JVM_TARGET: 1.8 interface KInterface : Test { } diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920.kt index a923ce45f98..ca7b6462c4b 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: disable // JVM_TARGET: 1.8 // TARGET_BACKEND: JVM +// WITH_RUNTIME // FILE: JBase.java public interface JBase extends Base { @@ -10,7 +11,6 @@ public interface JBase extends Base { } // FILE: main.kt -// WITH_RUNTIME interface Base { fun test(): String = "Base" diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java.kt index 07bc70caddf..3a098ffde2a 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: disable // JVM_TARGET: 1.8 // TARGET_BACKEND: JVM +// WITH_RUNTIME // FILE: Base.java public interface Base { @@ -11,7 +12,6 @@ public interface Base { // FILE: main.kt -// WITH_RUNTIME interface LeftBase : Base interface Right : Base { diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java2.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java2.kt index 1dd1bb39699..71f311f87dc 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java2.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_java2.kt @@ -1,6 +1,7 @@ // !JVM_DEFAULT_MODE: disable // JVM_TARGET: 1.8 // TARGET_BACKEND: JVM +// WITH_RUNTIME // FILE: Base.java public interface Base { @@ -15,7 +16,6 @@ public interface Left extends Base { } // FILE: main.kt -// WITH_RUNTIME interface Right : Base { override fun test(): String = "OK" diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_map.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_map.kt index dfad0aea567..b8b95adf319 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_map.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_map.kt @@ -1,9 +1,9 @@ // !JVM_DEFAULT_MODE: disable // JVM_TARGET: 1.8 // TARGET_BACKEND: JVM -// FILE: main.kt // WITH_RUNTIME // FULL_JDK +// FILE: main.kt var result = "" interface A : MutableMap @@ -72,4 +72,4 @@ fun box(): String { val value = map.getOrDefault("O", "OK") if (result != "O=fail;O;O;") return "fail 3: $result" return value -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/longChainOfKotlinExtendsFromJavaWithDefault.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/longChainOfKotlinExtendsFromJavaWithDefault.kt index 05e0eb936ed..7cd55756e42 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/longChainOfKotlinExtendsFromJavaWithDefault.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/longChainOfKotlinExtendsFromJavaWithDefault.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: Base.java public interface Base { @@ -8,7 +9,6 @@ public interface Base { } // FILE: derived.kt -// JVM_TARGET: 1.8 interface K1 : Base interface K2 : K1 diff --git a/compiler/testData/codegen/box/jvm8/javaDefaults/samOnInterfaceWithDefaultMethod.kt b/compiler/testData/codegen/box/jvm8/javaDefaults/samOnInterfaceWithDefaultMethod.kt index 9afd98732b1..5eb27508dcb 100644 --- a/compiler/testData/codegen/box/jvm8/javaDefaults/samOnInterfaceWithDefaultMethod.kt +++ b/compiler/testData/codegen/box/jvm8/javaDefaults/samOnInterfaceWithDefaultMethod.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: JavaCall.java class JavaCall { @@ -23,7 +24,6 @@ interface Test { } // FILE: sam.kt -// JVM_TARGET: 1.8 fun box(): String { val lambda = { "X" } diff --git a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt index 22817339509..7930d4caa95 100644 --- a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt +++ b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiverInPrivateOperator_lv11.kt @@ -1,7 +1,7 @@ // !LANGUAGE: -NullabilityAssertionOnExtensionReceiver // TARGET_BACKEND: JVM -// FILE: test.kt // WITH_RUNTIME +// FILE: test.kt private operator fun A.inc() = A() fun box(): String { @@ -14,4 +14,4 @@ fun box(): String { // FILE: A.java public class A { public static A n() { return null; } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt index 2b480ab26ea..32e4fb1942b 100644 --- a/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt +++ b/compiler/testData/codegen/box/oldLanguageVersions/javaInterop/notNullAssertions/incWithNullabilityAssertionOnExtensionReceiver_lv11.kt @@ -1,7 +1,7 @@ // !LANGUAGE: -NullabilityAssertionOnExtensionReceiver // TARGET_BACKEND: JVM -// FILE: test.kt // WITH_RUNTIME +// FILE: test.kt import kotlin.test.* diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt index 4525a8a1180..24b7f3a199a 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultAndNamedCombination.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt index 89dddf3b8e7..acd94051bf2 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultBoxTypes.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; @@ -79,4 +79,4 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt index 19a7df4e6f5..2eabc0de9b2 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultEnumType.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: Signs.java -// ANDROID_ANNOTATIONS public enum Signs { HELLO, diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt index 01667dd4112..3432249dd8d 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultLongLiteral.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt index 388d146a78a..9a8de425a9d 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultMultipleParams.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt index c735e66f2f3..29a3f9cebee 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultNull.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; @@ -55,4 +55,4 @@ fun box(): String { if (D().baz() != 42) return "FAIL 5" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt index 7a6c2d436b4..62249a7f70d 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultNullableBoxTypes.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; import org.jetbrains.annotations.*; @@ -80,4 +80,4 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt index 99b591be472..6c41645a32e 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultOverrides.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; @@ -37,4 +37,4 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt index 9a194d7d4b8..99a5295c319 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultPrimitiveTypes.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt index f0a89a6a3a9..416fb512aab 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultValueInConstructor.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt b/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt index 8465bd6b52d..6e751c3cdb9 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/defaultWithJavaBase.kt @@ -1,9 +1,9 @@ // IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt b/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt index 6227b07240c..fbd23206736 100644 --- a/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt +++ b/compiler/testData/codegen/box/signatureAnnotations/reorderedParameterNames.kt @@ -1,7 +1,7 @@ // TARGET_BACKEND: JVM +// ANDROID_ANNOTATIONS // FILE: A.java -// ANDROID_ANNOTATIONS import kotlin.annotations.jvm.internal.*; @@ -28,4 +28,4 @@ fun box(): String { } return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/traits/multipleImplFromJava.kt b/compiler/testData/codegen/box/traits/multipleImplFromJava.kt index 276f901456f..6d4d3983f9f 100644 --- a/compiler/testData/codegen/box/traits/multipleImplFromJava.kt +++ b/compiler/testData/codegen/box/traits/multipleImplFromJava.kt @@ -1,4 +1,5 @@ // TARGET_BACKEND: JVM +// JVM_TARGET: 1.8 // FILE: I.java interface I { default String ifun() { return "fail"; } @@ -13,7 +14,6 @@ public class Z { public class Zz extends Z implements I {} // FILE: multipleImplFromJava.kt -// JVM_TARGET: 1.8 class Cc : Zz() diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.fir.kt index 088e4a26ebf..f808283850c 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.fir.kt @@ -1,6 +1,6 @@ -// FILE: Bar.java // !DIAGNOSTICS: -UNUSED_PARAMETER // SKIP_TXT +// FILE: Bar.java public class Bar { } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.kt index 39f61226a39..611e9e1b158 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.kt @@ -1,6 +1,6 @@ -// FILE: Bar.java // !DIAGNOSTICS: -UNUSED_PARAMETER // SKIP_TXT +// FILE: Bar.java public class Bar { } diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt index 10f4ab7708b..00fba4d7682 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.fir.kt @@ -1,5 +1,5 @@ -// FILE: Signs.java // ANDROID_ANNOTATIONS +// FILE: Signs.java public enum Signs { HELLO, @@ -64,4 +64,4 @@ fun test(){ a.baz() a.bam() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt index 9acd15eee4f..da9c00ceb7f 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultEnum.kt @@ -1,5 +1,5 @@ -// FILE: Signs.java // ANDROID_ANNOTATIONS +// FILE: Signs.java public enum Signs { HELLO, @@ -64,4 +64,4 @@ fun test(){ a.baz() a.bam() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt index 78bf0a516ad..fb58760dce0 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt index f02358f1c9f..11c7b4ba3e4 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultLongLiteral.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt index b492eaa5f6f..9d374ae004d 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; @@ -28,4 +28,4 @@ fun test(a: A, first: B, second: B) { second.foo() second.foo(5) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt index 2e851602818..6d93e590297 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNull.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; @@ -28,4 +28,4 @@ fun test(a: A, first: B, second: B) { second.foo() second.foo(5) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt index f18e0a87d41..1387049e9df 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultNullAndParameter.kt @@ -1,6 +1,6 @@ // FIR_IDENTICAL -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt index 230257989ee..2795c35fcdb 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt index b3e40b48c7b..be351fecb58 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/defaultParameter.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt index f9718064622..284a8a3aa16 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; @@ -24,4 +24,4 @@ fun main() { test.missingName("arg") test.numberName("first") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt index 769af592f37..161fa85a5bc 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/emptyParameterName.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; @@ -24,4 +24,4 @@ fun main() { test.missingName("arg") test.numberName("first") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt index fe5fecb195c..350353f2296 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt index c92cd863e65..bf9bfd58166 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesDefaultValue.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt index 3c46406ebaf..b022821911c 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt index bb64c719102..8c13de9edbb 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/overridesParameterName.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt index 4aaa69f7cdb..037a24865c1 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/reorderedParameterNames.kt @@ -1,7 +1,7 @@ // FIR_IDENTICAL -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; public class A { @@ -15,4 +15,4 @@ fun main() { test.connect("127.0.0.1", 8080) test.connect(host = "127.0.0.1", port = 8080) test.connect(port = 8080, host = "127.0.0.1") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt index 01a29b0c13c..9a1dd337a6d 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.fir.kt @@ -1,6 +1,6 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; public class A { @@ -14,4 +14,4 @@ fun main() { test.same("hello", "world") test.same(ok = "hello", ok = world) test.same("hello", ok = "world") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt index c6bacf0a039..c9aa9b97ec0 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/sameParameterName.kt @@ -1,6 +1,6 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; public class A { @@ -14,4 +14,4 @@ fun main() { test.same("hello", "world") test.same(ok = "hello", ok = world) test.same("hello", ok = "world") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt index 0070bd9f64e..b1b5dab88ea 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.fir.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; import kotlin.internal.*; @@ -21,4 +21,4 @@ fun main() { test.numberName(`42` = "world") test.numberName("world") test.numberName(field = "world") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt index b9541b7e646..9220cc35987 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/specialCharsParameterName.kt @@ -1,5 +1,5 @@ -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; import kotlin.internal.*; @@ -21,4 +21,4 @@ fun main() { test.numberName(`42` = "world") test.numberName("world") test.numberName(field = "world") -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt index 834176d51cb..b6b925cc71e 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/stableParameterName.kt @@ -1,6 +1,6 @@ // FIR_IDENTICAL -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt index c6dab56099a..70df865ef8d 100644 --- a/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt +++ b/compiler/testData/diagnostics/tests/j+k/signatureAnnotations/staticMethodWithDefaultValue.kt @@ -1,8 +1,8 @@ // FIR_IDENTICAL // IGNORE_BACKEND: JS, NATIVE -// FILE: A.java // ANDROID_ANNOTATIONS +// FILE: A.java import kotlin.annotations.jvm.internal.*; diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt index fe2f57ae149..06f07e576f9 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.fir.kt @@ -1,6 +1,6 @@ // !SKIP_JAVAC -// FILE: SLRUMap.java // !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// FILE: SLRUMap.java import org.jetbrains.annotations.NotNull; import java.util.List; diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt index 6f3750e41e5..eca01079b02 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullable.kt @@ -1,6 +1,6 @@ // !SKIP_JAVAC -// FILE: SLRUMap.java // !LANGUAGE: +ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// FILE: SLRUMap.java import org.jetbrains.annotations.NotNull; import java.util.List; diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.fir.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.fir.kt index a543c1946e4..f85cd4aa40b 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.fir.kt @@ -1,6 +1,6 @@ // !SKIP_JAVAC -// FILE: SLRUMap.java // !LANGUAGE: -ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// FILE: SLRUMap.java import org.jetbrains.annotations.NotNull; import java.util.List; diff --git a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.kt b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.kt index d845d14c68d..f0f37293165 100644 --- a/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.kt +++ b/compiler/testData/diagnostics/tests/j+k/types/notNullTypeParameterWithKotlinNullableWarnings.kt @@ -1,6 +1,6 @@ // !SKIP_JAVAC -// FILE: SLRUMap.java // !LANGUAGE: -ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated +// FILE: SLRUMap.java import org.jetbrains.annotations.NotNull; import java.util.List; diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.kt index aa0e88d1590..60c747a0c2d 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.kt @@ -1,6 +1,6 @@ // FIR_IDENTICAL -// FILE: f1.kt // SKIP_TXT +// FILE: f1.kt package kotlin @@ -19,4 +19,4 @@ class C: MutableIterator { throw UnsupportedOperationException() } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt index 379189d3aef..d744b200b60 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.fir.kt @@ -1,10 +1,10 @@ +// SKIP_TXT // FILE: a.kt package p class FilteringSequence // FILE: b.kt -// SKIP_TXT package kotlin.sequences import p.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.kt b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.kt index bb4f2196574..1ddb1aebd9c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/InaccessibleInternalClass.kt @@ -1,10 +1,10 @@ +// SKIP_TXT // FILE: a.kt package p class FilteringSequence // FILE: b.kt -// SKIP_TXT package kotlin.sequences import p.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41741.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41741.kt index d1efd92c4d1..4bf23c5ff67 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41741.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/performance/kt41741.kt @@ -1,8 +1,8 @@ // FIR_IDENTICAL -// FILE: Simple.java // FULL_JDK // WITH_RUNTIME // !DIAGNOSTICS: -UNUSED_PARAMETER -CAST_NEVER_SUCCEEDS -UNUSED_VARIABLE +// FILE: Simple.java import java.util.*; import java.util.function.Supplier; diff --git a/compiler/testData/foreignAnnotations/tests/aosp.kt b/compiler/testData/foreignAnnotations/tests/aosp.kt index 6abbe23f7f1..b4dd6a2731a 100644 --- a/compiler/testData/foreignAnnotations/tests/aosp.kt +++ b/compiler/testData/foreignAnnotations/tests/aosp.kt @@ -1,4 +1,5 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// SOURCE_RETENTION_ANNOTATIONS // FILE: A.java import com.android.annotations.*; @@ -21,7 +22,6 @@ public class A { } // FILE: main.kt -// SOURCE_RETENTION_ANNOTATIONS fun main(a: A, a1: A) { a.foo("", null)?.length diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt index 0819011bceb..b72f6694491 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt @@ -6,15 +6,19 @@ package org.jetbrains.kotlin.test.directives import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer object CodegenTestDirectives : SimpleDirectivesContainer() { val IGNORE_BACKEND by enumDirective( - description = "Ignore failures of test on target backend" + description = "Ignore failures of test on target backend", + applicability = Global ) val IGNORE_BACKEND_FIR by enumDirective( - description = "Ignore specific backend if test uses FIR" + description = "Ignore specific backend if test uses FIR", + applicability = Global ) val JAVAC_OPTIONS by stringDirective( @@ -29,7 +33,8 @@ object CodegenTestDirectives : SimpleDirectivesContainer() { ) val CHECK_BYTECODE_LISTING by directive( - description = "Dump resulting bytecode to .txt or _ir.txt file" + description = "Dump resulting bytecode to .txt or _ir.txt file", + applicability = Global ) val RUN_DEX_CHECKER by directive( diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt index 487acb809f7..9d55370f74e 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/DiagnosticsDirectives.kt @@ -7,6 +7,9 @@ package org.jetbrains.kotlin.test.directives import org.jetbrains.kotlin.test.backend.handlers.JvmBackendDiagnosticsHandler import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirectives.USE_JAVAC +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Any +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer object DiagnosticsDirectives : SimpleDirectivesContainer() { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt index 0edefff5924..05a4249f885 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/FirDiagnosticsDirectives.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.test.directives +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer object FirDiagnosticsDirectives : SimpleDirectivesContainer() { @@ -12,17 +13,20 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() { description = """ Dumps control flow graphs of all declarations to `testName.dot` file This directive may be applied only to all modules - """.trimIndent() + """.trimIndent(), + applicability = Global ) val FIR_DUMP by directive( description = """ Dumps resulting fir to `testName.fir` file - """.trimIndent() + """.trimIndent(), + applicability = Global ) val FIR_IDENTICAL by directive( - description = "Contents of fir test data file and FE 1.0 are identical" + description = "Contents of fir test data file and FE 1.0 are identical", + applicability = Global ) val USE_LIGHT_TREE by directive( @@ -33,7 +37,8 @@ object FirDiagnosticsDirectives : SimpleDirectivesContainer() { description = """ Enable comparing diagnostics between PSI and light tree modes For enabling light tree mode use $USE_LIGHT_TREE directive - """.trimIndent() + """.trimIndent(), + applicability = Global ) val WITH_EXTENDED_CHECKERS by directive( diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt index ec63451a9d9..40ccbbe429a 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.test.builders.LanguageVersionSettingsBuilder import org.jetbrains.kotlin.test.directives.AdditionalFilesDirectives import org.jetbrains.kotlin.test.directives.ModuleStructureDirectives import org.jetbrains.kotlin.test.directives.model.ComposedRegisteredDirectives +import org.jetbrains.kotlin.test.directives.model.Directive import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives import org.jetbrains.kotlin.test.model.* @@ -240,14 +241,38 @@ class ModuleStructureExtractorImpl( } private fun finishGlobalDirectives() { - globalDirectives = directivesBuilder.build() + globalDirectives = directivesBuilder.build().also { directives -> + directives.forEach { it.checkDirectiveApplicability(contextIsGlobal = true) } + } resetModuleCaches() resetFileCaches() } + @OptIn(ExperimentalStdlibApi::class) + private fun Directive.checkDirectiveApplicability( + contextIsGlobal: Boolean = false, + contextIsModule: Boolean = false, + contextIsFile: Boolean = false + ) { + when { + applicability.forGlobal && contextIsGlobal -> return + applicability.forModule && contextIsModule -> return + applicability.forFile && contextIsFile -> return + } + val context = buildList { + if (contextIsGlobal) add("Global") + if (contextIsModule) add("Module") + if (contextIsFile) add("File") + }.joinToString("|") + error("Directive $this has $applicability applicability but it declared in $context") + } + private fun finishModule() { finishFile() + val isImplicitModule = currentModuleName == null val moduleDirectives = moduleDirectivesBuilder.build() + testServices.defaultDirectives + globalDirectives + moduleDirectives.forEach { it.checkDirectiveApplicability(contextIsGlobal = isImplicitModule, contextIsModule = true) } + currentModuleLanguageVersionSettingsBuilder.configureUsingDirectives(moduleDirectives, environmentConfigurators) val moduleName = currentModuleName ?: defaultModuleName val testModule = TestModule( @@ -298,6 +323,9 @@ class ModuleStructureExtractorImpl( if (filesOfCurrentModule.any { it.name == filename }) { error("File with name \"$filename\" already defined in module ${currentModuleName ?: actualDefaultFileName}") } + val directives = fileDirectivesBuilder?.build()?.also { directives -> + directives.forEach { it.checkDirectiveApplicability(contextIsFile = true) } + } filesOfCurrentModule.add( TestFile( relativePath = filename, @@ -305,7 +333,7 @@ class ModuleStructureExtractorImpl( originalFile = currentTestDataFile, startLineNumberInOriginalFile = startLineNumberOfCurrentFile, isAdditional = false, - directives = fileDirectivesBuilder?.build() ?: RegisteredDirectives.Empty + directives = directives ?: RegisteredDirectives.Empty ) ) firstFileInModule = false @@ -333,6 +361,8 @@ class ModuleStructureExtractorImpl( private fun resetFileCaches() { if (!firstFileInModule) { linesOfCurrentFile = mutableListOf() + } + if (firstFileInModule) { moduleDirectivesBuilder = directivesBuilder } currentFileName = null From acb6d2e1966a711c652e0b6c726a2a08ae032cae Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 18 Jan 2021 15:44:46 +0300 Subject: [PATCH 079/122] [Test] Allow facades to return null which indicates that facade can't complete it's job This is needed for cases when test pipeline assumes that some part of pipeline may be unavailable because of errors on previous stage. For example, this may occur in some test which check something on IR but contains backend facade for compiling binary dependencies. In this case testdata with frontend errors is allowed if test has only one module which should not be compiled --- .../tests/org/jetbrains/kotlin/test/TestRunner.kt | 12 ++++++------ .../tests/org/jetbrains/kotlin/test/model/Facades.kt | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt index b2b661094eb..7a1332471ff 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/TestRunner.kt @@ -98,7 +98,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) { if (!frontendKind.shouldRunAnalysis) return val frontendArtifacts: ResultingArtifact.FrontendOutput<*> = testConfiguration.getFacade(SourcesKind, frontendKind) - .transform(module, sourcesArtifact).also { dependencyProvider.registerArtifact(module, it) } + .transform(module, sourcesArtifact)?.also { dependencyProvider.registerArtifact(module, it) } ?: return val frontendHandlers: List> = testConfiguration.getHandlers(frontendKind) for (frontendHandler in frontendHandlers) { withAssertionCatching { @@ -110,7 +110,7 @@ class TestRunner(private val testConfiguration: TestConfiguration) { if (!backendKind.shouldRunAnalysis) return val backendInputInfo = testConfiguration.getFacade(frontendKind, backendKind) - .hackyTransform(module, frontendArtifacts).also { dependencyProvider.registerArtifact(module, it) } + .hackyTransform(module, frontendArtifacts)?.also { dependencyProvider.registerArtifact(module, it) } ?: return val backendHandlers: List> = testConfiguration.getHandlers(backendKind) for (backendHandler in backendHandlers) { @@ -120,9 +120,9 @@ class TestRunner(private val testConfiguration: TestConfiguration) { for (artifactKind in moduleStructure.getTargetArtifactKinds(module)) { if (!artifactKind.shouldRunAnalysis) continue val binaryArtifact = testConfiguration.getFacade(backendKind, artifactKind) - .hackyTransform(module, backendInputInfo).also { + .hackyTransform(module, backendInputInfo)?.also { dependencyProvider.registerArtifact(module, it) - } + } ?: return val binaryHandlers: List> = testConfiguration.getHandlers(artifactKind) for (binaryHandler in binaryHandlers) { @@ -167,7 +167,7 @@ private fun > AnalysisHandler.processModule(module: private fun AbstractTestFacade<*, *>.hackyTransform( module: TestModule, artifact: ResultingArtifact<*> -): ResultingArtifact<*> { +): ResultingArtifact<*>? { @Suppress("UNCHECKED_CAST") return (this as AbstractTestFacade) .transform(module, artifact as ResultingArtifact) @@ -176,7 +176,7 @@ private fun AbstractTestFacade<*, *>.hackyTransform( private fun , O : ResultingArtifact> AbstractTestFacade.transform( module: TestModule, inputArtifact: ResultingArtifact -): O { +): O? { @Suppress("UNCHECKED_CAST") return transform(module, inputArtifact as I) } diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt index d6f075f226b..dc6fbba6eb2 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Facades.kt @@ -13,7 +13,7 @@ abstract class AbstractTestFacade, O : ResultingArtifac abstract val inputKind: TestArtifactKind abstract val outputKind: TestArtifactKind - abstract fun transform(module: TestModule, inputArtifact: I): O + abstract fun transform(module: TestModule, inputArtifact: I): O? open val additionalServices: List get() = emptyList() From a2ae6181858516a6e21c97799a29b056326d6d87 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 18 Jan 2021 15:50:28 +0300 Subject: [PATCH 080/122] [Test] Introduce IGNORE_ERRORS diagnostic to suppressing backend errors --- .../kotlin/backend/jvm/JvmIrCodegenFactory.kt | 5 ++-- .../handlers/NoCompilationErrorsHandler.kt | 7 ++++++ .../test/backend/ir/JvmIrBackendFacade.kt | 13 ++++++++-- .../test/directives/CodegenTestDirectives.kt | 25 +++++++++++++++++++ .../classic/ClassicFrontend2IrConverter.kt | 4 ++- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt index 9377e498c7b..20448eacf35 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt @@ -57,10 +57,11 @@ class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory doGenerateFilesInternal(input) } - fun convertToIr(state: GenerationState, files: Collection): JvmIrBackendInput { + @JvmOverloads + fun convertToIr(state: GenerationState, files: Collection, ignoreErrors: Boolean = false): JvmIrBackendInput { val extensions = JvmGeneratorExtensions() val mangler = JvmManglerDesc(MainFunctionDetector(state.bindingContext, state.languageVersionSettings)) - val psi2ir = Psi2IrTranslator(state.languageVersionSettings, Psi2IrConfiguration()) + val psi2ir = Psi2IrTranslator(state.languageVersionSettings, Psi2IrConfiguration(ignoreErrors)) val symbolTable = SymbolTable(JvmIdSignatureDescriptor(mangler), IrFactoryImpl, JvmNameProvider) val psi2irContext = psi2ir.createGeneratorContext(state.module, state.bindingContext, symbolTable, extensions) val pluginExtensions = IrGenerationExtension.getInstances(state.project) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/NoCompilationErrorsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/NoCompilationErrorsHandler.kt index 1dd5c945063..7fb53fdb433 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/NoCompilationErrorsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/NoCompilationErrorsHandler.kt @@ -6,13 +6,20 @@ package org.jetbrains.kotlin.test.backend.handlers import org.jetbrains.kotlin.resolve.AnalyzingUtils +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.IGNORE_ERRORS +import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact import org.jetbrains.kotlin.test.frontend.classic.handlers.ClassicFrontendAnalysisHandler import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices class NoCompilationErrorsHandler(testServices: TestServices) : ClassicFrontendAnalysisHandler(testServices) { + override val directivesContainers: List + get() = listOf(CodegenTestDirectives) + override fun processModule(module: TestModule, info: ClassicFrontendOutputArtifact) { + if (IGNORE_ERRORS in module.directives) return AnalyzingUtils.throwExceptionOnErrors(info.analysisResult.bindingContext) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/JvmIrBackendFacade.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/JvmIrBackendFacade.kt index 522ca4ad17c..1e21f3e79c8 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/JvmIrBackendFacade.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/JvmIrBackendFacade.kt @@ -5,8 +5,10 @@ package org.jetbrains.kotlin.test.backend.ir +import org.jetbrains.kotlin.backend.common.BackendException import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory import org.jetbrains.kotlin.test.backend.classic.JavaCompilerFacade +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.model.* import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.compilerConfigurationProvider @@ -19,10 +21,17 @@ class JvmIrBackendFacade( override fun transform( module: TestModule, inputArtifact: IrBackendInput - ): BinaryArtifacts.Jvm { + ): BinaryArtifacts.Jvm? { val state = inputArtifact.backendInput.state val codegenFactory = state.codegenFactory as JvmIrCodegenFactory - codegenFactory.doGenerateFilesInternal(inputArtifact.backendInput) + try { + codegenFactory.doGenerateFilesInternal(inputArtifact.backendInput) + } catch (e: BackendException) { + if (CodegenTestDirectives.IGNORE_ERRORS in module.directives) { + return null + } + throw e + } state.factory.done() val configuration = testServices.compilerConfigurationProvider.getCompilerConfiguration(module) javaCompilerFacade.compileJavaFiles(module, configuration, state.factory) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt index b72f6694491..3fc068dcdf4 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt @@ -6,7 +6,10 @@ package org.jetbrains.kotlin.test.directives import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.handlers.NoCompilationErrorsHandler +import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability +import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.File import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer @@ -45,7 +48,29 @@ object CodegenTestDirectives : SimpleDirectivesContainer() { description = "Ignore dex checkers" ) + val IGNORE_ERRORS by directive( + description = """ + Ignore frontend errors in ${NoCompilationErrorsHandler::class} + If this directive is enabled then ${JvmIrBackendFacade::class} won't produce any binaries for test + if there are errors in it + """.trimIndent() + ) + val IGNORE_FIR_DIAGNOSTICS by directive( description = "Run backend even FIR reported some diagnostics with ERROR severity" ) + + val IR_FILE by stringDirective( + description = "Specifies file name for IR text dump", + applicability = File + ) + + val DUMP_EXTERNAL_CLASS by stringDirective( + description = "Specifies names of external classes which IR should be dumped" + ) + + val EXTERNAL_FILE by directive( + description = "Indicates that test file is external", + applicability = File + ) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt index 089e44c0a56..10b960cc1b6 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/ClassicFrontend2IrConverter.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.codegen.ClassBuilderFactories import org.jetbrains.kotlin.codegen.state.GenerationState import org.jetbrains.kotlin.test.backend.ir.IrBackendInput +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.model.BackendKinds import org.jetbrains.kotlin.test.model.Frontend2BackendConverter import org.jetbrains.kotlin.test.model.FrontendKinds @@ -44,6 +45,7 @@ class ClassicFrontend2IrConverter( .isIrBackend(true) .build() - return IrBackendInput(codegenFactory.convertToIr(state, files)) + val ignoreErrors = CodegenTestDirectives.IGNORE_ERRORS in module.directives + return IrBackendInput(codegenFactory.convertToIr(state, files, ignoreErrors)) } } From 5ae5f660f6605c590d4def3ffcd6f09b4cd973f0 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 16:39:54 +0300 Subject: [PATCH 081/122] [Test] Add ability to explicitly declare default binary kind for test --- .../tests/org/jetbrains/kotlin/test/model/Modules.kt | 1 + .../org/jetbrains/kotlin/test/services/DefaultsProvider.kt | 3 +++ .../kotlin/test/builders/DefaultsProviderBuilder.kt | 4 ++++ .../test/services/impl/ModuleStructureExtractorImpl.kt | 5 ++++- .../kotlin/test/services/impl/TestModuleStructureImpl.kt | 6 +++--- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt index 0996531b75b..f040006446d 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/model/Modules.kt @@ -16,6 +16,7 @@ data class TestModule( val targetPlatform: TargetPlatform, val targetBackend: TargetBackend?, val frontendKind: FrontendKind<*>, + val binaryKind: BinaryKind<*>, val files: List, val dependencies: List, val friends: List, diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DefaultsProvider.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DefaultsProvider.kt index 54310fdb033..9b1988dd582 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DefaultsProvider.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/DefaultsProvider.kt @@ -9,8 +9,10 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.builders.LanguageVersionSettingsBuilder +import org.jetbrains.kotlin.test.model.BinaryKind import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.FrontendKind +import org.jetbrains.kotlin.test.model.TestArtifactKind /* * TODO: @@ -22,6 +24,7 @@ class DefaultsProvider( val defaultLanguageSettings: LanguageVersionSettings, private val defaultLanguageSettingsBuilder: LanguageVersionSettingsBuilder, val defaultPlatform: TargetPlatform, + val defaultArtifactKind: BinaryKind<*>?, val defaultTargetBackend: TargetBackend?, val defaultDependencyKind: DependencyKind ) : TestService { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/DefaultsProviderBuilder.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/DefaultsProviderBuilder.kt index 5a99cc25118..381cb2bc253 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/DefaultsProviderBuilder.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/builders/DefaultsProviderBuilder.kt @@ -12,16 +12,19 @@ import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl import org.jetbrains.kotlin.fir.PrivateForInline import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.model.BinaryKind import org.jetbrains.kotlin.test.services.DefaultsDsl import org.jetbrains.kotlin.test.services.DefaultsProvider import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.FrontendKind +import org.jetbrains.kotlin.test.model.TestArtifactKind @DefaultsDsl class DefaultsProviderBuilder { lateinit var frontend: FrontendKind<*> var targetBackend: TargetBackend? = null lateinit var targetPlatform: TargetPlatform + var artifactKind: BinaryKind<*>? = null lateinit var dependencyKind: DependencyKind @PrivateForInline @@ -44,6 +47,7 @@ class DefaultsProviderBuilder { languageVersionSettings ?: LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE), languageVersionSettingsBuilder ?: LanguageVersionSettingsBuilder(), targetPlatform, + artifactKind, targetBackend, dependencyKind ) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt index 40ccbbe429a..63077ebfd23 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt @@ -22,6 +22,7 @@ import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.directives.model.RegisteredDirectives import org.jetbrains.kotlin.test.model.* import org.jetbrains.kotlin.test.services.* +import org.jetbrains.kotlin.test.services.impl.TestModuleStructureImpl.Companion.toArtifactKind import org.jetbrains.kotlin.test.util.joinToArrayString import org.jetbrains.kotlin.utils.DFS import java.io.File @@ -275,11 +276,13 @@ class ModuleStructureExtractorImpl( currentModuleLanguageVersionSettingsBuilder.configureUsingDirectives(moduleDirectives, environmentConfigurators) val moduleName = currentModuleName ?: defaultModuleName + val targetPlatform = currentModuleTargetPlatform ?: parseModulePlatformByName(moduleName) ?: defaultsProvider.defaultPlatform val testModule = TestModule( name = moduleName, - targetPlatform = currentModuleTargetPlatform ?: parseModulePlatformByName(moduleName) ?: defaultsProvider.defaultPlatform, + targetPlatform = targetPlatform, targetBackend = currentModuleTargetBackend ?: defaultsProvider.defaultTargetBackend, frontendKind = currentModuleFrontendKind ?: defaultsProvider.defaultFrontend, + binaryKind = defaultsProvider.defaultArtifactKind ?: targetPlatform.toArtifactKind(), files = filesOfCurrentModule, dependencies = dependenciesOfCurrentModule, friends = friendsOfCurrentModule, diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TestModuleStructureImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TestModuleStructureImpl.kt index 8b8e0a16151..5c2e74baf4e 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TestModuleStructureImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/TestModuleStructureImpl.kt @@ -33,7 +33,7 @@ class TestModuleStructureImpl( result += ArtifactKinds.KLib } } - module.targetPlatform.toArtifactKind()?.let { result += it } + result += module.binaryKind put(module.name, result) } } @@ -52,11 +52,11 @@ class TestModuleStructureImpl( } companion object { - private fun TargetPlatform.toArtifactKind(): BinaryKind<*>? = when (this) { + fun TargetPlatform.toArtifactKind(): BinaryKind<*> = when (this) { in JvmPlatforms.allJvmPlatforms -> ArtifactKinds.Jvm in JsPlatforms.allJsPlatforms -> ArtifactKinds.Js in NativePlatforms.allNativePlatforms -> ArtifactKinds.Native - else -> null + else -> BinaryKind.NoArtifact } } } From aaa3fa58452eb98e74b804d4f06138f48f37fc3c Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 18 Jan 2021 18:00:44 +0300 Subject: [PATCH 082/122] [Test] Migrate IrTextTestGenerated to new infrastructure --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 6 +- .../ir/declarations/lazy/IrLazyFunction.kt | 4 + .../test/runners/ir/IrTextTestGenerated.java} | 665 +++++++++++++----- .../backend/classic/JavaCompilerFacade.kt | 13 +- .../backend/handlers/AbstractIrHandler.kt | 13 + .../backend/handlers/IrTextDumpHandler.kt | 116 +++ .../test/directives/CodegenTestDirectives.kt | 13 +- ...ractKotlinCompilerWithTargetBackendTest.kt | 10 +- .../test/runners/ir/AbstractIrTextTest.kt | 66 ++ .../kotlin/ir/AbstractIrTextTestCase.kt | 196 +----- .../org/jetbrains/kotlin/ir/IrVerifier.kt | 201 ++++++ .../kotlin/test/JvmCompilationUtils.kt | 10 +- .../generators/GenerateJUnit3CompilerTests.kt | 4 - .../generators/GenerateJUnit5CompilerTests.kt | 6 +- 14 files changed, 953 insertions(+), 370 deletions(-) rename compiler/{tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java => tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java} (91%) create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt create mode 100644 compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 6459d0e19a0..dfda9c6abff 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1063,9 +1063,9 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); } - @TestMetadata("javaSyntheticGenericPropretyAccess.kt") - public void testJavaSyntheticGenericPropretyAccess() throws Exception { - runTest("compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.kt"); + @TestMetadata("javaSyntheticGenericPropertyAccess.kt") + public void testJavaSyntheticGenericPropertyAccess() throws Exception { + runTest("compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.kt"); } @TestMetadata("javaSyntheticPropertyAccess.kt") diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt index 1ca7751f7ff..b575411e7f2 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt @@ -44,6 +44,10 @@ class IrLazyFunction( override val stubGenerator: DeclarationStubGenerator, override val typeTranslator: TypeTranslator, ) : IrSimpleFunction(), IrLazyFunctionBase { + init { + @Suppress("UNUSED_VARIABLE") val x = 1 + } + override var parent: IrDeclarationParent by createLazyParent() override var annotations: List by createLazyAnnotations() diff --git a/compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java similarity index 91% rename from compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java rename to compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index e64f9d6ebf1..9a902176101 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -3,728 +3,831 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.ir; +package org.jetbrains.kotlin.test.runners.ir; import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.regex.Pattern; -/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("compiler/testData/ir/irText") @TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - +public class IrTextTestGenerated extends AbstractIrTextTest { + @Test public void testAllFilesPresentInIrText() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Nested @TestMetadata("compiler/testData/ir/irText/classes") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Classes extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Classes extends AbstractIrTextTest { + @Test @TestMetadata("abstractMembers.kt") public void testAbstractMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/abstractMembers.kt"); } + @Test public void testAllFilesPresentInClasses() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/classes"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/classes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("annotationClasses.kt") public void testAnnotationClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/annotationClasses.kt"); } + @Test @TestMetadata("argumentReorderingInDelegatingConstructorCall.kt") public void testArgumentReorderingInDelegatingConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.kt"); } + @Test @TestMetadata("clashingFakeOverrideSignatures.kt") public void testClashingFakeOverrideSignatures() throws Exception { runTest("compiler/testData/ir/irText/classes/clashingFakeOverrideSignatures.kt"); } + @Test @TestMetadata("classMembers.kt") public void testClassMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/classMembers.kt"); } + @Test @TestMetadata("classes.kt") public void testClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/classes.kt"); } + @Test @TestMetadata("cloneable.kt") public void testCloneable() throws Exception { runTest("compiler/testData/ir/irText/classes/cloneable.kt"); } + @Test @TestMetadata("companionObject.kt") public void testCompanionObject() throws Exception { runTest("compiler/testData/ir/irText/classes/companionObject.kt"); } + @Test @TestMetadata("dataClassWithArrayMembers.kt") public void testDataClassWithArrayMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/dataClassWithArrayMembers.kt"); } + @Test @TestMetadata("dataClasses.kt") public void testDataClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/dataClasses.kt"); } + @Test @TestMetadata("dataClassesGeneric.kt") public void testDataClassesGeneric() throws Exception { runTest("compiler/testData/ir/irText/classes/dataClassesGeneric.kt"); } + @Test @TestMetadata("delegatedGenericImplementation.kt") public void testDelegatedGenericImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt"); } + @Test @TestMetadata("delegatedImplementation.kt") public void testDelegatedImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementation.kt"); } + @Test @TestMetadata("delegatedImplementationOfJavaInterface.kt") public void testDelegatedImplementationOfJavaInterface() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt"); } + @Test @TestMetadata("delegatedImplementationWithExplicitOverride.kt") public void testDelegatedImplementationWithExplicitOverride() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.kt"); } + @Test @TestMetadata("delegatingConstructorCallToTypeAliasConstructor.kt") public void testDelegatingConstructorCallToTypeAliasConstructor() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.kt"); } + @Test @TestMetadata("delegatingConstructorCallsInSecondaryConstructors.kt") public void testDelegatingConstructorCallsInSecondaryConstructors() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.kt"); } + @Test @TestMetadata("enum.kt") public void testEnum() throws Exception { runTest("compiler/testData/ir/irText/classes/enum.kt"); } + @Test @TestMetadata("enumClassModality.kt") public void testEnumClassModality() throws Exception { runTest("compiler/testData/ir/irText/classes/enumClassModality.kt"); } + @Test @TestMetadata("enumWithMultipleCtors.kt") public void testEnumWithMultipleCtors() throws Exception { runTest("compiler/testData/ir/irText/classes/enumWithMultipleCtors.kt"); } + @Test @TestMetadata("enumWithSecondaryCtor.kt") public void testEnumWithSecondaryCtor() throws Exception { runTest("compiler/testData/ir/irText/classes/enumWithSecondaryCtor.kt"); } + @Test @TestMetadata("fakeOverridesForJavaStaticMembers.kt") public void testFakeOverridesForJavaStaticMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/fakeOverridesForJavaStaticMembers.kt"); } + @Test @TestMetadata("implicitNotNullOnDelegatedImplementation.kt") public void testImplicitNotNullOnDelegatedImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt"); } + @Test @TestMetadata("initBlock.kt") public void testInitBlock() throws Exception { runTest("compiler/testData/ir/irText/classes/initBlock.kt"); } + @Test @TestMetadata("initVal.kt") public void testInitVal() throws Exception { runTest("compiler/testData/ir/irText/classes/initVal.kt"); } + @Test @TestMetadata("initValInLambda.kt") public void testInitValInLambda() throws Exception { runTest("compiler/testData/ir/irText/classes/initValInLambda.kt"); } + @Test @TestMetadata("initVar.kt") public void testInitVar() throws Exception { runTest("compiler/testData/ir/irText/classes/initVar.kt"); } + @Test @TestMetadata("inlineClass.kt") public void testInlineClass() throws Exception { runTest("compiler/testData/ir/irText/classes/inlineClass.kt"); } + @Test @TestMetadata("inlineClassSyntheticMethods.kt") public void testInlineClassSyntheticMethods() throws Exception { runTest("compiler/testData/ir/irText/classes/inlineClassSyntheticMethods.kt"); } + @Test @TestMetadata("innerClass.kt") public void testInnerClass() throws Exception { runTest("compiler/testData/ir/irText/classes/innerClass.kt"); } + @Test @TestMetadata("innerClassWithDelegatingConstructor.kt") public void testInnerClassWithDelegatingConstructor() throws Exception { runTest("compiler/testData/ir/irText/classes/innerClassWithDelegatingConstructor.kt"); } + @Test @TestMetadata("kt19306.kt") public void testKt19306() throws Exception { runTest("compiler/testData/ir/irText/classes/kt19306.kt"); } + @Test @TestMetadata("kt31649.kt") public void testKt31649() throws Exception { runTest("compiler/testData/ir/irText/classes/kt31649.kt"); } + @Test @TestMetadata("kt43217.kt") public void testKt43217() throws Exception { runTest("compiler/testData/ir/irText/classes/kt43217.kt"); } + @Test @TestMetadata("lambdaInDataClassDefaultParameter.kt") public void testLambdaInDataClassDefaultParameter() throws Exception { runTest("compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.kt"); } + @Test @TestMetadata("localClasses.kt") public void testLocalClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/localClasses.kt"); } + @Test @TestMetadata("objectLiteralExpressions.kt") public void testObjectLiteralExpressions() throws Exception { runTest("compiler/testData/ir/irText/classes/objectLiteralExpressions.kt"); } + @Test @TestMetadata("objectWithInitializers.kt") public void testObjectWithInitializers() throws Exception { runTest("compiler/testData/ir/irText/classes/objectWithInitializers.kt"); } + @Test @TestMetadata("openDataClass.kt") public void testOpenDataClass() throws Exception { runTest("compiler/testData/ir/irText/classes/openDataClass.kt"); } + @Test @TestMetadata("outerClassAccess.kt") public void testOuterClassAccess() throws Exception { runTest("compiler/testData/ir/irText/classes/outerClassAccess.kt"); } + @Test @TestMetadata("primaryConstructor.kt") public void testPrimaryConstructor() throws Exception { runTest("compiler/testData/ir/irText/classes/primaryConstructor.kt"); } + @Test @TestMetadata("primaryConstructorWithSuperConstructorCall.kt") public void testPrimaryConstructorWithSuperConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.kt"); } + @Test @TestMetadata("qualifiedSuperCalls.kt") public void testQualifiedSuperCalls() throws Exception { runTest("compiler/testData/ir/irText/classes/qualifiedSuperCalls.kt"); } + @Test @TestMetadata("sealedClasses.kt") public void testSealedClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/sealedClasses.kt"); } + @Test @TestMetadata("secondaryConstructorWithInitializersFromClassBody.kt") public void testSecondaryConstructorWithInitializersFromClassBody() throws Exception { runTest("compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt"); } + @Test @TestMetadata("secondaryConstructors.kt") public void testSecondaryConstructors() throws Exception { runTest("compiler/testData/ir/irText/classes/secondaryConstructors.kt"); } + @Test @TestMetadata("superCalls.kt") public void testSuperCalls() throws Exception { runTest("compiler/testData/ir/irText/classes/superCalls.kt"); } + @Test @TestMetadata("superCallsComposed.kt") public void testSuperCallsComposed() throws Exception { runTest("compiler/testData/ir/irText/classes/superCallsComposed.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Declarations extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Declarations extends AbstractIrTextTest { + @Test public void testAllFilesPresentInDeclarations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("catchParameterInTopLevelProperty.kt") public void testCatchParameterInTopLevelProperty() throws Exception { runTest("compiler/testData/ir/irText/declarations/catchParameterInTopLevelProperty.kt"); } + @Test @TestMetadata("classLevelProperties.kt") public void testClassLevelProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/classLevelProperties.kt"); } + @Test @TestMetadata("constValInitializers.kt") public void testConstValInitializers() throws Exception { runTest("compiler/testData/ir/irText/declarations/constValInitializers.kt"); } + @Test @TestMetadata("defaultArguments.kt") public void testDefaultArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/defaultArguments.kt"); } + @Test @TestMetadata("delegatedProperties.kt") public void testDelegatedProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/delegatedProperties.kt"); } + @Test @TestMetadata("deprecatedProperty.kt") public void testDeprecatedProperty() throws Exception { runTest("compiler/testData/ir/irText/declarations/deprecatedProperty.kt"); } + @Test @TestMetadata("extensionProperties.kt") public void testExtensionProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt"); } + @Test @TestMetadata("fakeOverrides.kt") public void testFakeOverrides() throws Exception { runTest("compiler/testData/ir/irText/declarations/fakeOverrides.kt"); } + @Test @TestMetadata("fileWithAnnotations.kt") public void testFileWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/fileWithAnnotations.kt"); } + @Test @TestMetadata("fileWithTypeAliasesOnly.kt") public void testFileWithTypeAliasesOnly() throws Exception { runTest("compiler/testData/ir/irText/declarations/fileWithTypeAliasesOnly.kt"); } + @Test @TestMetadata("genericDelegatedProperty.kt") public void testGenericDelegatedProperty() throws Exception { runTest("compiler/testData/ir/irText/declarations/genericDelegatedProperty.kt"); } + @Test @TestMetadata("inlineCollectionOfInlineClass.kt") public void testInlineCollectionOfInlineClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt"); } + @Test @TestMetadata("interfaceProperties.kt") public void testInterfaceProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/interfaceProperties.kt"); } + @Test @TestMetadata("kt27005.kt") public void testKt27005() throws Exception { runTest("compiler/testData/ir/irText/declarations/kt27005.kt"); } + @Test @TestMetadata("kt29833.kt") public void testKt29833() throws Exception { runTest("compiler/testData/ir/irText/declarations/kt29833.kt"); } + @Test @TestMetadata("kt35550.kt") public void testKt35550() throws Exception { runTest("compiler/testData/ir/irText/declarations/kt35550.kt"); } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { runTest("compiler/testData/ir/irText/declarations/localClassWithOverrides.kt"); } + @Test @TestMetadata("localDelegatedProperties.kt") public void testLocalDelegatedProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/localDelegatedProperties.kt"); } + @Test @TestMetadata("localVarInDoWhile.kt") public void testLocalVarInDoWhile() throws Exception { runTest("compiler/testData/ir/irText/declarations/localVarInDoWhile.kt"); } + @Test @TestMetadata("packageLevelProperties.kt") public void testPackageLevelProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/packageLevelProperties.kt"); } + @Test @TestMetadata("primaryCtorDefaultArguments.kt") public void testPrimaryCtorDefaultArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/primaryCtorDefaultArguments.kt"); } + @Test @TestMetadata("primaryCtorProperties.kt") public void testPrimaryCtorProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/primaryCtorProperties.kt"); } + @Test @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/ir/irText/declarations/typeAlias.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/annotations") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Annotations extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Annotations extends AbstractIrTextTest { + @Test public void testAllFilesPresentInAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/annotations"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("annotationsInAnnotationArguments.kt") public void testAnnotationsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt"); } + @Test @TestMetadata("annotationsOnDelegatedMembers.kt") public void testAnnotationsOnDelegatedMembers() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.kt"); } + @Test @TestMetadata("annotationsWithDefaultParameterValues.kt") public void testAnnotationsWithDefaultParameterValues() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt"); } + @Test @TestMetadata("annotationsWithVarargParameters.kt") public void testAnnotationsWithVarargParameters() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt"); } + @Test @TestMetadata("arrayInAnnotationArguments.kt") public void testArrayInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt"); } + @Test @TestMetadata("classLiteralInAnnotation.kt") public void testClassLiteralInAnnotation() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.kt"); } + @Test @TestMetadata("classesWithAnnotations.kt") public void testClassesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.kt"); } + @Test @TestMetadata("constExpressionsInAnnotationArguments.kt") public void testConstExpressionsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt"); } + @Test @TestMetadata("constructorsWithAnnotations.kt") public void testConstructorsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt"); } + @Test @TestMetadata("delegateFieldWithAnnotations.kt") public void testDelegateFieldWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt"); } + @Test @TestMetadata("delegatedPropertyAccessorsWithAnnotations.kt") public void testDelegatedPropertyAccessorsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.kt"); } + @Test @TestMetadata("enumEntriesWithAnnotations.kt") public void testEnumEntriesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.kt"); } + @Test @TestMetadata("enumsInAnnotationArguments.kt") public void testEnumsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt"); } + @Test @TestMetadata("fieldsWithAnnotations.kt") public void testFieldsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt"); } + @Test @TestMetadata("fileAnnotations.kt") public void testFileAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt"); } + @Test @TestMetadata("functionsWithAnnotations.kt") public void testFunctionsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt"); } + @Test @TestMetadata("inheritingDeprecation.kt") public void testInheritingDeprecation() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.kt"); } + @Test @TestMetadata("javaAnnotation.kt") public void testJavaAnnotation() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt"); } + @Test @TestMetadata("localDelegatedPropertiesWithAnnotations.kt") public void testLocalDelegatedPropertiesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.kt"); } + @Test @TestMetadata("multipleAnnotationsInSquareBrackets.kt") public void testMultipleAnnotationsInSquareBrackets() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt"); } + @Test @TestMetadata("primaryConstructorParameterWithAnnotations.kt") public void testPrimaryConstructorParameterWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt"); } + @Test @TestMetadata("propertiesWithAnnotations.kt") public void testPropertiesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt"); } + @Test @TestMetadata("propertyAccessorsFromClassHeaderWithAnnotations.kt") public void testPropertyAccessorsFromClassHeaderWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt"); } + @Test @TestMetadata("propertyAccessorsWithAnnotations.kt") public void testPropertyAccessorsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt"); } + @Test @TestMetadata("propertySetterParameterWithAnnotations.kt") public void testPropertySetterParameterWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt"); } + @Test @TestMetadata("receiverParameterWithAnnotations.kt") public void testReceiverParameterWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.kt"); } + @Test @TestMetadata("spreadOperatorInAnnotationArguments.kt") public void testSpreadOperatorInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.kt"); } + @Test @TestMetadata("typeAliasesWithAnnotations.kt") public void testTypeAliasesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.kt"); } + @Test @TestMetadata("typeParametersWithAnnotations.kt") public void testTypeParametersWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.kt"); } + @Test @TestMetadata("valueParametersWithAnnotations.kt") public void testValueParametersWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt"); } + @Test @TestMetadata("varargsInAnnotationArguments.kt") public void testVarargsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt"); } + @Test @TestMetadata("variablesWithAnnotations.kt") public void testVariablesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/multiplatform") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Multiplatform extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Multiplatform extends AbstractIrTextTest { + @Test public void testAllFilesPresentInMultiplatform() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("expectClassInherited.kt") public void testExpectClassInherited() throws Exception { runTest("compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.kt"); } + @Test @TestMetadata("expectedEnumClass.kt") public void testExpectedEnumClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.kt"); } + @Test @TestMetadata("expectedSealedClass.kt") public void testExpectedSealedClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/parameters") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Parameters extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Parameters extends AbstractIrTextTest { + @Test public void testAllFilesPresentInParameters() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/parameters"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/parameters"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("class.kt") public void testClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/class.kt"); } + @Test @TestMetadata("constructor.kt") public void testConstructor() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/constructor.kt"); } + @Test @TestMetadata("dataClassMembers.kt") public void testDataClassMembers() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/dataClassMembers.kt"); } + @Test @TestMetadata("defaultPropertyAccessors.kt") public void testDefaultPropertyAccessors() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/defaultPropertyAccessors.kt"); } + @Test @TestMetadata("delegatedMembers.kt") public void testDelegatedMembers() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/delegatedMembers.kt"); } + @Test @TestMetadata("fun.kt") public void testFun() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/fun.kt"); } + @Test @TestMetadata("genericInnerClass.kt") public void testGenericInnerClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/genericInnerClass.kt"); } + @Test @TestMetadata("lambdas.kt") public void testLambdas() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/lambdas.kt"); } + @Test @TestMetadata("localFun.kt") public void testLocalFun() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/localFun.kt"); } + @Test @TestMetadata("propertyAccessors.kt") public void testPropertyAccessors() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/propertyAccessors.kt"); } + @Test @TestMetadata("typeParameterBeforeBound.kt") public void testTypeParameterBeforeBound() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt"); } + @Test @TestMetadata("typeParameterBoundedBySubclass.kt") public void testTypeParameterBoundedBySubclass() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.kt"); } + @Test @TestMetadata("useNextParamInLambda.kt") public void testUseNextParamInLambda() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/provideDelegate") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProvideDelegate extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class ProvideDelegate extends AbstractIrTextTest { + @Test public void testAllFilesPresentInProvideDelegate() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/provideDelegate"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/provideDelegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("differentReceivers.kt") public void testDifferentReceivers() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.kt"); } + @Test @TestMetadata("local.kt") public void testLocal() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/local.kt"); } + @Test @TestMetadata("localDifferentReceivers.kt") public void testLocalDifferentReceivers() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.kt"); } + @Test @TestMetadata("member.kt") public void testMember() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/member.kt"); } + @Test @TestMetadata("memberExtension.kt") public void testMemberExtension() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.kt"); } + @Test @TestMetadata("topLevel.kt") public void testTopLevel() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/topLevel.kt"); @@ -732,1037 +835,1211 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { } } + @Nested @TestMetadata("compiler/testData/ir/irText/errors") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Errors extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Errors extends AbstractIrTextTest { + @Test public void testAllFilesPresentInErrors() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/errors"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/errors"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("suppressedNonPublicCall.kt") public void testSuppressedNonPublicCall() throws Exception { runTest("compiler/testData/ir/irText/errors/suppressedNonPublicCall.kt"); } + @Test @TestMetadata("unresolvedReference.kt") public void testUnresolvedReference() throws Exception { runTest("compiler/testData/ir/irText/errors/unresolvedReference.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Expressions extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Expressions extends AbstractIrTextTest { + @Test public void testAllFilesPresentInExpressions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("argumentMappedWithError.kt") public void testArgumentMappedWithError() throws Exception { runTest("compiler/testData/ir/irText/expressions/argumentMappedWithError.kt"); } + @Test @TestMetadata("arrayAccess.kt") public void testArrayAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAccess.kt"); } + @Test @TestMetadata("arrayAssignment.kt") public void testArrayAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAssignment.kt"); } + @Test @TestMetadata("arrayAugmentedAssignment1.kt") public void testArrayAugmentedAssignment1() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.kt"); } + @Test @TestMetadata("arrayAugmentedAssignment2.kt") public void testArrayAugmentedAssignment2() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAugmentedAssignment2.kt"); } + @Test @TestMetadata("assignments.kt") public void testAssignments() throws Exception { runTest("compiler/testData/ir/irText/expressions/assignments.kt"); } + @Test @TestMetadata("augmentedAssignment1.kt") public void testAugmentedAssignment1() throws Exception { runTest("compiler/testData/ir/irText/expressions/augmentedAssignment1.kt"); } + @Test @TestMetadata("augmentedAssignment2.kt") public void testAugmentedAssignment2() throws Exception { runTest("compiler/testData/ir/irText/expressions/augmentedAssignment2.kt"); } + @Test @TestMetadata("augmentedAssignmentWithExpression.kt") public void testAugmentedAssignmentWithExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.kt"); } + @Test @TestMetadata("badBreakContinue.kt") public void testBadBreakContinue() throws Exception { runTest("compiler/testData/ir/irText/expressions/badBreakContinue.kt"); } + @Test @TestMetadata("bangbang.kt") public void testBangbang() throws Exception { runTest("compiler/testData/ir/irText/expressions/bangbang.kt"); } + @Test @TestMetadata("booleanConstsInAndAndOrOr.kt") public void testBooleanConstsInAndAndOrOr() throws Exception { runTest("compiler/testData/ir/irText/expressions/booleanConstsInAndAndOrOr.kt"); } + @Test @TestMetadata("booleanOperators.kt") public void testBooleanOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/booleanOperators.kt"); } + @Test @TestMetadata("boundCallableReferences.kt") public void testBoundCallableReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/boundCallableReferences.kt"); } + @Test @TestMetadata("boxOk.kt") public void testBoxOk() throws Exception { runTest("compiler/testData/ir/irText/expressions/boxOk.kt"); } + @Test @TestMetadata("breakContinue.kt") public void testBreakContinue() throws Exception { runTest("compiler/testData/ir/irText/expressions/breakContinue.kt"); } + @Test @TestMetadata("breakContinueInLoopHeader.kt") public void testBreakContinueInLoopHeader() throws Exception { runTest("compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.kt"); } + @Test @TestMetadata("breakContinueInWhen.kt") public void testBreakContinueInWhen() throws Exception { runTest("compiler/testData/ir/irText/expressions/breakContinueInWhen.kt"); } + @Test @TestMetadata("callWithReorderedArguments.kt") public void testCallWithReorderedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callWithReorderedArguments.kt"); } + @Test @TestMetadata("calls.kt") public void testCalls() throws Exception { runTest("compiler/testData/ir/irText/expressions/calls.kt"); } + @Test @TestMetadata("castToTypeParameter.kt") public void testCastToTypeParameter() throws Exception { runTest("compiler/testData/ir/irText/expressions/castToTypeParameter.kt"); } + @Test @TestMetadata("catchParameterAccess.kt") public void testCatchParameterAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/catchParameterAccess.kt"); } + @Test @TestMetadata("chainOfSafeCalls.kt") public void testChainOfSafeCalls() throws Exception { runTest("compiler/testData/ir/irText/expressions/chainOfSafeCalls.kt"); } + @Test @TestMetadata("classReference.kt") public void testClassReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/classReference.kt"); } + @Test @TestMetadata("coercionToUnit.kt") public void testCoercionToUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/coercionToUnit.kt"); } + @Test @TestMetadata("complexAugmentedAssignment.kt") public void testComplexAugmentedAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/complexAugmentedAssignment.kt"); } + @Test @TestMetadata("constructorWithOwnTypeParametersCall.kt") public void testConstructorWithOwnTypeParametersCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.kt"); } + @Test @TestMetadata("contructorCall.kt") public void testContructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/contructorCall.kt"); } + @Test @TestMetadata("conventionComparisons.kt") public void testConventionComparisons() throws Exception { runTest("compiler/testData/ir/irText/expressions/conventionComparisons.kt"); } + @Test @TestMetadata("destructuring1.kt") public void testDestructuring1() throws Exception { runTest("compiler/testData/ir/irText/expressions/destructuring1.kt"); } + @Test @TestMetadata("destructuringWithUnderscore.kt") public void testDestructuringWithUnderscore() throws Exception { runTest("compiler/testData/ir/irText/expressions/destructuringWithUnderscore.kt"); } + @Test @TestMetadata("dotQualified.kt") public void testDotQualified() throws Exception { runTest("compiler/testData/ir/irText/expressions/dotQualified.kt"); } + @Test @TestMetadata("elvis.kt") public void testElvis() throws Exception { runTest("compiler/testData/ir/irText/expressions/elvis.kt"); } + @Test @TestMetadata("enumEntryAsReceiver.kt") public void testEnumEntryAsReceiver() throws Exception { runTest("compiler/testData/ir/irText/expressions/enumEntryAsReceiver.kt"); } + @Test @TestMetadata("enumEntryReferenceFromEnumEntryClass.kt") public void testEnumEntryReferenceFromEnumEntryClass() throws Exception { runTest("compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.kt"); } + @Test @TestMetadata("equality.kt") public void testEquality() throws Exception { runTest("compiler/testData/ir/irText/expressions/equality.kt"); } + @Test @TestMetadata("equals.kt") public void testEquals() throws Exception { runTest("compiler/testData/ir/irText/expressions/equals.kt"); } + @Test @TestMetadata("exhaustiveWhenElseBranch.kt") public void testExhaustiveWhenElseBranch() throws Exception { runTest("compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.kt"); } + @Test @TestMetadata("extFunInvokeAsFun.kt") public void testExtFunInvokeAsFun() throws Exception { runTest("compiler/testData/ir/irText/expressions/extFunInvokeAsFun.kt"); } + @Test @TestMetadata("extFunSafeInvoke.kt") public void testExtFunSafeInvoke() throws Exception { runTest("compiler/testData/ir/irText/expressions/extFunSafeInvoke.kt"); } + @Test @TestMetadata("extensionPropertyGetterCall.kt") public void testExtensionPropertyGetterCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/extensionPropertyGetterCall.kt"); } + @Test @TestMetadata("field.kt") public void testField() throws Exception { runTest("compiler/testData/ir/irText/expressions/field.kt"); } + @Test @TestMetadata("for.kt") public void testFor() throws Exception { runTest("compiler/testData/ir/irText/expressions/for.kt"); } + @Test @TestMetadata("forWithBreakContinue.kt") public void testForWithBreakContinue() throws Exception { runTest("compiler/testData/ir/irText/expressions/forWithBreakContinue.kt"); } + @Test @TestMetadata("forWithImplicitReceivers.kt") public void testForWithImplicitReceivers() throws Exception { runTest("compiler/testData/ir/irText/expressions/forWithImplicitReceivers.kt"); } + @Test @TestMetadata("funImportedFromObject.kt") public void testFunImportedFromObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/funImportedFromObject.kt"); } + @Test @TestMetadata("genericConstructorCallWithTypeArguments.kt") public void testGenericConstructorCallWithTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.kt"); } + @Test @TestMetadata("genericPropertyCall.kt") public void testGenericPropertyCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/genericPropertyCall.kt"); } + @Test @TestMetadata("genericPropertyRef.kt") public void testGenericPropertyRef() throws Exception { runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); } + @Test @TestMetadata("identity.kt") public void testIdentity() throws Exception { runTest("compiler/testData/ir/irText/expressions/identity.kt"); } + @Test @TestMetadata("ifElseIf.kt") public void testIfElseIf() throws Exception { runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastInReturnFromConstructor.kt"); } + @Test @TestMetadata("implicitCastOnPlatformType.kt") public void testImplicitCastOnPlatformType() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.kt"); } + @Test @TestMetadata("implicitCastToNonNull.kt") public void testImplicitCastToNonNull() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt"); } + @Test @TestMetadata("implicitCastToTypeParameter.kt") public void testImplicitCastToTypeParameter() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt"); } + @Test @TestMetadata("implicitNotNullInDestructuringAssignment.kt") public void testImplicitNotNullInDestructuringAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt"); } + @Test @TestMetadata("in.kt") public void testIn() throws Exception { runTest("compiler/testData/ir/irText/expressions/in.kt"); } + @Test @TestMetadata("incrementDecrement.kt") public void testIncrementDecrement() throws Exception { runTest("compiler/testData/ir/irText/expressions/incrementDecrement.kt"); } + @Test @TestMetadata("interfaceThisRef.kt") public void testInterfaceThisRef() throws Exception { runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); } + @Test @TestMetadata("javaSyntheticGenericPropretyAccess.kt") public void testJavaSyntheticGenericPropretyAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.kt"); } + @Test @TestMetadata("javaSyntheticPropertyAccess.kt") public void testJavaSyntheticPropertyAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.kt"); } + @Test @TestMetadata("jvmFieldReferenceWithIntersectionTypes.kt") public void testJvmFieldReferenceWithIntersectionTypes() throws Exception { runTest("compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.kt"); } + @Test @TestMetadata("jvmInstanceFieldReference.kt") public void testJvmInstanceFieldReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/jvmInstanceFieldReference.kt"); } + @Test @TestMetadata("jvmStaticFieldReference.kt") public void testJvmStaticFieldReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/jvmStaticFieldReference.kt"); } + @Test @TestMetadata("kt16904.kt") public void testKt16904() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt16904.kt"); } + @Test @TestMetadata("kt16905.kt") public void testKt16905() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt16905.kt"); } + @Test @TestMetadata("kt23030.kt") public void testKt23030() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt23030.kt"); } + @Test @TestMetadata("kt24804.kt") public void testKt24804() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt24804.kt"); } + @Test @TestMetadata("kt27933.kt") public void testKt27933() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt27933.kt"); } + @Test @TestMetadata("kt28006.kt") public void testKt28006() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28006.kt"); } + @Test @TestMetadata("kt28456.kt") public void testKt28456() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28456.kt"); } + @Test @TestMetadata("kt28456a.kt") public void testKt28456a() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28456a.kt"); } + @Test @TestMetadata("kt28456b.kt") public void testKt28456b() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28456b.kt"); } + @Test @TestMetadata("kt30020.kt") public void testKt30020() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt30020.kt"); } + @Test @TestMetadata("kt30796.kt") public void testKt30796() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt30796.kt"); } + @Test @TestMetadata("kt35730.kt") public void testKt35730() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt35730.kt"); } + @Test @TestMetadata("kt36956.kt") public void testKt36956() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt36956.kt"); } + @Test @TestMetadata("kt36963.kt") public void testKt36963() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt36963.kt"); } + @Test @TestMetadata("kt37570.kt") public void testKt37570() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt37570.kt"); } + @Test @TestMetadata("kt37779.kt") public void testKt37779() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt37779.kt"); } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { runTest("compiler/testData/ir/irText/expressions/lambdaInCAO.kt"); } + @Test @TestMetadata("literals.kt") public void testLiterals() throws Exception { runTest("compiler/testData/ir/irText/expressions/literals.kt"); } + @Test @TestMetadata("memberTypeArguments.kt") public void testMemberTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/memberTypeArguments.kt"); } + @Test @TestMetadata("membersImportedFromObject.kt") public void testMembersImportedFromObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/membersImportedFromObject.kt"); } + @Test @TestMetadata("multipleSmartCasts.kt") public void testMultipleSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/multipleSmartCasts.kt"); } + @Test @TestMetadata("multipleThisReferences.kt") public void testMultipleThisReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/multipleThisReferences.kt"); } + @Test @TestMetadata("nullCheckOnGenericLambdaReturn.kt") public void testNullCheckOnGenericLambdaReturn() throws Exception { runTest("compiler/testData/ir/irText/expressions/nullCheckOnGenericLambdaReturn.kt"); } + @Test @TestMetadata("nullCheckOnLambdaReturn.kt") public void testNullCheckOnLambdaReturn() throws Exception { runTest("compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.kt"); } + @Test @TestMetadata("objectAsCallable.kt") public void testObjectAsCallable() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectAsCallable.kt"); } + @Test @TestMetadata("objectByNameInsideObject.kt") public void testObjectByNameInsideObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectByNameInsideObject.kt"); } + @Test @TestMetadata("objectClassReference.kt") public void testObjectClassReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectClassReference.kt"); } + @Test @TestMetadata("objectReference.kt") public void testObjectReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectReference.kt"); } + @Test @TestMetadata("objectReferenceInClosureInSuperConstructorCall.kt") public void testObjectReferenceInClosureInSuperConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.kt"); } + @Test @TestMetadata("objectReferenceInFieldInitializer.kt") public void testObjectReferenceInFieldInitializer() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectReferenceInFieldInitializer.kt"); } + @Test @TestMetadata("outerClassInstanceReference.kt") public void testOuterClassInstanceReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/outerClassInstanceReference.kt"); } + @Test @TestMetadata("primitiveComparisons.kt") public void testPrimitiveComparisons() throws Exception { runTest("compiler/testData/ir/irText/expressions/primitiveComparisons.kt"); } + @Test @TestMetadata("primitivesImplicitConversions.kt") public void testPrimitivesImplicitConversions() throws Exception { runTest("compiler/testData/ir/irText/expressions/primitivesImplicitConversions.kt"); } + @Test @TestMetadata("propertyReferences.kt") public void testPropertyReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/propertyReferences.kt"); } + @Test @TestMetadata("references.kt") public void testReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/references.kt"); } + @Test @TestMetadata("reflectionLiterals.kt") public void testReflectionLiterals() throws Exception { runTest("compiler/testData/ir/irText/expressions/reflectionLiterals.kt"); } + @Test @TestMetadata("safeAssignment.kt") public void testSafeAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/safeAssignment.kt"); } + @Test @TestMetadata("safeCallWithIncrementDecrement.kt") public void testSafeCallWithIncrementDecrement() throws Exception { runTest("compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.kt"); } + @Test @TestMetadata("safeCalls.kt") public void testSafeCalls() throws Exception { runTest("compiler/testData/ir/irText/expressions/safeCalls.kt"); } + @Test @TestMetadata("setFieldWithImplicitCast.kt") public void testSetFieldWithImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.kt"); } + @Test @TestMetadata("signedToUnsignedConversions.kt") public void testSignedToUnsignedConversions() throws Exception { runTest("compiler/testData/ir/irText/expressions/signedToUnsignedConversions.kt"); } + @Test @TestMetadata("simpleOperators.kt") public void testSimpleOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/simpleOperators.kt"); } + @Test @TestMetadata("simpleUnaryOperators.kt") public void testSimpleUnaryOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/simpleUnaryOperators.kt"); } + @Test @TestMetadata("smartCasts.kt") public void testSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/smartCasts.kt"); } + @Test @TestMetadata("smartCastsWithDestructuring.kt") public void testSmartCastsWithDestructuring() throws Exception { runTest("compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.kt"); } + @Test @TestMetadata("specializedTypeAliasConstructorCall.kt") public void testSpecializedTypeAliasConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.kt"); } + @Test @TestMetadata("stringComparisons.kt") public void testStringComparisons() throws Exception { runTest("compiler/testData/ir/irText/expressions/stringComparisons.kt"); } + @Test @TestMetadata("stringPlus.kt") public void testStringPlus() throws Exception { runTest("compiler/testData/ir/irText/expressions/stringPlus.kt"); } + @Test @TestMetadata("stringTemplates.kt") public void testStringTemplates() throws Exception { runTest("compiler/testData/ir/irText/expressions/stringTemplates.kt"); } + @Test @TestMetadata("suspendConversionOnArbitraryExpression.kt") public void testSuspendConversionOnArbitraryExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.kt"); } + @Test @TestMetadata("temporaryInEnumEntryInitializer.kt") public void testTemporaryInEnumEntryInitializer() throws Exception { runTest("compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.kt"); } + @Test @TestMetadata("temporaryInInitBlock.kt") public void testTemporaryInInitBlock() throws Exception { runTest("compiler/testData/ir/irText/expressions/temporaryInInitBlock.kt"); } + @Test @TestMetadata("thisOfGenericOuterClass.kt") public void testThisOfGenericOuterClass() throws Exception { runTest("compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.kt"); } + @Test @TestMetadata("thisRefToObjectInNestedClassConstructorCall.kt") public void testThisRefToObjectInNestedClassConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.kt"); } + @Test @TestMetadata("thisReferenceBeforeClassDeclared.kt") public void testThisReferenceBeforeClassDeclared() throws Exception { runTest("compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.kt"); } + @Test @TestMetadata("throw.kt") public void testThrow() throws Exception { runTest("compiler/testData/ir/irText/expressions/throw.kt"); } + @Test @TestMetadata("tryCatch.kt") public void testTryCatch() throws Exception { runTest("compiler/testData/ir/irText/expressions/tryCatch.kt"); } + @Test @TestMetadata("tryCatchWithImplicitCast.kt") public void testTryCatchWithImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/expressions/tryCatchWithImplicitCast.kt"); } + @Test @TestMetadata("typeAliasConstructorReference.kt") public void testTypeAliasConstructorReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeAliasConstructorReference.kt"); } + @Test @TestMetadata("typeArguments.kt") public void testTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeArguments.kt"); } + @Test @TestMetadata("typeOperators.kt") public void testTypeOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeOperators.kt"); } + @Test @TestMetadata("typeParameterClassLiteral.kt") public void testTypeParameterClassLiteral() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeParameterClassLiteral.kt"); } + @Test @TestMetadata("unsignedIntegerLiterals.kt") public void testUnsignedIntegerLiterals() throws Exception { runTest("compiler/testData/ir/irText/expressions/unsignedIntegerLiterals.kt"); } + @Test @TestMetadata("useImportedMember.kt") public void testUseImportedMember() throws Exception { runTest("compiler/testData/ir/irText/expressions/useImportedMember.kt"); } + @Test @TestMetadata("values.kt") public void testValues() throws Exception { runTest("compiler/testData/ir/irText/expressions/values.kt"); } + @Test @TestMetadata("vararg.kt") public void testVararg() throws Exception { runTest("compiler/testData/ir/irText/expressions/vararg.kt"); } + @Test @TestMetadata("varargWithImplicitCast.kt") public void testVarargWithImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/expressions/varargWithImplicitCast.kt"); } + @Test @TestMetadata("variableAsFunctionCall.kt") public void testVariableAsFunctionCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/variableAsFunctionCall.kt"); } + @Test @TestMetadata("variableAsFunctionCallWithGenerics.kt") public void testVariableAsFunctionCallWithGenerics() throws Exception { runTest("compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.kt"); } + @Test @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/ir/irText/expressions/when.kt"); } + @Test @TestMetadata("whenCoercedToUnit.kt") public void testWhenCoercedToUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenCoercedToUnit.kt"); } + @Test @TestMetadata("whenElse.kt") public void testWhenElse() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenElse.kt"); } + @Test @TestMetadata("whenReturn.kt") public void testWhenReturn() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenReturn.kt"); } + @Test @TestMetadata("whenReturnUnit.kt") public void testWhenReturnUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenReturnUnit.kt"); } + @Test @TestMetadata("whenSmartCastToEnum.kt") public void testWhenSmartCastToEnum() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt"); } + @Test @TestMetadata("whenUnusedExpression.kt") public void testWhenUnusedExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenUnusedExpression.kt"); } + @Test @TestMetadata("whenWithSubjectVariable.kt") public void testWhenWithSubjectVariable() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenWithSubjectVariable.kt"); } + @Test @TestMetadata("whileDoWhile.kt") public void testWhileDoWhile() throws Exception { runTest("compiler/testData/ir/irText/expressions/whileDoWhile.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/callableReferences") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class CallableReferences extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class CallableReferences extends AbstractIrTextTest { + @Test @TestMetadata("adaptedExtensionFunctions.kt") public void testAdaptedExtensionFunctions() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.kt"); } + @Test @TestMetadata("adaptedWithCoercionToUnit.kt") public void testAdaptedWithCoercionToUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt"); } + @Test public void testAllFilesPresentInCallableReferences() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("boundInlineAdaptedReference.kt") public void testBoundInlineAdaptedReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt"); } + @Test @TestMetadata("boundInnerGenericConstructor.kt") public void testBoundInnerGenericConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.kt"); } + @Test @TestMetadata("caoWithAdaptationForSam.kt") public void testCaoWithAdaptationForSam() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt"); } + @Test @TestMetadata("constructorWithAdaptedArguments.kt") public void testConstructorWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt"); } + @Test @TestMetadata("funWithDefaultParametersAsKCallableStar.kt") public void testFunWithDefaultParametersAsKCallableStar() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.kt"); } + @Test @TestMetadata("genericLocalClassConstructorReference.kt") public void testGenericLocalClassConstructorReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt"); } + @Test @TestMetadata("genericMember.kt") public void testGenericMember() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/genericMember.kt"); } + @Test @TestMetadata("importedFromObject.kt") public void testImportedFromObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.kt"); } + @Test @TestMetadata("kt37131.kt") public void testKt37131() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt"); } + @Test @TestMetadata("suspendConversion.kt") public void testSuspendConversion() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt"); } + @Test @TestMetadata("typeArguments.kt") public void testTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/typeArguments.kt"); } + @Test @TestMetadata("unboundMemberReferenceWithAdaptedArguments.kt") public void testUnboundMemberReferenceWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt"); } + @Test @TestMetadata("withAdaptationForSam.kt") public void testWithAdaptationForSam() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt"); } + @Test @TestMetadata("withAdaptedArguments.kt") public void testWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt"); } + @Test @TestMetadata("withArgumentAdaptationAndReceiver.kt") public void testWithArgumentAdaptationAndReceiver() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.kt"); } + @Test @TestMetadata("withVarargViewedAsArray.kt") public void testWithVarargViewedAsArray() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FloatingPointComparisons extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class FloatingPointComparisons extends AbstractIrTextTest { + @Test public void testAllFilesPresentInFloatingPointComparisons() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/floatingPointComparisons"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/floatingPointComparisons"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("comparableWithDoubleOrFloat.kt") public void testComparableWithDoubleOrFloat() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.kt"); } + @Test @TestMetadata("eqeqRhsConditionPossiblyAffectingLhs.kt") public void testEqeqRhsConditionPossiblyAffectingLhs() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/eqeqRhsConditionPossiblyAffectingLhs.kt"); } + @Test @TestMetadata("floatingPointCompareTo.kt") public void testFloatingPointCompareTo() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.kt"); } + @Test @TestMetadata("floatingPointEqeq.kt") public void testFloatingPointEqeq() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.kt"); } + @Test @TestMetadata("floatingPointEquals.kt") public void testFloatingPointEquals() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.kt"); } + @Test @TestMetadata("floatingPointExcleq.kt") public void testFloatingPointExcleq() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.kt"); } + @Test @TestMetadata("floatingPointLess.kt") public void testFloatingPointLess() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.kt"); } + @Test @TestMetadata("nullableAnyAsIntToDouble.kt") public void testNullableAnyAsIntToDouble() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt"); } + @Test @TestMetadata("nullableFloatingPointEqeq.kt") public void testNullableFloatingPointEqeq() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.kt"); } + @Test @TestMetadata("typeParameterWithPrimitiveNumericSupertype.kt") public void testTypeParameterWithPrimitiveNumericSupertype() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/typeParameterWithPrimitiveNumericSupertype.kt"); } + @Test @TestMetadata("whenByFloatingPoint.kt") public void testWhenByFloatingPoint() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/funInterface") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FunInterface extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class FunInterface extends AbstractIrTextTest { + @Test public void testAllFilesPresentInFunInterface() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("arrayAsVarargAfterSamArgument_fi.kt") public void testArrayAsVarargAfterSamArgument_fi() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/arrayAsVarargAfterSamArgument_fi.kt"); } + @Test @TestMetadata("basicFunInterfaceConversion.kt") public void testBasicFunInterfaceConversion() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/basicFunInterfaceConversion.kt"); } + @Test @TestMetadata("castFromAny.kt") public void testCastFromAny() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/castFromAny.kt"); } + @Test @TestMetadata("partialSam.kt") public void testPartialSam() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/partialSam.kt"); } + @Test @TestMetadata("samConversionInVarargs.kt") public void testSamConversionInVarargs() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.kt"); } + @Test @TestMetadata("samConversionInVarargsMixed.kt") public void testSamConversionInVarargsMixed() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.kt"); } + @Test @TestMetadata("samConversionOnCallableReference.kt") public void testSamConversionOnCallableReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt"); } + @Test @TestMetadata("samConversionsWithSmartCasts.kt") public void testSamConversionsWithSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/sam") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Sam extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Sam extends AbstractIrTextTest { + @Test public void testAllFilesPresentInSam() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/sam"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("arrayAsVarargAfterSamArgument.kt") public void testArrayAsVarargAfterSamArgument() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/arrayAsVarargAfterSamArgument.kt"); } + @Test @TestMetadata("genericSamProjectedOut.kt") public void testGenericSamProjectedOut() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.kt"); } + @Test @TestMetadata("genericSamSmartcast.kt") public void testGenericSamSmartcast() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.kt"); } + @Test @TestMetadata("samByProjectedType.kt") public void testSamByProjectedType() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samByProjectedType.kt"); } + @Test @TestMetadata("samConstructors.kt") public void testSamConstructors() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConstructors.kt"); } + @Test @TestMetadata("samConversionInGenericConstructorCall.kt") public void testSamConversionInGenericConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.kt"); } + @Test @TestMetadata("samConversionInGenericConstructorCall_NI.kt") public void testSamConversionInGenericConstructorCall_NI() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.kt"); } + @Test @TestMetadata("samConversionToGeneric.kt") public void testSamConversionToGeneric() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.kt"); } + @Test @TestMetadata("samConversions.kt") public void testSamConversions() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversions.kt"); } + @Test @TestMetadata("samConversionsWithSmartCasts.kt") public void testSamConversionsWithSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.kt"); } + @Test @TestMetadata("samOperators.kt") public void testSamOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samOperators.kt"); @@ -1770,251 +2047,279 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { } } + @Nested @TestMetadata("compiler/testData/ir/irText/firProblems") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FirProblems extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class FirProblems extends AbstractIrTextTest { + @Test @TestMetadata("AbstractMutableMap.kt") public void testAbstractMutableMap() throws Exception { runTest("compiler/testData/ir/irText/firProblems/AbstractMutableMap.kt"); } + @Test @TestMetadata("AllCandidates.kt") public void testAllCandidates() throws Exception { runTest("compiler/testData/ir/irText/firProblems/AllCandidates.kt"); } + @Test public void testAllFilesPresentInFirProblems() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("AnnotationInAnnotation.kt") public void testAnnotationInAnnotation() throws Exception { runTest("compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt"); } + @Test @TestMetadata("candidateSymbol.kt") public void testCandidateSymbol() throws Exception { runTest("compiler/testData/ir/irText/firProblems/candidateSymbol.kt"); } + @Test @TestMetadata("ClashResolutionDescriptor.kt") public void testClashResolutionDescriptor() throws Exception { runTest("compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.kt"); } + @Test @TestMetadata("coercionToUnitForNestedWhen.kt") public void testCoercionToUnitForNestedWhen() throws Exception { runTest("compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.kt"); } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { runTest("compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt"); } + @Test @TestMetadata("DelegationAndInheritanceFromJava.kt") public void testDelegationAndInheritanceFromJava() throws Exception { runTest("compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.kt"); } + @Test @TestMetadata("deprecated.kt") public void testDeprecated() throws Exception { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + @Test @TestMetadata("FirBuilder.kt") public void testFirBuilder() throws Exception { runTest("compiler/testData/ir/irText/firProblems/FirBuilder.kt"); } + @Test @TestMetadata("ImplicitReceiverStack.kt") public void testImplicitReceiverStack() throws Exception { runTest("compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.kt"); } + @Test @TestMetadata("inapplicableCollectionSet.kt") public void testInapplicableCollectionSet() throws Exception { runTest("compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.kt"); } + @Test @TestMetadata("InnerClassInAnonymous.kt") public void testInnerClassInAnonymous() throws Exception { runTest("compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.kt"); } + @Test @TestMetadata("kt43342.kt") public void testKt43342() throws Exception { runTest("compiler/testData/ir/irText/firProblems/kt43342.kt"); } + @Test @TestMetadata("MultiList.kt") public void testMultiList() throws Exception { runTest("compiler/testData/ir/irText/firProblems/MultiList.kt"); } + @Test @TestMetadata("putIfAbsent.kt") public void testPutIfAbsent() throws Exception { runTest("compiler/testData/ir/irText/firProblems/putIfAbsent.kt"); } + @Test @TestMetadata("readWriteProperty.kt") public void testReadWriteProperty() throws Exception { runTest("compiler/testData/ir/irText/firProblems/readWriteProperty.kt"); } + @Test @TestMetadata("recursiveCapturedTypeInPropertyReference.kt") public void testRecursiveCapturedTypeInPropertyReference() throws Exception { runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt"); } + @Test @TestMetadata("SameJavaFieldReferences.kt") public void testSameJavaFieldReferences() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SameJavaFieldReferences.kt"); } + @Test @TestMetadata("SignatureClash.kt") public void testSignatureClash() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SignatureClash.kt"); } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SyntheticSetterType.kt"); } + @Test @TestMetadata("throwableStackTrace.kt") public void testThrowableStackTrace() throws Exception { runTest("compiler/testData/ir/irText/firProblems/throwableStackTrace.kt"); } + @Test @TestMetadata("typeParameterFromJavaClass.kt") public void testTypeParameterFromJavaClass() throws Exception { runTest("compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt"); } + @Test @TestMetadata("typeVariableAfterBuildMap.kt") public void testTypeVariableAfterBuildMap() throws Exception { runTest("compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.kt"); } + @Test @TestMetadata("V8ArrayToList.kt") public void testV8ArrayToList() throws Exception { runTest("compiler/testData/ir/irText/firProblems/V8ArrayToList.kt"); } + @Test @TestMetadata("VarInInit.kt") public void testVarInInit() throws Exception { runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/lambdas") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Lambdas extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Lambdas extends AbstractIrTextTest { + @Test public void testAllFilesPresentInLambdas() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/lambdas"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/lambdas"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("anonymousFunction.kt") public void testAnonymousFunction() throws Exception { runTest("compiler/testData/ir/irText/lambdas/anonymousFunction.kt"); } + @Test @TestMetadata("destructuringInLambda.kt") public void testDestructuringInLambda() throws Exception { runTest("compiler/testData/ir/irText/lambdas/destructuringInLambda.kt"); } + @Test @TestMetadata("extensionLambda.kt") public void testExtensionLambda() throws Exception { runTest("compiler/testData/ir/irText/lambdas/extensionLambda.kt"); } + @Test @TestMetadata("justLambda.kt") public void testJustLambda() throws Exception { runTest("compiler/testData/ir/irText/lambdas/justLambda.kt"); } + @Test @TestMetadata("localFunction.kt") public void testLocalFunction() throws Exception { runTest("compiler/testData/ir/irText/lambdas/localFunction.kt"); } + @Test @TestMetadata("multipleImplicitReceivers.kt") public void testMultipleImplicitReceivers() throws Exception { runTest("compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.kt"); } + @Test @TestMetadata("nonLocalReturn.kt") public void testNonLocalReturn() throws Exception { runTest("compiler/testData/ir/irText/lambdas/nonLocalReturn.kt"); } + @Test @TestMetadata("samAdapter.kt") public void testSamAdapter() throws Exception { runTest("compiler/testData/ir/irText/lambdas/samAdapter.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/regressions") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Regressions extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Regressions extends AbstractIrTextTest { + @Test public void testAllFilesPresentInRegressions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("coercionInLoop.kt") public void testCoercionInLoop() throws Exception { runTest("compiler/testData/ir/irText/regressions/coercionInLoop.kt"); } + @Test @TestMetadata("integerCoercionToT.kt") public void testIntegerCoercionToT() throws Exception { runTest("compiler/testData/ir/irText/regressions/integerCoercionToT.kt"); } + @Test @TestMetadata("kt24114.kt") public void testKt24114() throws Exception { runTest("compiler/testData/ir/irText/regressions/kt24114.kt"); } + @Test @TestMetadata("typeAliasCtorForGenericClass.kt") public void testTypeAliasCtorForGenericClass() throws Exception { runTest("compiler/testData/ir/irText/regressions/typeAliasCtorForGenericClass.kt"); } + @Test @TestMetadata("typeParametersInImplicitCast.kt") public void testTypeParametersInImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/regressions/newInference") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NewInference extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class NewInference extends AbstractIrTextTest { + @Test public void testAllFilesPresentInNewInference() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions/newInference"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions/newInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("fixationOrder1.kt") public void testFixationOrder1() throws Exception { runTest("compiler/testData/ir/irText/regressions/newInference/fixationOrder1.kt"); @@ -2022,348 +2327,390 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { } } + @Nested @TestMetadata("compiler/testData/ir/irText/singletons") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Singletons extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Singletons extends AbstractIrTextTest { + @Test public void testAllFilesPresentInSingletons() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/singletons"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/singletons"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("companion.kt") public void testCompanion() throws Exception { runTest("compiler/testData/ir/irText/singletons/companion.kt"); } + @Test @TestMetadata("enumEntry.kt") public void testEnumEntry() throws Exception { runTest("compiler/testData/ir/irText/singletons/enumEntry.kt"); } + @Test @TestMetadata("object.kt") public void testObject() throws Exception { runTest("compiler/testData/ir/irText/singletons/object.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/stubs") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Stubs extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Stubs extends AbstractIrTextTest { + @Test public void testAllFilesPresentInStubs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("builtinMap.kt") public void testBuiltinMap() throws Exception { runTest("compiler/testData/ir/irText/stubs/builtinMap.kt"); } + @Test @TestMetadata("constFromBuiltins.kt") public void testConstFromBuiltins() throws Exception { runTest("compiler/testData/ir/irText/stubs/constFromBuiltins.kt"); } + @Test @TestMetadata("genericClassInDifferentModule.kt") public void testGenericClassInDifferentModule() throws Exception { runTest("compiler/testData/ir/irText/stubs/genericClassInDifferentModule.kt"); } + @Test @TestMetadata("javaConstructorWithTypeParameters.kt") public void testJavaConstructorWithTypeParameters() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaConstructorWithTypeParameters.kt"); } + @Test @TestMetadata("javaEnum.kt") public void testJavaEnum() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaEnum.kt"); } + @Test @TestMetadata("javaInnerClass.kt") public void testJavaInnerClass() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaInnerClass.kt"); } + @Test @TestMetadata("javaMethod.kt") public void testJavaMethod() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaMethod.kt"); } + @Test @TestMetadata("javaNestedClass.kt") public void testJavaNestedClass() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaNestedClass.kt"); } + @Test @TestMetadata("javaStaticMethod.kt") public void testJavaStaticMethod() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaStaticMethod.kt"); } + @Test @TestMetadata("javaSyntheticProperty.kt") public void testJavaSyntheticProperty() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaSyntheticProperty.kt"); } + @Test @TestMetadata("jdkClassSyntheticProperty.kt") public void testJdkClassSyntheticProperty() throws Exception { runTest("compiler/testData/ir/irText/stubs/jdkClassSyntheticProperty.kt"); } + @Test @TestMetadata("kotlinInnerClass.kt") public void testKotlinInnerClass() throws Exception { runTest("compiler/testData/ir/irText/stubs/kotlinInnerClass.kt"); } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/ir/irText/stubs/simple.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/types") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Types extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class Types extends AbstractIrTextTest { + @Test @TestMetadata("abbreviatedTypes.kt") public void testAbbreviatedTypes() throws Exception { runTest("compiler/testData/ir/irText/types/abbreviatedTypes.kt"); } + @Test public void testAllFilesPresentInTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("asOnPlatformType.kt") public void testAsOnPlatformType() throws Exception { runTest("compiler/testData/ir/irText/types/asOnPlatformType.kt"); } + @Test @TestMetadata("castsInsideCoroutineInference.kt") public void testCastsInsideCoroutineInference() throws Exception { runTest("compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt"); } + @Test @TestMetadata("coercionToUnitInLambdaReturnValue.kt") public void testCoercionToUnitInLambdaReturnValue() throws Exception { runTest("compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt"); } + @Test @TestMetadata("genericDelegatedDeepProperty.kt") public void testGenericDelegatedDeepProperty() throws Exception { runTest("compiler/testData/ir/irText/types/genericDelegatedDeepProperty.kt"); } + @Test @TestMetadata("genericFunWithStar.kt") public void testGenericFunWithStar() throws Exception { runTest("compiler/testData/ir/irText/types/genericFunWithStar.kt"); } + @Test @TestMetadata("genericPropertyReferenceType.kt") public void testGenericPropertyReferenceType() throws Exception { runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt"); } + @Test @TestMetadata("inStarProjectionInReceiverType.kt") public void testInStarProjectionInReceiverType() throws Exception { runTest("compiler/testData/ir/irText/types/inStarProjectionInReceiverType.kt"); } + @Test @TestMetadata("intersectionType1_NI.kt") public void testIntersectionType1_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt"); } + @Test @TestMetadata("intersectionType1_OI.kt") public void testIntersectionType1_OI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType1_OI.kt"); } + @Test @TestMetadata("intersectionType2_NI.kt") public void testIntersectionType2_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType2_NI.kt"); } + @Test @TestMetadata("intersectionType2_OI.kt") public void testIntersectionType2_OI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType2_OI.kt"); } + @Test @TestMetadata("intersectionType3_NI.kt") public void testIntersectionType3_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType3_NI.kt"); } + @Test @TestMetadata("intersectionType3_OI.kt") public void testIntersectionType3_OI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType3_OI.kt"); } + @Test @TestMetadata("javaWildcardType.kt") public void testJavaWildcardType() throws Exception { runTest("compiler/testData/ir/irText/types/javaWildcardType.kt"); } + @Test @TestMetadata("kt36143.kt") public void testKt36143() throws Exception { runTest("compiler/testData/ir/irText/types/kt36143.kt"); } + @Test @TestMetadata("localVariableOfIntersectionType_NI.kt") public void testLocalVariableOfIntersectionType_NI() throws Exception { runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt"); } + @Test @TestMetadata("rawTypeInSignature.kt") public void testRawTypeInSignature() throws Exception { runTest("compiler/testData/ir/irText/types/rawTypeInSignature.kt"); } + @Test @TestMetadata("receiverOfIntersectionType.kt") public void testReceiverOfIntersectionType() throws Exception { runTest("compiler/testData/ir/irText/types/receiverOfIntersectionType.kt"); } + @Test @TestMetadata("smartCastOnFakeOverrideReceiver.kt") public void testSmartCastOnFakeOverrideReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/smartCastOnFakeOverrideReceiver.kt"); } + @Test @TestMetadata("smartCastOnFieldReceiverOfGenericType.kt") public void testSmartCastOnFieldReceiverOfGenericType() throws Exception { runTest("compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.kt"); } + @Test @TestMetadata("smartCastOnReceiverOfGenericType.kt") public void testSmartCastOnReceiverOfGenericType() throws Exception { runTest("compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.kt"); } + @Test @TestMetadata("starProjection_OI.kt") public void testStarProjection_OI() throws Exception { runTest("compiler/testData/ir/irText/types/starProjection_OI.kt"); } + @Test @TestMetadata("typeAliasWithUnsafeVariance.kt") public void testTypeAliasWithUnsafeVariance() throws Exception { runTest("compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/types/nullChecks") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NullChecks extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class NullChecks extends AbstractIrTextTest { + @Test public void testAllFilesPresentInNullChecks() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("enhancedNullability.kt") public void testEnhancedNullability() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/enhancedNullability.kt"); } + @Test @TestMetadata("enhancedNullabilityInDestructuringAssignment.kt") public void testEnhancedNullabilityInDestructuringAssignment() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.kt"); } + @Test @TestMetadata("enhancedNullabilityInForLoop.kt") public void testEnhancedNullabilityInForLoop() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.kt"); } + @Test @TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt") public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt"); } + @Test @TestMetadata("implicitNotNullOnPlatformType.kt") public void testImplicitNotNullOnPlatformType() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.kt"); } + @Test @TestMetadata("nullabilityAssertionOnExtensionReceiver.kt") public void testNullabilityAssertionOnExtensionReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.kt"); } + @Test @TestMetadata("platformTypeReceiver.kt") public void testPlatformTypeReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/platformTypeReceiver.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NullCheckOnLambdaResult extends AbstractIrTextTestCase { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); - } - + public class NullCheckOnLambdaResult extends AbstractIrTextTest { + @Test public void testAllFilesPresentInNullCheckOnLambdaResult() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("nnStringVsT.kt") public void testNnStringVsT() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt"); } + @Test @TestMetadata("nnStringVsTAny.kt") public void testNnStringVsTAny() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt"); } + @Test @TestMetadata("nnStringVsTConstrained.kt") public void testNnStringVsTConstrained() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt"); } + @Test @TestMetadata("nnStringVsTXArray.kt") public void testNnStringVsTXArray() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt"); } + @Test @TestMetadata("nnStringVsTXString.kt") public void testNnStringVsTXString() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt"); } + @Test @TestMetadata("stringVsT.kt") public void testStringVsT() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt"); } + @Test @TestMetadata("stringVsTAny.kt") public void testStringVsTAny() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt"); } + @Test @TestMetadata("stringVsTConstrained.kt") public void testStringVsTConstrained() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt"); } + @Test @TestMetadata("stringVsTXArray.kt") public void testStringVsTXArray() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt"); } + @Test @TestMetadata("stringVsTXString.kt") public void testStringVsTXString() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt"); diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt index 36dbf239d20..cba8fcead40 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/classic/JavaCompilerFacade.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager import org.jetbrains.kotlin.test.services.sourceFileProvider import org.jetbrains.kotlin.test.util.KtTestUtil import java.io.File -import java.nio.file.Paths class JavaCompilerFacade(private val testServices: TestServices) { @OptIn(ExperimentalStdlibApi::class) @@ -51,7 +50,8 @@ class JavaCompilerFacade(private val testServices: TestServices) { ) val javaFiles = module.javaFiles.map { testServices.sourceFileProvider.getRealFileForSourceFile(it) } - compileJavaFiles(configuration[JVMConfigurationKeys.JVM_TARGET] ?: JvmTarget.DEFAULT, javaFiles, finalJavacOptions) + val ignoreErrors = CodegenTestDirectives.IGNORE_JAVA_ERRORS in module.directives + compileJavaFiles(configuration[JVMConfigurationKeys.JVM_TARGET] ?: JvmTarget.DEFAULT, javaFiles, finalJavacOptions, ignoreErrors) } @OptIn(ExperimentalStdlibApi::class) @@ -73,10 +73,15 @@ class JavaCompilerFacade(private val testServices: TestServices) { } } - private fun compileJavaFiles(jvmTarget: JvmTarget, files: List, javacOptions: List) { + private fun compileJavaFiles(jvmTarget: JvmTarget, files: List, javacOptions: List, ignoreErrors: Boolean) { val targetIsJava8OrLower = System.getProperty("java.version").startsWith("1.") if (targetIsJava8OrLower) { - org.jetbrains.kotlin.test.compileJavaFiles(files, javacOptions, assertions = testServices.assertions) + org.jetbrains.kotlin.test.compileJavaFiles( + files, + javacOptions, + assertions = testServices.assertions, + ignoreJavaErrors = ignoreErrors + ) return } val jdkHome = when (jvmTarget) { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt new file mode 100644 index 00000000000..bc259a5f85b --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/AbstractIrHandler.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test.backend.handlers + +import org.jetbrains.kotlin.test.backend.ir.IrBackendInput +import org.jetbrains.kotlin.test.model.BackendInputHandler +import org.jetbrains.kotlin.test.model.BackendKinds +import org.jetbrains.kotlin.test.services.TestServices + +abstract class AbstractIrHandler(testServices: TestServices) : BackendInputHandler(testServices, BackendKinds.IrBackend) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt new file mode 100644 index 00000000000..c012607e5de --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt @@ -0,0 +1,116 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test.backend.handlers + +import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor +import org.jetbrains.kotlin.config.languageVersionSettings +import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies +import org.jetbrains.kotlin.ir.IrVerifier +import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsManglerDesc +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.test.backend.ir.IrBackendInput +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_EXTERNAL_CLASS +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.EXTERNAL_FILE +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_IDENTICAL +import org.jetbrains.kotlin.test.directives.model.DirectivesContainer +import org.jetbrains.kotlin.test.model.FrontendKinds +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.moduleStructure +import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumperImpl +import org.jetbrains.kotlin.test.utils.withExtension +import org.jetbrains.kotlin.test.utils.withSuffixAndExtension +import java.io.File + +class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServices) { + override val directivesContainers: List + get() = listOf(CodegenTestDirectives, FirDiagnosticsDirectives) + + private val baseDumper = MultiModuleInfoDumperImpl() + private val buildersForSeparateFileDumps: MutableMap = mutableMapOf() + + @OptIn(ExperimentalStdlibApi::class) + override fun processModule(module: TestModule, info: IrBackendInput) { + if (DUMP_IR !in module.directives) return + val irFiles = info.backendInput.irModuleFragment.files + val testFileToIrFile = irFiles.mapNotNull { irFile -> + val name = irFile.fileEntry.name.removePrefix("/") + val testFile = module.files.firstOrNull { it.name == name } ?: return@mapNotNull null + testFile to irFile + } + val builder = baseDumper.builderForModule(module) + for ((testFile, irFile) in testFileToIrFile) { + if (EXTERNAL_FILE in testFile.directives) continue + val actualDump = irFile.dumpTreesFromLineNumber(lineNumber = 0, normalizeNames = true) + builder.append(actualDump) + verify(irFile) + + val irFileCopy = irFile.deepCopyWithSymbols() + val dumpOfCopy = irFileCopy.dumpTreesFromLineNumber(lineNumber = 0, normalizeNames = true) + assertions.assertEquals(actualDump, dumpOfCopy) { "IR dump mismatch after deep copy with symbols" } + } + compareDumpsOfExternalClasses(module, info) + } + + private fun compareDumpsOfExternalClasses(module: TestModule, info: IrBackendInput) { + val externalClassFqns = module.directives[DUMP_EXTERNAL_CLASS] + if (externalClassFqns.isEmpty()) return + + // TODO: why JS one is used here in original AbstractIrTextTestCase? + val mangler = JsManglerDesc + val signaturer = IdSignatureDescriptor(mangler) + val irModule = info.backendInput.irModuleFragment + val stubGenerator = DeclarationStubGenerator( + irModule.descriptor, + SymbolTable(signaturer, IrFactoryImpl), // TODO + module.languageVersionSettings + ) + + val baseFile = testServices.moduleStructure.originalTestDataFiles.first() + for (externalClassFqn in externalClassFqns) { + val classDump = stubGenerator.generateExternalClass(irModule.descriptor, externalClassFqn).dump() + val expectedFile = baseFile.withSuffixAndExtension("__$externalClassFqn", module.dumpExtension) + assertions.assertEqualsToFile(expectedFile, classDump) + } + } + + private fun DeclarationStubGenerator.generateExternalClass(descriptor: ModuleDescriptor, externalClassFqn: String): IrClass { + val classDescriptor = + descriptor.findClassAcrossModuleDependencies(ClassId.topLevel(FqName(externalClassFqn))) + ?: throw AssertionError("Can't find a class in external dependencies: $externalClassFqn") + + return generateMemberStub(classDescriptor) as IrClass + } + + override fun processAfterAllModules(someAssertionWasFailed: Boolean) { + val moduleStructure = testServices.moduleStructure + val defaultExpectedFile = moduleStructure.originalTestDataFiles.first().withExtension(moduleStructure.modules.first().dumpExtension) + checkOneExpectedFile(defaultExpectedFile, baseDumper.generateResultingDump()) + buildersForSeparateFileDumps.entries.forEach { (expectedFile, dump) -> checkOneExpectedFile(expectedFile, dump.toString()) } + } + + private fun checkOneExpectedFile(expectedFile: File, actualDump: String) { + if (actualDump.isNotEmpty()) { + assertions.assertEqualsToFile(expectedFile, actualDump) + } + } + + private fun verify(irFile: IrFile) { + IrVerifier(assertions).verifyWithAssert(irFile) + } + + private val TestModule.dumpExtension: String + get() = if (frontendKind == FrontendKinds.ClassicFrontend || FIR_IDENTICAL in directives) "txt" else "fir.txt" +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt index 3fc068dcdf4..5a3dbfcd17b 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt @@ -6,9 +6,9 @@ package org.jetbrains.kotlin.test.directives import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler import org.jetbrains.kotlin.test.backend.handlers.NoCompilationErrorsHandler import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade -import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.File import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability.Global import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer @@ -56,13 +56,16 @@ object CodegenTestDirectives : SimpleDirectivesContainer() { """.trimIndent() ) + val IGNORE_JAVA_ERRORS by directive( + description = "Ignore compilation errors from java" + ) + val IGNORE_FIR_DIAGNOSTICS by directive( description = "Run backend even FIR reported some diagnostics with ERROR severity" ) - val IR_FILE by stringDirective( - description = "Specifies file name for IR text dump", - applicability = File + val DUMP_IR by directive( + description = "Dumps generated backend IR (enables ${IrTextDumpHandler::class})" ) val DUMP_EXTERNAL_CLASS by stringDirective( @@ -70,7 +73,7 @@ object CodegenTestDirectives : SimpleDirectivesContainer() { ) val EXTERNAL_FILE by directive( - description = "Indicates that test file is external", + description = "Indicates that test file is external and should be skipped in ${IrTextDumpHandler::class}", applicability = File ) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractKotlinCompilerWithTargetBackendTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractKotlinCompilerWithTargetBackendTest.kt index a53260e7cac..7386e0d6428 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractKotlinCompilerWithTargetBackendTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractKotlinCompilerWithTargetBackendTest.kt @@ -15,7 +15,15 @@ abstract class AbstractKotlinCompilerWithTargetBackendTest( super.configure(builder) with(builder) { globalDefaults { - targetBackend = this@AbstractKotlinCompilerWithTargetBackendTest.targetBackend + val targetBackendFromMarker = this@AbstractKotlinCompilerWithTargetBackendTest.targetBackend + if (targetBackend == null) { + targetBackend = this@AbstractKotlinCompilerWithTargetBackendTest.targetBackend + } else { + require(targetBackend == targetBackendFromMarker) { + """Target backend in configuration specified to $targetBackend but in + |AbstractKotlinCompilerWithTargetBackendTest parent it is set to $targetBackendFromMarker""".trimMargin() + } + } } } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt new file mode 100644 index 00000000000..6908a7392fa --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt @@ -0,0 +1,66 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test.runners.ir + +import org.jetbrains.kotlin.platform.jvm.JvmPlatforms +import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor +import org.jetbrains.kotlin.test.backend.handlers.* +import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR +import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2IrConverter +import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade +import org.jetbrains.kotlin.test.frontend.fir.Fir2IrResultsConverter +import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade +import org.jetbrains.kotlin.test.model.* +import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerWithTargetBackendTest +import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator +import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator +import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider +import org.jetbrains.kotlin.test.services.sourceProviders.CodegenHelpersSourceFilesProvider +import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider + +abstract class AbstractIrTextTestBase( + private val frontend: FrontendKind<*> +) : AbstractKotlinCompilerWithTargetBackendTest(TargetBackend.JVM_IR) { + override fun TestConfigurationBuilder.configuration() { + globalDefaults { + frontend = this@AbstractIrTextTestBase.frontend + targetPlatform = JvmPlatforms.defaultJvmPlatform + artifactKind = BinaryKind.NoArtifact + targetBackend = TargetBackend.JVM_IR + dependencyKind = DependencyKind.Source + } + + defaultDirectives { + +DUMP_IR + } + + useConfigurators( + ::CommonEnvironmentConfigurator, + ::JvmEnvironmentConfigurator + ) + + useAdditionalSourceProviders( + ::AdditionalDiagnosticsSourceFilesProvider, + ::CoroutineHelpersSourceFilesProvider, + ::CodegenHelpersSourceFilesProvider, + ) + + useFrontendFacades( + ::ClassicFrontendFacade, + ::FirFrontendFacade + ) + useFrontend2BackendConverters( + ::ClassicFrontend2IrConverter, + ::Fir2IrResultsConverter + ) + + useBackendHandlers(::IrTextDumpHandler) + } +} + +open class AbstractIrTextTest : AbstractIrTextTestBase(FrontendKinds.ClassicFrontend) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt index 897dac34dd2..7ade4a7b952 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/ir/AbstractIrTextTestCase.kt @@ -11,23 +11,20 @@ import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDe import org.jetbrains.kotlin.cli.js.loadPluginsForTests import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.languageVersionSettings -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies import org.jetbrains.kotlin.ir.backend.js.lower.serialization.ir.JsManglerDesc -import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl -import org.jetbrains.kotlin.ir.expressions.* -import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.util.* -import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid -import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.scripting.compiler.plugin.loadScriptConfiguration import org.jetbrains.kotlin.test.KotlinTestUtils import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase +import org.jetbrains.kotlin.test.util.JUnit4Assertions import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull import org.jetbrains.kotlin.utils.rethrow import java.io.File @@ -141,190 +138,7 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() { } private fun verify(irFile: IrFile) { - IrVerifier().verifyWithAssert(irFile) - } - - private class IrVerifier : IrElementVisitorVoid { - private val errors = ArrayList() - - private val symbolForDeclaration = HashMap() - - val hasErrors get() = errors.isNotEmpty() - - val errorsAsMessage get() = errors.joinToString(prefix = "IR verifier errors:\n", separator = "\n") - - private fun error(message: String) { - errors.add(message) - } - - private inline fun require(condition: Boolean, message: () -> String) { - if (!condition) { - errors.add(message()) - } - } - - private val elementsAreUniqueChecker = object : IrElementVisitorVoid { - private val elements = HashSet() - - override fun visitElement(element: IrElement) { - require(elements.add(element)) { "Non-unique element: ${element.render()}" } - element.acceptChildrenVoid(this) - } - } - - fun verifyWithAssert(irFile: IrFile) { - irFile.acceptChildrenVoid(this) - irFile.acceptChildrenVoid(elementsAreUniqueChecker) - TestCase.assertFalse(errorsAsMessage + "\n\n\n" + irFile.dump(), hasErrors) - } - - override fun visitElement(element: IrElement) { - element.acceptChildrenVoid(this) - } - - @OptIn(ObsoleteDescriptorBasedAPI::class) - override fun visitDeclaration(declaration: IrDeclarationBase) { - declaration.symbol.checkBinding("decl", declaration) - - require(declaration.symbol.owner == declaration) { - "Symbol is not bound to declaration: ${declaration.render()}" - } - - val containingDeclarationDescriptor = declaration.descriptor.containingDeclaration - if (containingDeclarationDescriptor != null) { - val parent = declaration.parent - if (parent is IrDeclaration) { - require(parent.descriptor == containingDeclarationDescriptor) { - "In declaration ${declaration.descriptor}: " + - "Mismatching parent descriptor (${parent.descriptor}) " + - "and containing declaration descriptor ($containingDeclarationDescriptor)" - } - } - } - } - - override fun visitProperty(declaration: IrProperty) { - visitDeclaration(declaration) - - require((declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE) == declaration.isFakeOverride) { - "${declaration.render()}: origin: ${declaration.origin}; isFakeOverride: ${declaration.isFakeOverride}" - } - } - - @OptIn(ObsoleteDescriptorBasedAPI::class) - override fun visitFunction(declaration: IrFunction) { - visitDeclaration(declaration) - - val functionDescriptor = declaration.descriptor - - checkTypeParameters(functionDescriptor, declaration, functionDescriptor.typeParameters) - - val expectedDispatchReceiver = functionDescriptor.dispatchReceiverParameter - val actualDispatchReceiver = declaration.dispatchReceiverParameter?.descriptor - require(expectedDispatchReceiver == actualDispatchReceiver) { - "$functionDescriptor: Dispatch receiver parameter mismatch: " + - "expected $expectedDispatchReceiver, actual $actualDispatchReceiver" - - } - - val expectedExtensionReceiver = functionDescriptor.extensionReceiverParameter - val actualExtensionReceiver = declaration.extensionReceiverParameter?.descriptor - require(expectedExtensionReceiver == actualExtensionReceiver) { - "$functionDescriptor: Extension receiver parameter mismatch: " + - "expected $expectedExtensionReceiver, actual $actualExtensionReceiver" - - } - - val declaredValueParameters = declaration.valueParameters.map { it.descriptor } - val actualValueParameters = functionDescriptor.valueParameters - if (declaredValueParameters.size != actualValueParameters.size) { - error("$functionDescriptor: Value parameters mismatch: $declaredValueParameters != $actualValueParameters") - } else { - declaredValueParameters.zip(actualValueParameters).forEach { (declaredValueParameter, actualValueParameter) -> - require(declaredValueParameter == actualValueParameter) { - "$functionDescriptor: Value parameters mismatch: $declaredValueParameter != $actualValueParameter" - } - } - } - } - - override fun visitSimpleFunction(declaration: IrSimpleFunction) { - visitFunction(declaration) - - require((declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE) == declaration.isFakeOverride) { - "${declaration.render()}: origin: ${declaration.origin}; isFakeOverride: ${declaration.isFakeOverride}" - } - } - - override fun visitDeclarationReference(expression: IrDeclarationReference) { - expression.symbol.checkBinding("ref", expression) - } - - override fun visitFunctionReference(expression: IrFunctionReference) { - expression.symbol.checkBinding("ref", expression) - } - - override fun visitPropertyReference(expression: IrPropertyReference) { - expression.field?.checkBinding("field", expression) - expression.getter?.checkBinding("getter", expression) - expression.setter?.checkBinding("setter", expression) - } - - override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference) { - expression.delegate.checkBinding("delegate", expression) - expression.getter.checkBinding("getter", expression) - expression.setter?.checkBinding("setter", expression) - } - - private fun IrSymbol.checkBinding(kind: String, irElement: IrElement) { - if (!isBound) { - error("${javaClass.simpleName} descriptor is unbound @$kind ${irElement.render()}") - } else { - val irDeclaration = owner as? IrDeclaration - if (irDeclaration != null) { - try { - irDeclaration.parent - } catch (e: Throwable) { - error("Referenced declaration has no parent: ${irDeclaration.render()}") - } - } - } - - val otherSymbol = symbolForDeclaration.getOrPut(owner) { this } - if (this != otherSymbol) { - error("Multiple symbols for descriptor of @$kind ${irElement.render()}") - } - } - - @OptIn(ObsoleteDescriptorBasedAPI::class) - override fun visitClass(declaration: IrClass) { - visitDeclaration(declaration) - - checkTypeParameters(declaration.descriptor, declaration, declaration.descriptor.declaredTypeParameters) - } - - @ObsoleteDescriptorBasedAPI - private fun checkTypeParameters( - descriptor: DeclarationDescriptor, - declaration: IrTypeParametersContainer, - expectedTypeParameters: List - ) { - val declaredTypeParameters = declaration.typeParameters.map { it.descriptor } - - if (declaredTypeParameters.size != expectedTypeParameters.size) { - error("$descriptor: Type parameters mismatch: $declaredTypeParameters != $expectedTypeParameters") - } else { - declaredTypeParameters.zip(expectedTypeParameters).forEach { (declaredTypeParameter, expectedTypeParameter) -> - require(declaredTypeParameter == expectedTypeParameter) { - "$descriptor: Type parameters mismatch: $declaredTypeParameter != $expectedTypeParameter" - } - } - } - } - - override fun visitTypeOperator(expression: IrTypeOperatorCall) { - expression.typeOperandClassifier.checkBinding("type operand", expression) - } + IrVerifier(JUnit4Assertions).verifyWithAssert(irFile) } internal class Expectations(val regexps: List, val irTreeFileLabels: List) diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt new file mode 100644 index 00000000000..29ac8e9be42 --- /dev/null +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt @@ -0,0 +1,201 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.ir + +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.* +import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.util.dump +import org.jetbrains.kotlin.ir.util.render +import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid +import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid +import org.jetbrains.kotlin.test.Assertions + +class IrVerifier(private val assertions: Assertions) : IrElementVisitorVoid { + private val errors = ArrayList() + + private val symbolForDeclaration = HashMap() + + val hasErrors get() = errors.isNotEmpty() + + val errorsAsMessage get() = errors.joinToString(prefix = "IR verifier errors:\n", separator = "\n") + + private fun error(message: String) { + errors.add(message) + } + + private inline fun require(condition: Boolean, message: () -> String) { + if (!condition) { + errors.add(message()) + } + } + + private val elementsAreUniqueChecker = object : IrElementVisitorVoid { + private val elements = HashSet() + + override fun visitElement(element: IrElement) { + require(elements.add(element)) { "Non-unique element: ${element.render()}" } + element.acceptChildrenVoid(this) + } + } + + fun verifyWithAssert(irFile: IrFile) { + irFile.acceptChildrenVoid(this) + irFile.acceptChildrenVoid(elementsAreUniqueChecker) + assertions.assertFalse(hasErrors) { errorsAsMessage + "\n\n\n" + irFile.dump() } + } + + override fun visitElement(element: IrElement) { + element.acceptChildrenVoid(this) + } + + @OptIn(ObsoleteDescriptorBasedAPI::class) + override fun visitDeclaration(declaration: IrDeclarationBase) { + declaration.symbol.checkBinding("decl", declaration) + + require(declaration.symbol.owner == declaration) { + "Symbol is not bound to declaration: ${declaration.render()}" + } + + val containingDeclarationDescriptor = declaration.descriptor.containingDeclaration + if (containingDeclarationDescriptor != null) { + val parent = declaration.parent + if (parent is IrDeclaration) { + require(parent.descriptor == containingDeclarationDescriptor) { + "In declaration ${declaration.descriptor}: " + + "Mismatching parent descriptor (${parent.descriptor}) " + + "and containing declaration descriptor ($containingDeclarationDescriptor)" + } + } + } + } + + override fun visitProperty(declaration: IrProperty) { + visitDeclaration(declaration) + + require((declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE) == declaration.isFakeOverride) { + "${declaration.render()}: origin: ${declaration.origin}; isFakeOverride: ${declaration.isFakeOverride}" + } + } + + @OptIn(ObsoleteDescriptorBasedAPI::class) + override fun visitFunction(declaration: IrFunction) { + visitDeclaration(declaration) + + val functionDescriptor = declaration.descriptor + + checkTypeParameters(functionDescriptor, declaration, functionDescriptor.typeParameters) + + val expectedDispatchReceiver = functionDescriptor.dispatchReceiverParameter + val actualDispatchReceiver = declaration.dispatchReceiverParameter?.descriptor + require(expectedDispatchReceiver == actualDispatchReceiver) { + "$functionDescriptor: Dispatch receiver parameter mismatch: " + + "expected $expectedDispatchReceiver, actual $actualDispatchReceiver" + + } + + val expectedExtensionReceiver = functionDescriptor.extensionReceiverParameter + val actualExtensionReceiver = declaration.extensionReceiverParameter?.descriptor + require(expectedExtensionReceiver == actualExtensionReceiver) { + "$functionDescriptor: Extension receiver parameter mismatch: " + + "expected $expectedExtensionReceiver, actual $actualExtensionReceiver" + + } + + val declaredValueParameters = declaration.valueParameters.map { it.descriptor } + val actualValueParameters = functionDescriptor.valueParameters + if (declaredValueParameters.size != actualValueParameters.size) { + error("$functionDescriptor: Value parameters mismatch: $declaredValueParameters != $actualValueParameters") + } else { + declaredValueParameters.zip(actualValueParameters).forEach { (declaredValueParameter, actualValueParameter) -> + require(declaredValueParameter == actualValueParameter) { + "$functionDescriptor: Value parameters mismatch: $declaredValueParameter != $actualValueParameter" + } + } + } + } + + override fun visitSimpleFunction(declaration: IrSimpleFunction) { + visitFunction(declaration) + + require((declaration.origin == IrDeclarationOrigin.FAKE_OVERRIDE) == declaration.isFakeOverride) { + "${declaration.render()}: origin: ${declaration.origin}; isFakeOverride: ${declaration.isFakeOverride}" + } + } + + override fun visitDeclarationReference(expression: IrDeclarationReference) { + expression.symbol.checkBinding("ref", expression) + } + + override fun visitFunctionReference(expression: IrFunctionReference) { + expression.symbol.checkBinding("ref", expression) + } + + override fun visitPropertyReference(expression: IrPropertyReference) { + expression.field?.checkBinding("field", expression) + expression.getter?.checkBinding("getter", expression) + expression.setter?.checkBinding("setter", expression) + } + + override fun visitLocalDelegatedPropertyReference(expression: IrLocalDelegatedPropertyReference) { + expression.delegate.checkBinding("delegate", expression) + expression.getter.checkBinding("getter", expression) + expression.setter?.checkBinding("setter", expression) + } + + private fun IrSymbol.checkBinding(kind: String, irElement: IrElement) { + if (!isBound) { + error("${javaClass.simpleName} descriptor is unbound @$kind ${irElement.render()}") + } else { + val irDeclaration = owner as? IrDeclaration + if (irDeclaration != null) { + try { + irDeclaration.parent + } catch (e: Throwable) { + error("Referenced declaration has no parent: ${irDeclaration.render()}") + } + } + } + + val otherSymbol = symbolForDeclaration.getOrPut(owner) { this } + if (this != otherSymbol) { + error("Multiple symbols for descriptor of @$kind ${irElement.render()}") + } + } + + @OptIn(ObsoleteDescriptorBasedAPI::class) + override fun visitClass(declaration: IrClass) { + visitDeclaration(declaration) + + checkTypeParameters(declaration.descriptor, declaration, declaration.descriptor.declaredTypeParameters) + } + + @ObsoleteDescriptorBasedAPI + private fun checkTypeParameters( + descriptor: DeclarationDescriptor, + declaration: IrTypeParametersContainer, + expectedTypeParameters: List + ) { + val declaredTypeParameters = declaration.typeParameters.map { it.descriptor } + + if (declaredTypeParameters.size != expectedTypeParameters.size) { + error("$descriptor: Type parameters mismatch: $declaredTypeParameters != $expectedTypeParameters") + } else { + declaredTypeParameters.zip(expectedTypeParameters).forEach { (declaredTypeParameter, expectedTypeParameter) -> + require(declaredTypeParameter == expectedTypeParameter) { + "$descriptor: Type parameters mismatch: $declaredTypeParameter != $expectedTypeParameter" + } + } + } + } + + override fun visitTypeOperator(expression: IrTypeOperatorCall) { + expression.typeOperandClassifier.checkBinding("type operand", expression) + } +} + diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/JvmCompilationUtils.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/JvmCompilationUtils.kt index ec832e7e1e1..099e1460c83 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/JvmCompilationUtils.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/test/JvmCompilationUtils.kt @@ -21,7 +21,13 @@ import javax.tools.ToolProvider @JvmOverloads @Throws(IOException::class) -fun compileJavaFiles(files: Collection, options: List?, javaErrorFile: File? = null, assertions: Assertions): Boolean { +fun compileJavaFiles( + files: Collection, + options: List?, + javaErrorFile: File? = null, + assertions: Assertions, + ignoreJavaErrors: Boolean = false +): Boolean { val javaCompiler = ToolProvider.getSystemJavaCompiler() val diagnosticCollector = DiagnosticCollector() javaCompiler.getStandardFileManager(diagnosticCollector, Locale.ENGLISH, Charset.forName("utf-8")).use { fileManager -> @@ -36,7 +42,7 @@ fun compileJavaFiles(files: Collection, options: List?, javaError ) val success = task.call() // do NOT inline this variable, call() should complete before errorsToString() if (javaErrorFile == null || !javaErrorFile.exists()) { - assertions.assertTrue(success) { errorsToString(diagnosticCollector, true) } + assertions.assertTrue(success || ignoreJavaErrors) { errorsToString(diagnosticCollector, true) } } else { assertions.assertEqualsToFile(javaErrorFile, errorsToString(diagnosticCollector, false)) } diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt index 2bf92c94611..16d624c8299 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt @@ -144,10 +144,6 @@ fun generateJUnit3CompilerTests(args: Array) { model("codegen/bytecodeText", targetBackend = TargetBackend.JVM) } - testClass { - model("ir/irText") - } - testClass { model("ir/irJsText", pattern = "^(.+)\\.kt(s)?\$") } diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt index adf3bf71f13..26f4475dbf3 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.test.generators -import org.jetbrains.kotlin.generators.model.AnnotationModel import org.jetbrains.kotlin.generators.model.annotation import org.jetbrains.kotlin.generators.util.TestGeneratorUtil import org.jetbrains.kotlin.test.TargetBackend @@ -13,6 +12,7 @@ import org.jetbrains.kotlin.test.runners.* import org.jetbrains.kotlin.test.runners.codegen.AbstractBlackBoxCodegenTest import org.jetbrains.kotlin.test.runners.codegen.AbstractFirBlackBoxCodegenTest import org.jetbrains.kotlin.test.runners.codegen.AbstractIrBlackBoxCodegenTest +import org.jetbrains.kotlin.test.runners.ir.AbstractIrTextTest import org.junit.jupiter.api.parallel.Execution import org.junit.jupiter.api.parallel.ExecutionMode @@ -68,6 +68,10 @@ fun generateJUnit5CompilerTests(args: Array) { testClass { model("codegen/box", excludeDirs = listOf("oldLanguageVersions")) } + + testClass { + model("ir/irText") + } } // ---------------------------------------------- FIR tests ---------------------------------------------- From 87ffbd82063aefb5649432a6ce191e3664823e21 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 17:30:39 +0300 Subject: [PATCH 083/122] [IR] Collect all dependencies of module recursively --- .../kotlin/backend/jvm/JvmIrCodegenFactory.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt index 20448eacf35..ec2fea20048 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt @@ -115,7 +115,7 @@ class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory } } - val dependencies = psi2irContext.moduleDescriptor.allDependencyModules.map { + val dependencies = psi2irContext.moduleDescriptor.collectAllDependencyModulesTransitively().map { val kotlinLibrary = (it.getCapability(KlibModuleOrigin.CAPABILITY) as? DeserializedKlibModuleOrigin)?.library if (it.hasJdkCapability) { // For IDE environment only, i.e. when compiling for debugger @@ -153,6 +153,17 @@ class JvmIrCodegenFactory(private val phaseConfig: PhaseConfig) : CodegenFactory ) } + private fun ModuleDescriptor.collectAllDependencyModulesTransitively(): List { + val result = LinkedHashSet() + fun collectImpl(descriptor: ModuleDescriptor) { + val dependencies = descriptor.allDependencyModules + dependencies.forEach { if (it !in result) collectImpl(it) } + result += dependencies + } + collectImpl(this) + return result.toList() + } + fun doGenerateFilesInternal(input: JvmIrBackendInput) { val (state, irModuleFragment, symbolTable, sourceManager, phaseConfig, irProviders, extensions, backendExtension) = input val context = JvmBackendContext( From aba029237ddbb0877a7006bbf926fe2fa1e68e69 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 11:40:04 +0300 Subject: [PATCH 084/122] [Test] Add handler for comparing pretty kt ir dumps --- ...ieldReferenceWithIntersectionTypes.kt.txt} | 0 ...txt => signedToUnsignedConversions.kt.txt} | 10 ++++ ...nedToUnsignedConversions_annotation.kt.txt | 7 --- .../ir/irText/firProblems/FirBuilder.kt.txt | 19 +++++++ ...rrayToList.kt.txt => V8ArrayToList.kt.txt} | 0 .../lambdas/destructuringInLambda.kt.txt | 5 +- .../genericClassInDifferentModule.kt.txt | 53 ++++++++++++++++++ .../genericClassInDifferentModule_m1.kt.txt | 22 -------- .../genericClassInDifferentModule_m2.kt.txt | 25 --------- .../handlers/IrPrettyKotlinDumpHandler.kt | 54 +++++++++++++++++++ .../backend/handlers/IrTextDumpHandler.kt | 23 +++++--- .../test/directives/CodegenTestDirectives.kt | 9 ++++ .../test/runners/ir/AbstractIrTextTest.kt | 8 ++- 13 files changed, 171 insertions(+), 64 deletions(-) rename compiler/testData/ir/irText/expressions/{jvmFieldWithIntersectionTypes.kt.txt => jvmFieldReferenceWithIntersectionTypes.kt.txt} (100%) rename compiler/testData/ir/irText/expressions/{signedToUnsignedConversions_test.kt.txt => signedToUnsignedConversions.kt.txt} (84%) delete mode 100644 compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.kt.txt rename compiler/testData/ir/irText/firProblems/{v8arrayToList.kt.txt => V8ArrayToList.kt.txt} (100%) create mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule.kt.txt delete mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.kt.txt delete mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.kt.txt create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt diff --git a/compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.kt.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.kt.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.kt.txt rename to compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.kt.txt diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.kt.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.kt.txt similarity index 84% rename from compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.kt.txt rename to compiler/testData/ir/irText/expressions/signedToUnsignedConversions.kt.txt index 5f4f54b6c20..6adfd3c2011 100644 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.kt.txt +++ b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.kt.txt @@ -1,3 +1,13 @@ +// FILE: signedToUnsignedConversions_annotation.kt +package kotlin.internal + +annotation class ImplicitIntegerCoercion : Annotation { + constructor() /* primary */ + +} + +// FILE: signedToUnsignedConversions_test.kt + @ImplicitIntegerCoercion const val IMPLICIT_INT: Int field = 255 diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.kt.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.kt.txt deleted file mode 100644 index 5ff874c983e..00000000000 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.kt.txt +++ /dev/null @@ -1,7 +0,0 @@ -package kotlin.internal - -annotation class ImplicitIntegerCoercion : Annotation { - constructor() /* primary */ - -} - diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.kt.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.kt.txt index bd90c729acd..aab5e1a0795 100644 --- a/compiler/testData/ir/irText/firProblems/FirBuilder.kt.txt +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.kt.txt @@ -1,3 +1,22 @@ +// MODULE: m1 +// FILE: BaseFirBuilder.kt + +abstract class BaseFirBuilder { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + inline fun withCapturedTypeParameters(block: Function0): T { + return block.invoke() + } + +} + +// MODULE: m2 +// FILE: FirBuilder.kt + open class BaseConverter : BaseFirBuilder { constructor() /* primary */ { super/*BaseFirBuilder*/() diff --git a/compiler/testData/ir/irText/firProblems/v8arrayToList.kt.txt b/compiler/testData/ir/irText/firProblems/V8ArrayToList.kt.txt similarity index 100% rename from compiler/testData/ir/irText/firProblems/v8arrayToList.kt.txt rename to compiler/testData/ir/irText/firProblems/V8ArrayToList.kt.txt diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt index b26f811287d..e649a874898 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.kt.txt @@ -55,11 +55,12 @@ data class A { } var fn: Function1 - field = local fun (: A): Int { - val y: Int = .component2() + field = local fun ($dstr$_u24__u24$y: A): Int { + val y: Int = $dstr$_u24__u24$y.component2() return 42.plus(other = y) } get set + diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.kt.txt new file mode 100644 index 00000000000..c9afe4180b8 --- /dev/null +++ b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.kt.txt @@ -0,0 +1,53 @@ +// MODULE: m1 +// FILE: genericClassInDifferentModule_m1.kt + +abstract class Base { + constructor(x: T) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: T + field = x + get + + abstract fun foo(y: Y): T + abstract var bar: T + abstract get + abstract set + + abstract var Z.exn: T + abstract get + abstract set + +} + +// MODULE: m2 +// FILE: genericClassInDifferentModule_m2.kt + +class Derived1 : Base { + constructor(x: T) /* primary */ { + super/*Base*/(x = x) + /* () */ + + } + + override fun foo(y: Y): T { + return .() + } + + override var bar: T + field = x + override get + override set + + override var Z.exn: T + override get(): T { + return .() + } + override set(value: T) { + } + +} + diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.kt.txt deleted file mode 100644 index fefa1a2c832..00000000000 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.kt.txt +++ /dev/null @@ -1,22 +0,0 @@ -abstract class Base { - constructor(x: T) /* primary */ { - super/*Any*/() - /* () */ - - } - - val x: T - field = x - get - - abstract fun foo(y: Y): T - abstract var bar: T - abstract get - abstract set - - abstract var Z.exn: T - abstract get - abstract set - -} - diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.kt.txt deleted file mode 100644 index 1143ff25dd0..00000000000 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.kt.txt +++ /dev/null @@ -1,25 +0,0 @@ -class Derived1 : Base { - constructor(x: T) /* primary */ { - super/*Base*/(x = x) - /* () */ - - } - - override fun foo(y: Y): T { - return .() - } - - override var bar: T - field = x - override get - override set - - override var Z.exn: T - override get(): T { - return .() - } - override set(value: T) { - } - -} - diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt new file mode 100644 index 00000000000..9cf9e7fe0c9 --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt @@ -0,0 +1,54 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test.backend.handlers + +import org.jetbrains.kotlin.ir.util.FakeOverridesStrategy +import org.jetbrains.kotlin.ir.util.KotlinLikeDumpOptions +import org.jetbrains.kotlin.ir.util.dumpKotlinLike +import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler.Companion.computeDumpExtension +import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler.Companion.groupWithTestFiles +import org.jetbrains.kotlin.test.backend.ir.IrBackendInput +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_KT_IR +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.EXTERNAL_FILE +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.SKIP_KT_DUMP +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.moduleStructure +import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumperImpl +import org.jetbrains.kotlin.test.utils.withExtension + +class IrPrettyKotlinDumpHandler(testServices: TestServices) : AbstractIrHandler(testServices) { + private val dumper = MultiModuleInfoDumperImpl("// MODULE: %s") + + override fun processModule(module: TestModule, info: IrBackendInput) { + if (DUMP_KT_IR !in module.directives || SKIP_KT_DUMP in module.directives) return + + val irFiles = info.backendInput.irModuleFragment.files + val builder = dumper.builderForModule(module) + val filteredIrFiles = irFiles.groupWithTestFiles(module).filter { + EXTERNAL_FILE !in it.first.directives + }.map { it.second } + val printFileName = filteredIrFiles.size > 1 || testServices.moduleStructure.modules.size > 1 + for (irFile in filteredIrFiles) { + val dump = irFile.dumpKotlinLike( + KotlinLikeDumpOptions( + printFileName = printFileName, + printFilePath = false, + printFakeOverridesStrategy = FakeOverridesStrategy.NONE + ) + ) + builder.append(dump) + } + } + + override fun processAfterAllModules(someAssertionWasFailed: Boolean) { + if (dumper.isEmpty()) return + val moduleStructure = testServices.moduleStructure + val extension = computeDumpExtension(moduleStructure.modules.first(), "kt.txt") + val expectedFile = moduleStructure.originalTestDataFiles.first().withExtension(extension) + assertions.assertEqualsToFile(expectedFile, dumper.generateResultingDump()) + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt index c012607e5de..964cd62f34e 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt @@ -6,7 +6,6 @@ package org.jetbrains.kotlin.test.backend.handlers import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor -import org.jetbrains.kotlin.config.languageVersionSettings import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies import org.jetbrains.kotlin.ir.IrVerifier @@ -26,6 +25,7 @@ import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_IDENTICAL import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.model.FrontendKinds +import org.jetbrains.kotlin.test.model.TestFile import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.moduleStructure @@ -35,6 +35,19 @@ import org.jetbrains.kotlin.test.utils.withSuffixAndExtension import java.io.File class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServices) { + companion object { + fun computeDumpExtension(module: TestModule, defaultExtension: String): String { + return if (module.frontendKind == FrontendKinds.ClassicFrontend || FIR_IDENTICAL in module.directives) + defaultExtension else "fir.$defaultExtension" + } + + fun List.groupWithTestFiles(module: TestModule): List> = mapNotNull { irFile -> + val name = irFile.fileEntry.name.removePrefix("/") + val testFile = module.files.firstOrNull { it.name == name } ?: return@mapNotNull null + testFile to irFile + } + } + override val directivesContainers: List get() = listOf(CodegenTestDirectives, FirDiagnosticsDirectives) @@ -45,11 +58,7 @@ class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServ override fun processModule(module: TestModule, info: IrBackendInput) { if (DUMP_IR !in module.directives) return val irFiles = info.backendInput.irModuleFragment.files - val testFileToIrFile = irFiles.mapNotNull { irFile -> - val name = irFile.fileEntry.name.removePrefix("/") - val testFile = module.files.firstOrNull { it.name == name } ?: return@mapNotNull null - testFile to irFile - } + val testFileToIrFile = irFiles.groupWithTestFiles(module) val builder = baseDumper.builderForModule(module) for ((testFile, irFile) in testFileToIrFile) { if (EXTERNAL_FILE in testFile.directives) continue @@ -112,5 +121,5 @@ class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServ } private val TestModule.dumpExtension: String - get() = if (frontendKind == FrontendKinds.ClassicFrontend || FIR_IDENTICAL in directives) "txt" else "fir.txt" + get() = computeDumpExtension(this, "txt") } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt index 5a3dbfcd17b..0cacf9dcfee 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/directives/CodegenTestDirectives.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.test.directives import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.handlers.IrPrettyKotlinDumpHandler import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler import org.jetbrains.kotlin.test.backend.handlers.NoCompilationErrorsHandler import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade @@ -76,4 +77,12 @@ object CodegenTestDirectives : SimpleDirectivesContainer() { description = "Indicates that test file is external and should be skipped in ${IrTextDumpHandler::class}", applicability = File ) + + val DUMP_KT_IR by directive( + description = "Dumps generated backend IR in pretty kotlin dump (enables ${IrPrettyKotlinDumpHandler::class})" + ) + + val SKIP_KT_DUMP by directive( + description = "Skips check pretty kt IR dump (disables ${IrPrettyKotlinDumpHandler::class})" + ) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt index 6908a7392fa..ffdd84a09d2 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt @@ -7,10 +7,12 @@ package org.jetbrains.kotlin.test.runners.ir import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.test.TargetBackend +import org.jetbrains.kotlin.test.backend.handlers.IrPrettyKotlinDumpHandler import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor import org.jetbrains.kotlin.test.backend.handlers.* import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_KT_IR import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontend2IrConverter import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade import org.jetbrains.kotlin.test.frontend.fir.Fir2IrResultsConverter @@ -37,6 +39,7 @@ abstract class AbstractIrTextTestBase( defaultDirectives { +DUMP_IR + +DUMP_KT_IR } useConfigurators( @@ -59,7 +62,10 @@ abstract class AbstractIrTextTestBase( ::Fir2IrResultsConverter ) - useBackendHandlers(::IrTextDumpHandler) + useBackendHandlers( + ::IrTextDumpHandler, + ::IrPrettyKotlinDumpHandler + ) } } From bdcb8aecab1ebffa4532fac4a4a94fb64d93bff0 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 13:00:22 +0300 Subject: [PATCH 085/122] [Test] Migrate AbstractFir2IrTextTest to new infrastructure --- .../runners/ir}/Fir2IrTextTestGenerated.java | 668 +++++++++++++----- .../kotlin/fir/AbstractFir2IrTextTest.kt | 61 -- .../handlers/FirIrDumpIdenticalCheckers.kt | 59 ++ .../handlers/IrPrettyKotlinDumpHandler.kt | 12 +- .../backend/handlers/IrTextDumpHandler.kt | 7 +- .../fir/handlers/FirIdenticalChecker.kt | 50 +- .../test/runners/ir/AbstractIrTextTest.kt | 11 +- .../test/utils/FirIdenticalCheckerHelper.kt | 55 ++ .../generators/GenerateJUnit3CompilerTests.kt | 10 - .../generators/GenerateJUnit5CompilerTests.kt | 8 +- 10 files changed, 677 insertions(+), 264 deletions(-) rename compiler/fir/{fir2ir/tests-gen/org/jetbrains/kotlin/fir => analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir}/Fir2IrTextTestGenerated.java (90%) delete mode 100644 compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/AbstractFir2IrTextTest.kt create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/FirIrDumpIdenticalCheckers.kt create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java similarity index 90% rename from compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java rename to compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index dfda9c6abff..bb8072a0083 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -3,729 +3,831 @@ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ -package org.jetbrains.kotlin.fir; +package org.jetbrains.kotlin.test.runners.ir; import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; import org.jetbrains.kotlin.test.util.KtTestUtil; import org.jetbrains.kotlin.test.TargetBackend; import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; import java.io.File; import java.util.regex.Pattern; -/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("compiler/testData/ir/irText") @TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + @Test public void testAllFilesPresentInIrText() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Nested @TestMetadata("compiler/testData/ir/irText/classes") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Classes extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Classes extends AbstractFir2IrTextTest { + @Test @TestMetadata("abstractMembers.kt") public void testAbstractMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/abstractMembers.kt"); } + @Test public void testAllFilesPresentInClasses() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/classes"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/classes"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("annotationClasses.kt") public void testAnnotationClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/annotationClasses.kt"); } + @Test @TestMetadata("argumentReorderingInDelegatingConstructorCall.kt") public void testArgumentReorderingInDelegatingConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.kt"); } + @Test @TestMetadata("clashingFakeOverrideSignatures.kt") public void testClashingFakeOverrideSignatures() throws Exception { runTest("compiler/testData/ir/irText/classes/clashingFakeOverrideSignatures.kt"); } + @Test @TestMetadata("classMembers.kt") public void testClassMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/classMembers.kt"); } + @Test @TestMetadata("classes.kt") public void testClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/classes.kt"); } + @Test @TestMetadata("cloneable.kt") public void testCloneable() throws Exception { runTest("compiler/testData/ir/irText/classes/cloneable.kt"); } + @Test @TestMetadata("companionObject.kt") public void testCompanionObject() throws Exception { runTest("compiler/testData/ir/irText/classes/companionObject.kt"); } + @Test @TestMetadata("dataClassWithArrayMembers.kt") public void testDataClassWithArrayMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/dataClassWithArrayMembers.kt"); } + @Test @TestMetadata("dataClasses.kt") public void testDataClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/dataClasses.kt"); } + @Test @TestMetadata("dataClassesGeneric.kt") public void testDataClassesGeneric() throws Exception { runTest("compiler/testData/ir/irText/classes/dataClassesGeneric.kt"); } + @Test @TestMetadata("delegatedGenericImplementation.kt") public void testDelegatedGenericImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedGenericImplementation.kt"); } + @Test @TestMetadata("delegatedImplementation.kt") public void testDelegatedImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementation.kt"); } + @Test @TestMetadata("delegatedImplementationOfJavaInterface.kt") public void testDelegatedImplementationOfJavaInterface() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt"); } + @Test @TestMetadata("delegatedImplementationWithExplicitOverride.kt") public void testDelegatedImplementationWithExplicitOverride() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.kt"); } + @Test @TestMetadata("delegatingConstructorCallToTypeAliasConstructor.kt") public void testDelegatingConstructorCallToTypeAliasConstructor() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatingConstructorCallToTypeAliasConstructor.kt"); } + @Test @TestMetadata("delegatingConstructorCallsInSecondaryConstructors.kt") public void testDelegatingConstructorCallsInSecondaryConstructors() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.kt"); } + @Test @TestMetadata("enum.kt") public void testEnum() throws Exception { runTest("compiler/testData/ir/irText/classes/enum.kt"); } + @Test @TestMetadata("enumClassModality.kt") public void testEnumClassModality() throws Exception { runTest("compiler/testData/ir/irText/classes/enumClassModality.kt"); } + @Test @TestMetadata("enumWithMultipleCtors.kt") public void testEnumWithMultipleCtors() throws Exception { runTest("compiler/testData/ir/irText/classes/enumWithMultipleCtors.kt"); } + @Test @TestMetadata("enumWithSecondaryCtor.kt") public void testEnumWithSecondaryCtor() throws Exception { runTest("compiler/testData/ir/irText/classes/enumWithSecondaryCtor.kt"); } + @Test @TestMetadata("fakeOverridesForJavaStaticMembers.kt") public void testFakeOverridesForJavaStaticMembers() throws Exception { runTest("compiler/testData/ir/irText/classes/fakeOverridesForJavaStaticMembers.kt"); } + @Test @TestMetadata("implicitNotNullOnDelegatedImplementation.kt") public void testImplicitNotNullOnDelegatedImplementation() throws Exception { runTest("compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.kt"); } + @Test @TestMetadata("initBlock.kt") public void testInitBlock() throws Exception { runTest("compiler/testData/ir/irText/classes/initBlock.kt"); } + @Test @TestMetadata("initVal.kt") public void testInitVal() throws Exception { runTest("compiler/testData/ir/irText/classes/initVal.kt"); } + @Test @TestMetadata("initValInLambda.kt") public void testInitValInLambda() throws Exception { runTest("compiler/testData/ir/irText/classes/initValInLambda.kt"); } + @Test @TestMetadata("initVar.kt") public void testInitVar() throws Exception { runTest("compiler/testData/ir/irText/classes/initVar.kt"); } + @Test @TestMetadata("inlineClass.kt") public void testInlineClass() throws Exception { runTest("compiler/testData/ir/irText/classes/inlineClass.kt"); } + @Test @TestMetadata("inlineClassSyntheticMethods.kt") public void testInlineClassSyntheticMethods() throws Exception { runTest("compiler/testData/ir/irText/classes/inlineClassSyntheticMethods.kt"); } + @Test @TestMetadata("innerClass.kt") public void testInnerClass() throws Exception { runTest("compiler/testData/ir/irText/classes/innerClass.kt"); } + @Test @TestMetadata("innerClassWithDelegatingConstructor.kt") public void testInnerClassWithDelegatingConstructor() throws Exception { runTest("compiler/testData/ir/irText/classes/innerClassWithDelegatingConstructor.kt"); } + @Test @TestMetadata("kt19306.kt") public void testKt19306() throws Exception { runTest("compiler/testData/ir/irText/classes/kt19306.kt"); } + @Test @TestMetadata("kt31649.kt") public void testKt31649() throws Exception { runTest("compiler/testData/ir/irText/classes/kt31649.kt"); } + @Test @TestMetadata("kt43217.kt") public void testKt43217() throws Exception { runTest("compiler/testData/ir/irText/classes/kt43217.kt"); } + @Test @TestMetadata("lambdaInDataClassDefaultParameter.kt") public void testLambdaInDataClassDefaultParameter() throws Exception { runTest("compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.kt"); } + @Test @TestMetadata("localClasses.kt") public void testLocalClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/localClasses.kt"); } + @Test @TestMetadata("objectLiteralExpressions.kt") public void testObjectLiteralExpressions() throws Exception { runTest("compiler/testData/ir/irText/classes/objectLiteralExpressions.kt"); } + @Test @TestMetadata("objectWithInitializers.kt") public void testObjectWithInitializers() throws Exception { runTest("compiler/testData/ir/irText/classes/objectWithInitializers.kt"); } + @Test @TestMetadata("openDataClass.kt") public void testOpenDataClass() throws Exception { runTest("compiler/testData/ir/irText/classes/openDataClass.kt"); } + @Test @TestMetadata("outerClassAccess.kt") public void testOuterClassAccess() throws Exception { runTest("compiler/testData/ir/irText/classes/outerClassAccess.kt"); } + @Test @TestMetadata("primaryConstructor.kt") public void testPrimaryConstructor() throws Exception { runTest("compiler/testData/ir/irText/classes/primaryConstructor.kt"); } + @Test @TestMetadata("primaryConstructorWithSuperConstructorCall.kt") public void testPrimaryConstructorWithSuperConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.kt"); } + @Test @TestMetadata("qualifiedSuperCalls.kt") public void testQualifiedSuperCalls() throws Exception { runTest("compiler/testData/ir/irText/classes/qualifiedSuperCalls.kt"); } + @Test @TestMetadata("sealedClasses.kt") public void testSealedClasses() throws Exception { runTest("compiler/testData/ir/irText/classes/sealedClasses.kt"); } + @Test @TestMetadata("secondaryConstructorWithInitializersFromClassBody.kt") public void testSecondaryConstructorWithInitializersFromClassBody() throws Exception { runTest("compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.kt"); } + @Test @TestMetadata("secondaryConstructors.kt") public void testSecondaryConstructors() throws Exception { runTest("compiler/testData/ir/irText/classes/secondaryConstructors.kt"); } + @Test @TestMetadata("superCalls.kt") public void testSuperCalls() throws Exception { runTest("compiler/testData/ir/irText/classes/superCalls.kt"); } + @Test @TestMetadata("superCallsComposed.kt") public void testSuperCallsComposed() throws Exception { runTest("compiler/testData/ir/irText/classes/superCallsComposed.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Declarations extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Declarations extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInDeclarations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("catchParameterInTopLevelProperty.kt") public void testCatchParameterInTopLevelProperty() throws Exception { runTest("compiler/testData/ir/irText/declarations/catchParameterInTopLevelProperty.kt"); } + @Test @TestMetadata("classLevelProperties.kt") public void testClassLevelProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/classLevelProperties.kt"); } + @Test @TestMetadata("constValInitializers.kt") public void testConstValInitializers() throws Exception { runTest("compiler/testData/ir/irText/declarations/constValInitializers.kt"); } + @Test @TestMetadata("defaultArguments.kt") public void testDefaultArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/defaultArguments.kt"); } + @Test @TestMetadata("delegatedProperties.kt") public void testDelegatedProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/delegatedProperties.kt"); } + @Test @TestMetadata("deprecatedProperty.kt") public void testDeprecatedProperty() throws Exception { runTest("compiler/testData/ir/irText/declarations/deprecatedProperty.kt"); } + @Test @TestMetadata("extensionProperties.kt") public void testExtensionProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/extensionProperties.kt"); } + @Test @TestMetadata("fakeOverrides.kt") public void testFakeOverrides() throws Exception { runTest("compiler/testData/ir/irText/declarations/fakeOverrides.kt"); } + @Test @TestMetadata("fileWithAnnotations.kt") public void testFileWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/fileWithAnnotations.kt"); } + @Test @TestMetadata("fileWithTypeAliasesOnly.kt") public void testFileWithTypeAliasesOnly() throws Exception { runTest("compiler/testData/ir/irText/declarations/fileWithTypeAliasesOnly.kt"); } + @Test @TestMetadata("genericDelegatedProperty.kt") public void testGenericDelegatedProperty() throws Exception { runTest("compiler/testData/ir/irText/declarations/genericDelegatedProperty.kt"); } + @Test @TestMetadata("inlineCollectionOfInlineClass.kt") public void testInlineCollectionOfInlineClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/inlineCollectionOfInlineClass.kt"); } + @Test @TestMetadata("interfaceProperties.kt") public void testInterfaceProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/interfaceProperties.kt"); } + @Test @TestMetadata("kt27005.kt") public void testKt27005() throws Exception { runTest("compiler/testData/ir/irText/declarations/kt27005.kt"); } + @Test @TestMetadata("kt29833.kt") public void testKt29833() throws Exception { runTest("compiler/testData/ir/irText/declarations/kt29833.kt"); } + @Test @TestMetadata("kt35550.kt") public void testKt35550() throws Exception { runTest("compiler/testData/ir/irText/declarations/kt35550.kt"); } + @Test @TestMetadata("localClassWithOverrides.kt") public void testLocalClassWithOverrides() throws Exception { runTest("compiler/testData/ir/irText/declarations/localClassWithOverrides.kt"); } + @Test @TestMetadata("localDelegatedProperties.kt") public void testLocalDelegatedProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/localDelegatedProperties.kt"); } + @Test @TestMetadata("localVarInDoWhile.kt") public void testLocalVarInDoWhile() throws Exception { runTest("compiler/testData/ir/irText/declarations/localVarInDoWhile.kt"); } + @Test @TestMetadata("packageLevelProperties.kt") public void testPackageLevelProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/packageLevelProperties.kt"); } + @Test @TestMetadata("primaryCtorDefaultArguments.kt") public void testPrimaryCtorDefaultArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/primaryCtorDefaultArguments.kt"); } + @Test @TestMetadata("primaryCtorProperties.kt") public void testPrimaryCtorProperties() throws Exception { runTest("compiler/testData/ir/irText/declarations/primaryCtorProperties.kt"); } + @Test @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/ir/irText/declarations/typeAlias.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/annotations") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Annotations extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Annotations extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInAnnotations() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/annotations"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("annotationsInAnnotationArguments.kt") public void testAnnotationsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt"); } + @Test @TestMetadata("annotationsOnDelegatedMembers.kt") public void testAnnotationsOnDelegatedMembers() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsOnDelegatedMembers.kt"); } + @Test @TestMetadata("annotationsWithDefaultParameterValues.kt") public void testAnnotationsWithDefaultParameterValues() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt"); } + @Test @TestMetadata("annotationsWithVarargParameters.kt") public void testAnnotationsWithVarargParameters() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt"); } + @Test @TestMetadata("arrayInAnnotationArguments.kt") public void testArrayInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt"); } + @Test @TestMetadata("classLiteralInAnnotation.kt") public void testClassLiteralInAnnotation() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/classLiteralInAnnotation.kt"); } + @Test @TestMetadata("classesWithAnnotations.kt") public void testClassesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.kt"); } + @Test @TestMetadata("constExpressionsInAnnotationArguments.kt") public void testConstExpressionsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt"); } + @Test @TestMetadata("constructorsWithAnnotations.kt") public void testConstructorsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt"); } + @Test @TestMetadata("delegateFieldWithAnnotations.kt") public void testDelegateFieldWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt"); } + @Test @TestMetadata("delegatedPropertyAccessorsWithAnnotations.kt") public void testDelegatedPropertyAccessorsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.kt"); } + @Test @TestMetadata("enumEntriesWithAnnotations.kt") public void testEnumEntriesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.kt"); } + @Test @TestMetadata("enumsInAnnotationArguments.kt") public void testEnumsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt"); } + @Test @TestMetadata("fieldsWithAnnotations.kt") public void testFieldsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt"); } + @Test @TestMetadata("fileAnnotations.kt") public void testFileAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt"); } + @Test @TestMetadata("functionsWithAnnotations.kt") public void testFunctionsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt"); } + @Test @TestMetadata("inheritingDeprecation.kt") public void testInheritingDeprecation() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/inheritingDeprecation.kt"); } + @Test @TestMetadata("javaAnnotation.kt") public void testJavaAnnotation() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt"); } + @Test @TestMetadata("localDelegatedPropertiesWithAnnotations.kt") public void testLocalDelegatedPropertiesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.kt"); } + @Test @TestMetadata("multipleAnnotationsInSquareBrackets.kt") public void testMultipleAnnotationsInSquareBrackets() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt"); } + @Test @TestMetadata("primaryConstructorParameterWithAnnotations.kt") public void testPrimaryConstructorParameterWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt"); } + @Test @TestMetadata("propertiesWithAnnotations.kt") public void testPropertiesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt"); } + @Test @TestMetadata("propertyAccessorsFromClassHeaderWithAnnotations.kt") public void testPropertyAccessorsFromClassHeaderWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt"); } + @Test @TestMetadata("propertyAccessorsWithAnnotations.kt") public void testPropertyAccessorsWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt"); } + @Test @TestMetadata("propertySetterParameterWithAnnotations.kt") public void testPropertySetterParameterWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt"); } + @Test @TestMetadata("receiverParameterWithAnnotations.kt") public void testReceiverParameterWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.kt"); } + @Test @TestMetadata("spreadOperatorInAnnotationArguments.kt") public void testSpreadOperatorInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.kt"); } + @Test @TestMetadata("typeAliasesWithAnnotations.kt") public void testTypeAliasesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.kt"); } + @Test @TestMetadata("typeParametersWithAnnotations.kt") public void testTypeParametersWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.kt"); } + @Test @TestMetadata("valueParametersWithAnnotations.kt") public void testValueParametersWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt"); } + @Test @TestMetadata("varargsInAnnotationArguments.kt") public void testVarargsInAnnotationArguments() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt"); } + @Test @TestMetadata("variablesWithAnnotations.kt") public void testVariablesWithAnnotations() throws Exception { runTest("compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/multiplatform") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Multiplatform extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Multiplatform extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInMultiplatform() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/multiplatform"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("expectClassInherited.kt") public void testExpectClassInherited() throws Exception { runTest("compiler/testData/ir/irText/declarations/multiplatform/expectClassInherited.kt"); } + @Test @TestMetadata("expectedEnumClass.kt") public void testExpectedEnumClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.kt"); } + @Test @TestMetadata("expectedSealedClass.kt") public void testExpectedSealedClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/multiplatform/expectedSealedClass.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/parameters") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Parameters extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Parameters extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInParameters() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/parameters"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/parameters"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("class.kt") public void testClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/class.kt"); } + @Test @TestMetadata("constructor.kt") public void testConstructor() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/constructor.kt"); } + @Test @TestMetadata("dataClassMembers.kt") public void testDataClassMembers() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/dataClassMembers.kt"); } + @Test @TestMetadata("defaultPropertyAccessors.kt") public void testDefaultPropertyAccessors() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/defaultPropertyAccessors.kt"); } + @Test @TestMetadata("delegatedMembers.kt") public void testDelegatedMembers() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/delegatedMembers.kt"); } + @Test @TestMetadata("fun.kt") public void testFun() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/fun.kt"); } + @Test @TestMetadata("genericInnerClass.kt") public void testGenericInnerClass() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/genericInnerClass.kt"); } + @Test @TestMetadata("lambdas.kt") public void testLambdas() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/lambdas.kt"); } + @Test @TestMetadata("localFun.kt") public void testLocalFun() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/localFun.kt"); } + @Test @TestMetadata("propertyAccessors.kt") public void testPropertyAccessors() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/propertyAccessors.kt"); } + @Test @TestMetadata("typeParameterBeforeBound.kt") public void testTypeParameterBeforeBound() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/typeParameterBeforeBound.kt"); } + @Test @TestMetadata("typeParameterBoundedBySubclass.kt") public void testTypeParameterBoundedBySubclass() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/typeParameterBoundedBySubclass.kt"); } + @Test @TestMetadata("useNextParamInLambda.kt") public void testUseNextParamInLambda() throws Exception { runTest("compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/provideDelegate") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ProvideDelegate extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class ProvideDelegate extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInProvideDelegate() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/provideDelegate"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/provideDelegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("differentReceivers.kt") public void testDifferentReceivers() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/differentReceivers.kt"); } + @Test @TestMetadata("local.kt") public void testLocal() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/local.kt"); } + @Test @TestMetadata("localDifferentReceivers.kt") public void testLocalDifferentReceivers() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/localDifferentReceivers.kt"); } + @Test @TestMetadata("member.kt") public void testMember() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/member.kt"); } + @Test @TestMetadata("memberExtension.kt") public void testMemberExtension() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/memberExtension.kt"); } + @Test @TestMetadata("topLevel.kt") public void testTopLevel() throws Exception { runTest("compiler/testData/ir/irText/declarations/provideDelegate/topLevel.kt"); @@ -733,1037 +835,1211 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { } } + @Nested @TestMetadata("compiler/testData/ir/irText/errors") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Errors extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Errors extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInErrors() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/errors"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/errors"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("suppressedNonPublicCall.kt") public void testSuppressedNonPublicCall() throws Exception { runTest("compiler/testData/ir/irText/errors/suppressedNonPublicCall.kt"); } + @Test @TestMetadata("unresolvedReference.kt") public void testUnresolvedReference() throws Exception { runTest("compiler/testData/ir/irText/errors/unresolvedReference.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Expressions extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Expressions extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInExpressions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("argumentMappedWithError.kt") public void testArgumentMappedWithError() throws Exception { runTest("compiler/testData/ir/irText/expressions/argumentMappedWithError.kt"); } + @Test @TestMetadata("arrayAccess.kt") public void testArrayAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAccess.kt"); } + @Test @TestMetadata("arrayAssignment.kt") public void testArrayAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAssignment.kt"); } + @Test @TestMetadata("arrayAugmentedAssignment1.kt") public void testArrayAugmentedAssignment1() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.kt"); } + @Test @TestMetadata("arrayAugmentedAssignment2.kt") public void testArrayAugmentedAssignment2() throws Exception { runTest("compiler/testData/ir/irText/expressions/arrayAugmentedAssignment2.kt"); } + @Test @TestMetadata("assignments.kt") public void testAssignments() throws Exception { runTest("compiler/testData/ir/irText/expressions/assignments.kt"); } + @Test @TestMetadata("augmentedAssignment1.kt") public void testAugmentedAssignment1() throws Exception { runTest("compiler/testData/ir/irText/expressions/augmentedAssignment1.kt"); } + @Test @TestMetadata("augmentedAssignment2.kt") public void testAugmentedAssignment2() throws Exception { runTest("compiler/testData/ir/irText/expressions/augmentedAssignment2.kt"); } + @Test @TestMetadata("augmentedAssignmentWithExpression.kt") public void testAugmentedAssignmentWithExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/augmentedAssignmentWithExpression.kt"); } + @Test @TestMetadata("badBreakContinue.kt") public void testBadBreakContinue() throws Exception { runTest("compiler/testData/ir/irText/expressions/badBreakContinue.kt"); } + @Test @TestMetadata("bangbang.kt") public void testBangbang() throws Exception { runTest("compiler/testData/ir/irText/expressions/bangbang.kt"); } + @Test @TestMetadata("booleanConstsInAndAndOrOr.kt") public void testBooleanConstsInAndAndOrOr() throws Exception { runTest("compiler/testData/ir/irText/expressions/booleanConstsInAndAndOrOr.kt"); } + @Test @TestMetadata("booleanOperators.kt") public void testBooleanOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/booleanOperators.kt"); } + @Test @TestMetadata("boundCallableReferences.kt") public void testBoundCallableReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/boundCallableReferences.kt"); } + @Test @TestMetadata("boxOk.kt") public void testBoxOk() throws Exception { runTest("compiler/testData/ir/irText/expressions/boxOk.kt"); } + @Test @TestMetadata("breakContinue.kt") public void testBreakContinue() throws Exception { runTest("compiler/testData/ir/irText/expressions/breakContinue.kt"); } + @Test @TestMetadata("breakContinueInLoopHeader.kt") public void testBreakContinueInLoopHeader() throws Exception { runTest("compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.kt"); } + @Test @TestMetadata("breakContinueInWhen.kt") public void testBreakContinueInWhen() throws Exception { runTest("compiler/testData/ir/irText/expressions/breakContinueInWhen.kt"); } + @Test @TestMetadata("callWithReorderedArguments.kt") public void testCallWithReorderedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callWithReorderedArguments.kt"); } + @Test @TestMetadata("calls.kt") public void testCalls() throws Exception { runTest("compiler/testData/ir/irText/expressions/calls.kt"); } + @Test @TestMetadata("castToTypeParameter.kt") public void testCastToTypeParameter() throws Exception { runTest("compiler/testData/ir/irText/expressions/castToTypeParameter.kt"); } + @Test @TestMetadata("catchParameterAccess.kt") public void testCatchParameterAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/catchParameterAccess.kt"); } + @Test @TestMetadata("chainOfSafeCalls.kt") public void testChainOfSafeCalls() throws Exception { runTest("compiler/testData/ir/irText/expressions/chainOfSafeCalls.kt"); } + @Test @TestMetadata("classReference.kt") public void testClassReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/classReference.kt"); } + @Test @TestMetadata("coercionToUnit.kt") public void testCoercionToUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/coercionToUnit.kt"); } + @Test @TestMetadata("complexAugmentedAssignment.kt") public void testComplexAugmentedAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/complexAugmentedAssignment.kt"); } + @Test @TestMetadata("constructorWithOwnTypeParametersCall.kt") public void testConstructorWithOwnTypeParametersCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/constructorWithOwnTypeParametersCall.kt"); } + @Test @TestMetadata("contructorCall.kt") public void testContructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/contructorCall.kt"); } + @Test @TestMetadata("conventionComparisons.kt") public void testConventionComparisons() throws Exception { runTest("compiler/testData/ir/irText/expressions/conventionComparisons.kt"); } + @Test @TestMetadata("destructuring1.kt") public void testDestructuring1() throws Exception { runTest("compiler/testData/ir/irText/expressions/destructuring1.kt"); } + @Test @TestMetadata("destructuringWithUnderscore.kt") public void testDestructuringWithUnderscore() throws Exception { runTest("compiler/testData/ir/irText/expressions/destructuringWithUnderscore.kt"); } + @Test @TestMetadata("dotQualified.kt") public void testDotQualified() throws Exception { runTest("compiler/testData/ir/irText/expressions/dotQualified.kt"); } + @Test @TestMetadata("elvis.kt") public void testElvis() throws Exception { runTest("compiler/testData/ir/irText/expressions/elvis.kt"); } + @Test @TestMetadata("enumEntryAsReceiver.kt") public void testEnumEntryAsReceiver() throws Exception { runTest("compiler/testData/ir/irText/expressions/enumEntryAsReceiver.kt"); } + @Test @TestMetadata("enumEntryReferenceFromEnumEntryClass.kt") public void testEnumEntryReferenceFromEnumEntryClass() throws Exception { runTest("compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.kt"); } + @Test @TestMetadata("equality.kt") public void testEquality() throws Exception { runTest("compiler/testData/ir/irText/expressions/equality.kt"); } + @Test @TestMetadata("equals.kt") public void testEquals() throws Exception { runTest("compiler/testData/ir/irText/expressions/equals.kt"); } + @Test @TestMetadata("exhaustiveWhenElseBranch.kt") public void testExhaustiveWhenElseBranch() throws Exception { runTest("compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.kt"); } + @Test @TestMetadata("extFunInvokeAsFun.kt") public void testExtFunInvokeAsFun() throws Exception { runTest("compiler/testData/ir/irText/expressions/extFunInvokeAsFun.kt"); } + @Test @TestMetadata("extFunSafeInvoke.kt") public void testExtFunSafeInvoke() throws Exception { runTest("compiler/testData/ir/irText/expressions/extFunSafeInvoke.kt"); } + @Test @TestMetadata("extensionPropertyGetterCall.kt") public void testExtensionPropertyGetterCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/extensionPropertyGetterCall.kt"); } + @Test @TestMetadata("field.kt") public void testField() throws Exception { runTest("compiler/testData/ir/irText/expressions/field.kt"); } + @Test @TestMetadata("for.kt") public void testFor() throws Exception { runTest("compiler/testData/ir/irText/expressions/for.kt"); } + @Test @TestMetadata("forWithBreakContinue.kt") public void testForWithBreakContinue() throws Exception { runTest("compiler/testData/ir/irText/expressions/forWithBreakContinue.kt"); } + @Test @TestMetadata("forWithImplicitReceivers.kt") public void testForWithImplicitReceivers() throws Exception { runTest("compiler/testData/ir/irText/expressions/forWithImplicitReceivers.kt"); } + @Test @TestMetadata("funImportedFromObject.kt") public void testFunImportedFromObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/funImportedFromObject.kt"); } + @Test @TestMetadata("genericConstructorCallWithTypeArguments.kt") public void testGenericConstructorCallWithTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/genericConstructorCallWithTypeArguments.kt"); } + @Test @TestMetadata("genericPropertyCall.kt") public void testGenericPropertyCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/genericPropertyCall.kt"); } + @Test @TestMetadata("genericPropertyRef.kt") public void testGenericPropertyRef() throws Exception { runTest("compiler/testData/ir/irText/expressions/genericPropertyRef.kt"); } + @Test @TestMetadata("identity.kt") public void testIdentity() throws Exception { runTest("compiler/testData/ir/irText/expressions/identity.kt"); } + @Test @TestMetadata("ifElseIf.kt") public void testIfElseIf() throws Exception { runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastInReturnFromConstructor.kt"); } + @Test @TestMetadata("implicitCastOnPlatformType.kt") public void testImplicitCastOnPlatformType() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.kt"); } + @Test @TestMetadata("implicitCastToNonNull.kt") public void testImplicitCastToNonNull() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastToNonNull.kt"); } + @Test @TestMetadata("implicitCastToTypeParameter.kt") public void testImplicitCastToTypeParameter() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt"); } + @Test @TestMetadata("implicitNotNullInDestructuringAssignment.kt") public void testImplicitNotNullInDestructuringAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt"); } + @Test @TestMetadata("in.kt") public void testIn() throws Exception { runTest("compiler/testData/ir/irText/expressions/in.kt"); } + @Test @TestMetadata("incrementDecrement.kt") public void testIncrementDecrement() throws Exception { runTest("compiler/testData/ir/irText/expressions/incrementDecrement.kt"); } + @Test @TestMetadata("interfaceThisRef.kt") public void testInterfaceThisRef() throws Exception { runTest("compiler/testData/ir/irText/expressions/interfaceThisRef.kt"); } - @TestMetadata("javaSyntheticGenericPropertyAccess.kt") - public void testJavaSyntheticGenericPropertyAccess() throws Exception { - runTest("compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.kt"); + @Test + @TestMetadata("javaSyntheticGenericPropretyAccess.kt") + public void testJavaSyntheticGenericPropretyAccess() throws Exception { + runTest("compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.kt"); } + @Test @TestMetadata("javaSyntheticPropertyAccess.kt") public void testJavaSyntheticPropertyAccess() throws Exception { runTest("compiler/testData/ir/irText/expressions/javaSyntheticPropertyAccess.kt"); } + @Test @TestMetadata("jvmFieldReferenceWithIntersectionTypes.kt") public void testJvmFieldReferenceWithIntersectionTypes() throws Exception { runTest("compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.kt"); } + @Test @TestMetadata("jvmInstanceFieldReference.kt") public void testJvmInstanceFieldReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/jvmInstanceFieldReference.kt"); } + @Test @TestMetadata("jvmStaticFieldReference.kt") public void testJvmStaticFieldReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/jvmStaticFieldReference.kt"); } + @Test @TestMetadata("kt16904.kt") public void testKt16904() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt16904.kt"); } + @Test @TestMetadata("kt16905.kt") public void testKt16905() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt16905.kt"); } + @Test @TestMetadata("kt23030.kt") public void testKt23030() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt23030.kt"); } + @Test @TestMetadata("kt24804.kt") public void testKt24804() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt24804.kt"); } + @Test @TestMetadata("kt27933.kt") public void testKt27933() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt27933.kt"); } + @Test @TestMetadata("kt28006.kt") public void testKt28006() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28006.kt"); } + @Test @TestMetadata("kt28456.kt") public void testKt28456() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28456.kt"); } + @Test @TestMetadata("kt28456a.kt") public void testKt28456a() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28456a.kt"); } + @Test @TestMetadata("kt28456b.kt") public void testKt28456b() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt28456b.kt"); } + @Test @TestMetadata("kt30020.kt") public void testKt30020() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt30020.kt"); } + @Test @TestMetadata("kt30796.kt") public void testKt30796() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt30796.kt"); } + @Test @TestMetadata("kt35730.kt") public void testKt35730() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt35730.kt"); } + @Test @TestMetadata("kt36956.kt") public void testKt36956() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt36956.kt"); } + @Test @TestMetadata("kt36963.kt") public void testKt36963() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt36963.kt"); } + @Test @TestMetadata("kt37570.kt") public void testKt37570() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt37570.kt"); } + @Test @TestMetadata("kt37779.kt") public void testKt37779() throws Exception { runTest("compiler/testData/ir/irText/expressions/kt37779.kt"); } + @Test @TestMetadata("lambdaInCAO.kt") public void testLambdaInCAO() throws Exception { runTest("compiler/testData/ir/irText/expressions/lambdaInCAO.kt"); } + @Test @TestMetadata("literals.kt") public void testLiterals() throws Exception { runTest("compiler/testData/ir/irText/expressions/literals.kt"); } + @Test @TestMetadata("memberTypeArguments.kt") public void testMemberTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/memberTypeArguments.kt"); } + @Test @TestMetadata("membersImportedFromObject.kt") public void testMembersImportedFromObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/membersImportedFromObject.kt"); } + @Test @TestMetadata("multipleSmartCasts.kt") public void testMultipleSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/multipleSmartCasts.kt"); } + @Test @TestMetadata("multipleThisReferences.kt") public void testMultipleThisReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/multipleThisReferences.kt"); } + @Test @TestMetadata("nullCheckOnGenericLambdaReturn.kt") public void testNullCheckOnGenericLambdaReturn() throws Exception { runTest("compiler/testData/ir/irText/expressions/nullCheckOnGenericLambdaReturn.kt"); } + @Test @TestMetadata("nullCheckOnLambdaReturn.kt") public void testNullCheckOnLambdaReturn() throws Exception { runTest("compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.kt"); } + @Test @TestMetadata("objectAsCallable.kt") public void testObjectAsCallable() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectAsCallable.kt"); } + @Test @TestMetadata("objectByNameInsideObject.kt") public void testObjectByNameInsideObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectByNameInsideObject.kt"); } + @Test @TestMetadata("objectClassReference.kt") public void testObjectClassReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectClassReference.kt"); } + @Test @TestMetadata("objectReference.kt") public void testObjectReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectReference.kt"); } + @Test @TestMetadata("objectReferenceInClosureInSuperConstructorCall.kt") public void testObjectReferenceInClosureInSuperConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectReferenceInClosureInSuperConstructorCall.kt"); } + @Test @TestMetadata("objectReferenceInFieldInitializer.kt") public void testObjectReferenceInFieldInitializer() throws Exception { runTest("compiler/testData/ir/irText/expressions/objectReferenceInFieldInitializer.kt"); } + @Test @TestMetadata("outerClassInstanceReference.kt") public void testOuterClassInstanceReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/outerClassInstanceReference.kt"); } + @Test @TestMetadata("primitiveComparisons.kt") public void testPrimitiveComparisons() throws Exception { runTest("compiler/testData/ir/irText/expressions/primitiveComparisons.kt"); } + @Test @TestMetadata("primitivesImplicitConversions.kt") public void testPrimitivesImplicitConversions() throws Exception { runTest("compiler/testData/ir/irText/expressions/primitivesImplicitConversions.kt"); } + @Test @TestMetadata("propertyReferences.kt") public void testPropertyReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/propertyReferences.kt"); } + @Test @TestMetadata("references.kt") public void testReferences() throws Exception { runTest("compiler/testData/ir/irText/expressions/references.kt"); } + @Test @TestMetadata("reflectionLiterals.kt") public void testReflectionLiterals() throws Exception { runTest("compiler/testData/ir/irText/expressions/reflectionLiterals.kt"); } + @Test @TestMetadata("safeAssignment.kt") public void testSafeAssignment() throws Exception { runTest("compiler/testData/ir/irText/expressions/safeAssignment.kt"); } + @Test @TestMetadata("safeCallWithIncrementDecrement.kt") public void testSafeCallWithIncrementDecrement() throws Exception { runTest("compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.kt"); } + @Test @TestMetadata("safeCalls.kt") public void testSafeCalls() throws Exception { runTest("compiler/testData/ir/irText/expressions/safeCalls.kt"); } + @Test @TestMetadata("setFieldWithImplicitCast.kt") public void testSetFieldWithImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.kt"); } + @Test @TestMetadata("signedToUnsignedConversions.kt") public void testSignedToUnsignedConversions() throws Exception { runTest("compiler/testData/ir/irText/expressions/signedToUnsignedConversions.kt"); } + @Test @TestMetadata("simpleOperators.kt") public void testSimpleOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/simpleOperators.kt"); } + @Test @TestMetadata("simpleUnaryOperators.kt") public void testSimpleUnaryOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/simpleUnaryOperators.kt"); } + @Test @TestMetadata("smartCasts.kt") public void testSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/smartCasts.kt"); } + @Test @TestMetadata("smartCastsWithDestructuring.kt") public void testSmartCastsWithDestructuring() throws Exception { runTest("compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.kt"); } + @Test @TestMetadata("specializedTypeAliasConstructorCall.kt") public void testSpecializedTypeAliasConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/specializedTypeAliasConstructorCall.kt"); } + @Test @TestMetadata("stringComparisons.kt") public void testStringComparisons() throws Exception { runTest("compiler/testData/ir/irText/expressions/stringComparisons.kt"); } + @Test @TestMetadata("stringPlus.kt") public void testStringPlus() throws Exception { runTest("compiler/testData/ir/irText/expressions/stringPlus.kt"); } + @Test @TestMetadata("stringTemplates.kt") public void testStringTemplates() throws Exception { runTest("compiler/testData/ir/irText/expressions/stringTemplates.kt"); } + @Test @TestMetadata("suspendConversionOnArbitraryExpression.kt") public void testSuspendConversionOnArbitraryExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/suspendConversionOnArbitraryExpression.kt"); } + @Test @TestMetadata("temporaryInEnumEntryInitializer.kt") public void testTemporaryInEnumEntryInitializer() throws Exception { runTest("compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.kt"); } + @Test @TestMetadata("temporaryInInitBlock.kt") public void testTemporaryInInitBlock() throws Exception { runTest("compiler/testData/ir/irText/expressions/temporaryInInitBlock.kt"); } + @Test @TestMetadata("thisOfGenericOuterClass.kt") public void testThisOfGenericOuterClass() throws Exception { runTest("compiler/testData/ir/irText/expressions/thisOfGenericOuterClass.kt"); } + @Test @TestMetadata("thisRefToObjectInNestedClassConstructorCall.kt") public void testThisRefToObjectInNestedClassConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/thisRefToObjectInNestedClassConstructorCall.kt"); } + @Test @TestMetadata("thisReferenceBeforeClassDeclared.kt") public void testThisReferenceBeforeClassDeclared() throws Exception { runTest("compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.kt"); } + @Test @TestMetadata("throw.kt") public void testThrow() throws Exception { runTest("compiler/testData/ir/irText/expressions/throw.kt"); } + @Test @TestMetadata("tryCatch.kt") public void testTryCatch() throws Exception { runTest("compiler/testData/ir/irText/expressions/tryCatch.kt"); } + @Test @TestMetadata("tryCatchWithImplicitCast.kt") public void testTryCatchWithImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/expressions/tryCatchWithImplicitCast.kt"); } + @Test @TestMetadata("typeAliasConstructorReference.kt") public void testTypeAliasConstructorReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeAliasConstructorReference.kt"); } + @Test @TestMetadata("typeArguments.kt") public void testTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeArguments.kt"); } + @Test @TestMetadata("typeOperators.kt") public void testTypeOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeOperators.kt"); } + @Test @TestMetadata("typeParameterClassLiteral.kt") public void testTypeParameterClassLiteral() throws Exception { runTest("compiler/testData/ir/irText/expressions/typeParameterClassLiteral.kt"); } + @Test @TestMetadata("unsignedIntegerLiterals.kt") public void testUnsignedIntegerLiterals() throws Exception { runTest("compiler/testData/ir/irText/expressions/unsignedIntegerLiterals.kt"); } + @Test @TestMetadata("useImportedMember.kt") public void testUseImportedMember() throws Exception { runTest("compiler/testData/ir/irText/expressions/useImportedMember.kt"); } + @Test @TestMetadata("values.kt") public void testValues() throws Exception { runTest("compiler/testData/ir/irText/expressions/values.kt"); } + @Test @TestMetadata("vararg.kt") public void testVararg() throws Exception { runTest("compiler/testData/ir/irText/expressions/vararg.kt"); } + @Test @TestMetadata("varargWithImplicitCast.kt") public void testVarargWithImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/expressions/varargWithImplicitCast.kt"); } + @Test @TestMetadata("variableAsFunctionCall.kt") public void testVariableAsFunctionCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/variableAsFunctionCall.kt"); } + @Test @TestMetadata("variableAsFunctionCallWithGenerics.kt") public void testVariableAsFunctionCallWithGenerics() throws Exception { runTest("compiler/testData/ir/irText/expressions/variableAsFunctionCallWithGenerics.kt"); } + @Test @TestMetadata("when.kt") public void testWhen() throws Exception { runTest("compiler/testData/ir/irText/expressions/when.kt"); } + @Test @TestMetadata("whenCoercedToUnit.kt") public void testWhenCoercedToUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenCoercedToUnit.kt"); } + @Test @TestMetadata("whenElse.kt") public void testWhenElse() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenElse.kt"); } + @Test @TestMetadata("whenReturn.kt") public void testWhenReturn() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenReturn.kt"); } + @Test @TestMetadata("whenReturnUnit.kt") public void testWhenReturnUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenReturnUnit.kt"); } + @Test @TestMetadata("whenSmartCastToEnum.kt") public void testWhenSmartCastToEnum() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenSmartCastToEnum.kt"); } + @Test @TestMetadata("whenUnusedExpression.kt") public void testWhenUnusedExpression() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenUnusedExpression.kt"); } + @Test @TestMetadata("whenWithSubjectVariable.kt") public void testWhenWithSubjectVariable() throws Exception { runTest("compiler/testData/ir/irText/expressions/whenWithSubjectVariable.kt"); } + @Test @TestMetadata("whileDoWhile.kt") public void testWhileDoWhile() throws Exception { runTest("compiler/testData/ir/irText/expressions/whileDoWhile.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/callableReferences") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class CallableReferences extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class CallableReferences extends AbstractFir2IrTextTest { + @Test @TestMetadata("adaptedExtensionFunctions.kt") public void testAdaptedExtensionFunctions() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/adaptedExtensionFunctions.kt"); } + @Test @TestMetadata("adaptedWithCoercionToUnit.kt") public void testAdaptedWithCoercionToUnit() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/adaptedWithCoercionToUnit.kt"); } + @Test public void testAllFilesPresentInCallableReferences() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("boundInlineAdaptedReference.kt") public void testBoundInlineAdaptedReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt"); } + @Test @TestMetadata("boundInnerGenericConstructor.kt") public void testBoundInnerGenericConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.kt"); } + @Test @TestMetadata("caoWithAdaptationForSam.kt") public void testCaoWithAdaptationForSam() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/caoWithAdaptationForSam.kt"); } + @Test @TestMetadata("constructorWithAdaptedArguments.kt") public void testConstructorWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.kt"); } + @Test @TestMetadata("funWithDefaultParametersAsKCallableStar.kt") public void testFunWithDefaultParametersAsKCallableStar() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/funWithDefaultParametersAsKCallableStar.kt"); } + @Test @TestMetadata("genericLocalClassConstructorReference.kt") public void testGenericLocalClassConstructorReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/genericLocalClassConstructorReference.kt"); } + @Test @TestMetadata("genericMember.kt") public void testGenericMember() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/genericMember.kt"); } + @Test @TestMetadata("importedFromObject.kt") public void testImportedFromObject() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.kt"); } + @Test @TestMetadata("kt37131.kt") public void testKt37131() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/kt37131.kt"); } + @Test @TestMetadata("suspendConversion.kt") public void testSuspendConversion() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/suspendConversion.kt"); } + @Test @TestMetadata("typeArguments.kt") public void testTypeArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/typeArguments.kt"); } + @Test @TestMetadata("unboundMemberReferenceWithAdaptedArguments.kt") public void testUnboundMemberReferenceWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.kt"); } + @Test @TestMetadata("withAdaptationForSam.kt") public void testWithAdaptationForSam() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withAdaptationForSam.kt"); } + @Test @TestMetadata("withAdaptedArguments.kt") public void testWithAdaptedArguments() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.kt"); } + @Test @TestMetadata("withArgumentAdaptationAndReceiver.kt") public void testWithArgumentAdaptationAndReceiver() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.kt"); } + @Test @TestMetadata("withVarargViewedAsArray.kt") public void testWithVarargViewedAsArray() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FloatingPointComparisons extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class FloatingPointComparisons extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInFloatingPointComparisons() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/floatingPointComparisons"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/floatingPointComparisons"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("comparableWithDoubleOrFloat.kt") public void testComparableWithDoubleOrFloat() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.kt"); } + @Test @TestMetadata("eqeqRhsConditionPossiblyAffectingLhs.kt") public void testEqeqRhsConditionPossiblyAffectingLhs() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/eqeqRhsConditionPossiblyAffectingLhs.kt"); } + @Test @TestMetadata("floatingPointCompareTo.kt") public void testFloatingPointCompareTo() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.kt"); } + @Test @TestMetadata("floatingPointEqeq.kt") public void testFloatingPointEqeq() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.kt"); } + @Test @TestMetadata("floatingPointEquals.kt") public void testFloatingPointEquals() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.kt"); } + @Test @TestMetadata("floatingPointExcleq.kt") public void testFloatingPointExcleq() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.kt"); } + @Test @TestMetadata("floatingPointLess.kt") public void testFloatingPointLess() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.kt"); } + @Test @TestMetadata("nullableAnyAsIntToDouble.kt") public void testNullableAnyAsIntToDouble() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt"); } + @Test @TestMetadata("nullableFloatingPointEqeq.kt") public void testNullableFloatingPointEqeq() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.kt"); } + @Test @TestMetadata("typeParameterWithPrimitiveNumericSupertype.kt") public void testTypeParameterWithPrimitiveNumericSupertype() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/typeParameterWithPrimitiveNumericSupertype.kt"); } + @Test @TestMetadata("whenByFloatingPoint.kt") public void testWhenByFloatingPoint() throws Exception { runTest("compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/funInterface") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FunInterface extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class FunInterface extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInFunInterface() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("arrayAsVarargAfterSamArgument_fi.kt") public void testArrayAsVarargAfterSamArgument_fi() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/arrayAsVarargAfterSamArgument_fi.kt"); } + @Test @TestMetadata("basicFunInterfaceConversion.kt") public void testBasicFunInterfaceConversion() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/basicFunInterfaceConversion.kt"); } + @Test @TestMetadata("castFromAny.kt") public void testCastFromAny() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/castFromAny.kt"); } + @Test @TestMetadata("partialSam.kt") public void testPartialSam() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/partialSam.kt"); } + @Test @TestMetadata("samConversionInVarargs.kt") public void testSamConversionInVarargs() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargs.kt"); } + @Test @TestMetadata("samConversionInVarargsMixed.kt") public void testSamConversionInVarargsMixed() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionInVarargsMixed.kt"); } + @Test @TestMetadata("samConversionOnCallableReference.kt") public void testSamConversionOnCallableReference() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt"); } + @Test @TestMetadata("samConversionsWithSmartCasts.kt") public void testSamConversionsWithSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/expressions/sam") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Sam extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Sam extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInSam() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/sam"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/sam"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("arrayAsVarargAfterSamArgument.kt") public void testArrayAsVarargAfterSamArgument() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/arrayAsVarargAfterSamArgument.kt"); } + @Test @TestMetadata("genericSamProjectedOut.kt") public void testGenericSamProjectedOut() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/genericSamProjectedOut.kt"); } + @Test @TestMetadata("genericSamSmartcast.kt") public void testGenericSamSmartcast() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.kt"); } + @Test @TestMetadata("samByProjectedType.kt") public void testSamByProjectedType() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samByProjectedType.kt"); } + @Test @TestMetadata("samConstructors.kt") public void testSamConstructors() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConstructors.kt"); } + @Test @TestMetadata("samConversionInGenericConstructorCall.kt") public void testSamConversionInGenericConstructorCall() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall.kt"); } + @Test @TestMetadata("samConversionInGenericConstructorCall_NI.kt") public void testSamConversionInGenericConstructorCall_NI() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionInGenericConstructorCall_NI.kt"); } + @Test @TestMetadata("samConversionToGeneric.kt") public void testSamConversionToGeneric() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionToGeneric.kt"); } + @Test @TestMetadata("samConversions.kt") public void testSamConversions() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversions.kt"); } + @Test @TestMetadata("samConversionsWithSmartCasts.kt") public void testSamConversionsWithSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.kt"); } + @Test @TestMetadata("samOperators.kt") public void testSamOperators() throws Exception { runTest("compiler/testData/ir/irText/expressions/sam/samOperators.kt"); @@ -1771,251 +2047,279 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { } } + @Nested @TestMetadata("compiler/testData/ir/irText/firProblems") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class FirProblems extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class FirProblems extends AbstractFir2IrTextTest { + @Test @TestMetadata("AbstractMutableMap.kt") public void testAbstractMutableMap() throws Exception { runTest("compiler/testData/ir/irText/firProblems/AbstractMutableMap.kt"); } + @Test @TestMetadata("AllCandidates.kt") public void testAllCandidates() throws Exception { runTest("compiler/testData/ir/irText/firProblems/AllCandidates.kt"); } + @Test public void testAllFilesPresentInFirProblems() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("AnnotationInAnnotation.kt") public void testAnnotationInAnnotation() throws Exception { runTest("compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt"); } + @Test @TestMetadata("candidateSymbol.kt") public void testCandidateSymbol() throws Exception { runTest("compiler/testData/ir/irText/firProblems/candidateSymbol.kt"); } + @Test @TestMetadata("ClashResolutionDescriptor.kt") public void testClashResolutionDescriptor() throws Exception { runTest("compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.kt"); } + @Test @TestMetadata("coercionToUnitForNestedWhen.kt") public void testCoercionToUnitForNestedWhen() throws Exception { runTest("compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.kt"); } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { runTest("compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt"); } + @Test @TestMetadata("DelegationAndInheritanceFromJava.kt") public void testDelegationAndInheritanceFromJava() throws Exception { runTest("compiler/testData/ir/irText/firProblems/DelegationAndInheritanceFromJava.kt"); } + @Test @TestMetadata("deprecated.kt") public void testDeprecated() throws Exception { runTest("compiler/testData/ir/irText/firProblems/deprecated.kt"); } + @Test @TestMetadata("FirBuilder.kt") public void testFirBuilder() throws Exception { runTest("compiler/testData/ir/irText/firProblems/FirBuilder.kt"); } + @Test @TestMetadata("ImplicitReceiverStack.kt") public void testImplicitReceiverStack() throws Exception { runTest("compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.kt"); } + @Test @TestMetadata("inapplicableCollectionSet.kt") public void testInapplicableCollectionSet() throws Exception { runTest("compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.kt"); } + @Test @TestMetadata("InnerClassInAnonymous.kt") public void testInnerClassInAnonymous() throws Exception { runTest("compiler/testData/ir/irText/firProblems/InnerClassInAnonymous.kt"); } + @Test @TestMetadata("kt43342.kt") public void testKt43342() throws Exception { runTest("compiler/testData/ir/irText/firProblems/kt43342.kt"); } + @Test @TestMetadata("MultiList.kt") public void testMultiList() throws Exception { runTest("compiler/testData/ir/irText/firProblems/MultiList.kt"); } + @Test @TestMetadata("putIfAbsent.kt") public void testPutIfAbsent() throws Exception { runTest("compiler/testData/ir/irText/firProblems/putIfAbsent.kt"); } + @Test @TestMetadata("readWriteProperty.kt") public void testReadWriteProperty() throws Exception { runTest("compiler/testData/ir/irText/firProblems/readWriteProperty.kt"); } + @Test @TestMetadata("recursiveCapturedTypeInPropertyReference.kt") public void testRecursiveCapturedTypeInPropertyReference() throws Exception { runTest("compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.kt"); } + @Test @TestMetadata("SameJavaFieldReferences.kt") public void testSameJavaFieldReferences() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SameJavaFieldReferences.kt"); } + @Test @TestMetadata("SignatureClash.kt") public void testSignatureClash() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SignatureClash.kt"); } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception { runTest("compiler/testData/ir/irText/firProblems/SyntheticSetterType.kt"); } + @Test @TestMetadata("throwableStackTrace.kt") public void testThrowableStackTrace() throws Exception { runTest("compiler/testData/ir/irText/firProblems/throwableStackTrace.kt"); } + @Test @TestMetadata("typeParameterFromJavaClass.kt") public void testTypeParameterFromJavaClass() throws Exception { runTest("compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt"); } + @Test @TestMetadata("typeVariableAfterBuildMap.kt") public void testTypeVariableAfterBuildMap() throws Exception { runTest("compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.kt"); } + @Test @TestMetadata("V8ArrayToList.kt") public void testV8ArrayToList() throws Exception { runTest("compiler/testData/ir/irText/firProblems/V8ArrayToList.kt"); } + @Test @TestMetadata("VarInInit.kt") public void testVarInInit() throws Exception { runTest("compiler/testData/ir/irText/firProblems/VarInInit.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/lambdas") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Lambdas extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Lambdas extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInLambdas() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/lambdas"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/lambdas"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("anonymousFunction.kt") public void testAnonymousFunction() throws Exception { runTest("compiler/testData/ir/irText/lambdas/anonymousFunction.kt"); } + @Test @TestMetadata("destructuringInLambda.kt") public void testDestructuringInLambda() throws Exception { runTest("compiler/testData/ir/irText/lambdas/destructuringInLambda.kt"); } + @Test @TestMetadata("extensionLambda.kt") public void testExtensionLambda() throws Exception { runTest("compiler/testData/ir/irText/lambdas/extensionLambda.kt"); } + @Test @TestMetadata("justLambda.kt") public void testJustLambda() throws Exception { runTest("compiler/testData/ir/irText/lambdas/justLambda.kt"); } + @Test @TestMetadata("localFunction.kt") public void testLocalFunction() throws Exception { runTest("compiler/testData/ir/irText/lambdas/localFunction.kt"); } + @Test @TestMetadata("multipleImplicitReceivers.kt") public void testMultipleImplicitReceivers() throws Exception { runTest("compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.kt"); } + @Test @TestMetadata("nonLocalReturn.kt") public void testNonLocalReturn() throws Exception { runTest("compiler/testData/ir/irText/lambdas/nonLocalReturn.kt"); } + @Test @TestMetadata("samAdapter.kt") public void testSamAdapter() throws Exception { runTest("compiler/testData/ir/irText/lambdas/samAdapter.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/regressions") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Regressions extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Regressions extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInRegressions() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("coercionInLoop.kt") public void testCoercionInLoop() throws Exception { runTest("compiler/testData/ir/irText/regressions/coercionInLoop.kt"); } + @Test @TestMetadata("integerCoercionToT.kt") public void testIntegerCoercionToT() throws Exception { runTest("compiler/testData/ir/irText/regressions/integerCoercionToT.kt"); } + @Test @TestMetadata("kt24114.kt") public void testKt24114() throws Exception { runTest("compiler/testData/ir/irText/regressions/kt24114.kt"); } + @Test @TestMetadata("typeAliasCtorForGenericClass.kt") public void testTypeAliasCtorForGenericClass() throws Exception { runTest("compiler/testData/ir/irText/regressions/typeAliasCtorForGenericClass.kt"); } + @Test @TestMetadata("typeParametersInImplicitCast.kt") public void testTypeParametersInImplicitCast() throws Exception { runTest("compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/regressions/newInference") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NewInference extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class NewInference extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInNewInference() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions/newInference"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/regressions/newInference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("fixationOrder1.kt") public void testFixationOrder1() throws Exception { runTest("compiler/testData/ir/irText/regressions/newInference/fixationOrder1.kt"); @@ -2023,348 +2327,390 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { } } + @Nested @TestMetadata("compiler/testData/ir/irText/singletons") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Singletons extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Singletons extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInSingletons() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/singletons"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/singletons"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("companion.kt") public void testCompanion() throws Exception { runTest("compiler/testData/ir/irText/singletons/companion.kt"); } + @Test @TestMetadata("enumEntry.kt") public void testEnumEntry() throws Exception { runTest("compiler/testData/ir/irText/singletons/enumEntry.kt"); } + @Test @TestMetadata("object.kt") public void testObject() throws Exception { runTest("compiler/testData/ir/irText/singletons/object.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/stubs") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Stubs extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Stubs extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInStubs() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("builtinMap.kt") public void testBuiltinMap() throws Exception { runTest("compiler/testData/ir/irText/stubs/builtinMap.kt"); } + @Test @TestMetadata("constFromBuiltins.kt") public void testConstFromBuiltins() throws Exception { runTest("compiler/testData/ir/irText/stubs/constFromBuiltins.kt"); } + @Test @TestMetadata("genericClassInDifferentModule.kt") public void testGenericClassInDifferentModule() throws Exception { runTest("compiler/testData/ir/irText/stubs/genericClassInDifferentModule.kt"); } + @Test @TestMetadata("javaConstructorWithTypeParameters.kt") public void testJavaConstructorWithTypeParameters() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaConstructorWithTypeParameters.kt"); } + @Test @TestMetadata("javaEnum.kt") public void testJavaEnum() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaEnum.kt"); } + @Test @TestMetadata("javaInnerClass.kt") public void testJavaInnerClass() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaInnerClass.kt"); } + @Test @TestMetadata("javaMethod.kt") public void testJavaMethod() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaMethod.kt"); } + @Test @TestMetadata("javaNestedClass.kt") public void testJavaNestedClass() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaNestedClass.kt"); } + @Test @TestMetadata("javaStaticMethod.kt") public void testJavaStaticMethod() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaStaticMethod.kt"); } + @Test @TestMetadata("javaSyntheticProperty.kt") public void testJavaSyntheticProperty() throws Exception { runTest("compiler/testData/ir/irText/stubs/javaSyntheticProperty.kt"); } + @Test @TestMetadata("jdkClassSyntheticProperty.kt") public void testJdkClassSyntheticProperty() throws Exception { runTest("compiler/testData/ir/irText/stubs/jdkClassSyntheticProperty.kt"); } + @Test @TestMetadata("kotlinInnerClass.kt") public void testKotlinInnerClass() throws Exception { runTest("compiler/testData/ir/irText/stubs/kotlinInnerClass.kt"); } + @Test @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/ir/irText/stubs/simple.kt"); } } + @Nested @TestMetadata("compiler/testData/ir/irText/types") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class Types extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class Types extends AbstractFir2IrTextTest { + @Test @TestMetadata("abbreviatedTypes.kt") public void testAbbreviatedTypes() throws Exception { runTest("compiler/testData/ir/irText/types/abbreviatedTypes.kt"); } + @Test public void testAllFilesPresentInTypes() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("asOnPlatformType.kt") public void testAsOnPlatformType() throws Exception { runTest("compiler/testData/ir/irText/types/asOnPlatformType.kt"); } + @Test @TestMetadata("castsInsideCoroutineInference.kt") public void testCastsInsideCoroutineInference() throws Exception { runTest("compiler/testData/ir/irText/types/castsInsideCoroutineInference.kt"); } + @Test @TestMetadata("coercionToUnitInLambdaReturnValue.kt") public void testCoercionToUnitInLambdaReturnValue() throws Exception { runTest("compiler/testData/ir/irText/types/coercionToUnitInLambdaReturnValue.kt"); } + @Test @TestMetadata("genericDelegatedDeepProperty.kt") public void testGenericDelegatedDeepProperty() throws Exception { runTest("compiler/testData/ir/irText/types/genericDelegatedDeepProperty.kt"); } + @Test @TestMetadata("genericFunWithStar.kt") public void testGenericFunWithStar() throws Exception { runTest("compiler/testData/ir/irText/types/genericFunWithStar.kt"); } + @Test @TestMetadata("genericPropertyReferenceType.kt") public void testGenericPropertyReferenceType() throws Exception { runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt"); } + @Test @TestMetadata("inStarProjectionInReceiverType.kt") public void testInStarProjectionInReceiverType() throws Exception { runTest("compiler/testData/ir/irText/types/inStarProjectionInReceiverType.kt"); } + @Test @TestMetadata("intersectionType1_NI.kt") public void testIntersectionType1_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt"); } + @Test @TestMetadata("intersectionType1_OI.kt") public void testIntersectionType1_OI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType1_OI.kt"); } + @Test @TestMetadata("intersectionType2_NI.kt") public void testIntersectionType2_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType2_NI.kt"); } + @Test @TestMetadata("intersectionType2_OI.kt") public void testIntersectionType2_OI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType2_OI.kt"); } + @Test @TestMetadata("intersectionType3_NI.kt") public void testIntersectionType3_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType3_NI.kt"); } + @Test @TestMetadata("intersectionType3_OI.kt") public void testIntersectionType3_OI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType3_OI.kt"); } + @Test @TestMetadata("javaWildcardType.kt") public void testJavaWildcardType() throws Exception { runTest("compiler/testData/ir/irText/types/javaWildcardType.kt"); } + @Test @TestMetadata("kt36143.kt") public void testKt36143() throws Exception { runTest("compiler/testData/ir/irText/types/kt36143.kt"); } + @Test @TestMetadata("localVariableOfIntersectionType_NI.kt") public void testLocalVariableOfIntersectionType_NI() throws Exception { runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt"); } + @Test @TestMetadata("rawTypeInSignature.kt") public void testRawTypeInSignature() throws Exception { runTest("compiler/testData/ir/irText/types/rawTypeInSignature.kt"); } + @Test @TestMetadata("receiverOfIntersectionType.kt") public void testReceiverOfIntersectionType() throws Exception { runTest("compiler/testData/ir/irText/types/receiverOfIntersectionType.kt"); } + @Test @TestMetadata("smartCastOnFakeOverrideReceiver.kt") public void testSmartCastOnFakeOverrideReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/smartCastOnFakeOverrideReceiver.kt"); } + @Test @TestMetadata("smartCastOnFieldReceiverOfGenericType.kt") public void testSmartCastOnFieldReceiverOfGenericType() throws Exception { runTest("compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.kt"); } + @Test @TestMetadata("smartCastOnReceiverOfGenericType.kt") public void testSmartCastOnReceiverOfGenericType() throws Exception { runTest("compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.kt"); } + @Test @TestMetadata("starProjection_OI.kt") public void testStarProjection_OI() throws Exception { runTest("compiler/testData/ir/irText/types/starProjection_OI.kt"); } + @Test @TestMetadata("typeAliasWithUnsafeVariance.kt") public void testTypeAliasWithUnsafeVariance() throws Exception { runTest("compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/types/nullChecks") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NullChecks extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class NullChecks extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInNullChecks() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("enhancedNullability.kt") public void testEnhancedNullability() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/enhancedNullability.kt"); } + @Test @TestMetadata("enhancedNullabilityInDestructuringAssignment.kt") public void testEnhancedNullabilityInDestructuringAssignment() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.kt"); } + @Test @TestMetadata("enhancedNullabilityInForLoop.kt") public void testEnhancedNullabilityInForLoop() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.kt"); } + @Test @TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt") public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt"); } + @Test @TestMetadata("implicitNotNullOnPlatformType.kt") public void testImplicitNotNullOnPlatformType() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.kt"); } + @Test @TestMetadata("nullabilityAssertionOnExtensionReceiver.kt") public void testNullabilityAssertionOnExtensionReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.kt"); } + @Test @TestMetadata("platformTypeReceiver.kt") public void testPlatformTypeReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/platformTypeReceiver.kt"); } + @Nested @TestMetadata("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult") @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class NullCheckOnLambdaResult extends AbstractFir2IrTextTest { - private void runTest(String testDataFilePath) throws Exception { - KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); - } - + public class NullCheckOnLambdaResult extends AbstractFir2IrTextTest { + @Test public void testAllFilesPresentInNullCheckOnLambdaResult() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult"), Pattern.compile("^(.+)\\.kt$"), null, true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test @TestMetadata("nnStringVsT.kt") public void testNnStringVsT() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt"); } + @Test @TestMetadata("nnStringVsTAny.kt") public void testNnStringVsTAny() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt"); } + @Test @TestMetadata("nnStringVsTConstrained.kt") public void testNnStringVsTConstrained() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt"); } + @Test @TestMetadata("nnStringVsTXArray.kt") public void testNnStringVsTXArray() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt"); } + @Test @TestMetadata("nnStringVsTXString.kt") public void testNnStringVsTXString() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt"); } + @Test @TestMetadata("stringVsT.kt") public void testStringVsT() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt"); } + @Test @TestMetadata("stringVsTAny.kt") public void testStringVsTAny() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt"); } + @Test @TestMetadata("stringVsTConstrained.kt") public void testStringVsTConstrained() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt"); } + @Test @TestMetadata("stringVsTXArray.kt") public void testStringVsTXArray() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt"); } + @Test @TestMetadata("stringVsTXString.kt") public void testStringVsTXString() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt"); diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/AbstractFir2IrTextTest.kt b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/AbstractFir2IrTextTest.kt deleted file mode 100644 index 15714781e03..00000000000 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/AbstractFir2IrTextTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.fir - -import com.intellij.openapi.project.Project -import com.intellij.psi.PsiElementFinder -import com.intellij.psi.search.GlobalSearchScope -import org.jetbrains.kotlin.asJava.finder.JavaElementFinder -import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensions -import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM -import org.jetbrains.kotlin.config.languageVersionSettings -import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade -import org.jetbrains.kotlin.ir.AbstractIrTextTestCase -import org.jetbrains.kotlin.ir.declarations.IrModuleFragment -import java.io.File - -abstract class AbstractFir2IrTextTest : AbstractIrTextTestCase() { - - private fun prepareProjectExtensions(project: Project) { - PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java) - } - - override fun doTest(wholeFile: File, testFiles: List) { - buildFragmentAndTestIt(wholeFile, testFiles) - } - - override fun doTest(filePath: String) { - val oldFrontendTextPath = filePath.replace(".kt", ".txt") - val firTextPath = filePath.replace(".kt", ".fir.txt") - val oldFrontendTextFile = File(oldFrontendTextPath) - val firTextFile = File(firTextPath) - if (oldFrontendTextFile.exists() && firTextFile.exists()) { - compareAndMergeFirFileAndOldFrontendFile(oldFrontendTextFile, firTextFile, compareWithTrimming = true) - } - super.doTest(filePath) - } - - override fun getExpectedTextFileName(testFile: TestFile, name: String): String { - // NB: replace with if (true) to make test against old FE results - if ("// FIR_IDENTICAL" in testFile.content.split("\n")) { - return super.getExpectedTextFileName(testFile, name) - } - return name.replace(".txt", ".fir.txt").replace(".kt", ".fir.txt") - } - - override fun generateIrModule(ignoreErrors: Boolean): IrModuleFragment { - val psiFiles = myFiles.psiFiles - - val project = psiFiles.first().project - prepareProjectExtensions(project) - - val scope = GlobalSearchScope.filesScope(project, psiFiles.map { it.virtualFile }) - .uniteWith(TopDownAnalyzerFacadeForJVM.AllJavaSourcesInProjectScope(project)) - val session = createSession(myEnvironment, scope) - val firAnalyzerFacade = FirAnalyzerFacade(session, myEnvironment.configuration.languageVersionSettings, psiFiles) - return firAnalyzerFacade.convertToIr(JvmGeneratorExtensions(generateFacades = false)).irModuleFragment - } -} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/FirIrDumpIdenticalCheckers.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/FirIrDumpIdenticalCheckers.kt new file mode 100644 index 00000000000..23e719d6ca7 --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/FirIrDumpIdenticalCheckers.kt @@ -0,0 +1,59 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test.backend.handlers + +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives.FIR_IDENTICAL +import org.jetbrains.kotlin.test.directives.model.DirectivesContainer +import org.jetbrains.kotlin.test.model.AfterAnalysisChecker +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.moduleStructure +import org.jetbrains.kotlin.test.utils.FirIdenticalCheckerHelper +import org.jetbrains.kotlin.test.utils.withExtension +import java.io.File + +class FirIrDumpIdenticalChecker(testServices: TestServices) : AfterAnalysisChecker(testServices) { + override val directives: List + get() = listOf(FirDiagnosticsDirectives) + + private val simpleDumpChecker = object : FirIdenticalCheckerHelper(testServices) { + override fun getClassicFileToCompare(testDataFile: File): File? { + return testDataFile.withExtension(IrTextDumpHandler.DUMP_EXTENSION).takeIf { it.exists() } + } + + override fun getFirFileToCompare(testDataFile: File): File? { + return testDataFile.withExtension("fir.${IrTextDumpHandler.DUMP_EXTENSION}").takeIf { it.exists() } + } + } + + private val prettyDumpChecker = object : FirIdenticalCheckerHelper(testServices) { + override fun getClassicFileToCompare(testDataFile: File): File? { + return testDataFile.withExtension(IrPrettyKotlinDumpHandler.DUMP_EXTENSION).takeIf { it.exists() } + } + + override fun getFirFileToCompare(testDataFile: File): File? { + return testDataFile.withExtension("fir.${IrPrettyKotlinDumpHandler.DUMP_EXTENSION}").takeIf { it.exists() } + } + } + + override fun check(failedAssertions: List) { + if (failedAssertions.isNotEmpty()) return + val testDataFile = testServices.moduleStructure.originalTestDataFiles.first() + if (FIR_IDENTICAL in testServices.moduleStructure.allDirectives) { + simpleDumpChecker.deleteFirFile(testDataFile) + prettyDumpChecker.deleteFirFile(testDataFile) + return + } + if ( + simpleDumpChecker.firAndClassicContentsAreEquals(testDataFile) && + prettyDumpChecker.firAndClassicContentsAreEquals(testDataFile, trimLines = true) + ) { + simpleDumpChecker.deleteFirFile(testDataFile) + prettyDumpChecker.deleteFirFile(testDataFile) + simpleDumpChecker.addDirectiveToClassicFileAndAssert(testDataFile) + } + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt index 9cf9e7fe0c9..115856f3a3b 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrPrettyKotlinDumpHandler.kt @@ -11,9 +11,12 @@ import org.jetbrains.kotlin.ir.util.dumpKotlinLike import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler.Companion.computeDumpExtension import org.jetbrains.kotlin.test.backend.handlers.IrTextDumpHandler.Companion.groupWithTestFiles import org.jetbrains.kotlin.test.backend.ir.IrBackendInput +import org.jetbrains.kotlin.test.directives.CodegenTestDirectives import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_KT_IR import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.EXTERNAL_FILE import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.SKIP_KT_DUMP +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives +import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.moduleStructure @@ -21,8 +24,15 @@ import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumperImpl import org.jetbrains.kotlin.test.utils.withExtension class IrPrettyKotlinDumpHandler(testServices: TestServices) : AbstractIrHandler(testServices) { + companion object { + const val DUMP_EXTENSION = "kt.txt" + } + private val dumper = MultiModuleInfoDumperImpl("// MODULE: %s") + override val directivesContainers: List + get() = listOf(CodegenTestDirectives, FirDiagnosticsDirectives) + override fun processModule(module: TestModule, info: IrBackendInput) { if (DUMP_KT_IR !in module.directives || SKIP_KT_DUMP in module.directives) return @@ -47,7 +57,7 @@ class IrPrettyKotlinDumpHandler(testServices: TestServices) : AbstractIrHandler( override fun processAfterAllModules(someAssertionWasFailed: Boolean) { if (dumper.isEmpty()) return val moduleStructure = testServices.moduleStructure - val extension = computeDumpExtension(moduleStructure.modules.first(), "kt.txt") + val extension = computeDumpExtension(moduleStructure.modules.first(), DUMP_EXTENSION) val expectedFile = moduleStructure.originalTestDataFiles.first().withExtension(extension) assertions.assertEqualsToFile(expectedFile, dumper.generateResultingDump()) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt index 964cd62f34e..205c682b4d8 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/IrTextDumpHandler.kt @@ -36,6 +36,8 @@ import java.io.File class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServices) { companion object { + const val DUMP_EXTENSION = "txt" + fun computeDumpExtension(module: TestModule, defaultExtension: String): String { return if (module.frontendKind == FrontendKinds.ClassicFrontend || FIR_IDENTICAL in module.directives) defaultExtension else "fir.$defaultExtension" @@ -74,6 +76,9 @@ class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServ } private fun compareDumpsOfExternalClasses(module: TestModule, info: IrBackendInput) { + // FIR doesn't support searching descriptors + if (module.frontendKind == FrontendKinds.FIR) return + val externalClassFqns = module.directives[DUMP_EXTERNAL_CLASS] if (externalClassFqns.isEmpty()) return @@ -121,5 +126,5 @@ class IrTextDumpHandler(testServices: TestServices) : AbstractIrHandler(testServ } private val TestModule.dumpExtension: String - get() = computeDumpExtension(this, "txt") + get() = computeDumpExtension(this, DUMP_EXTENSION) } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirIdenticalChecker.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirIdenticalChecker.kt index 1416eaedd9f..d080ddbef6f 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirIdenticalChecker.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirIdenticalChecker.kt @@ -5,49 +5,43 @@ package org.jetbrains.kotlin.test.frontend.fir.handlers -import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives import org.jetbrains.kotlin.test.model.AfterAnalysisChecker import org.jetbrains.kotlin.test.services.TestServices -import org.jetbrains.kotlin.test.services.assertions import org.jetbrains.kotlin.test.services.moduleStructure +import org.jetbrains.kotlin.test.utils.FirIdenticalCheckerHelper import org.jetbrains.kotlin.test.utils.firTestDataFile import org.jetbrains.kotlin.test.utils.isFirTestData import org.jetbrains.kotlin.test.utils.originalTestDataFile import java.io.File class FirIdenticalChecker(testServices: TestServices) : AfterAnalysisChecker(testServices) { + private val helper = object : FirIdenticalCheckerHelper(testServices) { + override fun getClassicFileToCompare(testDataFile: File): File { + return if (testDataFile.isFirTestData) testDataFile.originalTestDataFile else testDataFile + } + + override fun getFirFileToCompare(testDataFile: File): File { + return if (testDataFile.isFirTestData) testDataFile else testDataFile.firTestDataFile + } + } + override fun check(failedAssertions: List) { if (failedAssertions.isNotEmpty()) return - val file = testServices.moduleStructure.originalTestDataFiles.first() - if (file.isFirTestData) { - addDirectiveToClassicFile(file) + val testDataFile = testServices.moduleStructure.originalTestDataFiles.first() + if (testDataFile.isFirTestData) { + val firFile = helper.getFirFileToCompare(testDataFile) + val classicFile = helper.getClassicFileToCompare(testDataFile) + if (helper.contentsAreEquals(classicFile, firFile)) { + helper.deleteFirFile(testDataFile) + helper.addDirectiveToClassicFileAndAssert(testDataFile) + } } else { - removeFirFileIfExist(file) + removeFirFileIfExist(testDataFile) } } - private fun addDirectiveToClassicFile(firFile: File) { - val classicFile = firFile.originalTestDataFile - val classicFileContent = classicFile.readText() - val firFileContent = firFile.readText() - if (classicFileContent == firFileContent) { - classicFile.writer().use { - it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}") - it.append(classicFileContent) - } - firFile.delete() - testServices.assertions.fail { - """ - Dumps via FIR & via old FE are the same. - Deleted .fir.txt dump, added // FIR_IDENTICAL to test source - Please re-run the test now - """.trimIndent() - } - } - } - - private fun removeFirFileIfExist(classicFile: File) { - val firFile = classicFile.firTestDataFile + private fun removeFirFileIfExist(testDataFile: File) { + val firFile = helper.getFirFileToCompare(testDataFile) firFile.delete() } } diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt index ffdd84a09d2..410ff9b9c40 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt @@ -7,9 +7,9 @@ package org.jetbrains.kotlin.test.runners.ir import org.jetbrains.kotlin.platform.jvm.JvmPlatforms import org.jetbrains.kotlin.test.TargetBackend -import org.jetbrains.kotlin.test.backend.handlers.IrPrettyKotlinDumpHandler import org.jetbrains.kotlin.test.backend.BlackBoxCodegenSuppressor import org.jetbrains.kotlin.test.backend.handlers.* +import org.jetbrains.kotlin.test.backend.ir.JvmIrBackendFacade import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_IR import org.jetbrains.kotlin.test.directives.CodegenTestDirectives.DUMP_KT_IR @@ -70,3 +70,12 @@ abstract class AbstractIrTextTestBase( } open class AbstractIrTextTest : AbstractIrTextTestBase(FrontendKinds.ClassicFrontend) + +open class AbstractFir2IrTextTest : AbstractIrTextTestBase(FrontendKinds.FIR) { + override fun configure(builder: TestConfigurationBuilder) { + super.configure(builder) + with(builder) { + useAfterAnalysisCheckers(::FirIrDumpIdenticalChecker) + } + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt new file mode 100644 index 00000000000..6f5e5cb8a5d --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/utils/FirIdenticalCheckerHelper.kt @@ -0,0 +1,55 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test.utils + +import org.jetbrains.kotlin.test.directives.FirDiagnosticsDirectives +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.assertions +import java.io.File + +abstract class FirIdenticalCheckerHelper(private val testServices: TestServices) { + abstract fun getClassicFileToCompare(testDataFile: File): File? + abstract fun getFirFileToCompare(testDataFile: File): File? + + fun firAndClassicContentsAreEquals(testDataFile: File, trimLines: Boolean = false): Boolean { + val classicFile = getClassicFileToCompare(testDataFile) ?: return true + val firFile = getFirFileToCompare(testDataFile) ?: return true + return contentsAreEquals(classicFile, firFile, trimLines) + } + + fun contentsAreEquals(classicFile: File, firFile: File, trimLines: Boolean = false): Boolean { + val classicFileContent = classicFile.readContent(trimLines) + val firFileContent = firFile.readContent(trimLines) + return classicFileContent == firFileContent + } + + private fun File.readContent(trimLines: Boolean): String { + return if (trimLines) { + this.readLines().map { it.trimEnd() }.joinToString("\n").trimEnd() + } else { + this.readText() + } + } + + fun addDirectiveToClassicFileAndAssert(testDataFile: File) { + val classicFileContent = testDataFile.readText() + testDataFile.writer().use { + it.appendLine("// ${FirDiagnosticsDirectives.FIR_IDENTICAL.name}") + it.append(classicFileContent) + } + testServices.assertions.fail { + """ + Dumps via FIR & via old FE are the same. + Deleted .fir.txt dump, added // FIR_IDENTICAL to test source + Please re-run the test now + """.trimIndent() + } + } + + fun deleteFirFile(testDataFile: File) { + getFirFileToCompare(testDataFile)?.takeIf { it.exists() }?.delete() + } +} diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt index 16d624c8299..762bc10c62f 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt @@ -597,16 +597,6 @@ fun generateJUnit3CompilerTests(args: Array) { } } - testGroup( - "compiler/fir/fir2ir/tests-gen", "compiler/testData", - testRunnerMethodName = "runTestWithCustomIgnoreDirective", - additionalRunnerArguments = listOf("\"// IGNORE_BACKEND_FIR: \"") - ) { - testClass { - model("ir/irText") - } - } - testGroup("compiler/visualizer/tests-gen", "compiler/fir/raw-fir/psi2fir/testData") { testClass("PsiVisualizerForRawFirDataGenerated") { model("rawBuilder", testMethod = "doFirBuilderDataTest") diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt index 26f4475dbf3..41409bd3563 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.test.runners.* import org.jetbrains.kotlin.test.runners.codegen.AbstractBlackBoxCodegenTest import org.jetbrains.kotlin.test.runners.codegen.AbstractFirBlackBoxCodegenTest import org.jetbrains.kotlin.test.runners.codegen.AbstractIrBlackBoxCodegenTest +import org.jetbrains.kotlin.test.runners.ir.AbstractFir2IrTextTest import org.jetbrains.kotlin.test.runners.ir.AbstractIrTextTest import org.junit.jupiter.api.parallel.Execution import org.junit.jupiter.api.parallel.ExecutionMode @@ -99,6 +100,11 @@ fun generateJUnit5CompilerTests(args: Array) { model("resolve", pattern = TestGeneratorUtil.KT_WITHOUT_DOTS_IN_NAME) } } - } + testGroup(testsRoot = "compiler/fir/analysis-tests/tests-gen", testDataRoot = "compiler/testData") { + testClass { + model("ir/irText") + } + } + } } From 8286a160bdb22e6d82ae5aa56cc3b83ad490e1da Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 16:47:38 +0300 Subject: [PATCH 086/122] [TD] Update order of directives --- .../ir/irText/declarations/annotations/javaAnnotation.kt | 3 +-- compiler/testData/ir/irText/firProblems/AllCandidates.kt | 4 ++-- .../ir/irText/firProblems/typeParameterFromJavaClass.kt | 3 +-- compiler/testData/ir/irText/stubs/javaMethod.kt | 4 ++-- compiler/testData/ir/irText/stubs/javaNestedClass.kt | 4 ++-- compiler/testData/ir/irText/stubs/javaStaticMethod.kt | 4 ++-- compiler/testData/ir/irText/stubs/kotlinInnerClass.kt | 4 ++-- .../enhancedNullabilityInDestructuringAssignment.kt | 4 ++-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt b/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt index 984f836d08a..0a237e5613a 100644 --- a/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt +++ b/compiler/testData/ir/irText/declarations/annotations/javaAnnotation.kt @@ -1,5 +1,5 @@ -// FILE: JavaAnn.java // FIR_IDENTICAL +// FILE: JavaAnn.java import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -10,7 +10,6 @@ import java.lang.annotation.RetentionPolicy; } // FILE: javaAnnotation.kt -// FIR_IDENTICAL @JavaAnn fun test1() {} @JavaAnn(value="abc", i=123) fun test2() {} diff --git a/compiler/testData/ir/irText/firProblems/AllCandidates.kt b/compiler/testData/ir/irText/firProblems/AllCandidates.kt index 2be5a3b8e18..16e6942a26e 100644 --- a/compiler/testData/ir/irText/firProblems/AllCandidates.kt +++ b/compiler/testData/ir/irText/firProblems/AllCandidates.kt @@ -1,3 +1,5 @@ +// WITH_RUNTIME +// FULL_JDK // FILE: OverloadResolutionResultsImpl.java import java.util.*; @@ -18,8 +20,6 @@ public class OverloadResolutionResultsImpl { } // FILE: AllCandidates.kt -// WITH_RUNTIME -// FULL_JDK class ResolvedCall diff --git a/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt b/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt index 30faaaed089..5b16cd7ed69 100644 --- a/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt +++ b/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.kt @@ -1,3 +1,4 @@ +// WITH_RUNTIME // FILE: Pair.java public class Pair { @@ -26,8 +27,6 @@ public interface FilePath { // FILE: typeParameterFromJavaClass.kt -// WITH_RUNTIME - fun foo(movedPaths: MutableList>) { movedPaths.forEach { it.second.name } } diff --git a/compiler/testData/ir/irText/stubs/javaMethod.kt b/compiler/testData/ir/irText/stubs/javaMethod.kt index 647d84862f7..96a7df4b172 100644 --- a/compiler/testData/ir/irText/stubs/javaMethod.kt +++ b/compiler/testData/ir/irText/stubs/javaMethod.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DUMP_DEPENDENCIES // FILE: J.java @@ -6,6 +7,5 @@ public class J { } // FILE: javaMethod.kt -// FIR_IDENTICAL -fun test(j: J) = j.bar() \ No newline at end of file +fun test(j: J) = j.bar() diff --git a/compiler/testData/ir/irText/stubs/javaNestedClass.kt b/compiler/testData/ir/irText/stubs/javaNestedClass.kt index 69fc05a853f..faf0cc40427 100644 --- a/compiler/testData/ir/irText/stubs/javaNestedClass.kt +++ b/compiler/testData/ir/irText/stubs/javaNestedClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DUMP_DEPENDENCIES // FILE: J.java @@ -10,5 +11,4 @@ public class J { // FILE: javaNestedClass.kt -// FIR_IDENTICAL -fun test(jj: J.JJ) = jj.foo() \ No newline at end of file +fun test(jj: J.JJ) = jj.foo() diff --git a/compiler/testData/ir/irText/stubs/javaStaticMethod.kt b/compiler/testData/ir/irText/stubs/javaStaticMethod.kt index 72f4af43050..f69562021c6 100644 --- a/compiler/testData/ir/irText/stubs/javaStaticMethod.kt +++ b/compiler/testData/ir/irText/stubs/javaStaticMethod.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DUMP_DEPENDENCIES // FILE: J.java @@ -6,6 +7,5 @@ public class J { } // FILE: javaStaticMethod.kt -// FIR_IDENTICAL -fun test() = J.bar() \ No newline at end of file +fun test() = J.bar() diff --git a/compiler/testData/ir/irText/stubs/kotlinInnerClass.kt b/compiler/testData/ir/irText/stubs/kotlinInnerClass.kt index eb4db4b5d1d..f63f02bef84 100644 --- a/compiler/testData/ir/irText/stubs/kotlinInnerClass.kt +++ b/compiler/testData/ir/irText/stubs/kotlinInnerClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DUMP_DEPENDENCIES // FILE: external.kt @@ -10,5 +11,4 @@ class Outer { } // FILE: kotlinInnerClass.kt -// FIR_IDENTICAL -fun test(inner: Outer.Inner) = inner.foo() \ No newline at end of file +fun test(inner: Outer.Inner) = inner.foo() diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.kt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.kt index 854ac712de1..da44261caa0 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.kt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.kt @@ -1,5 +1,5 @@ -// FILE: enhancedNullabilityInDestructuringAssignment.kt // WITH_RUNTIME +// FILE: enhancedNullabilityInDestructuringAssignment.kt fun use(x: Any, y: Any) {} @@ -56,4 +56,4 @@ public static class J { public static @NotNull Q<@NotNull String, @NotNull String> notNullQAndComponents() { return null; } public static List<@NotNull P> listOfNotNull() { return null; } -} \ No newline at end of file +} From 4752924b1316e65552d42b4ac6af0431cc159085 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 17:27:09 +0300 Subject: [PATCH 087/122] [TD] Update FQN's in testdata of IR text tests --- .../ir/irText/classes/classMembers.txt | 8 +++---- .../testData/ir/irText/classes/enum.fir.txt | 6 ++--- compiler/testData/ir/irText/classes/enum.txt | 6 ++--- .../classes/enumWithSecondaryCtor.fir.txt | 4 ++-- .../irText/classes/enumWithSecondaryCtor.txt | 4 ++-- .../testData/ir/irText/classes/initBlock.txt | 14 +++++------ .../ir/irText/classes/initValInLambda.fir.txt | 2 +- .../ir/irText/classes/initValInLambda.txt | 2 +- .../classes/objectLiteralExpressions.fir.txt | 6 ++--- .../classes/objectLiteralExpressions.txt | 6 ++--- .../delegateFieldWithAnnotations.fir.txt | 4 ++-- .../delegateFieldWithAnnotations.txt | 4 ++-- ...DelegatedPropertiesWithAnnotations.fir.txt | 4 ++-- ...ocalDelegatedPropertiesWithAnnotations.txt | 4 ++-- .../declarations/classLevelProperties.fir.txt | 10 ++++---- .../declarations/classLevelProperties.txt | 16 ++++++------- .../declarations/delegatedProperties.fir.txt | 18 +++++++------- .../declarations/delegatedProperties.txt | 24 +++++++++---------- .../ir/irText/declarations/kt27005.txt | 2 +- .../localDelegatedProperties.fir.txt | 12 +++++----- .../declarations/localDelegatedProperties.txt | 22 ++++++++--------- .../packageLevelProperties.fir.txt | 10 ++++---- .../declarations/packageLevelProperties.txt | 16 ++++++------- .../parameters/useNextParamInLambda.txt | 4 ++-- .../argumentMappedWithError.fir.txt | 2 +- .../expressions/argumentMappedWithError.txt | 2 +- .../expressions/catchParameterAccess.txt | 6 ++--- .../irText/expressions/classReference.fir.txt | 4 ++-- .../ir/irText/expressions/classReference.txt | 4 ++-- .../ir/irText/expressions/for.fir.txt | 6 ++--- .../testData/ir/irText/expressions/for.txt | 6 ++--- .../forWithImplicitReceivers.fir.txt | 2 +- .../expressions/forWithImplicitReceivers.txt | 2 +- .../ir/irText/expressions/kt30020.fir.txt | 18 +++++++------- .../ir/irText/expressions/kt30020.txt | 18 +++++++------- .../ir/irText/expressions/kt37570.fir.txt | 2 +- .../ir/irText/expressions/kt37570.txt | 2 +- .../expressions/objectClassReference.txt | 2 +- .../ir/irText/expressions/smartCasts.txt | 2 +- .../ir/irText/expressions/tryCatch.fir.txt | 12 +++++----- .../ir/irText/expressions/tryCatch.txt | 12 +++++----- .../ir/irText/expressions/typeArguments.txt | 2 +- .../expressions/unsignedIntegerLiterals.txt | 8 +++---- .../ir/irText/expressions/when.fir.txt | 8 +++---- .../testData/ir/irText/expressions/when.txt | 8 +++---- .../ir/irText/expressions/whenReturnUnit.txt | 4 ++-- .../firProblems/AbstractMutableMap.fir.txt | 2 +- .../irText/firProblems/AbstractMutableMap.txt | 2 +- .../irText/firProblems/AllCandidates.fir.txt | 4 ++-- .../ir/irText/firProblems/AllCandidates.txt | 4 ++-- .../ClashResolutionDescriptor.fir.txt | 4 ++-- .../firProblems/ClashResolutionDescriptor.txt | 14 +++++------ .../irText/firProblems/DeepCopyIrTree.fir.txt | 6 ++--- .../ir/irText/firProblems/DeepCopyIrTree.txt | 6 ++--- .../firProblems/ImplicitReceiverStack.fir.txt | 8 +++---- .../firProblems/ImplicitReceiverStack.txt | 8 +++---- .../firProblems/SyntheticSetterType.fir.txt | 2 +- .../firProblems/SyntheticSetterType.txt | 2 +- .../coercionToUnitForNestedWhen.fir.txt | 4 ++-- .../coercionToUnitForNestedWhen.txt | 12 +++++----- .../inapplicableCollectionSet.fir.txt | 4 ++-- .../firProblems/inapplicableCollectionSet.txt | 4 ++-- .../ir/irText/firProblems/putIfAbsent.fir.txt | 2 +- .../ir/irText/firProblems/putIfAbsent.txt | 2 +- ...iveCapturedTypeInPropertyReference.fir.txt | 4 ++-- ...cursiveCapturedTypeInPropertyReference.txt | 4 ++-- .../typeParameterFromJavaClass.fir.txt | 2 +- .../typeParameterFromJavaClass.txt | 2 +- .../typeVariableAfterBuildMap.fir.txt | 2 +- .../firProblems/typeVariableAfterBuildMap.txt | 2 +- .../irText/lambdas/anonymousFunction.fir.txt | 2 +- .../ir/irText/lambdas/anonymousFunction.txt | 2 +- .../irText/lambdas/destructuringInLambda.txt | 8 +++---- .../ir/irText/lambdas/extensionLambda.fir.txt | 2 +- .../ir/irText/lambdas/extensionLambda.txt | 2 +- .../lambdas/multipleImplicitReceivers.fir.txt | 6 ++--- .../lambdas/multipleImplicitReceivers.txt | 6 ++--- .../ir/irText/lambdas/nonLocalReturn.fir.txt | 18 +++++++------- .../ir/irText/lambdas/nonLocalReturn.txt | 18 +++++++------- .../testData/ir/irText/lambdas/samAdapter.txt | 2 +- .../regressions/integerCoercionToT.fir.txt | 4 ++-- .../irText/regressions/integerCoercionToT.txt | 4 ++-- .../newInference/fixationOrder1.fir.txt | 4 ++-- .../newInference/fixationOrder1.txt | 4 ++-- .../typeParametersInImplicitCast.fir.txt | 2 +- .../typeParametersInImplicitCast.txt | 2 +- .../ir/irText/stubs/builtinMap.fir.txt | 4 ++-- .../testData/ir/irText/stubs/builtinMap.txt | 14 +++++------ .../castsInsideCoroutineInference.fir.txt | 8 +++---- .../types/castsInsideCoroutineInference.txt | 8 +++---- ...llabilityInDestructuringAssignment.fir.txt | 4 ++-- ...edNullabilityInDestructuringAssignment.txt | 4 ++-- .../implicitNotNullOnPlatformType.fir.txt | 10 ++++---- .../implicitNotNullOnPlatformType.txt | 10 ++++---- 94 files changed, 297 insertions(+), 297 deletions(-) diff --git a/compiler/testData/ir/irText/classes/classMembers.txt b/compiler/testData/ir/irText/classes/classMembers.txt index 9c1475e77d9..3a6d20f04be 100644 --- a/compiler/testData/ir/irText/classes/classMembers.txt +++ b/compiler/testData/ir/irText/classes/classMembers.txt @@ -83,13 +83,13 @@ FILE fqName: fileName:/classMembers.kt FUN name:function visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.C BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="1" FUN name:memberExtensionFunction visibility:public modality:FINAL <> ($this:.C, $receiver:kotlin.Int) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.C $receiver: VALUE_PARAMETER name: type:kotlin.Int BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="2" CLASS CLASS name:NestedClass modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C.NestedClass @@ -100,13 +100,13 @@ FILE fqName: fileName:/classMembers.kt FUN name:function visibility:public modality:FINAL <> ($this:.C.NestedClass) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.C.NestedClass BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="3" FUN name:memberExtensionFunction visibility:public modality:FINAL <> ($this:.C.NestedClass, $receiver:kotlin.Int) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.C.NestedClass $receiver: VALUE_PARAMETER name: type:kotlin.Int BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="4" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/classes/enum.fir.txt b/compiler/testData/ir/irText/classes/enum.fir.txt index 129b2d237b9..b6d1571880c 100644 --- a/compiler/testData/ir/irText/classes/enum.fir.txt +++ b/compiler/testData/ir/irText/classes/enum.fir.txt @@ -142,7 +142,7 @@ FILE fqName: fileName:/enum.kt public abstract fun foo (): kotlin.Unit declared in .TestEnum3 $this: VALUE_PARAMETER name: type:.TestEnum3.TEST BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="Hello, world!" FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] overridden: @@ -253,7 +253,7 @@ FILE fqName: fileName:/enum.kt public abstract fun foo (): kotlin.Unit declared in .TestEnum4 $this: VALUE_PARAMETER name: type:.TestEnum4.TEST1 BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_ENUM 'ENUM_ENTRY name:TEST1' type=.TestEnum4 PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.TestEnum4) returnType:kotlin.Int [fake_override] @@ -325,7 +325,7 @@ FILE fqName: fileName:/enum.kt public abstract fun foo (): kotlin.Unit declared in .TestEnum4 $this: VALUE_PARAMETER name: type:.TestEnum4.TEST2 BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_ENUM 'ENUM_ENTRY name:TEST2' type=.TestEnum4 PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.TestEnum4) returnType:kotlin.Int [fake_override] diff --git a/compiler/testData/ir/irText/classes/enum.txt b/compiler/testData/ir/irText/classes/enum.txt index 5aef9201e41..a4f022d978e 100644 --- a/compiler/testData/ir/irText/classes/enum.txt +++ b/compiler/testData/ir/irText/classes/enum.txt @@ -159,7 +159,7 @@ FILE fqName: fileName:/enum.kt public abstract fun foo (): kotlin.Unit declared in .TestEnum3 $this: VALUE_PARAMETER name: type:.TestEnum3.TEST BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="Hello, world!" FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.TestEnum3>) returnType:kotlin.Any [fake_override] overridden: @@ -287,7 +287,7 @@ FILE fqName: fileName:/enum.kt public abstract fun foo (): kotlin.Unit declared in .TestEnum4 $this: VALUE_PARAMETER name: type:.TestEnum4.TEST1 BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_ENUM 'ENUM_ENTRY name:TEST1' type=.TestEnum4 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.TestEnum4>) returnType:kotlin.Any [fake_override] overridden: @@ -368,7 +368,7 @@ FILE fqName: fileName:/enum.kt public abstract fun foo (): kotlin.Unit declared in .TestEnum4 $this: VALUE_PARAMETER name: type:.TestEnum4.TEST2 BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_ENUM 'ENUM_ENTRY name:TEST2' type=.TestEnum4 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.TestEnum4>) returnType:kotlin.Any [fake_override] overridden: diff --git a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt index 0f4d83ac40e..62e56bc6984 100644 --- a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt +++ b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt @@ -166,7 +166,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt public abstract fun foo (): kotlin.Unit declared in .Test2 $this: VALUE_PARAMETER name: type:.Test2.ZERO BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="ZERO" PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Test2) returnType:kotlin.Int [fake_override] @@ -223,7 +223,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt public abstract fun foo (): kotlin.Unit declared in .Test2 $this: VALUE_PARAMETER name: type:.Test2.ONE BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="ONE" PROPERTY FAKE_OVERRIDE name:x visibility:public modality:FINAL [fake_override,val] FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.Test2) returnType:kotlin.Int [fake_override] diff --git a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt index a2efb51a53a..92ac2b78dd6 100644 --- a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt +++ b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt @@ -183,7 +183,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt public abstract fun foo (): kotlin.Unit declared in .Test2 $this: VALUE_PARAMETER name: type:.Test2.ZERO BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="ZERO" FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.Test2>) returnType:kotlin.Any [fake_override] overridden: @@ -249,7 +249,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt public abstract fun foo (): kotlin.Unit declared in .Test2 $this: VALUE_PARAMETER name: type:.Test2.ONE BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="ONE" FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.Test2>) returnType:kotlin.Any [fake_override] overridden: diff --git a/compiler/testData/ir/irText/classes/initBlock.txt b/compiler/testData/ir/irText/classes/initBlock.txt index c54d2f1efe6..de0415d59e1 100644 --- a/compiler/testData/ir/irText/classes/initBlock.txt +++ b/compiler/testData/ir/irText/classes/initBlock.txt @@ -7,7 +7,7 @@ FILE fqName: fileName:/initBlock.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[kotlin.Any]' ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -41,7 +41,7 @@ FILE fqName: fileName:/initBlock.kt receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -59,7 +59,7 @@ FILE fqName: fileName:/initBlock.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test3 ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CONSTRUCTOR visibility:public <> () returnType:.Test3 BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' @@ -81,7 +81,7 @@ FILE fqName: fileName:/initBlock.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test4 ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="1" CONSTRUCTOR visibility:public <> () returnType:.Test4 BLOCK_BODY @@ -89,7 +89,7 @@ FILE fqName: fileName:/initBlock.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test4 modality:FINAL visibility:public superTypes:[kotlin.Any]' ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="2" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -112,7 +112,7 @@ FILE fqName: fileName:/initBlock.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test5 modality:FINAL visibility:public superTypes:[kotlin.Any]' ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="1" CLASS CLASS name:TestInner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test5.TestInner @@ -123,7 +123,7 @@ FILE fqName: fileName:/initBlock.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestInner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]' ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="2" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/classes/initValInLambda.fir.txt b/compiler/testData/ir/irText/classes/initValInLambda.fir.txt index c6efa0dc7d8..95468c94428 100644 --- a/compiler/testData/ir/irText/classes/initValInLambda.fir.txt +++ b/compiler/testData/ir/irText/classes/initValInLambda.fir.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/initValInLambda.kt receiver: GET_VAR ': .TestInitValInLambdaCalledOnce declared in .TestInitValInLambdaCalledOnce.' type=.TestInitValInLambdaCalledOnce origin=null ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Int : kotlin.Unit $receiver: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/classes/initValInLambda.txt b/compiler/testData/ir/irText/classes/initValInLambda.txt index 2cc06d155bd..90b288138ab 100644 --- a/compiler/testData/ir/irText/classes/initValInLambda.txt +++ b/compiler/testData/ir/irText/classes/initValInLambda.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/initValInLambda.kt receiver: GET_VAR ': .TestInitValInLambdaCalledOnce declared in .TestInitValInLambdaCalledOnce.' type=.TestInitValInLambdaCalledOnce origin=null ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Int : kotlin.Unit $receiver: CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt index 1344fe63c00..efbf62e8ce8 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.fir.txt @@ -60,7 +60,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public abstract fun foo (): kotlin.Unit declared in .IFoo $this: VALUE_PARAMETER name: type:.test2. BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -128,7 +128,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public abstract fun foo (): kotlin.Unit declared in .IFoo $this: VALUE_PARAMETER name: type:.Outer.test3. BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -174,7 +174,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public abstract fun foo (): kotlin.Unit declared in .IFoo $this: VALUE_PARAMETER name: type:.test4. BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt index f698ab93bb8..a5a5f30de8b 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt @@ -60,7 +60,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public abstract fun foo (): kotlin.Unit declared in .IFoo $this: VALUE_PARAMETER name: type:.test2. BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -128,7 +128,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public abstract fun foo (): kotlin.Unit [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:.Outer.test3. BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -174,7 +174,7 @@ FILE fqName: fileName:/objectLiteralExpressions.kt public abstract fun foo (): kotlin.Unit [fake_override] declared in .Outer.Inner $this: VALUE_PARAMETER name: type:.test4. BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="foo" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt index 129499afe41..2ec48ff8f2d 100644 --- a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.fir.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/delegateFieldWithAnnotations.kt annotations: Ann EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -31,7 +31,7 @@ FILE fqName: fileName:/delegateFieldWithAnnotations.kt correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt index 81a7539b596..f89150df626 100644 --- a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt +++ b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/delegateFieldWithAnnotations.kt annotations: Ann EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -31,7 +31,7 @@ FILE fqName: fileName:/delegateFieldWithAnnotations.kt correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt index ef62f77ab83..93831b6e718 100644 --- a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.fir.txt @@ -32,7 +32,7 @@ FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt BLOCK_BODY LOCAL_DELEGATED_PROPERTY name:test type:kotlin.Int flags:val VAR PROPERTY_DELEGATE name:test$delegate type:kotlin.Lazy [val] - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -42,7 +42,7 @@ FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .foo' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_VAR 'val test$delegate: kotlin.Lazy [val] declared in .foo' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt index d7e240d2665..bd1fd42e290 100644 --- a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt +++ b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt @@ -34,7 +34,7 @@ FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt annotations: A(x = 'foo/test') VAR PROPERTY_DELEGATE name:test$delegate type:kotlin.Lazy [val] - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -44,7 +44,7 @@ FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .foo' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_VAR 'val test$delegate: kotlin.Lazy [val] declared in .foo' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt b/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt index 5b84f0f2dd5..0937a01c2fd 100644 --- a/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/classLevelProperties.fir.txt @@ -94,7 +94,7 @@ FILE fqName: fileName:/classLevelProperties.kt PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -106,7 +106,7 @@ FILE fqName: fileName:/classLevelProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final]' type=kotlin.Lazy origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null @@ -115,7 +115,7 @@ FILE fqName: fileName:/classLevelProperties.kt PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap origin=null : kotlin.String : kotlin.Int FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int? @@ -123,7 +123,7 @@ FILE fqName: fileName:/classLevelProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int? declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int? origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Int? origin=null : kotlin.Int? : kotlin.Int? $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final]' type=java.util.HashMap origin=null @@ -135,7 +135,7 @@ FILE fqName: fileName:/classLevelProperties.kt $this: VALUE_PARAMETER name: type:.C VALUE_PARAMETER name: index:0 type:kotlin.Int? BLOCK_BODY - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Int? $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final]' type=java.util.HashMap origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/classLevelProperties.txt b/compiler/testData/ir/irText/declarations/classLevelProperties.txt index 6f033f9a951..298c94c5e41 100644 --- a/compiler/testData/ir/irText/declarations/classLevelProperties.txt +++ b/compiler/testData/ir/irText/declarations/classLevelProperties.txt @@ -94,7 +94,7 @@ FILE fqName: fileName:/classLevelProperties.kt PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -106,16 +106,16 @@ FILE fqName: fileName:/classLevelProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final]' type=kotlin.Lazy origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null thisRef: GET_VAR ': .C declared in .C.' type=.C origin=null property: PROPERTY_REFERENCE 'public final test7: kotlin.Int [delegated,val]' field=null getter='public final fun (): kotlin.Int declared in .C' setter=null type=kotlin.reflect.KProperty1<.C, kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final] + FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.HashMap } [inline] declared in kotlin.collections' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null : kotlin.String : kotlin.Int FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int @@ -123,10 +123,10 @@ FILE fqName: fileName:/classLevelProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Int origin=null : kotlin.Int : kotlin.Int - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null thisRef: GET_VAR ': .C declared in .C.' type=.C origin=null property: PROPERTY_REFERENCE 'public final test8: kotlin.Int [delegated,var]' field=null getter='public final fun (): kotlin.Int declared in .C' setter='public final fun (: kotlin.Int): kotlin.Unit declared in .C' type=kotlin.reflect.KMutableProperty1<.C, kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE @@ -136,9 +136,9 @@ FILE fqName: fileName:/classLevelProperties.kt VALUE_PARAMETER name: index:0 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (: kotlin.Int): kotlin.Unit declared in .C' - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Int - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null thisRef: GET_VAR ': .C declared in .C.' type=.C origin=null property: PROPERTY_REFERENCE 'public final test8: kotlin.Int [delegated,var]' field=null getter='public final fun (): kotlin.Int declared in .C' setter='public final fun (: kotlin.Int): kotlin.Unit declared in .C' type=kotlin.reflect.KMutableProperty1<.C, kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE diff --git a/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt index 47dad12b6e2..d4685811971 100644 --- a/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/delegatedProperties.fir.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/delegatedProperties.kt PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -13,7 +13,7 @@ FILE fqName: fileName:/delegatedProperties.kt correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null @@ -39,7 +39,7 @@ FILE fqName: fileName:/delegatedProperties.kt PROPERTY name:test2 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -51,7 +51,7 @@ FILE fqName: fileName:/delegatedProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final]' type=kotlin.Lazy origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null @@ -67,7 +67,7 @@ FILE fqName: fileName:/delegatedProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Any origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Any origin=null : kotlin.Any : kotlin.Any $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final]' type=kotlin.collections.MutableMap origin=null @@ -79,7 +79,7 @@ FILE fqName: fileName:/delegatedProperties.kt $this: VALUE_PARAMETER name: type:.C VALUE_PARAMETER name: index:0 type:kotlin.Any BLOCK_BODY - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Any $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final]' type=kotlin.collections.MutableMap origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null @@ -102,14 +102,14 @@ FILE fqName: fileName:/delegatedProperties.kt PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap origin=null : kotlin.String : kotlin.Any FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Any? correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Any? origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Any? origin=null : kotlin.Any? : kotlin.Any? $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap visibility:private [final,static]' type=java.util.HashMap origin=null @@ -119,7 +119,7 @@ FILE fqName: fileName:/delegatedProperties.kt correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] VALUE_PARAMETER name: index:0 type:kotlin.Any? BLOCK_BODY - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Any? $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap visibility:private [final,static]' type=java.util.HashMap origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/delegatedProperties.txt b/compiler/testData/ir/irText/declarations/delegatedProperties.txt index e1ad9d5af12..39b2e1e9244 100644 --- a/compiler/testData/ir/irText/declarations/delegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/delegatedProperties.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/delegatedProperties.kt PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -13,7 +13,7 @@ FILE fqName: fileName:/delegatedProperties.kt correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null @@ -39,7 +39,7 @@ FILE fqName: fileName:/delegatedProperties.kt PROPERTY name:test2 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -51,7 +51,7 @@ FILE fqName: fileName:/delegatedProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test2$delegate type:kotlin.Lazy visibility:private [final]' type=kotlin.Lazy origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null @@ -67,7 +67,7 @@ FILE fqName: fileName:/delegatedProperties.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .C' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Any origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Any origin=null : kotlin.Any : kotlin.Any $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final]' type=kotlin.collections.MutableMap origin=null @@ -80,7 +80,7 @@ FILE fqName: fileName:/delegatedProperties.kt VALUE_PARAMETER name: index:0 type:kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (: kotlin.Any): kotlin.Unit declared in .C' - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Any $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test3$delegate type:kotlin.collections.MutableMap visibility:private [final]' type=kotlin.collections.MutableMap origin=null receiver: GET_VAR ': .C declared in .C.' type=.C origin=null @@ -101,19 +101,19 @@ FILE fqName: fileName:/delegatedProperties.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static] + FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.HashMap } [inline] declared in kotlin.collections' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null : kotlin.String : kotlin.Any FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Any correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [delegated,var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Any origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Any origin=null : kotlin.Any : kotlin.Any - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: PROPERTY_REFERENCE 'public final test4: kotlin.Any [delegated,var]' field=null getter='public final fun (): kotlin.Any declared in ' setter='public final fun (: kotlin.Any): kotlin.Unit declared in ' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Any) returnType:kotlin.Unit @@ -121,9 +121,9 @@ FILE fqName: fileName:/delegatedProperties.kt VALUE_PARAMETER name: index:0 type:kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (: kotlin.Any): kotlin.Unit declared in ' - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Any - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test4$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: PROPERTY_REFERENCE 'public final test4: kotlin.Any [delegated,var]' field=null getter='public final fun (): kotlin.Any declared in ' setter='public final fun (: kotlin.Any): kotlin.Unit declared in ' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR ': kotlin.Any declared in .' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/declarations/kt27005.txt b/compiler/testData/ir/irText/declarations/kt27005.txt index fa7d020de30..aba726605a8 100644 --- a/compiler/testData/ir/irText/declarations/kt27005.txt +++ b/compiler/testData/ir/irText/declarations/kt27005.txt @@ -12,4 +12,4 @@ FILE fqName: fileName:/kt27005.kt FUN name:baz visibility:public modality:FINAL () returnType:T of .baz [suspend] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt index 95adaf325bb..31ba7b5da0f 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.fir.txt @@ -3,7 +3,7 @@ FILE fqName: fileName:/localDelegatedProperties.kt BLOCK_BODY LOCAL_DELEGATED_PROPERTY name:x type:kotlin.Int flags:val VAR PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy [val] - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -13,24 +13,24 @@ FILE fqName: fileName:/localDelegatedProperties.kt FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test1' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_VAR 'val x$delegate: kotlin.Lazy [val] declared in .test1' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'val x: kotlin.Int by (...)' delegate='val x$delegate: kotlin.Lazy [val] declared in .test1' getter='local final fun (): kotlin.Int declared in .test1' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CALL 'local final fun (): kotlin.Int declared in .test1' type=kotlin.Int origin=GET_LOCAL_PROPERTY FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY LOCAL_DELEGATED_PROPERTY name:x type:kotlin.Int? flags:var VAR PROPERTY_DELEGATE name:x$delegate type:java.util.HashMap [val] - CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap origin=null : kotlin.String : kotlin.Int FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:kotlin.Int? BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int? declared in .test2' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int? origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Int? origin=null : kotlin.Int? : kotlin.Int? $receiver: GET_VAR 'val x$delegate: java.util.HashMap [val] declared in .test2' type=java.util.HashMap origin=null @@ -39,7 +39,7 @@ FILE fqName: fileName:/localDelegatedProperties.kt FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> (:kotlin.Int?) returnType:kotlin.Unit VALUE_PARAMETER name: index:0 type:kotlin.Int? BLOCK_BODY - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Int? $receiver: GET_VAR 'val x$delegate: java.util.HashMap [val] declared in .test2' type=java.util.HashMap origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt index 286fb22d417..0697ccc57f5 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt @@ -3,7 +3,7 @@ FILE fqName: fileName:/localDelegatedProperties.kt BLOCK_BODY LOCAL_DELEGATED_PROPERTY name:x type:kotlin.Int flags:val VAR PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy [val] - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -13,38 +13,38 @@ FILE fqName: fileName:/localDelegatedProperties.kt FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test1' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_VAR 'val x$delegate: kotlin.Lazy [val] declared in .test1' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'val x: kotlin.Int by (...)' delegate='val x$delegate: kotlin.Lazy [val] declared in .test1' getter='local final fun (): kotlin.Int declared in .test1' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CALL 'local final fun (): kotlin.Int declared in .test1' type=kotlin.Int origin=GET_LOCAL_PROPERTY FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY LOCAL_DELEGATED_PROPERTY name:x type:kotlin.Int flags:var - VAR PROPERTY_DELEGATE name:x$delegate type:java.util.HashMap{ kotlin.collections.HashMap } [val] - CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.HashMap } [inline] declared in kotlin.collections' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + VAR PROPERTY_DELEGATE name:x$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [val] + CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null : kotlin.String : kotlin.Int FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test2' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Int origin=null : kotlin.Int : kotlin.Int - $receiver: GET_VAR 'val x$delegate: java.util.HashMap{ kotlin.collections.HashMap } [val] declared in .test2' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_VAR 'val x$delegate: java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [val] declared in .test2' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null thisRef: CONST Null type=kotlin.Nothing? value=null - property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'var x: kotlin.Int by (...)' delegate='val x$delegate: java.util.HashMap{ kotlin.collections.HashMap } [val] declared in .test2' getter='local final fun (): kotlin.Int declared in .test2' setter='local final fun (value: kotlin.Int): kotlin.Unit declared in .test2' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'var x: kotlin.Int by (...)' delegate='val x$delegate: java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [val] declared in .test2' getter='local final fun (): kotlin.Int declared in .test2' setter='local final fun (value: kotlin.Int): kotlin.Unit declared in .test2' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> (value:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER name:value index:0 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (value: kotlin.Int): kotlin.Unit declared in .test2' - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Int - $receiver: GET_VAR 'val x$delegate: java.util.HashMap{ kotlin.collections.HashMap } [val] declared in .test2' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_VAR 'val x$delegate: java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [val] declared in .test2' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null thisRef: CONST Null type=kotlin.Nothing? value=null - property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'var x: kotlin.Int by (...)' delegate='val x$delegate: java.util.HashMap{ kotlin.collections.HashMap } [val] declared in .test2' getter='local final fun (): kotlin.Int declared in .test2' setter='local final fun (value: kotlin.Int): kotlin.Unit declared in .test2' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'var x: kotlin.Int by (...)' delegate='val x$delegate: java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [val] declared in .test2' getter='local final fun (): kotlin.Int declared in .test2' setter='local final fun (value: kotlin.Int): kotlin.Unit declared in .test2' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR 'value: kotlin.Int declared in .test2.' type=kotlin.Int origin=null CALL 'local final fun (value: kotlin.Int): kotlin.Unit declared in .test2' type=kotlin.Unit origin=EQ value: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt b/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt index c8579179957..22a1b1d408c 100644 --- a/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt +++ b/compiler/testData/ir/irText/declarations/packageLevelProperties.fir.txt @@ -71,7 +71,7 @@ FILE fqName: fileName:/packageLevelProperties.kt PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -82,7 +82,7 @@ FILE fqName: fileName:/packageLevelProperties.kt correspondingProperty: PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null @@ -90,14 +90,14 @@ FILE fqName: fileName:/packageLevelProperties.kt PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap origin=null : kotlin.String : kotlin.Int FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int? correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int? declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int? origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Int? origin=null : kotlin.Int? : kotlin.Int? $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final,static]' type=java.util.HashMap origin=null @@ -107,7 +107,7 @@ FILE fqName: fileName:/packageLevelProperties.kt correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] VALUE_PARAMETER name: index:0 type:kotlin.Int? BLOCK_BODY - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Int? $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap visibility:private [final,static]' type=java.util.HashMap origin=null thisRef: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/declarations/packageLevelProperties.txt b/compiler/testData/ir/irText/declarations/packageLevelProperties.txt index 5bf68601e77..bb83755b223 100644 --- a/compiler/testData/ir/irText/declarations/packageLevelProperties.txt +++ b/compiler/testData/ir/irText/declarations/packageLevelProperties.txt @@ -71,7 +71,7 @@ FILE fqName: fileName:/packageLevelProperties.kt PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin' type=kotlin.Lazy origin=null + CALL 'public final fun lazy (initializer: kotlin.Function0): kotlin.Lazy declared in kotlin.LazyKt' type=kotlin.Lazy origin=null : kotlin.Int initializer: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Int @@ -82,25 +82,25 @@ FILE fqName: fileName:/packageLevelProperties.kt correspondingProperty: PROPERTY name:test7 visibility:public modality:FINAL [delegated,val] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.LazyKt.getValue [inline,operator] declared in kotlin.LazyKt' type=kotlin.Int origin=null : kotlin.Int $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test7$delegate type:kotlin.Lazy visibility:private [final,static]' type=kotlin.Lazy origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: PROPERTY_REFERENCE 'public final test7: kotlin.Int [delegated,val]' field=null getter='public final fun (): kotlin.Int declared in ' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] - FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static] + FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.HashMap } [inline] declared in kotlin.collections' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null : kotlin.String : kotlin.Int FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int correspondingProperty: PROPERTY name:test8 visibility:public modality:FINAL [delegated,var] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int origin=null + CALL 'public final fun getValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.MapAccessorsKt.getValue [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Int origin=null : kotlin.Int : kotlin.Int - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: PROPERTY_REFERENCE 'public final test8: kotlin.Int [delegated,var]' field=null getter='public final fun (): kotlin.Int declared in ' setter='public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit @@ -108,9 +108,9 @@ FILE fqName: fileName:/packageLevelProperties.kt VALUE_PARAMETER name: index:0 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (: kotlin.Int): kotlin.Unit declared in ' - CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun setValue (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.MapAccessorsKt.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections.MapAccessorsKt' type=kotlin.Unit origin=null : kotlin.Int - $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + $receiver: GET_FIELD 'FIELD PROPERTY_DELEGATE name:test8$delegate type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null thisRef: CONST Null type=kotlin.Nothing? value=null property: PROPERTY_REFERENCE 'public final test8: kotlin.Int [delegated,var]' field=null getter='public final fun (): kotlin.Int declared in ' setter='public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt b/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt index b6b6fa4b19f..d1942b6a6fd 100644 --- a/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt +++ b/compiler/testData/ir/irText/declarations/parameters/useNextParamInLambda.txt @@ -27,8 +27,8 @@ FILE fqName: fileName:/useNextParamInLambda.kt try: BLOCK type=kotlin.Unit origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun f (f1: kotlin.Function0, f2: kotlin.Function0): kotlin.String declared in ' type=kotlin.String origin=null - CATCH parameter=val e: java.lang.Exception{ kotlin.Exception } [val] declared in .box - VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.Exception } [val] + CATCH parameter=val e: java.lang.Exception{ kotlin.TypeAliasesKt.Exception } [val] declared in .box + VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.TypeAliasesKt.Exception } [val] BLOCK type=kotlin.Unit origin=null SET_VAR 'var result: kotlin.String [var] declared in .box' type=kotlin.Unit origin=EQ CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/expressions/argumentMappedWithError.fir.txt b/compiler/testData/ir/irText/expressions/argumentMappedWithError.fir.txt index d2c6c274f9c..2545cc9f75b 100644 --- a/compiler/testData/ir/irText/expressions/argumentMappedWithError.fir.txt +++ b/compiler/testData/ir/irText/expressions/argumentMappedWithError.fir.txt @@ -4,7 +4,7 @@ FILE fqName: fileName:/argumentMappedWithError.kt $receiver: VALUE_PARAMETER name: type:kotlin.Number BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun convert (): R of .convert declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:foo visibility:public modality:FINAL <> (arg:kotlin.Number) returnType:kotlin.Unit VALUE_PARAMETER name:arg index:0 type:kotlin.Number BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/argumentMappedWithError.txt b/compiler/testData/ir/irText/expressions/argumentMappedWithError.txt index ad3315b341a..166106f210b 100644 --- a/compiler/testData/ir/irText/expressions/argumentMappedWithError.txt +++ b/compiler/testData/ir/irText/expressions/argumentMappedWithError.txt @@ -3,7 +3,7 @@ FILE fqName: fileName:/argumentMappedWithError.kt TYPE_PARAMETER name:R index:0 variance: superTypes:[kotlin.Number] $receiver: VALUE_PARAMETER name: type:kotlin.Number BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:foo visibility:public modality:FINAL <> (arg:kotlin.Number) returnType:kotlin.Unit VALUE_PARAMETER name:arg index:0 type:kotlin.Number BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/catchParameterAccess.txt b/compiler/testData/ir/irText/expressions/catchParameterAccess.txt index b5b330a3790..a1690295ade 100644 --- a/compiler/testData/ir/irText/expressions/catchParameterAccess.txt +++ b/compiler/testData/ir/irText/expressions/catchParameterAccess.txt @@ -7,8 +7,8 @@ FILE fqName: fileName:/catchParameterAccess.kt try: BLOCK type=kotlin.Unit origin=null CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Unit origin=INVOKE $this: GET_VAR 'f: kotlin.Function0 declared in .test' type=kotlin.Function0 origin=VARIABLE_AS_FUNCTION - CATCH parameter=val e: java.lang.Exception{ kotlin.Exception } [val] declared in .test - VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.Exception } [val] + CATCH parameter=val e: java.lang.Exception{ kotlin.TypeAliasesKt.Exception } [val] declared in .test + VAR CATCH_PARAMETER name:e type:java.lang.Exception{ kotlin.TypeAliasesKt.Exception } [val] BLOCK type=kotlin.Unit origin=null THROW type=kotlin.Nothing - GET_VAR 'val e: java.lang.Exception{ kotlin.Exception } [val] declared in .test' type=java.lang.Exception{ kotlin.Exception } origin=null + GET_VAR 'val e: java.lang.Exception{ kotlin.TypeAliasesKt.Exception } [val] declared in .test' type=java.lang.Exception{ kotlin.TypeAliasesKt.Exception } origin=null diff --git a/compiler/testData/ir/irText/expressions/classReference.fir.txt b/compiler/testData/ir/irText/expressions/classReference.fir.txt index 247322d87b1..b86c24890c3 100644 --- a/compiler/testData/ir/irText/expressions/classReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/classReference.fir.txt @@ -26,11 +26,11 @@ FILE fqName: fileName:/classReference.kt GET_CLASS type=kotlin.reflect.KClass<.A> CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class<.A> origin=GET_PROPERTY + CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<.A> origin=GET_PROPERTY : .A $receiver: CLASS_REFERENCE 'CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<.A> TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class<.A> origin=GET_PROPERTY + CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<.A> origin=GET_PROPERTY : .A $receiver: GET_CLASS type=kotlin.reflect.KClass<.A> CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null diff --git a/compiler/testData/ir/irText/expressions/classReference.txt b/compiler/testData/ir/irText/expressions/classReference.txt index cadd4a41df2..3c6ec7a025a 100644 --- a/compiler/testData/ir/irText/expressions/classReference.txt +++ b/compiler/testData/ir/irText/expressions/classReference.txt @@ -26,11 +26,11 @@ FILE fqName: fileName:/classReference.kt GET_CLASS type=kotlin.reflect.KClass.A> CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class<.A> origin=GET_PROPERTY + CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<.A> origin=GET_PROPERTY : .A $receiver: CLASS_REFERENCE 'CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<.A> TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class.A> origin=GET_PROPERTY + CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class.A> origin=GET_PROPERTY : .A $receiver: GET_CLASS type=kotlin.reflect.KClass.A> CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null diff --git a/compiler/testData/ir/irText/expressions/for.fir.txt b/compiler/testData/ir/irText/expressions/for.fir.txt index 9807389f31d..e7afe2a82dd 100644 --- a/compiler/testData/ir/irText/expressions/for.fir.txt +++ b/compiler/testData/ir/irText/expressions/for.fir.txt @@ -27,7 +27,7 @@ FILE fqName: fileName:/for.kt VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val] CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator [val] declared in .testIterable' type=kotlin.collections.Iterator origin=null - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val s: kotlin.String [val] declared in .testIterable' type=kotlin.String origin=null FUN name:testDestructuring visibility:public modality:FINAL <> (pp:kotlin.collections.List>) returnType:kotlin.Unit VALUE_PARAMETER name:pp index:0 type:kotlin.collections.List> @@ -49,9 +49,9 @@ FILE fqName: fileName:/for.kt VAR name:s type:kotlin.String [val] CALL 'public final fun component2 (): B of kotlin.Pair [operator] declared in kotlin.Pair' type=kotlin.String origin=null $this: GET_VAR 'val : kotlin.Pair [val] declared in .testDestructuring' type=kotlin.Pair origin=null - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val i: kotlin.Int [val] declared in .testDestructuring' type=kotlin.Int origin=null - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val s: kotlin.String [val] declared in .testDestructuring' type=kotlin.String origin=null FUN name:testRange visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/for.txt b/compiler/testData/ir/irText/expressions/for.txt index 94209d7c2a8..7565f741ad9 100644 --- a/compiler/testData/ir/irText/expressions/for.txt +++ b/compiler/testData/ir/irText/expressions/for.txt @@ -28,7 +28,7 @@ FILE fqName: fileName:/for.kt CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_1: kotlin.collections.Iterator [val] declared in .testIterable' type=kotlin.collections.Iterator origin=null BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val s: kotlin.String [val] declared in .testIterable' type=kotlin.String origin=null FUN name:testDestructuring visibility:public modality:FINAL <> (pp:kotlin.collections.List>) returnType:kotlin.Unit VALUE_PARAMETER name:pp index:0 type:kotlin.collections.List> @@ -51,9 +51,9 @@ FILE fqName: fileName:/for.kt CALL 'public final fun component2 (): B of kotlin.Pair [operator] declared in kotlin.Pair' type=kotlin.String origin=COMPONENT_N(index=2) $this: GET_VAR 'val tmp_3: kotlin.Pair [val] declared in .testDestructuring' type=kotlin.Pair origin=null BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val i: kotlin.Int [val] declared in .testDestructuring' type=kotlin.Int origin=null - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val s: kotlin.String [val] declared in .testDestructuring' type=kotlin.String origin=null FUN name:testRange visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt index bc9283259c8..82669b03cfe 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt @@ -119,5 +119,5 @@ FILE fqName: fileName:/forWithImplicitReceivers.kt CALL 'public open fun next (): kotlin.Int [operator] declared in .IReceiver' type=kotlin.Int origin=null $this: GET_VAR ': .IReceiver declared in .test' type=.IReceiver origin=null $receiver: GET_VAR 'val tmp_1: .IntCell [val] declared in .test' type=.IntCell origin=null - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val i: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt index b1a5be3e576..3e539c09cbf 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt @@ -123,5 +123,5 @@ FILE fqName: fileName:/forWithImplicitReceivers.kt $this: GET_VAR ': .IReceiver declared in .test' type=.IReceiver origin=null $receiver: GET_VAR 'val tmp_2: .IntCell [val] declared in .test' type=.IntCell origin=null BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'val i: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/kt30020.fir.txt b/compiler/testData/ir/irText/expressions/kt30020.fir.txt index badb6bfbd06..1c57f6ea4a7 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.fir.txt @@ -24,29 +24,29 @@ FILE fqName: fileName:/kt30020.kt VALUE_PARAMETER name:x index:0 type:.X VALUE_PARAMETER name:nx index:1 type:.X? BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=GET_PROPERTY $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=1 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=2 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: TYPE_OP type=kotlin.collections.MutableList origin=CAST typeOperand=kotlin.collections.MutableList CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=GET_PROPERTY $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=3 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: TYPE_OP type=kotlin.collections.MutableList origin=CAST typeOperand=kotlin.collections.MutableList CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=4 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList @@ -64,7 +64,7 @@ FILE fqName: fileName:/kt30020.kt then: CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=GET_PROPERTY $this: GET_VAR 'val tmp_0: .X? [val] declared in .test' type=.X? origin=null element: CONST Int type=kotlin.Int value=5 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList @@ -85,7 +85,7 @@ FILE fqName: fileName:/kt30020.kt FUN name:testExtensionReceiver visibility:public modality:FINAL <> ($receiver:kotlin.collections.MutableList) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:kotlin.collections.MutableList BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR ': kotlin.collections.MutableList declared in .testExtensionReceiver' type=kotlin.collections.MutableList origin=null element: CONST Int type=kotlin.Int value=100 @@ -98,7 +98,7 @@ FILE fqName: fileName:/kt30020.kt FUN name:testExplicitThis visibility:public modality:FINAL <> ($this:.AML) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.AML BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR ': .AML declared in .AML.testExplicitThis' type=.AML origin=null element: CONST Int type=kotlin.Int value=200 @@ -112,7 +112,7 @@ FILE fqName: fileName:/kt30020.kt FUN name:testOuterThis visibility:public modality:FINAL <> ($this:.AML.Inner) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.AML.Inner BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR ': .AML declared in .AML' type=.AML origin=null element: CONST Int type=kotlin.Int value=300 diff --git a/compiler/testData/ir/irText/expressions/kt30020.txt b/compiler/testData/ir/irText/expressions/kt30020.txt index 36020834d97..2e50bcd7257 100644 --- a/compiler/testData/ir/irText/expressions/kt30020.txt +++ b/compiler/testData/ir/irText/expressions/kt30020.txt @@ -27,29 +27,29 @@ FILE fqName: fileName:/kt30020.kt BLOCK type=kotlin.Unit origin=PLUSEQ VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.X [val] GET_VAR 'x: .X declared in .test' type=.X origin=null - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=PLUSEQ $this: GET_VAR 'val tmp_0: .X [val] declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=1 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=2 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: TYPE_OP type=kotlin.collections.MutableList origin=CAST typeOperand=kotlin.collections.MutableList CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=GET_PROPERTY $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=3 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: TYPE_OP type=kotlin.collections.MutableList origin=CAST typeOperand=kotlin.collections.MutableList CALL 'public abstract fun f (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=null $this: GET_VAR 'x: .X declared in .test' type=.X origin=null element: CONST Int type=kotlin.Int value=4 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList @@ -67,7 +67,7 @@ FILE fqName: fileName:/kt30020.kt then: CALL 'public abstract fun (): kotlin.collections.MutableList declared in .X' type=kotlin.collections.MutableList origin=GET_PROPERTY $this: GET_VAR 'val tmp_1: .X? [val] declared in .test' type=.X? origin=null element: CONST Int type=kotlin.Int value=5 - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=kotlin.collections.MutableList origin=EXCLEXCL : kotlin.collections.MutableList @@ -88,7 +88,7 @@ FILE fqName: fileName:/kt30020.kt FUN name:testExtensionReceiver visibility:public modality:FINAL <> ($receiver:kotlin.collections.MutableList) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:kotlin.collections.MutableList BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: GET_VAR ': kotlin.collections.MutableList declared in .testExtensionReceiver' type=kotlin.collections.MutableList origin=PLUSEQ element: CONST Int type=kotlin.Int value=100 @@ -101,7 +101,7 @@ FILE fqName: fileName:/kt30020.kt FUN name:testExplicitThis visibility:public modality:FINAL <> ($this:.AML) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.AML BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: GET_VAR ': .AML declared in .AML.testExplicitThis' type=.AML origin=PLUSEQ element: CONST Int type=kotlin.Int value=200 @@ -115,7 +115,7 @@ FILE fqName: fileName:/kt30020.kt FUN name:testOuterThis visibility:public modality:FINAL <> ($this:.AML.Inner) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.AML.Inner BLOCK_BODY - CALL 'public final fun plusAssign (element: T of kotlin.collections.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plusAssign (element: T of kotlin.collections.CollectionsKt.plusAssign): kotlin.Unit [inline,operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=PLUSEQ : kotlin.Int $receiver: GET_VAR ': .AML declared in .AML' type=.AML origin=PLUSEQ element: CONST Int type=kotlin.Int value=300 diff --git a/compiler/testData/ir/irText/expressions/kt37570.fir.txt b/compiler/testData/ir/irText/expressions/kt37570.fir.txt index 16424ad49d3..d7d0151f215 100644 --- a/compiler/testData/ir/irText/expressions/kt37570.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt37570.fir.txt @@ -21,7 +21,7 @@ FILE fqName: fileName:/kt37570.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=kotlin.String origin=null + CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null : kotlin.String $receiver: CALL 'public final fun a (): kotlin.String declared in ' type=kotlin.String origin=null block: FUN_EXPR type=kotlin.Function1 origin=LAMBDA diff --git a/compiler/testData/ir/irText/expressions/kt37570.txt b/compiler/testData/ir/irText/expressions/kt37570.txt index 153663305a6..27725d6b40d 100644 --- a/compiler/testData/ir/irText/expressions/kt37570.txt +++ b/compiler/testData/ir/irText/expressions/kt37570.txt @@ -21,7 +21,7 @@ FILE fqName: fileName:/kt37570.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=kotlin.String origin=null + CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null : kotlin.String $receiver: CALL 'public final fun a (): kotlin.String declared in ' type=kotlin.String origin=null block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA diff --git a/compiler/testData/ir/irText/expressions/objectClassReference.txt b/compiler/testData/ir/irText/expressions/objectClassReference.txt index 82a6c36104c..f8e65241d75 100644 --- a/compiler/testData/ir/irText/expressions/objectClassReference.txt +++ b/compiler/testData/ir/irText/expressions/objectClassReference.txt @@ -23,6 +23,6 @@ FILE fqName: fileName:/objectClassReference.kt TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CLASS_REFERENCE 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<.A> TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class<.A> origin=GET_PROPERTY + CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm.JvmClassMappingKt' type=java.lang.Class<.A> origin=GET_PROPERTY : .A $receiver: CLASS_REFERENCE 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<.A> diff --git a/compiler/testData/ir/irText/expressions/smartCasts.txt b/compiler/testData/ir/irText/expressions/smartCasts.txt index 54a52534b88..65d595a93d7 100644 --- a/compiler/testData/ir/irText/expressions/smartCasts.txt +++ b/compiler/testData/ir/irText/expressions/smartCasts.txt @@ -24,7 +24,7 @@ FILE fqName: fileName:/smartCasts.kt GET_VAR 'x: kotlin.Any declared in .test1' type=kotlin.Any origin=null then: RETURN type=kotlin.Nothing from='public final fun test1 (x: kotlin.Any): kotlin.Unit declared in ' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY $this: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String GET_VAR 'x: kotlin.Any declared in .test1' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/tryCatch.fir.txt b/compiler/testData/ir/irText/expressions/tryCatch.fir.txt index 98bbfd7ef0c..668463370af 100644 --- a/compiler/testData/ir/irText/expressions/tryCatch.fir.txt +++ b/compiler/testData/ir/irText/expressions/tryCatch.fir.txt @@ -2,23 +2,23 @@ FILE fqName: fileName:/tryCatch.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY TRY type=kotlin.Unit - try: CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + try: CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CATCH parameter=val e: kotlin.Throwable [val] declared in .test1 VAR name:e type:kotlin.Throwable [val] - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null - finally: CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null + finally: CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Int declared in ' TRY type=kotlin.Int try: BLOCK type=kotlin.Int origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=42 CATCH parameter=val e: kotlin.Throwable [val] declared in .test2 VAR name:e type:kotlin.Throwable [val] BLOCK type=kotlin.Int origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=24 finally: BLOCK type=kotlin.Int origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=555 diff --git a/compiler/testData/ir/irText/expressions/tryCatch.txt b/compiler/testData/ir/irText/expressions/tryCatch.txt index 241dc83315b..16a3e71769d 100644 --- a/compiler/testData/ir/irText/expressions/tryCatch.txt +++ b/compiler/testData/ir/irText/expressions/tryCatch.txt @@ -3,26 +3,26 @@ FILE fqName: fileName:/tryCatch.kt BLOCK_BODY TRY type=kotlin.Unit try: BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CATCH parameter=val e: kotlin.Throwable [val] declared in .test1 VAR CATCH_PARAMETER name:e type:kotlin.Throwable [val] BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null finally: BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Int declared in ' TRY type=kotlin.Int try: BLOCK type=kotlin.Int origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=42 CATCH parameter=val e: kotlin.Throwable [val] declared in .test2 VAR CATCH_PARAMETER name:e type:kotlin.Throwable [val] BLOCK type=kotlin.Int origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null CONST Int type=kotlin.Int value=24 finally: BLOCK type=kotlin.Unit origin=null - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CONST Int type=kotlin.Int value=555 diff --git a/compiler/testData/ir/irText/expressions/typeArguments.txt b/compiler/testData/ir/irText/expressions/typeArguments.txt index 411e591baff..78ee6827b4b 100644 --- a/compiler/testData/ir/irText/expressions/typeArguments.txt +++ b/compiler/testData/ir/irText/expressions/typeArguments.txt @@ -7,7 +7,7 @@ FILE fqName: fileName:/typeArguments.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Array<*> GET_VAR 'x: kotlin.Any declared in .test1' type=kotlin.Any origin=null - then: CALL 'public final fun isArrayOf (): kotlin.Boolean declared in kotlin.jvm' type=kotlin.Boolean origin=null + then: CALL 'public final fun isArrayOf (): kotlin.Boolean declared in kotlin.jvm.JvmClassMappingKt' type=kotlin.Boolean origin=null : kotlin.String $receiver: TYPE_OP type=kotlin.Array<*> origin=IMPLICIT_CAST typeOperand=kotlin.Array<*> GET_VAR 'x: kotlin.Any declared in .test1' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/unsignedIntegerLiterals.txt b/compiler/testData/ir/irText/expressions/unsignedIntegerLiterals.txt index e9df54cd4c5..f1e428d0095 100644 --- a/compiler/testData/ir/irText/expressions/unsignedIntegerLiterals.txt +++ b/compiler/testData/ir/irText/expressions/unsignedIntegerLiterals.txt @@ -56,7 +56,7 @@ FILE fqName: fileName:/unsignedIntegerLiterals.kt PROPERTY name:testToUByte visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testToUByte type:kotlin.UByte visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin' type=kotlin.UByte origin=null + CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin.UByteKt' type=kotlin.UByte origin=null $receiver: CONST Int type=kotlin.Int value=1 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.UByte correspondingProperty: PROPERTY name:testToUByte visibility:public modality:FINAL [val] @@ -66,7 +66,7 @@ FILE fqName: fileName:/unsignedIntegerLiterals.kt PROPERTY name:testToUShort visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testToUShort type:kotlin.UShort visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun toUShort (): kotlin.UShort [inline] declared in kotlin' type=kotlin.UShort origin=null + CALL 'public final fun toUShort (): kotlin.UShort [inline] declared in kotlin.UShortKt' type=kotlin.UShort origin=null $receiver: CONST Int type=kotlin.Int value=1 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.UShort correspondingProperty: PROPERTY name:testToUShort visibility:public modality:FINAL [val] @@ -76,7 +76,7 @@ FILE fqName: fileName:/unsignedIntegerLiterals.kt PROPERTY name:testToUInt visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testToUInt type:kotlin.UInt visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun toUInt (): kotlin.UInt [inline] declared in kotlin' type=kotlin.UInt origin=null + CALL 'public final fun toUInt (): kotlin.UInt [inline] declared in kotlin.UIntKt' type=kotlin.UInt origin=null $receiver: CONST Int type=kotlin.Int value=1 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.UInt correspondingProperty: PROPERTY name:testToUInt visibility:public modality:FINAL [val] @@ -86,7 +86,7 @@ FILE fqName: fileName:/unsignedIntegerLiterals.kt PROPERTY name:testToULong visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testToULong type:kotlin.ULong visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun toULong (): kotlin.ULong [inline] declared in kotlin' type=kotlin.ULong origin=null + CALL 'public final fun toULong (): kotlin.ULong [inline] declared in kotlin.ULongKt' type=kotlin.ULong origin=null $receiver: CONST Int type=kotlin.Int value=1 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.ULong correspondingProperty: PROPERTY name:testToULong visibility:public modality:FINAL [val] diff --git a/compiler/testData/ir/irText/expressions/when.fir.txt b/compiler/testData/ir/irText/expressions/when.fir.txt index 56b4630684b..f57c1e163b2 100644 --- a/compiler/testData/ir/irText/expressions/when.fir.txt +++ b/compiler/testData/ir/irText/expressions/when.fir.txt @@ -45,9 +45,9 @@ FILE fqName: fileName:/when.kt GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .testWithSubject' type=kotlin.Any? origin=null then: CONST String type=kotlin.String value="!Number" BRANCH - if: CALL 'public final fun contains (element: T of kotlin.collections.contains): kotlin.Boolean [operator] declared in kotlin.collections' type=kotlin.Boolean origin=null + if: CALL 'public final fun contains (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=null : kotlin.Any? - $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections' type=kotlin.collections.Set origin=null + $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set origin=null : kotlin.Nothing element: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .testWithSubject' type=kotlin.Any? origin=null then: CONST String type=kotlin.String value="nothingness?" @@ -81,9 +81,9 @@ FILE fqName: fileName:/when.kt GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null then: CONST String type=kotlin.String value="!Number" BRANCH - if: CALL 'public final fun contains (element: T of kotlin.collections.contains): kotlin.Boolean [operator] declared in kotlin.collections' type=kotlin.Boolean origin=null + if: CALL 'public final fun contains (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=null : kotlin.Number - $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections' type=kotlin.collections.Set origin=null + $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set origin=null : kotlin.Nothing element: TYPE_OP type=kotlin.Number origin=IMPLICIT_CAST typeOperand=kotlin.Number GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/expressions/when.txt b/compiler/testData/ir/irText/expressions/when.txt index e09bfd0cf88..42e6190eca6 100644 --- a/compiler/testData/ir/irText/expressions/when.txt +++ b/compiler/testData/ir/irText/expressions/when.txt @@ -46,9 +46,9 @@ FILE fqName: fileName:/when.kt GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .testWithSubject' type=kotlin.Any? origin=null then: CONST String type=kotlin.String value="!Number" BRANCH - if: CALL 'public final fun contains (element: T of kotlin.collections.contains): kotlin.Boolean [operator] declared in kotlin.collections' type=kotlin.Boolean origin=IN + if: CALL 'public final fun contains (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=IN : kotlin.Number - $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections' type=kotlin.collections.Set origin=null + $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set origin=null : kotlin.Nothing element: TYPE_OP type=kotlin.Number origin=IMPLICIT_CAST typeOperand=kotlin.Number GET_VAR 'val tmp_0: kotlin.Any? [val] declared in .testWithSubject' type=kotlin.Any? origin=null @@ -80,9 +80,9 @@ FILE fqName: fileName:/when.kt GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null then: CONST String type=kotlin.String value="!Number" BRANCH - if: CALL 'public final fun contains (element: T of kotlin.collections.contains): kotlin.Boolean [operator] declared in kotlin.collections' type=kotlin.Boolean origin=IN + if: CALL 'public final fun contains (element: T of kotlin.collections.CollectionsKt.contains): kotlin.Boolean [operator] declared in kotlin.collections.CollectionsKt' type=kotlin.Boolean origin=IN : kotlin.Number - $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections' type=kotlin.collections.Set origin=null + $receiver: CALL 'public final fun setOf (): kotlin.collections.Set [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.Set origin=null : kotlin.Nothing element: TYPE_OP type=kotlin.Number origin=IMPLICIT_CAST typeOperand=kotlin.Number GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/expressions/whenReturnUnit.txt b/compiler/testData/ir/irText/expressions/whenReturnUnit.txt index 6f638bef7ad..dd615c2e3cb 100644 --- a/compiler/testData/ir/irText/expressions/whenReturnUnit.txt +++ b/compiler/testData/ir/irText/expressions/whenReturnUnit.txt @@ -18,11 +18,11 @@ FILE fqName: fileName:/whenReturnUnit.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .branch.' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=1 - then: CALL 'public final fun TODO (reason: kotlin.String): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + then: CALL 'public final fun TODO (reason: kotlin.String): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null reason: CONST String type=kotlin.String value="1" BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .branch.' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=2 - then: CALL 'public final fun TODO (reason: kotlin.String): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + then: CALL 'public final fun TODO (reason: kotlin.String): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null reason: CONST String type=kotlin.String value="2" diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt index 53ef0b5e355..3e9e782bea2 100644 --- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt +++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.fir.txt @@ -26,7 +26,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt $this: VALUE_PARAMETER name: type:.MyMap.MyMap, V of .MyMap> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.MutableSet.MyMap, V of .MyMap>> declared in .MyMap' - CALL 'public final fun mutableSetOf (): kotlin.collections.MutableSet [inline] declared in kotlin.collections' type=kotlin.collections.MutableSet.MyMap, V of .MyMap>> origin=null + CALL 'public final fun mutableSetOf (): kotlin.collections.MutableSet [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.MutableSet.MyMap, V of .MyMap>> origin=null : kotlin.collections.MutableMap.MutableEntry.MyMap, V of .MyMap> FUN FAKE_OVERRIDE name:clear visibility:public modality:OPEN <> ($this:kotlin.collections.MutableMap) returnType:kotlin.Unit [fake_override] overridden: diff --git a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt index adc95467a7c..1d27ae62b02 100644 --- a/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt +++ b/compiler/testData/ir/irText/firProblems/AbstractMutableMap.txt @@ -26,7 +26,7 @@ FILE fqName: fileName:/AbstractMutableMap.kt $this: VALUE_PARAMETER name: type:.MyMap.MyMap, V of .MyMap> BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.MutableSet.MyMap, V of .MyMap>> declared in .MyMap' - CALL 'public final fun mutableSetOf (): kotlin.collections.MutableSet [inline] declared in kotlin.collections' type=kotlin.collections.MutableSet.MyMap, V of .MyMap>> origin=null + CALL 'public final fun mutableSetOf (): kotlin.collections.MutableSet [inline] declared in kotlin.collections.SetsKt' type=kotlin.collections.MutableSet.MyMap, V of .MyMap>> origin=null : kotlin.collections.MutableMap.MutableEntry.MyMap, V of .MyMap> FUN FAKE_OVERRIDE name:getOrDefault visibility:public modality:OPEN <> ($this:kotlin.collections.Map.MyMap, V of .MyMap>, key:K of .MyMap, defaultValue:V of .MyMap) returnType:V of .MyMap [fake_override] annotations: diff --git a/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt b/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt index a9652095e84..0d38c3105ed 100644 --- a/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt +++ b/compiler/testData/ir/irText/firProblems/AllCandidates.fir.txt @@ -55,7 +55,7 @@ FILE fqName: fileName:/AllCandidates.kt VALUE_PARAMETER name:allCandidates index:0 type:kotlin.collections.Collection<.MyCandidate> BLOCK_BODY RETURN type=kotlin.Nothing from='private final fun allCandidatesResult (allCandidates: kotlin.collections.Collection<.MyCandidate>): .OverloadResolutionResultsImpl.allCandidatesResult?>? declared in ' - CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null + CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null : .OverloadResolutionResultsImpl.allCandidatesResult?>? $receiver: CALL 'public open fun nameNotFound (): .OverloadResolutionResultsImpl.OverloadResolutionResultsImpl.nameNotFound?>? declared in .OverloadResolutionResultsImpl' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null : A of .allCandidatesResult? @@ -65,7 +65,7 @@ FILE fqName: fileName:/AllCandidates.kt BLOCK_BODY CALL 'public open fun setAllCandidates (allCandidates: kotlin.collections.Collection<.ResolvedCall.OverloadResolutionResultsImpl?>?>?): kotlin.Unit declared in .OverloadResolutionResultsImpl' type=kotlin.Unit origin=EQ $this: GET_VAR ': .OverloadResolutionResultsImpl.allCandidatesResult?>? declared in .allCandidatesResult.' type=.OverloadResolutionResultsImpl.allCandidatesResult?>? origin=null - allCandidates: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.ResolvedCall.allCandidatesResult>> origin=null + allCandidates: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.ResolvedCall.allCandidatesResult>> origin=null : .MyCandidate : .ResolvedCall.allCandidatesResult> $receiver: GET_VAR 'allCandidates: kotlin.collections.Collection<.MyCandidate> declared in .allCandidatesResult' type=kotlin.collections.Collection<.MyCandidate> origin=null diff --git a/compiler/testData/ir/irText/firProblems/AllCandidates.txt b/compiler/testData/ir/irText/firProblems/AllCandidates.txt index 591878e17f6..d435cdb80ed 100644 --- a/compiler/testData/ir/irText/firProblems/AllCandidates.txt +++ b/compiler/testData/ir/irText/firProblems/AllCandidates.txt @@ -55,7 +55,7 @@ FILE fqName: fileName:/AllCandidates.kt VALUE_PARAMETER name:allCandidates index:0 type:kotlin.collections.Collection<.MyCandidate> BLOCK_BODY RETURN type=kotlin.Nothing from='private final fun allCandidatesResult (allCandidates: kotlin.collections.Collection<.MyCandidate>): @[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? declared in ' - CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=@[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? origin=null + CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=@[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? origin=null : @[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? $receiver: CALL 'public open fun nameNotFound (): @[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] R of .OverloadResolutionResultsImpl.nameNotFound?>? declared in .OverloadResolutionResultsImpl' type=@[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? origin=null : @[FlexibleNullability] A of .allCandidatesResult? @@ -67,7 +67,7 @@ FILE fqName: fileName:/AllCandidates.kt <1>: @[FlexibleNullability] A of .allCandidatesResult? $this: TYPE_OP type=.OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?> origin=IMPLICIT_NOTNULL typeOperand=.OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?> GET_VAR '$this$apply: @[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? declared in .allCandidatesResult.' type=@[FlexibleNullability] .OverloadResolutionResultsImpl<@[FlexibleNullability] A of .allCandidatesResult?>? origin=null - allCandidates: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.ResolvedCall.allCandidatesResult>> origin=null + allCandidates: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.ResolvedCall.allCandidatesResult>> origin=null : .MyCandidate : .ResolvedCall.allCandidatesResult> $receiver: GET_VAR 'allCandidates: kotlin.collections.Collection<.MyCandidate> declared in .allCandidatesResult' type=kotlin.collections.Collection<.MyCandidate> origin=null diff --git a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt index f774624f25c..e67870b6bbb 100644 --- a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt +++ b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.fir.txt @@ -125,7 +125,7 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt PROPERTY name:registrationMap visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:registrationMap type:java.util.HashMap visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections' type=java.util.HashMap origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap origin=null : java.lang.reflect.Type : kotlin.Any FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> () returnType:java.util.HashMap @@ -171,6 +171,6 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt : .PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>> container: GET_VAR 'container: .ComponentContainer declared in .resolveClashesIfAny' type=.ComponentContainer origin=null resolver: GET_VAR 'val resolver: .PlatformExtensionsClashResolver<*> [val] declared in .resolveClashesIfAny' type=.PlatformExtensionsClashResolver<*> origin=null - clashedComponents: CALL 'public final fun toList (): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<.ComponentDescriptor> origin=null + clashedComponents: CALL 'public final fun toList (): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.ComponentDescriptor> origin=null : .ComponentDescriptor $receiver: GET_VAR 'val clashedComponents: kotlin.collections.Collection<.ComponentDescriptor> [val] declared in .resolveClashesIfAny' type=kotlin.collections.Collection<.ComponentDescriptor> origin=null diff --git a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.txt b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.txt index 523faf606fd..a09fc527039 100644 --- a/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.txt +++ b/compiler/testData/ir/irText/firProblems/ClashResolutionDescriptor.txt @@ -123,16 +123,16 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any PROPERTY name:registrationMap visibility:private modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:registrationMap type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static] + FIELD PROPERTY_BACKING_FIELD name:registrationMap type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static] EXPRESSION_BODY - CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.HashMap } [inline] declared in kotlin.collections' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + CALL 'public final fun hashMapOf (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } [inline] declared in kotlin.collections.MapsKt' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null : java.lang.reflect.Type : kotlin.Any - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> () returnType:java.util.HashMap{ kotlin.collections.HashMap } + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> () returnType:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } correspondingProperty: PROPERTY name:registrationMap visibility:private modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='private final fun (): java.util.HashMap{ kotlin.collections.HashMap } declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:registrationMap type:java.util.HashMap{ kotlin.collections.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.HashMap } origin=null + RETURN type=kotlin.Nothing from='private final fun (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:registrationMap type:java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } visibility:private [final,static]' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=null FUN name:resolveClashesIfAny visibility:public modality:FINAL <> (container:.ComponentContainer, clashResolvers:kotlin.collections.List<.PlatformExtensionsClashResolver<*>>) returnType:kotlin.Unit VALUE_PARAMETER name:container index:0 type:.ComponentContainer VALUE_PARAMETER name:clashResolvers index:1 type:kotlin.collections.List<.PlatformExtensionsClashResolver<*>> @@ -154,7 +154,7 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.collections.Collection<.ComponentDescriptor>? [val] TYPE_OP type=kotlin.collections.Collection<.ComponentDescriptor>? origin=SAFE_CAST typeOperand=kotlin.collections.Collection<.ComponentDescriptor> CALL 'public open fun get (key: @[EnhancedNullability] K of java.util.HashMap): @[EnhancedNullability] V of java.util.HashMap? [operator] declared in java.util.HashMap' type=@[EnhancedNullability] kotlin.Any? origin=GET_ARRAY_ELEMENT - $this: CALL 'private final fun (): java.util.HashMap{ kotlin.collections.HashMap } declared in ' type=java.util.HashMap{ kotlin.collections.HashMap } origin=GET_PROPERTY + $this: CALL 'private final fun (): java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } declared in ' type=java.util.HashMap{ kotlin.collections.TypeAliasesKt.HashMap } origin=GET_PROPERTY key: CALL 'public final fun (): java.lang.Class.PlatformExtensionsClashResolver> declared in .PlatformExtensionsClashResolver' type=java.lang.Class.PlatformSpecificExtension<*>> origin=GET_PROPERTY $this: GET_VAR 'val resolver: .PlatformExtensionsClashResolver<*> [val] declared in .resolveClashesIfAny' type=.PlatformExtensionsClashResolver<*> origin=null WHEN type=kotlin.collections.Collection<.ComponentDescriptor> origin=null @@ -171,6 +171,6 @@ FILE fqName: fileName:/ClashResolutionDescriptor.kt : .PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension.PlatformSpecificExtension>>>> container: GET_VAR 'container: .ComponentContainer declared in .resolveClashesIfAny' type=.ComponentContainer origin=null resolver: GET_VAR 'val resolver: .PlatformExtensionsClashResolver<*> [val] declared in .resolveClashesIfAny' type=.PlatformExtensionsClashResolver<*> origin=null - clashedComponents: CALL 'public final fun toList (): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<.ComponentDescriptor> origin=null + clashedComponents: CALL 'public final fun toList (): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.ComponentDescriptor> origin=null : .ComponentDescriptor $receiver: GET_VAR 'val clashedComponents: kotlin.collections.Collection<.ComponentDescriptor> [val] declared in .resolveClashesIfAny' type=kotlin.collections.Collection<.ComponentDescriptor> origin=null diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt index b24d57cf46e..4f07bf8fbd4 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.fir.txt @@ -140,7 +140,7 @@ FILE fqName: fileName:/DeepCopyIrTree.kt BLOCK_BODY CALL 'public abstract fun (: kotlin.collections.List<.IrTypeParameter>): kotlin.Unit declared in .IrTypeParametersContainer' type=kotlin.Unit origin=EQ $this: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null - : CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.IrTypeParameter> origin=null + : CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.IrTypeParameter> origin=null : .IrTypeParameter : .IrTypeParameter $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY @@ -164,7 +164,7 @@ FILE fqName: fileName:/DeepCopyIrTree.kt BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] CALL 'public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.List' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=FOR_LOOP_ITERATOR - $this: CALL 'public final fun zip (other: kotlin.collections.Iterable): kotlin.collections.List> [infix] declared in kotlin.collections' type=kotlin.collections.List.IrTypeParameter, .IrTypeParameter>> origin=null + $this: CALL 'public final fun zip (other: kotlin.collections.Iterable): kotlin.collections.List> [infix] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List.IrTypeParameter, .IrTypeParameter>> origin=null : .IrTypeParameter : .IrTypeParameter $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY @@ -184,7 +184,7 @@ FILE fqName: fileName:/DeepCopyIrTree.kt VAR name:otherTypeParameter type:.IrTypeParameter [val] CALL 'public final fun component2 (): B of kotlin.Pair [operator] declared in kotlin.Pair' type=.IrTypeParameter origin=null $this: GET_VAR 'val : kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null - CALL 'public final fun mapTo (destination: C of kotlin.collections.mapTo, transform: kotlin.Function1): C of kotlin.collections.mapTo [inline] declared in kotlin.collections' type=kotlin.collections.MutableList<.IrType> origin=null + CALL 'public final fun mapTo (destination: C of kotlin.collections.CollectionsKt.mapTo, transform: kotlin.Function1): C of kotlin.collections.CollectionsKt.mapTo [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.MutableList<.IrType> origin=null : .IrType : .IrType : kotlin.collections.MutableList<.IrType> diff --git a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt index 83dcadb2d47..9aa3fba8932 100644 --- a/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt +++ b/compiler/testData/ir/irText/firProblems/DeepCopyIrTree.txt @@ -143,7 +143,7 @@ FILE fqName: fileName:/DeepCopyIrTree.kt BLOCK_BODY CALL 'public abstract fun (: kotlin.collections.List<.IrTypeParameter>): kotlin.Unit declared in .IrTypeParametersContainer' type=kotlin.Unit origin=EQ $this: GET_VAR ': .IrTypeParametersContainer declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom' type=.IrTypeParametersContainer origin=null - : CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.IrTypeParameter> origin=null + : CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.IrTypeParameter> origin=null : .IrTypeParameter : .IrTypeParameter $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY @@ -167,7 +167,7 @@ FILE fqName: fileName:/DeepCopyIrTree.kt BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> [val] CALL 'public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.List' type=kotlin.collections.Iterator.IrTypeParameter, .IrTypeParameter>> origin=FOR_LOOP_ITERATOR - $this: CALL 'public final fun zip (other: kotlin.collections.Iterable): kotlin.collections.List> [infix] declared in kotlin.collections' type=kotlin.collections.List.IrTypeParameter, .IrTypeParameter>> origin=null + $this: CALL 'public final fun zip (other: kotlin.collections.Iterable): kotlin.collections.List> [infix] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List.IrTypeParameter, .IrTypeParameter>> origin=null : .IrTypeParameter : .IrTypeParameter $receiver: CALL 'public abstract fun (): kotlin.collections.List<.IrTypeParameter> declared in .IrTypeParametersContainer' type=kotlin.collections.List<.IrTypeParameter> origin=GET_PROPERTY @@ -189,7 +189,7 @@ FILE fqName: fileName:/DeepCopyIrTree.kt $this: GET_VAR 'val tmp_1: kotlin.Pair<.IrTypeParameter, .IrTypeParameter> [val] declared in .DeepCopyIrTreeWithSymbols.copyTypeParametersFrom.' type=kotlin.Pair<.IrTypeParameter, .IrTypeParameter> origin=null BLOCK type=kotlin.Unit origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun mapTo (destination: C of kotlin.collections.mapTo, transform: kotlin.Function1): C of kotlin.collections.mapTo [inline] declared in kotlin.collections' type=kotlin.collections.MutableList<.IrType> origin=null + CALL 'public final fun mapTo (destination: C of kotlin.collections.CollectionsKt.mapTo, transform: kotlin.Function1): C of kotlin.collections.CollectionsKt.mapTo [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.MutableList<.IrType> origin=null : .IrType : .IrType : kotlin.collections.MutableList<.IrType> diff --git a/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt b/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt index 3be1f4a8686..06ec0dfc0fe 100644 --- a/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt +++ b/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.fir.txt @@ -165,7 +165,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt VALUE_PARAMETER name:name index:0 type:kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun get (name: kotlin.String?): .ImplicitReceiverValue<*>? [operator] declared in .PersistentImplicitReceiverStack' - CALL 'public final fun lastOrNull (): T of kotlin.collections.lastOrNull? declared in kotlin.collections' type=.ImplicitReceiverValue<*>? origin=null + CALL 'public final fun lastOrNull (): T of kotlin.collections.CollectionsKt.lastOrNull? declared in kotlin.collections.CollectionsKt' type=.ImplicitReceiverValue<*>? origin=null : .ImplicitReceiverValue<*> $receiver: CALL 'private final fun (): kotlin.collections.List<.ImplicitReceiverValue<*>> declared in .PersistentImplicitReceiverStack' type=kotlin.collections.List<.ImplicitReceiverValue<*>> origin=GET_PROPERTY $this: GET_VAR ': .PersistentImplicitReceiverStack declared in .PersistentImplicitReceiverStack.get' type=.PersistentImplicitReceiverStack origin=null @@ -199,7 +199,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt FUN name:foo visibility:public modality:FINAL <> (stack:.PersistentImplicitReceiverStack) returnType:kotlin.Unit VALUE_PARAMETER name:stack index:0 type:.PersistentImplicitReceiverStack BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : .ImplicitReceiverValue<*> $receiver: GET_VAR 'stack: .PersistentImplicitReceiverStack declared in .foo' type=.PersistentImplicitReceiverStack origin=null action: FUN_EXPR type=kotlin.Function1<.ImplicitReceiverValue<*>, kotlin.Unit> origin=LAMBDA @@ -216,7 +216,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt BLOCK_BODY VAR name:stack type:.PersistentImplicitReceiverStack [val] CONSTRUCTOR_CALL 'public constructor (stack: kotlin.collections.List<.ImplicitReceiverValue<*>>) [primary] declared in .PersistentImplicitReceiverStack' type=.PersistentImplicitReceiverStack origin=null - stack: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.listOf): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<.ImplicitReceiverValue> origin=null + stack: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.ImplicitReceiverValue> origin=null : .ImplicitReceiverValue elements: VARARG type=kotlin.Array.ImplicitReceiverValue> varargElementType=.ImplicitReceiverValue CONSTRUCTOR_CALL 'public constructor (boundSymbol: S of .ImplicitReceiverValue?, type: kotlin.String) [primary] declared in .ImplicitReceiverValue' type=.ImplicitReceiverValue origin=null @@ -232,7 +232,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public final fun (): kotlin.String declared in .ImplicitReceiverValue' type=kotlin.String origin=GET_PROPERTY - $this: CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=.ImplicitReceiverValue<*> origin=null + $this: CALL 'public final fun first (): T of kotlin.collections.CollectionsKt.first declared in kotlin.collections.CollectionsKt' type=.ImplicitReceiverValue<*> origin=null : .ImplicitReceiverValue<*> $receiver: GET_VAR 'val stack: .PersistentImplicitReceiverStack [val] declared in .box' type=.PersistentImplicitReceiverStack origin=null other: BLOCK type=kotlin.String? origin=SAFE_CALL diff --git a/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.txt b/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.txt index 2b363bfc8a8..c63227d524f 100644 --- a/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.txt +++ b/compiler/testData/ir/irText/firProblems/ImplicitReceiverStack.txt @@ -166,7 +166,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt VALUE_PARAMETER name:name index:0 type:kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun get (name: kotlin.String?): .ImplicitReceiverValue<*>? [operator] declared in .PersistentImplicitReceiverStack' - CALL 'public final fun lastOrNull (): T of kotlin.collections.lastOrNull? declared in kotlin.collections' type=.ImplicitReceiverValue<*>? origin=null + CALL 'public final fun lastOrNull (): T of kotlin.collections.CollectionsKt.lastOrNull? declared in kotlin.collections.CollectionsKt' type=.ImplicitReceiverValue<*>? origin=null : .ImplicitReceiverValue<*> $receiver: CALL 'private final fun (): kotlin.collections.List<.ImplicitReceiverValue<*>> declared in .PersistentImplicitReceiverStack' type=kotlin.collections.List<.ImplicitReceiverValue<*>> origin=GET_PROPERTY $this: GET_VAR ': .PersistentImplicitReceiverStack declared in .PersistentImplicitReceiverStack.get' type=.PersistentImplicitReceiverStack origin=null @@ -203,7 +203,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt FUN name:foo visibility:public modality:FINAL <> (stack:.PersistentImplicitReceiverStack) returnType:kotlin.Unit VALUE_PARAMETER name:stack index:0 type:.PersistentImplicitReceiverStack BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : .ImplicitReceiverValue<*> $receiver: GET_VAR 'stack: .PersistentImplicitReceiverStack declared in .foo' type=.PersistentImplicitReceiverStack origin=null action: FUN_EXPR type=kotlin.Function1<.ImplicitReceiverValue<*>, kotlin.Unit> origin=LAMBDA @@ -220,7 +220,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt BLOCK_BODY VAR name:stack type:.PersistentImplicitReceiverStack [val] CONSTRUCTOR_CALL 'public constructor (stack: kotlin.collections.List<.ImplicitReceiverValue<*>>) [primary] declared in .PersistentImplicitReceiverStack' type=.PersistentImplicitReceiverStack origin=null - stack: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.listOf): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<.ImplicitReceiverValue> origin=null + stack: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.ImplicitReceiverValue> origin=null : .ImplicitReceiverValue elements: VARARG type=kotlin.Array.ImplicitReceiverValue> varargElementType=.ImplicitReceiverValue CONSTRUCTOR_CALL 'public constructor (boundSymbol: S of .ImplicitReceiverValue?, type: kotlin.String) [primary] declared in .ImplicitReceiverValue' type=.ImplicitReceiverValue origin=null @@ -236,7 +236,7 @@ FILE fqName: fileName:/ImplicitReceiverStack.kt RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS $this: CALL 'public open fun (): kotlin.String declared in .ImplicitReceiverValue' type=kotlin.String origin=GET_PROPERTY - $this: CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=.ImplicitReceiverValue<*> origin=null + $this: CALL 'public final fun first (): T of kotlin.collections.CollectionsKt.first declared in kotlin.collections.CollectionsKt' type=.ImplicitReceiverValue<*> origin=null : .ImplicitReceiverValue<*> $receiver: GET_VAR 'val stack: .PersistentImplicitReceiverStack [val] declared in .box' type=.PersistentImplicitReceiverStack origin=null other: BLOCK type=kotlin.String? origin=SAFE_CALL diff --git a/compiler/testData/ir/irText/firProblems/SyntheticSetterType.fir.txt b/compiler/testData/ir/irText/firProblems/SyntheticSetterType.fir.txt index 3d107bdafb2..e9069a7a249 100644 --- a/compiler/testData/ir/irText/firProblems/SyntheticSetterType.fir.txt +++ b/compiler/testData/ir/irText/firProblems/SyntheticSetterType.fir.txt @@ -4,5 +4,5 @@ FILE fqName: fileName:/SyntheticSetterType.kt BLOCK_BODY CALL 'public open fun setOverriddenDescriptors (overriddenDescriptors: @[EnhancedNullability] kotlin.collections.Collection.CallableMemberDescriptor?>): kotlin.Unit declared in .PropertyDescriptorImpl' type=kotlin.Unit origin=EQ $this: GET_VAR 'descriptor: .PropertyDescriptorImpl declared in .foo' type=.PropertyDescriptorImpl origin=null - overriddenDescriptors: CALL 'public final fun emptyList (): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<.PropertyDescriptor?> origin=null + overriddenDescriptors: CALL 'public final fun emptyList (): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.PropertyDescriptor?> origin=null : .PropertyDescriptor? diff --git a/compiler/testData/ir/irText/firProblems/SyntheticSetterType.txt b/compiler/testData/ir/irText/firProblems/SyntheticSetterType.txt index bcdd3eb5187..bd2fffebf24 100644 --- a/compiler/testData/ir/irText/firProblems/SyntheticSetterType.txt +++ b/compiler/testData/ir/irText/firProblems/SyntheticSetterType.txt @@ -4,5 +4,5 @@ FILE fqName: fileName:/SyntheticSetterType.kt BLOCK_BODY CALL 'public open fun setOverriddenDescriptors (overriddenDescriptors: @[EnhancedNullability] kotlin.collections.MutableCollection.CallableMemberDescriptor?>): kotlin.Unit declared in .PropertyDescriptorImpl' type=kotlin.Unit origin=EQ $this: GET_VAR 'descriptor: .PropertyDescriptorImpl declared in .foo' type=.PropertyDescriptorImpl origin=null - overriddenDescriptors: CALL 'public final fun emptyList (): kotlin.collections.List declared in kotlin.collections' type=kotlin.collections.List<@[FlexibleNullability] .PropertyDescriptor?> origin=null + overriddenDescriptors: CALL 'public final fun emptyList (): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<@[FlexibleNullability] .PropertyDescriptor?> origin=null : @[FlexibleNullability] .PropertyDescriptor? diff --git a/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.fir.txt b/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.fir.txt index a5d704ba546..24624e3721b 100644 --- a/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.fir.txt +++ b/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.fir.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/coercionToUnitForNestedWhen.kt RETURN type=kotlin.Nothing from='private final fun nextChar (): kotlin.Char? declared in ' BLOCK type=kotlin.Char? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] - CALL 'public final fun takeUnless (predicate: kotlin.Function1): T of kotlin.takeUnless? [inline] declared in kotlin' type=kotlin.Int? origin=null + CALL 'public final fun takeUnless (predicate: kotlin.Function1): T of kotlin.StandardKt.takeUnless? [inline] declared in kotlin.StandardKt' type=kotlin.Int? origin=null : kotlin.Int $receiver: CALL 'public open fun read (): kotlin.Int declared in java.io.Reader' type=kotlin.Int origin=null $this: GET_VAR ': java.io.Reader declared in .nextChar' type=java.io.Reader origin=null @@ -79,7 +79,7 @@ FILE fqName: fileName:/coercionToUnitForNestedWhen.kt then: CONST Null type=kotlin.Nothing? value=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun let (block: kotlin.Function1): R of kotlin.let [inline] declared in kotlin' type=java.lang.StringBuilder? origin=null + then: CALL 'public final fun let (block: kotlin.Function1): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=java.lang.StringBuilder? origin=null : kotlin.Char : java.lang.StringBuilder? $receiver: GET_VAR 'val tmp_1: kotlin.Char? [val] declared in .consumeRestOfQuotedSequence' type=kotlin.Char? origin=null diff --git a/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.txt b/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.txt index 0696ec0655c..56cc9ca65ba 100644 --- a/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.txt +++ b/compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.txt @@ -14,7 +14,7 @@ FILE fqName: fileName:/coercionToUnitForNestedWhen.kt RETURN type=kotlin.Nothing from='private final fun nextChar (): kotlin.Char? declared in ' BLOCK type=kotlin.Char? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int? [val] - CALL 'public final fun takeUnless (predicate: kotlin.Function1): T of kotlin.takeUnless? [inline] declared in kotlin' type=kotlin.Int? origin=null + CALL 'public final fun takeUnless (predicate: kotlin.Function1): T of kotlin.StandardKt.takeUnless? [inline] declared in kotlin.StandardKt' type=kotlin.Int? origin=null : kotlin.Int $receiver: CALL 'public open fun read (): kotlin.Int declared in java.io.Reader' type=kotlin.Int origin=null $this: GET_VAR ': java.io.Reader declared in .nextChar' type=java.io.Reader origin=null @@ -36,9 +36,9 @@ FILE fqName: fileName:/coercionToUnitForNestedWhen.kt if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public open fun toChar (): kotlin.Char declared in kotlin.Int' type=kotlin.Char origin=null $this: GET_VAR 'val tmp_0: kotlin.Int? [val] declared in .nextChar' type=kotlin.Int? origin=null - FUN name:consumeRestOfQuotedSequence visibility:public modality:FINAL <> ($receiver:java.io.Reader, sb:java.lang.StringBuilder{ kotlin.text.StringBuilder }, quote:kotlin.Char) returnType:kotlin.Unit + FUN name:consumeRestOfQuotedSequence visibility:public modality:FINAL <> ($receiver:java.io.Reader, sb:java.lang.StringBuilder{ kotlin.text.TypeAliasesKt.StringBuilder }, quote:kotlin.Char) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:java.io.Reader - VALUE_PARAMETER name:sb index:0 type:java.lang.StringBuilder{ kotlin.text.StringBuilder } + VALUE_PARAMETER name:sb index:0 type:java.lang.StringBuilder{ kotlin.text.TypeAliasesKt.StringBuilder } VALUE_PARAMETER name:quote index:1 type:kotlin.Char BLOCK_BODY VAR name:ch type:kotlin.Char? [var] @@ -77,7 +77,7 @@ FILE fqName: fileName:/coercionToUnitForNestedWhen.kt then: CONST Null type=kotlin.Nothing? value=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun let (block: kotlin.Function1): R of kotlin.let [inline] declared in kotlin' type=@[FlexibleNullability] java.lang.StringBuilder? origin=null + then: CALL 'public final fun let (block: kotlin.Function1): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=@[FlexibleNullability] java.lang.StringBuilder? origin=null : kotlin.Char : @[FlexibleNullability] java.lang.StringBuilder? $receiver: GET_VAR 'val tmp_1: kotlin.Char? [val] declared in .consumeRestOfQuotedSequence' type=kotlin.Char? origin=null @@ -87,13 +87,13 @@ FILE fqName: fileName:/coercionToUnitForNestedWhen.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Char): @[FlexibleNullability] java.lang.StringBuilder? declared in .consumeRestOfQuotedSequence' CALL 'public open fun append (p0: kotlin.Char): @[FlexibleNullability] java.lang.StringBuilder? declared in java.lang.StringBuilder' type=@[FlexibleNullability] java.lang.StringBuilder? origin=null - $this: GET_VAR 'sb: java.lang.StringBuilder{ kotlin.text.StringBuilder } declared in .consumeRestOfQuotedSequence' type=java.lang.StringBuilder{ kotlin.text.StringBuilder } origin=null + $this: GET_VAR 'sb: java.lang.StringBuilder{ kotlin.text.TypeAliasesKt.StringBuilder } declared in .consumeRestOfQuotedSequence' type=java.lang.StringBuilder{ kotlin.text.TypeAliasesKt.StringBuilder } origin=null p0: GET_VAR 'it: kotlin.Char declared in .consumeRestOfQuotedSequence.' type=kotlin.Char origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public open fun append (p0: kotlin.Char): @[FlexibleNullability] java.lang.StringBuilder? declared in java.lang.StringBuilder' type=@[FlexibleNullability] java.lang.StringBuilder? origin=null - $this: GET_VAR 'sb: java.lang.StringBuilder{ kotlin.text.StringBuilder } declared in .consumeRestOfQuotedSequence' type=java.lang.StringBuilder{ kotlin.text.StringBuilder } origin=null + $this: GET_VAR 'sb: java.lang.StringBuilder{ kotlin.text.TypeAliasesKt.StringBuilder } declared in .consumeRestOfQuotedSequence' type=java.lang.StringBuilder{ kotlin.text.TypeAliasesKt.StringBuilder } origin=null p0: GET_VAR 'var ch: kotlin.Char? [var] declared in .consumeRestOfQuotedSequence' type=kotlin.Char? origin=null SET_VAR 'var ch: kotlin.Char? [var] declared in .consumeRestOfQuotedSequence' type=kotlin.Unit origin=EQ CALL 'private final fun nextChar (): kotlin.Char? declared in ' type=kotlin.Char? origin=null diff --git a/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.fir.txt b/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.fir.txt index 43ce9eeb68b..40d4e6eb48f 100644 --- a/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.fir.txt +++ b/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.fir.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/inapplicableCollectionSet.kt PROPERTY name:INSTANCES visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:INSTANCES type:kotlin.collections.MutableMap.Flaf> visibility:private [final] EXPRESSION_BODY - CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections' type=kotlin.collections.MutableMap.Flaf> origin=null + CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.MutableMap.Flaf> origin=null : kotlin.String : .Flaf FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.Flaf) returnType:kotlin.collections.MutableMap.Flaf> @@ -62,7 +62,7 @@ FILE fqName: fileName:/inapplicableCollectionSet.kt SET_VAR 'var result: .Flaf? [var] declared in .Flaf.forJavaName' type=kotlin.Unit origin=EQ CONSTRUCTOR_CALL 'public constructor (javaName: kotlin.String) [primary] declared in .Flaf' type=.Flaf origin=null javaName: GET_VAR 'javaName: kotlin.String declared in .Flaf.forJavaName' type=kotlin.String origin=null - CALL 'public final fun set (key: K of kotlin.collections.set, value: V of kotlin.collections.set): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun set (key: K of kotlin.collections.MapsKt.set, value: V of kotlin.collections.MapsKt.set): kotlin.Unit [inline,operator] declared in kotlin.collections.MapsKt' type=kotlin.Unit origin=null : kotlin.String : .Flaf $receiver: CALL 'private final fun (): kotlin.collections.MutableMap.Flaf> declared in .Flaf' type=kotlin.collections.MutableMap.Flaf> origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.txt b/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.txt index 961aaa9f82b..977e1e1d762 100644 --- a/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.txt +++ b/compiler/testData/ir/irText/firProblems/inapplicableCollectionSet.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/inapplicableCollectionSet.kt PROPERTY name:INSTANCES visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:INSTANCES type:kotlin.collections.MutableMap.Flaf> visibility:private [final] EXPRESSION_BODY - CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections' type=kotlin.collections.MutableMap.Flaf> origin=null + CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.MutableMap.Flaf> origin=null : kotlin.String : .Flaf FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.Flaf) returnType:kotlin.collections.MutableMap.Flaf> @@ -61,7 +61,7 @@ FILE fqName: fileName:/inapplicableCollectionSet.kt SET_VAR 'var result: .Flaf? [var] declared in .Flaf.forJavaName' type=kotlin.Unit origin=EQ CONSTRUCTOR_CALL 'public constructor (javaName: kotlin.String) [primary] declared in .Flaf' type=.Flaf origin=null javaName: GET_VAR 'javaName: kotlin.String declared in .Flaf.forJavaName' type=kotlin.String origin=null - CALL 'public final fun set (key: K of kotlin.collections.set, value: V of kotlin.collections.set): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=EQ + CALL 'public final fun set (key: K of kotlin.collections.MapsKt.set, value: V of kotlin.collections.MapsKt.set): kotlin.Unit [inline,operator] declared in kotlin.collections.MapsKt' type=kotlin.Unit origin=EQ : kotlin.String : .Flaf $receiver: CALL 'private final fun (): kotlin.collections.MutableMap.Flaf> declared in .Flaf' type=kotlin.collections.MutableMap.Flaf> origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt b/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt index ae5f3b7ef46..c3f972b808e 100644 --- a/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt +++ b/compiler/testData/ir/irText/firProblems/putIfAbsent.fir.txt @@ -12,7 +12,7 @@ FILE fqName: fileName:/putIfAbsent.kt VALUE_PARAMETER name:y index:1 type:T of .Owner.foo BLOCK_BODY VAR name:map type:kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> [val] - CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections' type=kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> origin=null + CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> origin=null : T of .Owner.foo : T of .Owner.foo TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit diff --git a/compiler/testData/ir/irText/firProblems/putIfAbsent.txt b/compiler/testData/ir/irText/firProblems/putIfAbsent.txt index bec7c5565e4..d865a1f5d2d 100644 --- a/compiler/testData/ir/irText/firProblems/putIfAbsent.txt +++ b/compiler/testData/ir/irText/firProblems/putIfAbsent.txt @@ -12,7 +12,7 @@ FILE fqName: fileName:/putIfAbsent.kt VALUE_PARAMETER name:y index:1 type:T of .Owner.foo BLOCK_BODY VAR name:map type:kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> [val] - CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections' type=kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> origin=null + CALL 'public final fun mutableMapOf (): kotlin.collections.MutableMap [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> origin=null : T of .Owner.foo : T of .Owner.foo TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit diff --git a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt index 23c851dd3b6..e8df2d7e507 100644 --- a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt +++ b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.fir.txt @@ -46,10 +46,10 @@ FILE fqName: fileName:/recursiveCapturedTypeInPropertyReference.kt VALUE_PARAMETER name:list index:0 type:kotlin.collections.List BLOCK_BODY VAR name:result type:kotlin.collections.List<.AbstractSymbol.Recursive<*>>> [val] - CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.AbstractSymbol.Recursive<*>>> origin=null + CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.AbstractSymbol.Recursive<*>>> origin=null : .Recursive<*> : .AbstractSymbol.Recursive<*>> - $receiver: CALL 'public final fun filterIsInstance (): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.Recursive<*>> origin=null + $receiver: CALL 'public final fun filterIsInstance (): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.Recursive<*>> origin=null : .Recursive<*> $receiver: GET_VAR 'list: kotlin.collections.List declared in .AbstractSymbol.foo' type=kotlin.collections.List origin=null transform: PROPERTY_REFERENCE 'public abstract symbol: .AbstractSymbol.Recursive> [val]' field=null getter='public abstract fun (): .AbstractSymbol.Recursive> declared in .Recursive' setter=null type=kotlin.reflect.KProperty1<.Recursive<*>, .AbstractSymbol<.Recursive<*>>> origin=null diff --git a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.txt b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.txt index ebfe0eed446..3e2d3d335b6 100644 --- a/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.txt +++ b/compiler/testData/ir/irText/firProblems/recursiveCapturedTypeInPropertyReference.txt @@ -46,10 +46,10 @@ FILE fqName: fileName:/recursiveCapturedTypeInPropertyReference.kt VALUE_PARAMETER name:list index:0 type:kotlin.collections.List BLOCK_BODY VAR name:result type:kotlin.collections.List<.AbstractSymbol.Recursive<*>>> [val] - CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<.AbstractSymbol.Recursive<*>>> origin=null + CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<.AbstractSymbol.Recursive<*>>> origin=null : .Recursive<*> : .AbstractSymbol.Recursive<*>> - $receiver: CALL 'public final fun filterIsInstance (): kotlin.collections.List<@[NoInfer] R of kotlin.collections.filterIsInstance> [inline] declared in kotlin.collections' type=kotlin.collections.List<@[NoInfer] .Recursive<*>> origin=null + $receiver: CALL 'public final fun filterIsInstance (): kotlin.collections.List<@[NoInfer] R of kotlin.collections.CollectionsKt.filterIsInstance> [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<@[NoInfer] .Recursive<*>> origin=null : .Recursive<*> $receiver: GET_VAR 'list: kotlin.collections.List declared in .AbstractSymbol.foo' type=kotlin.collections.List origin=null transform: PROPERTY_REFERENCE 'public abstract symbol: .AbstractSymbol.Recursive> [val]' field=null getter='public abstract fun (): .AbstractSymbol.Recursive> declared in .Recursive' setter=null type=kotlin.reflect.KProperty1<.Recursive<*>, .AbstractSymbol.Recursive<*>>> origin=null diff --git a/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.fir.txt b/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.fir.txt index 1d0d71e73db..91313fa3524 100644 --- a/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.fir.txt +++ b/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.fir.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/typeParameterFromJavaClass.kt FUN name:foo visibility:public modality:FINAL <> (movedPaths:kotlin.collections.MutableList<.Couple<.FilePath>>) returnType:kotlin.Unit VALUE_PARAMETER name:movedPaths index:0 type:kotlin.collections.MutableList<.Couple<.FilePath>> BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : .Couple<.FilePath> $receiver: GET_VAR 'movedPaths: kotlin.collections.MutableList<.Couple<.FilePath>> declared in .foo' type=kotlin.collections.MutableList<.Couple<.FilePath>> origin=null action: FUN_EXPR type=kotlin.Function1<.Couple<.FilePath>, kotlin.Unit> origin=LAMBDA diff --git a/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.txt b/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.txt index ca709a07f33..680f73821b8 100644 --- a/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.txt +++ b/compiler/testData/ir/irText/firProblems/typeParameterFromJavaClass.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/typeParameterFromJavaClass.kt FUN name:foo visibility:public modality:FINAL <> (movedPaths:kotlin.collections.MutableList<.Couple<.FilePath>>) returnType:kotlin.Unit VALUE_PARAMETER name:movedPaths index:0 type:kotlin.collections.MutableList<.Couple<.FilePath>> BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : .Couple<.FilePath> $receiver: GET_VAR 'movedPaths: kotlin.collections.MutableList<.Couple<.FilePath>> declared in .foo' type=kotlin.collections.MutableList<.Couple<.FilePath>> origin=null action: FUN_EXPR type=kotlin.Function1<.Couple<.FilePath>, kotlin.Unit> origin=LAMBDA diff --git a/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt b/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt index 1534070b987..9873d8f2b43 100644 --- a/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt +++ b/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.fir.txt @@ -545,7 +545,7 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt PROPERTY name:ORDERED_VISIBILITIES visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:ORDERED_VISIBILITIES type:kotlin.collections.Map<.Visibility, kotlin.Int> visibility:private [final] EXPRESSION_BODY - CALL 'public final fun buildMap (builderAction: @[ExtensionFunctionType] kotlin.Function1, kotlin.Unit>): kotlin.collections.Map [inline] declared in kotlin.collections' type=kotlin.collections.Map<.Visibility, kotlin.Int> origin=null + CALL 'public final fun buildMap (builderAction: @[ExtensionFunctionType] kotlin.Function1, kotlin.Unit>): kotlin.collections.Map [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.Map<.Visibility, kotlin.Int> origin=null : .Visibility : kotlin.Int builderAction: FUN_EXPR type=kotlin.Function1.Visibility, kotlin.Int>, kotlin.Unit> origin=LAMBDA diff --git a/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.txt b/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.txt index 848ef2c9314..86d06507ea3 100644 --- a/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.txt +++ b/compiler/testData/ir/irText/firProblems/typeVariableAfterBuildMap.txt @@ -545,7 +545,7 @@ FILE fqName: fileName:/typeVariableAfterBuildMap.kt PROPERTY name:ORDERED_VISIBILITIES visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:ORDERED_VISIBILITIES type:kotlin.collections.Map<.Visibility, kotlin.Int> visibility:private [final] EXPRESSION_BODY - CALL 'public final fun buildMap (builderAction: @[ExtensionFunctionType] kotlin.Function1, kotlin.Unit>): kotlin.collections.Map [inline] declared in kotlin.collections' type=kotlin.collections.Map<.Visibility, kotlin.Int> origin=null + CALL 'public final fun buildMap (builderAction: @[ExtensionFunctionType] kotlin.Function1, kotlin.Unit>): kotlin.collections.Map [inline] declared in kotlin.collections.MapsKt' type=kotlin.collections.Map<.Visibility, kotlin.Int> origin=null : .Visibility : kotlin.Int builderAction: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1.Visibility, kotlin.Int>, kotlin.Unit> origin=LAMBDA diff --git a/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.txt b/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.txt index 22af3b17f32..b2c5c1f00e3 100644 --- a/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.txt +++ b/compiler/testData/ir/irText/lambdas/anonymousFunction.fir.txt @@ -5,7 +5,7 @@ FILE fqName: fileName:/anonymousFunction.kt FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function0 correspondingProperty: PROPERTY name:anonymous visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/lambdas/anonymousFunction.txt b/compiler/testData/ir/irText/lambdas/anonymousFunction.txt index 1a05c052836..e74f95f7e7f 100644 --- a/compiler/testData/ir/irText/lambdas/anonymousFunction.txt +++ b/compiler/testData/ir/irText/lambdas/anonymousFunction.txt @@ -5,7 +5,7 @@ FILE fqName: fileName:/anonymousFunction.kt FUN_EXPR type=kotlin.Function0 origin=ANONYMOUS_FUNCTION FUN name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function0 correspondingProperty: PROPERTY name:anonymous visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.txt index dbc0fdb1d04..eec6bd8b2d1 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.txt @@ -139,13 +139,13 @@ FILE fqName: fileName:/destructuringInLambda.kt FIELD PROPERTY_BACKING_FIELD name:fn type:kotlin.Function1<.A, kotlin.Int> visibility:private [static] EXPRESSION_BODY FUN_EXPR type=kotlin.Function1<.A, kotlin.Int> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (:.A) returnType:kotlin.Int - VALUE_PARAMETER name: index:0 type:.A + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($dstr$_u24__u24$y:.A) returnType:kotlin.Int + VALUE_PARAMETER name:$dstr$_u24__u24$y index:0 type:.A BLOCK_BODY VAR name:y type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int [operator] declared in .A' type=kotlin.Int origin=COMPONENT_N(index=2) - $this: GET_VAR ': .A declared in .fn.' type=.A origin=DESTRUCTURING_DECLARATION - RETURN type=kotlin.Nothing from='local final fun (: .A): kotlin.Int declared in .fn' + $this: GET_VAR '$dstr$_u24__u24$y: .A declared in .fn.' type=.A origin=DESTRUCTURING_DECLARATION + RETURN type=kotlin.Nothing from='local final fun ($dstr$_u24__u24$y: .A): kotlin.Int declared in .fn' CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS $this: CONST Int type=kotlin.Int value=42 other: GET_VAR 'val y: kotlin.Int [val] declared in .fn.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/lambdas/extensionLambda.fir.txt b/compiler/testData/ir/irText/lambdas/extensionLambda.fir.txt index 56bbb873c5c..22aea224ecd 100644 --- a/compiler/testData/ir/irText/lambdas/extensionLambda.fir.txt +++ b/compiler/testData/ir/irText/lambdas/extensionLambda.fir.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/extensionLambda.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Int declared in ' - CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.run [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : kotlin.String : kotlin.Int $receiver: CONST String type=kotlin.String value="42" diff --git a/compiler/testData/ir/irText/lambdas/extensionLambda.txt b/compiler/testData/ir/irText/lambdas/extensionLambda.txt index 037908ce0e8..5edcadc10ed 100644 --- a/compiler/testData/ir/irText/lambdas/extensionLambda.txt +++ b/compiler/testData/ir/irText/lambdas/extensionLambda.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/extensionLambda.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Int declared in ' - CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.run [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun run (block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : kotlin.String : kotlin.Int $receiver: CONST String type=kotlin.String value="42" diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt index 7e81e71b4c3..382de868b94 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt @@ -86,7 +86,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt VALUE_PARAMETER name:invokeImpl index:1 type:.IInvoke BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : .A : kotlin.Int receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A @@ -95,7 +95,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt $receiver: VALUE_PARAMETER name: type:.A BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test' - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : .IFoo : kotlin.Int receiver: GET_VAR 'fooImpl: .IFoo declared in .test' type=.IFoo origin=null @@ -104,7 +104,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt $receiver: VALUE_PARAMETER name: type:.IFoo BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test.' - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : .IInvoke : kotlin.Int receiver: GET_VAR 'invokeImpl: .IInvoke declared in .test' type=.IInvoke origin=null diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt index 4caa81755a8..7eaf96d43f5 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt @@ -86,7 +86,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt VALUE_PARAMETER name:invokeImpl index:1 type:.IInvoke BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : .A : kotlin.Int receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A @@ -95,7 +95,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt $receiver: VALUE_PARAMETER name:$this$with type:.A BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test' - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : .IFoo : kotlin.Int receiver: GET_VAR 'fooImpl: .IFoo declared in .test' type=.IFoo origin=null @@ -104,7 +104,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt $receiver: VALUE_PARAMETER name:$this$with type:.IFoo BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test.' - CALL 'public final fun with (receiver: T of kotlin.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.with [inline] declared in kotlin' type=kotlin.Int origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null : .IInvoke : kotlin.Int receiver: GET_VAR 'invokeImpl: .IInvoke declared in .test' type=.IInvoke origin=null diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt index 40ce2bbb3e8..765c1c3280d 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.fir.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/nonLocalReturn.kt FUN name:test0 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null : kotlin.Nothing block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing @@ -10,7 +10,7 @@ FILE fqName: fileName:/nonLocalReturn.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit @@ -19,7 +19,7 @@ FILE fqName: fileName:/nonLocalReturn.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit @@ -28,13 +28,13 @@ FILE fqName: fileName:/nonLocalReturn.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test3' - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null : kotlin.Nothing block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing @@ -44,7 +44,7 @@ FILE fqName: fileName:/nonLocalReturn.kt FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR 'ints: kotlin.collections.List declared in .testLrmFoo1' type=kotlin.collections.List origin=null action: FUN_EXPR type=kotlin.Function1 origin=LAMBDA @@ -58,12 +58,12 @@ FILE fqName: fileName:/nonLocalReturn.kt arg1: CONST Int type=kotlin.Int value=0 then: RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Unit declared in .testLrmFoo1' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'it: kotlin.Int declared in .testLrmFoo1.' type=kotlin.Int origin=null FUN name:testLrmFoo2 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR 'ints: kotlin.collections.List declared in .testLrmFoo2' type=kotlin.collections.List origin=null action: FUN_EXPR type=kotlin.Function1 origin=LAMBDA @@ -77,5 +77,5 @@ FILE fqName: fileName:/nonLocalReturn.kt arg1: CONST Int type=kotlin.Int value=0 then: RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Unit declared in .testLrmFoo2' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'it: kotlin.Int declared in .testLrmFoo2.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt index 80eec40ce6c..f138c09fb02 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt @@ -1,7 +1,7 @@ FILE fqName: fileName:/nonLocalReturn.kt FUN name:test0 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null : kotlin.Nothing block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing @@ -10,7 +10,7 @@ FILE fqName: fileName:/nonLocalReturn.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit @@ -19,7 +19,7 @@ FILE fqName: fileName:/nonLocalReturn.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit @@ -28,12 +28,12 @@ FILE fqName: fileName:/nonLocalReturn.kt GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Unit origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null : kotlin.Unit block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun run (block: kotlin.Function0): R of kotlin.run [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun run (block: kotlin.Function0): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null : kotlin.Nothing block: FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Nothing @@ -43,7 +43,7 @@ FILE fqName: fileName:/nonLocalReturn.kt FUN name:testLrmFoo1 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR 'ints: kotlin.collections.List declared in .testLrmFoo1' type=kotlin.collections.List origin=null action: FUN_EXPR type=kotlin.Function1 origin=LAMBDA @@ -57,12 +57,12 @@ FILE fqName: fileName:/nonLocalReturn.kt arg1: CONST Int type=kotlin.Int value=0 then: RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Unit declared in .testLrmFoo1' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'it: kotlin.Int declared in .testLrmFoo1.' type=kotlin.Int origin=null FUN name:testLrmFoo2 visibility:public modality:FINAL <> (ints:kotlin.collections.List) returnType:kotlin.Unit VALUE_PARAMETER name:ints index:0 type:kotlin.collections.List BLOCK_BODY - CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections' type=kotlin.Unit origin=null + CALL 'public final fun forEach (action: kotlin.Function1): kotlin.Unit [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.Unit origin=null : kotlin.Int $receiver: GET_VAR 'ints: kotlin.collections.List declared in .testLrmFoo2' type=kotlin.collections.List origin=null action: FUN_EXPR type=kotlin.Function1 origin=LAMBDA @@ -76,5 +76,5 @@ FILE fqName: fileName:/nonLocalReturn.kt arg1: CONST Int type=kotlin.Int value=0 then: RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Unit declared in .testLrmFoo2' GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit - CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun print (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: GET_VAR 'it: kotlin.Int declared in .testLrmFoo2.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/lambdas/samAdapter.txt b/compiler/testData/ir/irText/lambdas/samAdapter.txt index 8e9063340a0..128ec44dbcd 100644 --- a/compiler/testData/ir/irText/lambdas/samAdapter.txt +++ b/compiler/testData/ir/irText/lambdas/samAdapter.txt @@ -6,7 +6,7 @@ FILE fqName: fileName:/samAdapter.kt FUN_EXPR type=kotlin.Function0 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null + CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io.ConsoleKt' type=kotlin.Unit origin=null message: CONST String type=kotlin.String value="Hello, world!" CALL 'public abstract fun run (): kotlin.Unit declared in java.lang.Runnable' type=kotlin.Unit origin=null $this: GET_VAR 'val hello: java.lang.Runnable [val] declared in .test1' type=java.lang.Runnable origin=null diff --git a/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt b/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt index 7a3c773ed34..f6d21f1e33a 100644 --- a/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt +++ b/compiler/testData/ir/irText/regressions/integerCoercionToT.fir.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/integerCoercionToT.kt $receiver: VALUE_PARAMETER name: type:.CPointed BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun reinterpret (): T of .reinterpret [inline] declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null CLASS CLASS name:CInt32VarX modality:FINAL visibility:public superTypes:[.CPointed] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.CInt32VarX.CInt32VarX> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] @@ -48,7 +48,7 @@ FILE fqName: fileName:/integerCoercionToT.kt $receiver: VALUE_PARAMETER name: type:.CInt32VarX.> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): T_INT of . declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name: visibility:public modality:FINAL ($receiver:.CInt32VarX.>, value:T_INT of .) returnType:kotlin.Unit correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [var] TYPE_PARAMETER name:T_INT index:0 variance: superTypes:[kotlin.Int] diff --git a/compiler/testData/ir/irText/regressions/integerCoercionToT.txt b/compiler/testData/ir/irText/regressions/integerCoercionToT.txt index 779d67178c1..e2463c6cfd6 100644 --- a/compiler/testData/ir/irText/regressions/integerCoercionToT.txt +++ b/compiler/testData/ir/irText/regressions/integerCoercionToT.txt @@ -18,7 +18,7 @@ FILE fqName: fileName:/integerCoercionToT.kt TYPE_PARAMETER name:T index:0 variance: superTypes:[.CPointed] $receiver: VALUE_PARAMETER name: type:.CPointed BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null CLASS CLASS name:CInt32VarX modality:FINAL visibility:public superTypes:[.CPointed] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.CInt32VarX.CInt32VarX> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] @@ -46,7 +46,7 @@ FILE fqName: fileName:/integerCoercionToT.kt TYPE_PARAMETER name:T_INT index:0 variance: superTypes:[kotlin.Int] $receiver: VALUE_PARAMETER name: type:.CInt32VarX.> BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name: visibility:public modality:FINAL ($receiver:.CInt32VarX.>, value:T_INT of .) returnType:kotlin.Unit correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [var] TYPE_PARAMETER name:T_INT index:0 variance: superTypes:[kotlin.Int] diff --git a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt index 4b783de2395..6367b2e0687 100644 --- a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt +++ b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.fir.txt @@ -4,7 +4,7 @@ FILE fqName: fileName:/fixationOrder1.kt TYPE_PARAMETER name:Y index:1 variance: superTypes:[kotlin.Any?] BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Function1.foo, Y of .foo> declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null CLASS INTERFACE name:Inv2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inv2.Inv2, B of .Inv2> TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] @@ -30,7 +30,7 @@ FILE fqName: fileName:/fixationOrder1.kt VALUE_PARAMETER name:f index:2 type:kotlin.Function1.check, R of .check> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun check (x: T of .check, y: R of .check, f: kotlin.Function1.check, R of .check>): .Inv2.check, R of .check> declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:test visibility:public modality:FINAL <> () returnType:.Inv2 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (): .Inv2 declared in ' diff --git a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.txt b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.txt index e0275e6350a..53c50b78d0d 100644 --- a/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.txt +++ b/compiler/testData/ir/irText/regressions/newInference/fixationOrder1.txt @@ -3,7 +3,7 @@ FILE fqName: fileName:/fixationOrder1.kt TYPE_PARAMETER name:X index:0 variance: superTypes:[kotlin.Any?] TYPE_PARAMETER name:Y index:1 variance: superTypes:[kotlin.Any?] BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null CLASS INTERFACE name:Inv2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inv2.Inv2, B of .Inv2> TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] @@ -28,7 +28,7 @@ FILE fqName: fileName:/fixationOrder1.kt VALUE_PARAMETER name:y index:1 type:R of .check VALUE_PARAMETER name:f index:2 type:kotlin.Function1.check, R of .check> BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:test visibility:public modality:FINAL <> () returnType:.Inv2 BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (): .Inv2 declared in ' diff --git a/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.fir.txt b/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.fir.txt index 2b7343b61d9..ebf2b86679b 100644 --- a/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.fir.txt +++ b/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.fir.txt @@ -4,7 +4,7 @@ FILE fqName: fileName:/typeParametersInImplicitCast.kt VALUE_PARAMETER name:lss index:0 type:kotlin.collections.List.problematic>> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun problematic (lss: kotlin.collections.List.problematic>>): kotlin.collections.List.problematic> declared in ' - CALL 'public final fun flatMap (transform: kotlin.Function1>): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List.problematic?> origin=null + CALL 'public final fun flatMap (transform: kotlin.Function1>): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List.problematic?> origin=null : kotlin.collections.List.problematic> : T of .problematic? $receiver: GET_VAR 'lss: kotlin.collections.List.problematic>> declared in .problematic' type=kotlin.collections.List.problematic>> origin=null diff --git a/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt b/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt index bb1508f09e3..97d6f871708 100644 --- a/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt +++ b/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt @@ -4,7 +4,7 @@ FILE fqName: fileName:/typeParametersInImplicitCast.kt VALUE_PARAMETER name:lss index:0 type:kotlin.collections.List.problematic>> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun problematic (lss: kotlin.collections.List.problematic>>): kotlin.collections.List.problematic> declared in ' - CALL 'public final fun flatMap (transform: kotlin.Function1>): kotlin.collections.List [inline] declared in kotlin.collections' type=kotlin.collections.List<@[FlexibleNullability] T of .problematic?> origin=null + CALL 'public final fun flatMap (transform: kotlin.Function1>): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List<@[FlexibleNullability] T of .problematic?> origin=null : kotlin.collections.List.problematic> : @[FlexibleNullability] T of .problematic? $receiver: GET_VAR 'lss: kotlin.collections.List.problematic>> declared in .problematic' type=kotlin.collections.List.problematic>> origin=null diff --git a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt index 6ec62b253cb..8fabbc89249 100644 --- a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt +++ b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt @@ -10,13 +10,13 @@ FILE fqName: fileName:/builtinMap.kt BRANCH if: CALL 'public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null $this: GET_VAR ': kotlin.collections.Map.plus, V1 of .plus> declared in .plus' type=kotlin.collections.Map.plus, V1 of .plus> origin=null - then: CALL 'public final fun mapOf (pair: kotlin.Pair): kotlin.collections.Map declared in kotlin.collections' type=kotlin.collections.Map.plus, V1 of .plus> origin=null + then: CALL 'public final fun mapOf (pair: kotlin.Pair): kotlin.collections.Map declared in kotlin.collections.MapsKt' type=kotlin.collections.Map.plus, V1 of .plus> origin=null : K1 of .plus : V1 of .plus pair: GET_VAR 'pair: kotlin.Pair.plus, V1 of .plus> declared in .plus' type=kotlin.Pair.plus, V1 of .plus> origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=java.util.LinkedHashMap.plus?, V1 of .plus?> origin=null + then: CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=java.util.LinkedHashMap.plus?, V1 of .plus?> origin=null : java.util.LinkedHashMap.plus?, V1 of .plus?> $receiver: CONSTRUCTOR_CALL 'public constructor (p0: kotlin.collections.Map?) declared in java.util.LinkedHashMap' type=java.util.LinkedHashMap.plus?, V1 of .plus?> origin=null : K1 of .plus? diff --git a/compiler/testData/ir/irText/stubs/builtinMap.txt b/compiler/testData/ir/irText/stubs/builtinMap.txt index 7698edb6c28..1f84835c0e7 100644 --- a/compiler/testData/ir/irText/stubs/builtinMap.txt +++ b/compiler/testData/ir/irText/stubs/builtinMap.txt @@ -10,25 +10,25 @@ FILE fqName: fileName:/builtinMap.kt BRANCH if: CALL 'public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null $this: GET_VAR ': kotlin.collections.Map.plus, V1 of .plus> declared in .plus' type=kotlin.collections.Map.plus, V1 of .plus> origin=null - then: CALL 'public final fun mapOf (pair: kotlin.Pair): kotlin.collections.Map declared in kotlin.collections' type=kotlin.collections.Map.plus, V1 of .plus> origin=null + then: CALL 'public final fun mapOf (pair: kotlin.Pair): kotlin.collections.Map declared in kotlin.collections.MapsKt' type=kotlin.collections.Map.plus, V1 of .plus> origin=null : K1 of .plus : V1 of .plus pair: GET_VAR 'pair: kotlin.Pair.plus, V1 of .plus> declared in .plus' type=kotlin.Pair.plus, V1 of .plus> origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } origin=null - : java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } + then: CALL 'public final fun apply (block: @[ExtensionFunctionType] kotlin.Function1): T of kotlin.StandardKt.apply [inline] declared in kotlin.StandardKt' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } origin=null + : java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } $receiver: CONSTRUCTOR_CALL 'public constructor (p0: @[FlexibleNullability] kotlin.collections.MutableMap?) declared in java.util.LinkedHashMap' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> origin=null : @[FlexibleNullability] K1 of .plus? : @[FlexibleNullability] V1 of .plus? p0: GET_VAR ': kotlin.collections.Map.plus, V1 of .plus> declared in .plus' type=kotlin.collections.Map.plus, V1 of .plus> origin=null - block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1.plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> }, kotlin.Unit> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> }) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER name:$this$apply type:java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1.plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> }, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> }) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$apply type:java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public open fun put (key: @[EnhancedNullability] K of java.util.LinkedHashMap, value: @[EnhancedNullability] V of java.util.LinkedHashMap): @[EnhancedNullability] V of java.util.LinkedHashMap? [fake_override] declared in java.util.LinkedHashMap' type=@[EnhancedNullability] V1 of .plus? origin=null - $this: GET_VAR '$this$apply: java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } declared in .plus.' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } origin=null + $this: GET_VAR '$this$apply: java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } declared in .plus.' type=java.util.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?>{ kotlin.collections.TypeAliasesKt.LinkedHashMap<@[FlexibleNullability] K1 of .plus?, @[FlexibleNullability] V1 of .plus?> } origin=null key: CALL 'public final fun (): A of kotlin.Pair declared in kotlin.Pair' type=K1 of .plus origin=GET_PROPERTY $this: GET_VAR 'pair: kotlin.Pair.plus, V1 of .plus> declared in .plus' type=kotlin.Pair.plus, V1 of .plus> origin=null value: CALL 'public final fun (): B of kotlin.Pair declared in kotlin.Pair' type=V1 of .plus origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt index d8b8c9ab8a9..b74e4cd4ea0 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.fir.txt @@ -61,7 +61,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BuilderInference BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun unsafeFlow (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.unsafeFlow>, kotlin.Unit>): .Flow.unsafeFlow> [inline] declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.coroutines.SuspendFunction1) returnType:IrErrorType annotations: Deprecated(message = 'binary compatibility with a version w/o FlowCollector receiver', replaceWith = , level = GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:HIDDEN' type=kotlin.DeprecationLevel) @@ -199,7 +199,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BuilderInference BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun flow (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.FlowCollector.flow>, kotlin.Unit>): .Flow.flow> declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:flowScope visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>) returnType:R of .flowScope [suspend] annotations: OptIn(markerClass = [CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass]) @@ -209,7 +209,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BuilderInference BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun flowScope (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>): R of .flowScope [suspend] declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:collect visibility:public modality:FINAL ($receiver:.Flow.collect>, action:kotlin.coroutines.SuspendFunction1.collect, kotlin.Unit>) returnType:kotlin.Unit [inline,suspend] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.collect> @@ -318,7 +318,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt BuilderInference BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun produce (block: @[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.ProducerScope.produce>, kotlin.Unit>): .ReceiveChannel.produce> declared in ' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null CLASS INTERFACE name:ProducerScope modality:ABSTRACT visibility:public superTypes:[.CoroutineScope; .SendChannel.ProducerScope>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ProducerScope.ProducerScope> TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] diff --git a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt index 0b261fec251..998c6c1d66f 100644 --- a/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt +++ b/compiler/testData/ir/irText/types/castsInsideCoroutineInference.txt @@ -59,7 +59,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt annotations: BuilderInference BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:onCompletion visibility:public modality:FINAL ($receiver:.Flow.onCompletion>, action:kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'cause')] kotlin.Throwable?, kotlin.Unit>) returnType:.Flow.onCompletion> annotations: Deprecated(message = 'binary compatibility with a version w/o FlowCollector receiver', replaceWith = , level = GET_ENUM 'ENUM_ENTRY IR_EXTERNAL_DECLARATION_STUB name:HIDDEN' type=kotlin.DeprecationLevel) @@ -198,7 +198,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt annotations: BuilderInference BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:flowScope visibility:public modality:FINAL (block:@[ExtensionFunctionType] kotlin.coroutines.SuspendFunction1<.CoroutineScope, R of .flowScope>) returnType:R of .flowScope [suspend] annotations: OptIn(markerClass = [CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB ANNOTATION_CLASS name:ExperimentalTypeInference modality:FINAL visibility:public superTypes:[kotlin.Annotation]' type=kotlin.reflect.KClass]) @@ -207,7 +207,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt annotations: BuilderInference BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:collect visibility:public modality:FINAL ($receiver:.Flow.collect>, action:kotlin.coroutines.SuspendFunction1<@[ParameterName(name = 'value')] T of .collect, kotlin.Unit>) returnType:kotlin.Unit [inline,suspend] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] $receiver: VALUE_PARAMETER name: type:.Flow.collect> @@ -315,7 +315,7 @@ FILE fqName: fileName:/castsInsideCoroutineInference.kt annotations: BuilderInference BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null CLASS INTERFACE name:ProducerScope modality:ABSTRACT visibility:public superTypes:[.CoroutineScope; .SendChannel.ProducerScope>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.ProducerScope.ProducerScope> TYPE_PARAMETER name:E index:0 variance:in superTypes:[kotlin.Any?] diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt index 71b5565933a..b67f09ac012 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt @@ -175,9 +175,9 @@ FILE fqName: fileName:/enhancedNullabilityInDestructuringAssignment.kt FUN name:test4 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.IndexedValue<.P?> [val] - CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=kotlin.collections.IndexedValue<.P?> origin=null + CALL 'public final fun first (): T of kotlin.collections.CollectionsKt.first declared in kotlin.collections.CollectionsKt' type=kotlin.collections.IndexedValue<.P?> origin=null : kotlin.collections.IndexedValue<.P?> - $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections' type=kotlin.collections.Iterable.P?>> origin=null + $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.Iterable.P?>> origin=null : .P? $receiver: TYPE_OP type=kotlin.collections.List<.P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<.P?> CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P?>? declared in .J' type=kotlin.collections.List<.P?>? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt index 752f209f441..b35ef0bb0bd 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt @@ -188,9 +188,9 @@ FILE fqName: fileName:/enhancedNullabilityInDestructuringAssignment.kt BLOCK_BODY COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> [val] - CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null + CALL 'public final fun first (): T of kotlin.collections.CollectionsKt.first declared in kotlin.collections.CollectionsKt' type=kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null : kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> - $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections' type=kotlin.collections.Iterable)] @[EnhancedNullability] .P>> origin=null + $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.Iterable)] @[EnhancedNullability] .P>> origin=null : @[NotNull(value = )] @[EnhancedNullability] .P $receiver: TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.MutableList<@[NotNull(value = )] @[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.MutableList<@[NotNull(value = )] @[EnhancedNullability] .P>? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.txt b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.txt index 48b734647ea..dc5107feb34 100644 --- a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt $this: VALUE_PARAMETER name: type:.MySet BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .MySet' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:contains visibility:public modality:FINAL <> ($this:.MySet, element:kotlin.String) returnType:kotlin.Boolean [operator] overridden: public abstract fun contains (element: E of kotlin.collections.Set): kotlin.Boolean [operator] declared in kotlin.collections.Set @@ -24,7 +24,7 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt VALUE_PARAMETER name:element index:0 type:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in .MySet' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:containsAll visibility:public modality:FINAL <> ($this:.MySet, elements:kotlin.collections.Collection) returnType:kotlin.Boolean overridden: public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Set @@ -32,21 +32,21 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in .MySet' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:isEmpty visibility:public modality:FINAL <> ($this:.MySet) returnType:kotlin.Boolean overridden: public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun isEmpty (): kotlin.Boolean declared in .MySet' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:iterator visibility:public modality:FINAL <> ($this:.MySet) returnType:kotlin.collections.Iterator [operator] overridden: public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun iterator (): kotlin.collections.Iterator [operator] declared in .MySet' - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.txt b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.txt index 2e123715a37..2aaf5a3c6f7 100644 --- a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.txt +++ b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.txt @@ -15,33 +15,33 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt public abstract fun (): kotlin.Int declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:contains visibility:public modality:OPEN <> ($this:.MySet, element:kotlin.String) returnType:kotlin.Boolean [operator] overridden: public abstract fun contains (element: E of kotlin.collections.Set): kotlin.Boolean [operator] declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet VALUE_PARAMETER name:element index:0 type:kotlin.String BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:containsAll visibility:public modality:OPEN <> ($this:.MySet, elements:kotlin.collections.Collection) returnType:kotlin.Boolean overridden: public abstract fun containsAll (elements: kotlin.collections.Collection): kotlin.Boolean declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet VALUE_PARAMETER name:elements index:0 type:kotlin.collections.Collection BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:isEmpty visibility:public modality:OPEN <> ($this:.MySet) returnType:kotlin.Boolean overridden: public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:iterator visibility:public modality:OPEN <> ($this:.MySet) returnType:kotlin.collections.Iterator [operator] overridden: public abstract fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.collections.Set $this: VALUE_PARAMETER name: type:.MySet BLOCK_BODY - CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin' type=kotlin.Nothing origin=null + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.Set From 77115cea92b1813c454dc15bf799850072bfbd8e Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 17:29:53 +0300 Subject: [PATCH 088/122] [TD] Union ir dumps of different test files --- .../clashingFakeOverrideSignatures.fir.kt.txt | 172 ++++++++++++++++++ ...{kt19306_test1.fir.txt => kt19306.fir.txt} | 36 ++++ .../{kt19306_test1.txt => kt19306.txt} | 36 ++++ .../ir/irText/classes/kt19306_test2.fir.txt | 36 ---- .../ir/irText/classes/kt19306_test2.txt | 36 ---- ...SyntheticGenericPropretyAccess.fir.kt.txt} | 0 ...avaSyntheticGenericPropretyAccess.fir.txt} | 0 ...javaSyntheticGenericPropretyAccess.kt.txt} | 1 - ...=> javaSyntheticGenericPropretyAccess.txt} | 0 ...ReferenceWithIntersectionTypes.fir.kt.txt} | 0 ...eldReferenceWithIntersectionTypes.fir.txt} | 0 ...vmFieldReferenceWithIntersectionTypes.txt} | 0 ...=> signedToUnsignedConversions.fir.kt.txt} | 11 +- ...xt => signedToUnsignedConversions.fir.txt} | 17 ++ ...st.txt => signedToUnsignedConversions.txt} | 33 +++- ...oUnsignedConversions_annotation.fir.kt.txt | 6 - ...edToUnsignedConversions_annotation.fir.txt | 17 -- ...signedToUnsignedConversions_annotation.txt | 17 -- .../irText/firProblems/FirBuilder.fir.kt.txt | 20 ++ .../ir/irText/firProblems/FirBuilder.fir.txt | 31 ++++ .../ir/irText/firProblems/FirBuilder.txt | 31 ++++ ...st.fir.kt.txt => V8ArrayToList.fir.kt.txt} | 0 ...ayToList.fir.txt => V8ArrayToList.fir.txt} | 0 .../{v8arrayToList.txt => V8ArrayToList.txt} | 0 .../genericClassInDifferentModule.fir.kt.txt | 52 ++++++ ... => genericClassInDifferentModule.fir.txt} | 67 ++++++- ....txt => genericClassInDifferentModule.txt} | 59 ++++++ ...enericClassInDifferentModule_m1.fir.kt.txt | 21 --- .../genericClassInDifferentModule_m1.fir.txt | 57 ------ .../genericClassInDifferentModule_m1.txt | 57 ------ ...enericClassInDifferentModule_m2.fir.kt.txt | 24 --- .../test/runners/ir/AbstractIrTextTest.kt | 5 +- 32 files changed, 556 insertions(+), 286 deletions(-) create mode 100644 compiler/testData/ir/irText/classes/clashingFakeOverrideSignatures.fir.kt.txt rename compiler/testData/ir/irText/classes/{kt19306_test1.fir.txt => kt19306.fir.txt} (51%) rename compiler/testData/ir/irText/classes/{kt19306_test1.txt => kt19306.txt} (51%) delete mode 100644 compiler/testData/ir/irText/classes/kt19306_test2.fir.txt delete mode 100644 compiler/testData/ir/irText/classes/kt19306_test2.txt rename compiler/testData/ir/irText/expressions/{javaSyntheticGenericPropertyAccess.fir.kt.txt => javaSyntheticGenericPropretyAccess.fir.kt.txt} (100%) rename compiler/testData/ir/irText/expressions/{javaSyntheticGenericPropertyAccess.fir.txt => javaSyntheticGenericPropretyAccess.fir.txt} (100%) rename compiler/testData/ir/irText/expressions/{javaSyntheticGenericPropertyAccess.kt.txt => javaSyntheticGenericPropretyAccess.kt.txt} (99%) rename compiler/testData/ir/irText/expressions/{javaSyntheticGenericPropertyAccess.txt => javaSyntheticGenericPropretyAccess.txt} (100%) rename compiler/testData/ir/irText/expressions/{jvmFieldWithIntersectionTypes.fir.kt.txt => jvmFieldReferenceWithIntersectionTypes.fir.kt.txt} (100%) rename compiler/testData/ir/irText/expressions/{jvmFieldWithIntersectionTypes.fir.txt => jvmFieldReferenceWithIntersectionTypes.fir.txt} (100%) rename compiler/testData/ir/irText/expressions/{jvmFieldWithIntersectionTypes.txt => jvmFieldReferenceWithIntersectionTypes.txt} (100%) rename compiler/testData/ir/irText/expressions/{signedToUnsignedConversions_test.fir.kt.txt => signedToUnsignedConversions.fir.kt.txt} (83%) rename compiler/testData/ir/irText/expressions/{signedToUnsignedConversions_test.fir.txt => signedToUnsignedConversions.fir.txt} (84%) rename compiler/testData/ir/irText/expressions/{signedToUnsignedConversions_test.txt => signedToUnsignedConversions.txt} (82%) delete mode 100644 compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.txt delete mode 100644 compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.txt rename compiler/testData/ir/irText/firProblems/{v8arrayToList.fir.kt.txt => V8ArrayToList.fir.kt.txt} (100%) rename compiler/testData/ir/irText/firProblems/{v8arrayToList.fir.txt => V8ArrayToList.fir.txt} (100%) rename compiler/testData/ir/irText/firProblems/{v8arrayToList.txt => V8ArrayToList.txt} (100%) create mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.kt.txt rename compiler/testData/ir/irText/stubs/{genericClassInDifferentModule_m2.fir.txt => genericClassInDifferentModule.fir.txt} (56%) rename compiler/testData/ir/irText/stubs/{genericClassInDifferentModule_m2.txt => genericClassInDifferentModule.txt} (59%) delete mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.txt delete mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.txt delete mode 100644 compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.kt.txt diff --git a/compiler/testData/ir/irText/classes/clashingFakeOverrideSignatures.fir.kt.txt b/compiler/testData/ir/irText/classes/clashingFakeOverrideSignatures.fir.kt.txt new file mode 100644 index 00000000000..a2d4c878a57 --- /dev/null +++ b/compiler/testData/ir/irText/classes/clashingFakeOverrideSignatures.fir.kt.txt @@ -0,0 +1,172 @@ +open class Base { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun foo(x: T) { + } + + fun foo(y: String) { + } + + val T.bar: Int + get(): Int { + return 1 + } + + val String.bar: Int + get(): Int { + return 2 + } + +} + +open class Derived : Base { + constructor() /* primary */ { + super/*Base*/() + /* () */ + + } + +} + +class Derived2 : Derived { + constructor() /* primary */ { + super/*Derived*/() + /* () */ + + } + +} + +fun test(b: Base, d: Derived, d2: Derived2) { + b.foo(x = "") + b.foo(y = "") + d.foo(x = "") + d.foo(y = "") + d2.foo(x = "") + d2.foo(y = "") +} + +open class BaseXY { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun foo(x: X, y: String) { + } + + fun foo(x: String, y: Y) { + } + +} + +class DerivedXY : BaseXY { + constructor() /* primary */ { + super/*BaseXY*/() + /* () */ + + } + +} + +fun outerFun() { + local open class LocalBase { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun foo(x: T) { + } + + fun foo(y: String) { + } + + val T.bar: Int + get(): Int { + return 1 + } + + val String.bar: Int + get(): Int { + return 2 + } + + } + + local open class LocalDerived : LocalBase { + constructor() /* primary */ { + super/*LocalBase*/() + /* () */ + + } + + } + + local class LocalDerived2 : LocalDerived { + constructor() /* primary */ { + super/*LocalDerived*/() + /* () */ + + } + + } + + local fun test(b: LocalBase, d: LocalDerived, d2: LocalDerived2) { + b.foo(x = "") + b.foo(y = "") + d.foo(x = "") + d.foo(y = "") + d2.foo(x = "") + d2.foo(y = "") + } + +} + +open class Outer { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + open inner class Inner { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun foo(x: T) { + } + + fun foo(y: String) { + } + + } + +} + +class OuterDerived : Outer { + constructor() /* primary */ { + super/*Outer*/() + /* () */ + + } + + inner class InnerDerived : Inner { + constructor() /* primary */ { + .super/*Inner*/() + /* () */ + + } + + } + +} diff --git a/compiler/testData/ir/irText/classes/kt19306_test1.fir.txt b/compiler/testData/ir/irText/classes/kt19306.fir.txt similarity index 51% rename from compiler/testData/ir/irText/classes/kt19306_test1.fir.txt rename to compiler/testData/ir/irText/classes/kt19306.fir.txt index 4fa37d61152..0720e5c09c4 100644 --- a/compiler/testData/ir/irText/classes/kt19306_test1.fir.txt +++ b/compiler/testData/ir/irText/classes/kt19306.fir.txt @@ -37,3 +37,39 @@ FILE fqName:test1 fileName:/kt19306_test1.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any +FILE fqName:test2 fileName:/kt19306_test2.kt + CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test2.B + CONSTRUCTOR visibility:public <> () returnType:test2.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in test1.A' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A]' + FUN name:test visibility:public modality:FINAL <> ($this:test2.B) returnType:kotlin.Function0 + $this: VALUE_PARAMETER name: type:test2.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test (): kotlin.Function0 declared in test2.B' + FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in test2.B.test' + CALL 'protected final fun (): kotlin.String declared in test1.A' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': test2.B declared in test2.B.test' type=test2.B origin=null + PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] + FUN FAKE_OVERRIDE name: visibility:protected modality:FINAL <> ($this:test1.A) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] + overridden: + protected final fun (): kotlin.String declared in test1.A + $this: VALUE_PARAMETER name: type:test1.A + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/kt19306_test1.txt b/compiler/testData/ir/irText/classes/kt19306.txt similarity index 51% rename from compiler/testData/ir/irText/classes/kt19306_test1.txt rename to compiler/testData/ir/irText/classes/kt19306.txt index 4fa37d61152..a721f8bbb06 100644 --- a/compiler/testData/ir/irText/classes/kt19306_test1.txt +++ b/compiler/testData/ir/irText/classes/kt19306.txt @@ -37,3 +37,39 @@ FILE fqName:test1 fileName:/kt19306_test1.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any +FILE fqName:test2 fileName:/kt19306_test2.kt + CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test2.B + CONSTRUCTOR visibility:public <> () returnType:test2.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in test1.A' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A]' + FUN name:test visibility:public modality:FINAL <> ($this:test2.B) returnType:kotlin.Function0 + $this: VALUE_PARAMETER name: type:test2.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test (): kotlin.Function0 declared in test2.B' + FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in test2.B.test' + CALL 'protected final fun (): kotlin.String [fake_override] declared in test2.B' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': test2.B declared in test2.B.test' type=test2.B origin=null + PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] + FUN FAKE_OVERRIDE name: visibility:protected modality:FINAL <> ($this:test1.A) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] + overridden: + protected final fun (): kotlin.String declared in test1.A + $this: VALUE_PARAMETER name: type:test1.A + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in test1.A + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in test1.A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in test1.A + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/kt19306_test2.fir.txt b/compiler/testData/ir/irText/classes/kt19306_test2.fir.txt deleted file mode 100644 index 967a701cd4e..00000000000 --- a/compiler/testData/ir/irText/classes/kt19306_test2.fir.txt +++ /dev/null @@ -1,36 +0,0 @@ -FILE fqName:test2 fileName:/kt19306_test2.kt - CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test2.B - CONSTRUCTOR visibility:public <> () returnType:test2.B [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in test1.A' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A]' - FUN name:test visibility:public modality:FINAL <> ($this:test2.B) returnType:kotlin.Function0 - $this: VALUE_PARAMETER name: type:test2.B - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (): kotlin.Function0 declared in test2.B' - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in test2.B.test' - CALL 'protected final fun (): kotlin.String declared in test1.A' type=kotlin.String origin=GET_PROPERTY - $this: GET_VAR ': test2.B declared in test2.B.test' type=test2.B origin=null - PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] - FUN FAKE_OVERRIDE name: visibility:protected modality:FINAL <> ($this:test1.A) returnType:kotlin.String [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] - overridden: - protected final fun (): kotlin.String declared in test1.A - $this: VALUE_PARAMETER name: type:test1.A - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/kt19306_test2.txt b/compiler/testData/ir/irText/classes/kt19306_test2.txt deleted file mode 100644 index 07b3e3b2e33..00000000000 --- a/compiler/testData/ir/irText/classes/kt19306_test2.txt +++ /dev/null @@ -1,36 +0,0 @@ -FILE fqName:test2 fileName:/kt19306_test2.kt - CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test2.B - CONSTRUCTOR visibility:public <> () returnType:test2.B [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in test1.A' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[test1.A]' - FUN name:test visibility:public modality:FINAL <> ($this:test2.B) returnType:kotlin.Function0 - $this: VALUE_PARAMETER name: type:test2.B - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test (): kotlin.Function0 declared in test2.B' - FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in test2.B.test' - CALL 'protected final fun (): kotlin.String [fake_override] declared in test2.B' type=kotlin.String origin=GET_PROPERTY - $this: GET_VAR ': test2.B declared in test2.B.test' type=test2.B origin=null - PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] - FUN FAKE_OVERRIDE name: visibility:protected modality:FINAL <> ($this:test1.A) returnType:kotlin.String [fake_override] - correspondingProperty: PROPERTY FAKE_OVERRIDE name:p visibility:protected modality:FINAL [fake_override,var] - overridden: - protected final fun (): kotlin.String declared in test1.A - $this: VALUE_PARAMETER name: type:test1.A - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in test1.A - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int [fake_override] declared in test1.A - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String [fake_override] declared in test1.A - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.fir.kt.txt b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.kt.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.fir.kt.txt rename to compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.kt.txt diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.fir.txt b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.fir.txt rename to compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.fir.txt diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.kt.txt b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.kt.txt similarity index 99% rename from compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.kt.txt rename to compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.kt.txt index 0d4ca8768c5..9551f5faaf1 100644 --- a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.kt.txt +++ b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.kt.txt @@ -14,4 +14,3 @@ fun test(j: J) { tmp2_receiver.setFoo(x = tmp2_receiver.getFoo().plus(other = 1)) } } - diff --git a/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.txt b/compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/javaSyntheticGenericPropertyAccess.txt rename to compiler/testData/ir/irText/expressions/javaSyntheticGenericPropretyAccess.txt diff --git a/compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.fir.kt.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.kt.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.fir.kt.txt rename to compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.kt.txt diff --git a/compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.fir.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.fir.txt rename to compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.fir.txt diff --git a/compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.txt b/compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.txt similarity index 100% rename from compiler/testData/ir/irText/expressions/jvmFieldWithIntersectionTypes.txt rename to compiler/testData/ir/irText/expressions/jvmFieldReferenceWithIntersectionTypes.txt diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.fir.kt.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.kt.txt similarity index 83% rename from compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.fir.kt.txt rename to compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.kt.txt index 49dbb8c9740..72545183027 100644 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.kt.txt @@ -1,3 +1,13 @@ +// FILE: signedToUnsignedConversions_annotation.kt +package kotlin.internal + +annotation class ImplicitIntegerCoercion : Annotation { + constructor() /* primary */ + +} + +// FILE: signedToUnsignedConversions_test.kt + @ImplicitIntegerCoercion const val IMPLICIT_INT: Int field = 255 @@ -55,4 +65,3 @@ fun test() { error("") /* ErrorCallExpression */255; error("") /* ErrorCallExpression */255; 255; 42; } - diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.fir.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt similarity index 84% rename from compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.fir.txt rename to compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt index 9ae545d9b20..4c2e1a69dca 100644 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.fir.txt +++ b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.fir.txt @@ -1,3 +1,20 @@ +FILE fqName:kotlin.internal fileName:/signedToUnsignedConversions_annotation.kt + CLASS ANNOTATION_CLASS name:ImplicitIntegerCoercion modality:FINAL visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.internal.ImplicitIntegerCoercion + CONSTRUCTOR visibility:public <> () returnType:kotlin.internal.ImplicitIntegerCoercion [primary] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any FILE fqName: fileName:/signedToUnsignedConversions_test.kt PROPERTY name:IMPLICIT_INT visibility:public modality:FINAL [const,val] annotations: diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.txt similarity index 82% rename from compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.txt rename to compiler/testData/ir/irText/expressions/signedToUnsignedConversions.txt index 1e1e6e7e94f..3c0815c6b4e 100644 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_test.txt +++ b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions.txt @@ -1,3 +1,20 @@ +FILE fqName:kotlin.internal fileName:/signedToUnsignedConversions_annotation.kt + CLASS ANNOTATION_CLASS name:ImplicitIntegerCoercion modality:FINAL visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.internal.ImplicitIntegerCoercion + CONSTRUCTOR visibility:public <> () returnType:kotlin.internal.ImplicitIntegerCoercion [primary] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any FILE fqName: fileName:/signedToUnsignedConversions_test.kt PROPERTY name:IMPLICIT_INT visibility:public modality:FINAL [const,val] annotations: @@ -98,27 +115,27 @@ FILE fqName: fileName:/signedToUnsignedConversions_test.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun takeUByte (u: kotlin.UByte): kotlin.Unit declared in ' type=kotlin.Unit origin=null - u: CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin' type=kotlin.UByte origin=null + u: CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin.UByteKt' type=kotlin.UByte origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun takeUByte (u: kotlin.UByte): kotlin.Unit declared in ' type=kotlin.Unit origin=null - u: CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin' type=kotlin.UByte origin=null + u: CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin.UByteKt' type=kotlin.UByte origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun takeUShort (u: kotlin.UShort): kotlin.Unit declared in ' type=kotlin.Unit origin=null - u: CALL 'public final fun toUShort (): kotlin.UShort [inline] declared in kotlin' type=kotlin.UShort origin=null + u: CALL 'public final fun toUShort (): kotlin.UShort [inline] declared in kotlin.UShortKt' type=kotlin.UShort origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun takeUShort (u: kotlin.UShort): kotlin.Unit declared in ' type=kotlin.Unit origin=null - u: CALL 'public final fun toUShort (): kotlin.UShort [inline] declared in kotlin' type=kotlin.UShort origin=null + u: CALL 'public final fun toUShort (): kotlin.UShort [inline] declared in kotlin.UShortKt' type=kotlin.UShort origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun takeUInt (u: kotlin.UInt): kotlin.Unit declared in ' type=kotlin.Unit origin=null - u: CALL 'public final fun toUInt (): kotlin.UInt [inline] declared in kotlin' type=kotlin.UInt origin=null + u: CALL 'public final fun toUInt (): kotlin.UInt [inline] declared in kotlin.UIntKt' type=kotlin.UInt origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun takeULong (u: kotlin.ULong): kotlin.Unit declared in ' type=kotlin.Unit origin=null - u: CALL 'public final fun toULong (): kotlin.ULong [inline] declared in kotlin' type=kotlin.ULong origin=null + u: CALL 'public final fun toULong (): kotlin.ULong [inline] declared in kotlin.ULongKt' type=kotlin.ULong origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun takeUBytes (vararg u: kotlin.UByte): kotlin.Unit declared in ' type=kotlin.Unit origin=null u: VARARG type=kotlin.UByteArray varargElementType=kotlin.UByte - CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin' type=kotlin.UByte origin=null + CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin.UByteKt' type=kotlin.UByte origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY - CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin' type=kotlin.UByte origin=null + CALL 'public final fun toUByte (): kotlin.UByte [inline] declared in kotlin.UByteKt' type=kotlin.UByte origin=null $receiver: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY CONST Byte type=kotlin.UByte value=42 diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.kt.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.kt.txt deleted file mode 100644 index 9acc6bebb01..00000000000 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.kt.txt +++ /dev/null @@ -1,6 +0,0 @@ -package kotlin.internal - -annotation class ImplicitIntegerCoercion : Annotation { - constructor() /* primary */ - -} diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.txt deleted file mode 100644 index e5ec2b99229..00000000000 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.fir.txt +++ /dev/null @@ -1,17 +0,0 @@ -FILE fqName:kotlin.internal fileName:/signedToUnsignedConversions_annotation.kt - CLASS ANNOTATION_CLASS name:ImplicitIntegerCoercion modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.internal.ImplicitIntegerCoercion - CONSTRUCTOR visibility:public <> () returnType:kotlin.internal.ImplicitIntegerCoercion [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.txt b/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.txt deleted file mode 100644 index dcd425b4b48..00000000000 --- a/compiler/testData/ir/irText/expressions/signedToUnsignedConversions_annotation.txt +++ /dev/null @@ -1,17 +0,0 @@ -FILE fqName:kotlin.internal fileName:/signedToUnsignedConversions_annotation.kt - CLASS ANNOTATION_CLASS name:ImplicitIntegerCoercion modality:FINAL visibility:public superTypes:[kotlin.Annotation] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:kotlin.internal.ImplicitIntegerCoercion - CONSTRUCTOR visibility:public <> () returnType:kotlin.internal.ImplicitIntegerCoercion [primary] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt index 62fa200f594..aab5e1a0795 100644 --- a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.kt.txt @@ -1,3 +1,22 @@ +// MODULE: m1 +// FILE: BaseFirBuilder.kt + +abstract class BaseFirBuilder { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + inline fun withCapturedTypeParameters(block: Function0): T { + return block.invoke() + } + +} + +// MODULE: m2 +// FILE: FirBuilder.kt + open class BaseConverter : BaseFirBuilder { constructor() /* primary */ { super/*BaseFirBuilder*/() @@ -15,3 +34,4 @@ class DeclarationsConverter : BaseConverter { } } + diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt index 8e2d8a94752..107db8c8551 100644 --- a/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.fir.txt @@ -1,3 +1,34 @@ +Module: m1 +FILE fqName: fileName:/BaseFirBuilder.kt + CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseFirBuilder.BaseFirBuilder> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.BaseFirBuilder.BaseFirBuilder> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + FUN name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder.BaseFirBuilder>, block:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>) returnType:T of .BaseFirBuilder.withCapturedTypeParameters [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder.BaseFirBuilder> + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .BaseFirBuilder.withCapturedTypeParameters origin=INVOKE + $this: GET_VAR 'block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> declared in .BaseFirBuilder.withCapturedTypeParameters' type=kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> origin=VARIABLE_AS_FUNCTION + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any +Module: m2 FILE fqName: fileName:/FirBuilder.kt CLASS CLASS name:BaseConverter modality:OPEN visibility:public superTypes:[.BaseFirBuilder] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseConverter diff --git a/compiler/testData/ir/irText/firProblems/FirBuilder.txt b/compiler/testData/ir/irText/firProblems/FirBuilder.txt index f71e2079911..8043b0f6957 100644 --- a/compiler/testData/ir/irText/firProblems/FirBuilder.txt +++ b/compiler/testData/ir/irText/firProblems/FirBuilder.txt @@ -1,3 +1,34 @@ +Module: m1 +FILE fqName: fileName:/BaseFirBuilder.kt + CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseFirBuilder.BaseFirBuilder> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> () returnType:.BaseFirBuilder.BaseFirBuilder> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseFirBuilder modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + FUN name:withCapturedTypeParameters visibility:public modality:FINAL ($this:.BaseFirBuilder.BaseFirBuilder>, block:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>) returnType:T of .BaseFirBuilder.withCapturedTypeParameters [inline] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.BaseFirBuilder.BaseFirBuilder> + VALUE_PARAMETER name:block index:0 type:kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withCapturedTypeParameters (block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters>): T of .BaseFirBuilder.withCapturedTypeParameters [inline] declared in .BaseFirBuilder' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .BaseFirBuilder.withCapturedTypeParameters origin=INVOKE + $this: GET_VAR 'block: kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> declared in .BaseFirBuilder.withCapturedTypeParameters' type=kotlin.Function0.BaseFirBuilder.withCapturedTypeParameters> origin=VARIABLE_AS_FUNCTION + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any +Module: m2 FILE fqName: fileName:/FirBuilder.kt CLASS CLASS name:BaseConverter modality:OPEN visibility:public superTypes:[.BaseFirBuilder] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.BaseConverter diff --git a/compiler/testData/ir/irText/firProblems/v8arrayToList.fir.kt.txt b/compiler/testData/ir/irText/firProblems/V8ArrayToList.fir.kt.txt similarity index 100% rename from compiler/testData/ir/irText/firProblems/v8arrayToList.fir.kt.txt rename to compiler/testData/ir/irText/firProblems/V8ArrayToList.fir.kt.txt diff --git a/compiler/testData/ir/irText/firProblems/v8arrayToList.fir.txt b/compiler/testData/ir/irText/firProblems/V8ArrayToList.fir.txt similarity index 100% rename from compiler/testData/ir/irText/firProblems/v8arrayToList.fir.txt rename to compiler/testData/ir/irText/firProblems/V8ArrayToList.fir.txt diff --git a/compiler/testData/ir/irText/firProblems/v8arrayToList.txt b/compiler/testData/ir/irText/firProblems/V8ArrayToList.txt similarity index 100% rename from compiler/testData/ir/irText/firProblems/v8arrayToList.txt rename to compiler/testData/ir/irText/firProblems/V8ArrayToList.txt diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.kt.txt new file mode 100644 index 00000000000..95c3a55ee57 --- /dev/null +++ b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.kt.txt @@ -0,0 +1,52 @@ +// MODULE: m1 +// FILE: genericClassInDifferentModule_m1.kt + +abstract class Base { + constructor(x: T) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: T + field = x + get + + abstract fun foo(y: Y): T + abstract var bar: T + abstract get + abstract set + + abstract var Z.exn: T + abstract get + abstract set + +} + +// MODULE: m2 +// FILE: genericClassInDifferentModule_m2.kt + +class Derived1 : Base { + constructor(x: T) /* primary */ { + super/*Base*/(x = x) + /* () */ + + } + + override fun foo(y: Y): T { + return .() + } + + override var bar: T + field = x + override get + override set + + override var Z.exn: T + override get(): T { + return .() + } + override set(value: T) { + } + +} diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt similarity index 56% rename from compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.txt rename to compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt index 5313447e273..6c4b4159ebf 100644 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.txt +++ b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.fir.txt @@ -1,3 +1,62 @@ +Module: m1 +FILE fqName: fileName:/genericClassInDifferentModule_m1.kt + CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base.Base> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (x:T of .Base) returnType:.Base.Base> [primary] + VALUE_PARAMETER name:x index:0 type:T of .Base + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: T of .Base declared in .Base.' type=T of .Base origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base.Base>) returnType:T of .Base + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base.Base> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of .Base declared in .Base' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final]' type=T of .Base origin=null + receiver: GET_VAR ': .Base.Base> declared in .Base.' type=.Base.Base> origin=null + FUN name:foo visibility:public modality:ABSTRACT ($this:.Base.Base>, y:Y of .Base.foo) returnType:T of .Base + TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Base.Base> + VALUE_PARAMETER name:y index:0 type:Y of .Base.foo + PROPERTY name:bar visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>) returnType:T of .Base + correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.Base.Base> + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>, :T of .Base) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.Base.Base> + VALUE_PARAMETER name: index:0 type:T of .Base + PROPERTY name:exn visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base.) returnType:T of .Base + correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] + TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Base.Base> + $receiver: VALUE_PARAMETER name: type:Z of .Base. + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base., :T of .Base) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] + TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Base.Base> + $receiver: VALUE_PARAMETER name: type:Z of .Base. + VALUE_PARAMETER name: index:0 type:T of .Base + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any +Module: m2 FILE fqName: fileName:/genericClassInDifferentModule_m2.kt CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base.Derived1>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived1.Derived1> @@ -26,7 +85,7 @@ FILE fqName: fileName:/genericClassInDifferentModule_m2.kt FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Derived1.Derived1>) returnType:T of .Derived1 correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [var] overridden: - public abstract fun (): T of .Base declared in .Base + public final fun (): T of .Base declared in .Base $this: VALUE_PARAMETER name: type:.Derived1.Derived1> BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): T of .Derived1 declared in .Derived1' @@ -35,7 +94,7 @@ FILE fqName: fileName:/genericClassInDifferentModule_m2.kt FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Derived1.Derived1>, :T of .Derived1) returnType:kotlin.Unit correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [var] overridden: - public abstract fun (: T of .Base): kotlin.Unit declared in .Base + public final fun (: T of .Base): kotlin.Unit declared in .Base $this: VALUE_PARAMETER name: type:.Derived1.Derived1> VALUE_PARAMETER name: index:0 type:T of .Derived1 BLOCK_BODY @@ -46,7 +105,7 @@ FILE fqName: fileName:/genericClassInDifferentModule_m2.kt FUN name: visibility:public modality:FINAL ($this:.Derived1.Derived1>, $receiver:Z of .Derived1.) returnType:T of .Derived1 correspondingProperty: PROPERTY name:exn visibility:public modality:FINAL [var] overridden: - public abstract fun (): T of .Base declared in .Base + public final fun (): T of .Base declared in .Base TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] $this: VALUE_PARAMETER name: type:.Derived1.Derived1> $receiver: VALUE_PARAMETER name: type:Z of .Derived1. @@ -57,7 +116,7 @@ FILE fqName: fileName:/genericClassInDifferentModule_m2.kt FUN name: visibility:public modality:FINAL ($this:.Derived1.Derived1>, $receiver:Z of .Derived1., value:T of .Derived1) returnType:kotlin.Unit correspondingProperty: PROPERTY name:exn visibility:public modality:FINAL [var] overridden: - public abstract fun (: T of .Base): kotlin.Unit declared in .Base + public final fun (: T of .Base): kotlin.Unit declared in .Base TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] $this: VALUE_PARAMETER name: type:.Derived1.Derived1> $receiver: VALUE_PARAMETER name: type:Z of .Derived1. diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.txt similarity index 59% rename from compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.txt rename to compiler/testData/ir/irText/stubs/genericClassInDifferentModule.txt index b78a131f60d..557bab4ce4b 100644 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.txt +++ b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule.txt @@ -1,3 +1,62 @@ +Module: m1 +FILE fqName: fileName:/genericClassInDifferentModule_m1.kt + CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base.Base> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (x:T of .Base) returnType:.Base.Base> [primary] + VALUE_PARAMETER name:x index:0 type:T of .Base + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: T of .Base declared in .Base.' type=T of .Base origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base.Base>) returnType:T of .Base + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Base.Base> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of .Base declared in .Base' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final]' type=T of .Base origin=null + receiver: GET_VAR ': .Base.Base> declared in .Base.' type=.Base.Base> origin=null + FUN name:foo visibility:public modality:ABSTRACT ($this:.Base.Base>, y:Y of .Base.foo) returnType:T of .Base + TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Base.Base> + VALUE_PARAMETER name:y index:0 type:Y of .Base.foo + PROPERTY name:bar visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>) returnType:T of .Base + correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.Base.Base> + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>, :T of .Base) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] + $this: VALUE_PARAMETER name: type:.Base.Base> + VALUE_PARAMETER name: index:0 type:T of .Base + PROPERTY name:exn visibility:public modality:ABSTRACT [var] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base.) returnType:T of .Base + correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] + TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Base.Base> + $receiver: VALUE_PARAMETER name: type:Z of .Base. + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base., :T of .Base) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] + TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] + $this: VALUE_PARAMETER name: type:.Base.Base> + $receiver: VALUE_PARAMETER name: type:Z of .Base. + VALUE_PARAMETER name: index:0 type:T of .Base + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any +Module: m2 FILE fqName: fileName:/genericClassInDifferentModule_m2.kt CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[.Base.Derived1>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived1.Derived1> diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.kt.txt deleted file mode 100644 index 75c23ef42be..00000000000 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.kt.txt +++ /dev/null @@ -1,21 +0,0 @@ -abstract class Base { - constructor(x: T) /* primary */ { - super/*Any*/() - /* () */ - - } - - val x: T - field = x - get - - abstract fun foo(y: Y): T - abstract var bar: T - abstract get - abstract set - - abstract var Z.exn: T - abstract get - abstract set - -} diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.txt deleted file mode 100644 index 550fbf0e573..00000000000 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.fir.txt +++ /dev/null @@ -1,57 +0,0 @@ -FILE fqName: fileName:/genericClassInDifferentModule_m1.kt - CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base.Base> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - CONSTRUCTOR visibility:public <> (x:T of .Base) returnType:.Base.Base> [primary] - VALUE_PARAMETER name:x index:0 type:T of .Base - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: T of .Base declared in .Base.' type=T of .Base origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base.Base>) returnType:T of .Base - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Base.Base> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): T of .Base declared in .Base' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final]' type=T of .Base origin=null - receiver: GET_VAR ': .Base.Base> declared in .Base.' type=.Base.Base> origin=null - FUN name:foo visibility:public modality:ABSTRACT ($this:.Base.Base>, y:Y of .Base.foo) returnType:T of .Base - TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.Base.Base> - VALUE_PARAMETER name:y index:0 type:Y of .Base.foo - PROPERTY name:bar visibility:public modality:ABSTRACT [var] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>) returnType:T of .Base - correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] - $this: VALUE_PARAMETER name: type:.Base.Base> - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>, :T of .Base) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] - $this: VALUE_PARAMETER name: type:.Base.Base> - VALUE_PARAMETER name: index:0 type:T of .Base - PROPERTY name:exn visibility:public modality:ABSTRACT [var] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base.) returnType:T of .Base - correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] - TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.Base.Base> - $receiver: VALUE_PARAMETER name: type:Z of .Base. - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base., :T of .Base) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] - TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.Base.Base> - $receiver: VALUE_PARAMETER name: type:Z of .Base. - VALUE_PARAMETER name: index:0 type:T of .Base - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.txt deleted file mode 100644 index 550fbf0e573..00000000000 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m1.txt +++ /dev/null @@ -1,57 +0,0 @@ -FILE fqName: fileName:/genericClassInDifferentModule_m1.kt - CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Base.Base> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - CONSTRUCTOR visibility:public <> (x:T of .Base) returnType:.Base.Base> [primary] - VALUE_PARAMETER name:x index:0 type:T of .Base - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]' - PROPERTY name:x visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final] - EXPRESSION_BODY - GET_VAR 'x: T of .Base declared in .Base.' type=T of .Base origin=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Base.Base>) returnType:T of .Base - correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] - $this: VALUE_PARAMETER name: type:.Base.Base> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): T of .Base declared in .Base' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Base visibility:private [final]' type=T of .Base origin=null - receiver: GET_VAR ': .Base.Base> declared in .Base.' type=.Base.Base> origin=null - FUN name:foo visibility:public modality:ABSTRACT ($this:.Base.Base>, y:Y of .Base.foo) returnType:T of .Base - TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.Base.Base> - VALUE_PARAMETER name:y index:0 type:Y of .Base.foo - PROPERTY name:bar visibility:public modality:ABSTRACT [var] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>) returnType:T of .Base - correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] - $this: VALUE_PARAMETER name: type:.Base.Base> - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Base.Base>, :T of .Base) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:bar visibility:public modality:ABSTRACT [var] - $this: VALUE_PARAMETER name: type:.Base.Base> - VALUE_PARAMETER name: index:0 type:T of .Base - PROPERTY name:exn visibility:public modality:ABSTRACT [var] - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base.) returnType:T of .Base - correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] - TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.Base.Base> - $receiver: VALUE_PARAMETER name: type:Z of .Base. - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT ($this:.Base.Base>, $receiver:Z of .Base., :T of .Base) returnType:kotlin.Unit - correspondingProperty: PROPERTY name:exn visibility:public modality:ABSTRACT [var] - TYPE_PARAMETER name:Z index:0 variance: superTypes:[kotlin.Any?] - $this: VALUE_PARAMETER name: type:.Base.Base> - $receiver: VALUE_PARAMETER name: type:Z of .Base. - VALUE_PARAMETER name: index:0 type:T of .Base - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.kt.txt b/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.kt.txt deleted file mode 100644 index 09a09d03532..00000000000 --- a/compiler/testData/ir/irText/stubs/genericClassInDifferentModule_m2.fir.kt.txt +++ /dev/null @@ -1,24 +0,0 @@ -class Derived1 : Base { - constructor(x: T) /* primary */ { - super/*Base*/(x = x) - /* () */ - - } - - override fun foo(y: Y): T { - return .() - } - - override var bar: T - field = x - override get - override set - - override var Z.exn: T - override get(): T { - return .() - } - override set(value: T) { - } - -} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt index 410ff9b9c40..648532c3c0a 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/ir/AbstractIrTextTest.kt @@ -75,7 +75,10 @@ open class AbstractFir2IrTextTest : AbstractIrTextTestBase(FrontendKinds.FIR) { override fun configure(builder: TestConfigurationBuilder) { super.configure(builder) with(builder) { - useAfterAnalysisCheckers(::FirIrDumpIdenticalChecker) + useAfterAnalysisCheckers( + ::FirIrDumpIdenticalChecker, + ::BlackBoxCodegenSuppressor + ) } } } From 842ed624a7bff345b2e71510ec28122ba9a38dec Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 17:36:20 +0300 Subject: [PATCH 089/122] [TD] Remove some outdated dumps in FIR_IDENTICAL tests --- .../nullableAnyAsIntToDouble.fir.kt.txt | 6 ------ compiler/testData/ir/irText/expressions/kt36963.fir.kt.txt | 6 ------ 2 files changed, 12 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/kt36963.fir.kt.txt diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.kt.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.kt.txt deleted file mode 100644 index 88e971888fe..00000000000 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.kt.txt +++ /dev/null @@ -1,6 +0,0 @@ -fun test(x: Any?, y: Double): Boolean { - return when { - x is Int -> less(arg0 = x /*as Int */.toDouble(), arg1 = y) - else -> false - } -} diff --git a/compiler/testData/ir/irText/expressions/kt36963.fir.kt.txt b/compiler/testData/ir/irText/expressions/kt36963.fir.kt.txt deleted file mode 100644 index 1121fbdab3a..00000000000 --- a/compiler/testData/ir/irText/expressions/kt36963.fir.kt.txt +++ /dev/null @@ -1,6 +0,0 @@ -fun foo() { -} - -fun test(): KFunction0 { - return CHECK_NOT_NULL>(arg0 = ::foo) -} From b9e9620ab598f9a6422d89c5c806f5dfde7352ea Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 20 Jan 2021 17:41:09 +0300 Subject: [PATCH 090/122] [TD] Unmute passing Fir2Ir text test --- .../testData/ir/irText/expressions/funInterface/partialSam.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/testData/ir/irText/expressions/funInterface/partialSam.kt b/compiler/testData/ir/irText/expressions/funInterface/partialSam.kt index 9050b87fc45..b14009b0d4e 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/partialSam.kt +++ b/compiler/testData/ir/irText/expressions/funInterface/partialSam.kt @@ -1,7 +1,6 @@ // !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions // TARGET_BACKEND: JVM // IGNORE_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR // WITH_RUNTIME fun interface Fn { @@ -25,4 +24,4 @@ val fis = object : Fn { fun test(j: J) { j.runConversion(fsi) { s, i, ti -> ""} j.runConversion({ s, i, ts -> 1 }, fis) -} \ No newline at end of file +} From 0d058c7c8cee9a30a378df3d5232bba659a00b7b Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 21 Jan 2021 11:32:15 +0300 Subject: [PATCH 091/122] [Test] Allow parse FILE and MODULE directives with other strings between them in old tests --- .../org/jetbrains/kotlin/test/TestFiles.java | 96 ++++++++++++------- 1 file changed, 59 insertions(+), 37 deletions(-) diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestFiles.java b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestFiles.java index 796dd81e0b8..ae54d7ef45a 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestFiles.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/test/TestFiles.java @@ -33,9 +33,8 @@ public class TestFiles { */ private static final String MODULE_DELIMITER = ",\\s*"; - private static final Pattern FILE_OR_MODULE_PATTERN = Pattern.compile( - "(?://\\s*MODULE:\\s*([^()\\n]+)(?:\\(([^()]+(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*(?:\\(([^()]+(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*)?" + - "//\\s*FILE:\\s*(.*)$", Pattern.MULTILINE); + private static final Pattern MODULE_PATTERN = Pattern.compile("//\\s*MODULE:\\s*([^()\\n]+)(?:\\(([^()]+(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\\s*(?:\\(([^()]+(?:" + MODULE_DELIMITER + "[^()]+)*)\\))?\n"); + private static final Pattern FILE_PATTERN = Pattern.compile("//\\s*FILE:\\s*(.*)\n"); private static final Pattern LINE_SEPARATOR_PATTERN = Pattern.compile("\\r\\n|\\r|\\n"); @@ -55,10 +54,14 @@ public class TestFiles { boolean preserveLocations, boolean parseDirectivesPerFile) { Map modules = new HashMap<>(); List testFiles = Lists.newArrayList(); - Matcher matcher = FILE_OR_MODULE_PATTERN.matcher(expectedText); + Matcher fileMatcher = FILE_PATTERN.matcher(expectedText); + Matcher moduleMatcher = MODULE_PATTERN.matcher(expectedText); boolean hasModules = false; String commonPrefixOrWholeFile; - if (!matcher.find()) { + + boolean fileFound = fileMatcher.find(); + boolean moduleFound = moduleMatcher.find(); + if (!fileFound && !moduleFound) { assert testFileName != null : "testFileName should not be null if no FILE directive defined"; // One file testFiles.add(factory.createFile(null, testFileName, expectedText, parseDirectives(expectedText))); @@ -69,45 +72,64 @@ public class TestFiles { int processedChars = 0; M module = null; boolean firstFileProcessed = false; - commonPrefixOrWholeFile = expectedText.substring(0, matcher.start()); + + int commonStart; + if (moduleFound) { + commonStart = moduleMatcher.start(); + } else { + commonStart = fileMatcher.start(); + } + + commonPrefixOrWholeFile = expectedText.substring(0, commonStart); // Many files while (true) { - String moduleName = matcher.group(1); - String moduleDependencies = matcher.group(2); - String moduleFriends = matcher.group(3); - if (moduleName != null) { - moduleName = moduleName.trim(); - hasModules = true; - module = factory.createModule(moduleName, parseModuleList(moduleDependencies), parseModuleList(moduleFriends)); - M oldValue = modules.put(moduleName, module); - assert oldValue == null : "Module with name " + moduleName + " already present in file"; + if (moduleFound) { + String moduleName = moduleMatcher.group(1); + String moduleDependencies = moduleMatcher.group(2); + String moduleFriends = moduleMatcher.group(3); + if (moduleName != null) { + moduleName = moduleName.trim(); + hasModules = true; + module = factory.createModule(moduleName, parseModuleList(moduleDependencies), parseModuleList(moduleFriends)); + M oldValue = modules.put(moduleName, module); + assert oldValue == null : "Module with name " + moduleName + " already present in file"; + } } - String fileName = matcher.group(4); - int start = processedChars; + boolean nextModuleExists = moduleMatcher.find(); + moduleFound = nextModuleExists; + while (true) { + String fileName = fileMatcher.group(1); + int start = processedChars; - boolean nextFileExists = matcher.find(); - int end; - if (nextFileExists) { - end = matcher.start(); + boolean nextFileExists = fileMatcher.find(); + int end; + if (nextFileExists && nextModuleExists) { + end = Math.min(fileMatcher.start(), moduleMatcher.start()); + } + else if (nextFileExists) { + end = fileMatcher.start(); + } + else { + end = expectedText.length(); + } + String fileText = preserveLocations ? + substringKeepingLocations(expectedText, start, end) : + expectedText.substring(start, end); + + + String expectedText1 = firstFileProcessed ? commonPrefixOrWholeFile + fileText : fileText; + testFiles.add(factory.createFile(module, fileName, fileText, + parseDirectivesPerFile ? + parseDirectives(expectedText1) + : allFilesOrCommonPrefixDirectives)); + processedChars = end; + firstFileProcessed = true; + if (!nextFileExists && !nextModuleExists) break; + if (nextModuleExists && fileMatcher.start() > moduleMatcher.start()) break; } - else { - end = expectedText.length(); - } - String fileText = preserveLocations ? - substringKeepingLocations(expectedText, start, end) : - expectedText.substring(start,end); - - - String expectedText1 = firstFileProcessed ? commonPrefixOrWholeFile + fileText : fileText; - testFiles.add(factory.createFile(module, fileName, fileText, - parseDirectivesPerFile ? - parseDirectives(expectedText1) - : allFilesOrCommonPrefixDirectives)); - processedChars = end; - firstFileProcessed = true; - if (!nextFileExists) break; + if (!nextModuleExists) break; } assert processedChars == expectedText.length() : "Characters skipped from " + processedChars + From c4237509621ab29921ab67dc9636a977bf1afc1d Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 22 Jan 2021 10:30:25 +0300 Subject: [PATCH 092/122] [TD] Fix incorrect module structure directives in test data file --- .../codegen/box/properties/lazyInitializationMultiModule.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/testData/codegen/box/properties/lazyInitializationMultiModule.kt b/compiler/testData/codegen/box/properties/lazyInitializationMultiModule.kt index 760168d7f46..0f6375e28b6 100644 --- a/compiler/testData/codegen/box/properties/lazyInitializationMultiModule.kt +++ b/compiler/testData/codegen/box/properties/lazyInitializationMultiModule.kt @@ -2,9 +2,11 @@ // PROPERTY_LAZY_INITIALIZATION // MODULE: lib1 +// FILE: lib.kt var log = "" val a = 1.also { log += "a" } val b = 2.also { log += "b" } // MODULE: main(lib1) -fun box(): String = if (log + a == "ab1") "OK" else "fail" \ No newline at end of file +// FILE: main.kt +fun box(): String = if (log + a == "ab1") "OK" else "fail" From d2ce73853daa70f7c3b9dd18b40c732d462b8fae Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 21 Jan 2021 16:23:03 +0300 Subject: [PATCH 093/122] Report more specific diagnostic for variable + invoke calls Do not report same set of diagnostics for variable call if actual error was happened with a function candidate. Here the candidate is invoke function on DeepRecursiveFunction ^KT-40991 Fixed ^KT-41491 Fixed ^KT-40926 In Progress --- ...irOldFrontendDiagnosticsTestGenerated.java | 6 +++++ .../tower/KotlinToResolvedCallTransformer.kt | 6 +++-- .../specialCallsWithCallableReferences.kt | 2 +- ...functionExpectedWhenSeveralInvokesExist.kt | 2 +- ...tFunctionExpectedOnSimpleUnresolved.fir.kt | 16 ++++++++++++ ...eportFunctionExpectedOnSimpleUnresolved.kt | 16 ++++++++++++ ...portFunctionExpectedOnSimpleUnresolved.txt | 25 +++++++++++++++++++ ...eportFunctionExpectedWhenOneInvokeExist.kt | 2 +- .../test/runners/DiagnosticTestGenerated.java | 6 +++++ 9 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt create mode 100644 compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 5db974d7ab7..a6b54dd2470 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -22962,6 +22962,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt"); } + @Test + @TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt") + public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt"); + } + @Test @TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt") public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt index fd143748cf1..af4e965302c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/KotlinToResolvedCallTransformer.kt @@ -205,10 +205,12 @@ class KotlinToResolvedCallTransformer( ): ResolvedCall { val psiKotlinCall = completedCallAtom.atom.psiKotlinCall return if (psiKotlinCall is PSIKotlinCallForInvoke) { + val diagnosticsForVariableCall = if (completedCallAtom.candidateDescriptor is FunctionDescriptor) emptyList() else diagnostics + val diagnosticsForFunctionCall = if (completedCallAtom.candidateDescriptor is FunctionDescriptor) diagnostics else emptyList() @Suppress("UNCHECKED_CAST") NewVariableAsFunctionResolvedCallImpl( - createOrGet(psiKotlinCall.variableCall.resolvedCall, trace, resultSubstitutor, diagnostics), - createOrGet(completedCallAtom, trace, resultSubstitutor, diagnostics), + createOrGet(psiKotlinCall.variableCall.resolvedCall, trace, resultSubstitutor, diagnosticsForVariableCall), + createOrGet(completedCallAtom, trace, resultSubstitutor, diagnosticsForFunctionCall), ) as ResolvedCall } else { createOrGet(completedCallAtom, trace, resultSubstitutor, diagnostics) diff --git a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt index 2ee1eebab8f..45c41ac0bbf 100644 --- a/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt +++ b/compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt @@ -275,7 +275,7 @@ fun poll8() { fun poll81() { val inv = ::bar2 in setOf(::foo2) - inv() + inv() } fun poll82() { diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt b/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt index cdcac34ffd7..aa925573843 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt @@ -7,7 +7,7 @@ fun Int.invoke(a: Int, b: Int) {} class SomeClass fun test(identifier: SomeClass, fn: String.() -> Unit) { - identifier() + identifier() identifier(123) identifier(1, 2) 1.fn() diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt new file mode 100644 index 00000000000..742e829b7aa --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.fir.kt @@ -0,0 +1,16 @@ +object Scope1 { + val someVar: Any = Any() + + fun foo() { + someVar(1) + } +} + +object Scope2 { + class Foo + + fun use() { + val foo = Foo() + foo() + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt new file mode 100644 index 00000000000..b6ef7b7e525 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt @@ -0,0 +1,16 @@ +object Scope1 { + val someVar: Any = Any() + + fun foo() { + someVar(1) + } +} + +object Scope2 { + class Foo + + fun use() { + val foo = Foo() + foo() + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt new file mode 100644 index 00000000000..994753b0225 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.txt @@ -0,0 +1,25 @@ +package + +public object Scope1 { + private constructor Scope1() + public final val someVar: kotlin.Any + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Scope2 { + private constructor Scope2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public final fun use(): kotlin.Unit + + public final class Foo { + public constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt index fccb7472ec7..ddf18776e96 100644 --- a/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt +++ b/compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt @@ -6,7 +6,7 @@ fun Int.invoke() {} class SomeClass fun test(identifier: SomeClass, fn: String.() -> Unit) { - identifier() + identifier() identifier(123) identifier(1, 2) 1.fn() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 6a69a0267a1..cc0bb43c59b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -22974,6 +22974,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt"); } + @Test + @TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt") + public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception { + runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt"); + } + @Test @TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt") public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception { From a33877a9b9784402d5a6f8eedbbf63d8adf9ae38 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 21 Jan 2021 16:24:26 +0300 Subject: [PATCH 094/122] Fix add import quick fix for unresolved conventional invoke operator After adding extension invoke on DeepRecursiveFunction in 1.4, the compiler start reporting another error and now it doesn't write info about callable descriptor. Therefore it's needed to use another source of info for expression type ^KT-40926 Fixed --- .../kotlin/idea/quickfix/AbstractImportFix.kt | 11 ++++++++--- .../ImportOperatorInvokeWithConvention.after.kt | 12 ++++++++++++ ...OperatorInvokeWithConvention.before.Dependency.kt | 6 ++++++ ...ImportOperatorInvokeWithConvention.before.Main.kt | 11 +++++++++++ .../quickfix/QuickFixMultiFileTestGenerated.java | 5 +++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.after.kt create mode 100644 idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Dependency.kt create mode 100644 idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Main.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AbstractImportFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AbstractImportFix.kt index bbad816414e..7d5ccb1c24e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AbstractImportFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AbstractImportFix.kt @@ -85,6 +85,7 @@ internal abstract class ImportFixBase protected constructor( protected abstract val importNames: Collection protected abstract fun getCallTypeAndReceiver(): CallTypeAndReceiver<*, *>? + protected open fun getReceiverTypeFromDiagnostic(): KotlinType? = null override fun showHint(editor: Editor): Boolean { val element = element ?: return false @@ -251,7 +252,7 @@ internal abstract class OrdinaryImportFixBase(expression: T, f indicesHelper.getTopLevelCallablesByName(name).filterTo(result, filterByCallType) } if (callTypeAndReceiver.callType == CallType.OPERATOR) { - val type = expression.getCallableDescriptor()?.returnType + val type = expression.getCallableDescriptor()?.returnType ?: getReceiverTypeFromDiagnostic() if (type != null) { result.addAll(indicesHelper.getCallableTopLevelExtensions(callTypeAndReceiver, listOf(type), { it == name })) } @@ -432,14 +433,18 @@ internal class ImportConstructorReferenceFix(expression: KtSimpleNameExpression) } } -internal class InvokeImportFix(expression: KtExpression) : OrdinaryImportFixBase(expression, MyFactory) { +internal class InvokeImportFix( + expression: KtExpression, val diagnostic: Diagnostic +) : OrdinaryImportFixBase(expression, MyFactory) { override val importNames = listOf(OperatorNameConventions.INVOKE) override fun getCallTypeAndReceiver() = element?.let { CallTypeAndReceiver.OPERATOR(it) } + override fun getReceiverTypeFromDiagnostic(): KotlinType = Errors.FUNCTION_EXPECTED.cast(diagnostic).b + companion object MyFactory : Factory() { override fun createImportAction(diagnostic: Diagnostic) = - (diagnostic.psiElement as? KtExpression)?.let(::InvokeImportFix) + (diagnostic.psiElement as? KtExpression)?.let { InvokeImportFix(it, diagnostic) } } } diff --git a/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.after.kt b/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.after.kt new file mode 100644 index 00000000000..4bfe41ecb25 --- /dev/null +++ b/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.after.kt @@ -0,0 +1,12 @@ +// "Import" "true" +// WITH_RUNTIME +// ERROR: Expression 'topVal' of type 'SomeType' cannot be invoked as a function. The function 'invoke()' is not found + +package mig + +import another.invoke +import another.topVal + +fun use() { + topVal() +} \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Dependency.kt b/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Dependency.kt new file mode 100644 index 00000000000..cf68d759222 --- /dev/null +++ b/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Dependency.kt @@ -0,0 +1,6 @@ +package another + +interface SomeType + +operator fun SomeType.invoke() {} +val topVal = object : SomeType {} \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Main.kt b/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Main.kt new file mode 100644 index 00000000000..0bf6613e0ff --- /dev/null +++ b/idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Main.kt @@ -0,0 +1,11 @@ +// "Import" "true" +// WITH_RUNTIME +// ERROR: Expression 'topVal' of type 'SomeType' cannot be invoked as a function. The function 'invoke()' is not found + +package mig + +import another.topVal + +fun use() { + topVal() +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index f4ec48d922e..a4d1154e619 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -795,6 +795,11 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes runTest("idea/testData/quickfix/autoImports/importKotlinStaticPropertyOverloadedSetterFromJava.test"); } + @TestMetadata("ImportOperatorInvokeWithConvention.before.Main.kt") + public void testImportOperatorInvokeWithConvention() throws Exception { + runTest("idea/testData/quickfix/autoImports/ImportOperatorInvokeWithConvention.before.Main.kt"); + } + @TestMetadata("importTrait.before.Main.kt") public void testImportTrait() throws Exception { runTest("idea/testData/quickfix/autoImports/importTrait.before.Main.kt"); From ef36b81c6764119941a39ee1ea0f58178f380a8c Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Tue, 19 Jan 2021 14:25:26 +0100 Subject: [PATCH 095/122] [JVM_IR] Reduce the amount of `super` suffixes on accesibility bridges. The super suffix was used for any static field/method that needed an accessor. We should only use it when that field or method is inherited. --- .../jvm/lower/SyntheticAccessorLowering.kt | 14 ++++++++------ .../accessorForTopLevelMembers.kt | 6 ++++++ .../accessorForTopLevelMembers.txt | 16 ++++++++++++++++ .../accessorForTopLevelMembers_ir.txt | 16 ++++++++++++++++ .../codegen/BytecodeListingTestGenerated.java | 5 +++++ .../ir/IrBytecodeListingTestGenerated.java | 5 +++++ .../testData/codegen/customSimple.ir.txt | 4 ++-- .../codegen/customSimpleWithNewArray.ir.txt | 4 ++-- 8 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.kt create mode 100644 compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.txt create mode 100644 compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers_ir.txt diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt index d7f3367875d..0af9cf5f60a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt @@ -531,9 +531,10 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle // Accessor for _s_uper-qualified call superQualifier != null -> "\$s" + superQualifier.owner.syntheticAccessorToSuperSuffix() - // Access to static members that need an accessor must be because they are inherited, - // hence accessed on a _s_upertype. - isStatic -> "\$s" + parentAsClass.syntheticAccessorToSuperSuffix() + // Access to protected members that need an accessor must be because they are inherited, + // hence accessed on a _s_upertype. If what is accessed is static, we can point to different + // parts of the inheritance hierarchy and need to distinguish with a suffix. + isStatic && visibility.isProtected -> "\$s" + parentAsClass.syntheticAccessorToSuperSuffix() else -> "" } @@ -556,9 +557,10 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle return "cp" } - // Static accesses that need an accessor must be due to being inherited, hence accessed on a - // _s_upertype - return "p" + if (isStatic) "\$s" + parentAsClass.syntheticAccessorToSuperSuffix() else "" + // Accesses to static protected fields that need an accessor must be due to being inherited, hence accessed on a + // _s_upertype. If the field is static, the super class the access is on can be different and therefore + // we generate a suffix to distinguish access to field with different receiver types in the super hierarchy. + return "p" + if (isStatic && visibility.isProtected) "\$s" + parentAsClass.syntheticAccessorToSuperSuffix() else "" } private val DescriptorVisibility.isPrivate diff --git a/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.kt b/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.kt new file mode 100644 index 00000000000..b7ff5b7e840 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.kt @@ -0,0 +1,6 @@ +private val x: String = "OK" +private fun f(y: String) = y + +class A { + fun g() = f(x) +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.txt b/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.txt new file mode 100644 index 00000000000..4bb382d5e44 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.txt @@ -0,0 +1,16 @@ +@kotlin.Metadata +public final class A { + // source: 'accessorForTopLevelMembers.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method g(): java.lang.String +} + +@kotlin.Metadata +public final class AccessorForTopLevelMembersKt { + // source: 'accessorForTopLevelMembers.kt' + private final static field x: java.lang.String + static method (): void + public synthetic final static method access$f(p0: java.lang.String): java.lang.String + public synthetic final static method access$getX$p(): java.lang.String + private final static method f(p0: java.lang.String): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers_ir.txt b/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers_ir.txt new file mode 100644 index 00000000000..9eb5b4f087f --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers_ir.txt @@ -0,0 +1,16 @@ +@kotlin.Metadata +public final class A { + // source: 'accessorForTopLevelMembers.kt' + public method (): void + public final @org.jetbrains.annotations.NotNull method g(): java.lang.String +} + +@kotlin.Metadata +public final class AccessorForTopLevelMembersKt { + // source: 'accessorForTopLevelMembers.kt' + private final static @org.jetbrains.annotations.NotNull field x: java.lang.String + static method (): void + public synthetic final static method access$f(p0: java.lang.String): java.lang.String + public synthetic final static method access$getX$p(): java.lang.String + private final static method f(p0: java.lang.String): java.lang.String +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index 721d9625682..9ebdc0c348a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -36,6 +36,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/accessorForProtectedPropertyWithPrivateSetterInObjectLiteral.kt"); } + @TestMetadata("accessorForTopLevelMembers.kt") + public void testAccessorForTopLevelMembers() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.kt"); + } + public void testAllFilesPresentInBytecodeListing() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 6dd28a1b051..cb0deeb7551 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -36,6 +36,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/accessorForProtectedPropertyWithPrivateSetterInObjectLiteral.kt"); } + @TestMetadata("accessorForTopLevelMembers.kt") + public void testAccessorForTopLevelMembers() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/accessorForTopLevelMembers.kt"); + } + public void testAllFilesPresentInBytecodeListing() throws Exception { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } diff --git a/plugins/parcelize/parcelize-compiler/testData/codegen/customSimple.ir.txt b/plugins/parcelize/parcelize-compiler/testData/codegen/customSimple.ir.txt index d3efd23f1c6..a3c900f529f 100644 --- a/plugins/parcelize/parcelize-compiler/testData/codegen/customSimple.ir.txt +++ b/plugins/parcelize/parcelize-compiler/testData/codegen/customSimple.ir.txt @@ -41,7 +41,7 @@ public final class User$Creator : java/lang/Object, android/os/Parcelable$Creato ALOAD (1) LDC (parcel) INVOKESTATIC (kotlin/jvm/internal/Intrinsics, checkNotNullParameter, (Ljava/lang/Object;Ljava/lang/String;)V) - INVOKESTATIC (User, access$getCompanion$p$s2645995, ()LUser$Companion;) + INVOKESTATIC (User, access$getCompanion$p, ()LUser$Companion;) ALOAD (1) INVOKEVIRTUAL (User$Companion, create, (Landroid/os/Parcel;)LUser;) ARETURN @@ -90,7 +90,7 @@ public final class User : java/lang/Object, android/os/Parcelable { public void (java.lang.String firstName, java.lang.String lastName, int age) - public final static User$Companion access$getCompanion$p$s2645995() + public final static User$Companion access$getCompanion$p() public int describeContents() diff --git a/plugins/parcelize/parcelize-compiler/testData/codegen/customSimpleWithNewArray.ir.txt b/plugins/parcelize/parcelize-compiler/testData/codegen/customSimpleWithNewArray.ir.txt index 63803c0dca9..aed21ea992e 100644 --- a/plugins/parcelize/parcelize-compiler/testData/codegen/customSimpleWithNewArray.ir.txt +++ b/plugins/parcelize/parcelize-compiler/testData/codegen/customSimpleWithNewArray.ir.txt @@ -40,7 +40,7 @@ public final class User$Creator : java/lang/Object, android/os/Parcelable$Creato public final User[] newArray(int size) { LABEL (L0) - INVOKESTATIC (User, access$getCompanion$p$s2645995, ()LUser$Companion;) + INVOKESTATIC (User, access$getCompanion$p, ()LUser$Companion;) ILOAD (1) INVOKEVIRTUAL (User$Companion, newArray, (I)[LUser;) ARETURN @@ -72,7 +72,7 @@ public final class User : java/lang/Object, android/os/Parcelable { public void (java.lang.String firstName, java.lang.String lastName, int age) - public final static User$Companion access$getCompanion$p$s2645995() + public final static User$Companion access$getCompanion$p() public int describeContents() From 4a76ea6ecb088341c084b9c99fa270a96f8e4e51 Mon Sep 17 00:00:00 2001 From: pyos Date: Tue, 5 Jan 2021 13:09:10 +0100 Subject: [PATCH 096/122] JVM: regenerate objects if they have been regenerated in parent contexts This is a hack to work around the fact that type mappings should not be inherited by inlining contexts for lambdas called from anonymous objects. As the lambda can call the inline function again, this could produce a reference to the original object, which is remapped to a new type in the parent context. Unfortunately, there are many redundant `MethodRemapper`s between the lambda and the class file, so simply editing `TypeRemapper` does not work. Hence, this hack. For now. (Issue found by compiling IntelliJ IDEA BTW.) --- .../kotlin/codegen/inline/MethodInliner.kt | 35 +++++++++---------- .../codegen/inline/TransformationInfo.kt | 18 +++++----- ...FirBlackBoxInlineCodegenTestGenerated.java | 5 +++ .../constructOriginalInRegenerated.kt | 15 ++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 5 +++ ...otlinAgainstInlineKotlinTestGenerated.java | 5 +++ .../IrBlackBoxInlineCodegenTestGenerated.java | 5 +++ ...otlinAgainstInlineKotlinTestGenerated.java | 5 +++ ...JvmIrAgainstOldBoxInlineTestGenerated.java | 5 +++ ...JvmOldAgainstIrBoxInlineTestGenerated.java | 5 +++ .../IrJsCodegenInlineES6TestGenerated.java | 5 +++ .../IrJsCodegenInlineTestGenerated.java | 5 +++ .../JsCodegenInlineTestGenerated.java | 5 +++ 13 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt index a1ffd4dbbdf..df48334c6e4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt @@ -157,13 +157,8 @@ class MethodInliner( // MethodRemapper doesn't extends LocalVariablesSorter, but RemappingMethodAdapter does. // So wrapping with LocalVariablesSorter to keep old behavior // TODO: investigate LocalVariablesSorter removing (see also same code in RemappingClassBuilder.java) - val remappingMethodAdapter = MethodRemapper( - LocalVariablesSorter( - resultNode.access, - resultNode.desc, - wrapWithMaxLocalCalc(resultNode) - ), AsmTypeRemapper(remapper, result) - ) + val localVariablesSorter = LocalVariablesSorter(resultNode.access, resultNode.desc, wrapWithMaxLocalCalc(resultNode)) + val remappingMethodAdapter = MethodRemapper(localVariablesSorter, AsmTypeRemapper(remapper, result)) val fakeContinuationName = CoroutineTransformer.findFakeContinuationConstructorClassName(node) val markerShift = calcMarkerShift(parameters, node) @@ -174,7 +169,9 @@ class MethodInliner( transformationInfo = iterator.next() val oldClassName = transformationInfo!!.oldClassName - if (transformationInfo!!.shouldRegenerate(isSameModule)) { + if (inliningContext.parent?.transformationInfo?.oldClassName == oldClassName) { + // Object constructs itself, don't enter an infinite recursion of regeneration. + } else if (transformationInfo!!.shouldRegenerate(isSameModule)) { //TODO: need poping of type but what to do with local funs??? val newClassName = transformationInfo!!.newClassName remapper.addMapping(oldClassName, newClassName) @@ -206,7 +203,7 @@ class MethodInliner( ReifiedTypeInliner.putNeedClassReificationMarker(mv) result.reifiedTypeParametersUsages.mergeAll(transformResult.reifiedTypeParametersUsages) } - } else if (!transformationInfo!!.wasAlreadyRegenerated) { + } else { result.addNotChangedClass(oldClassName) } } @@ -300,7 +297,7 @@ class MethodInliner( val varRemapper = LocalVarRemapper(lambdaParameters, valueParamShift) //TODO add skipped this and receiver - val lambdaResult = inliner.doInline(this.mv, varRemapper, true, info, invokeCall.finallyDepthShift) + val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info, invokeCall.finallyDepthShift) result.mergeWithNotChangeInfo(lambdaResult) result.reifiedTypeParametersUsages.mergeAll(lambdaResult.reifiedTypeParametersUsages) @@ -312,19 +309,19 @@ class MethodInliner( inlineOnlySmapSkipper?.onInlineLambdaEnd(remappingMethodAdapter) } else if (isAnonymousConstructorCall(owner, name)) { //TODO add method //TODO add proper message - var info = transformationInfo as? AnonymousObjectTransformationInfo ?: throw AssertionError( + val newInfo = transformationInfo as? AnonymousObjectTransformationInfo ?: throw AssertionError( " call doesn't correspond to object transformation info for '$owner.$name': $transformationInfo" ) - val objectConstructsItself = inlineCallSiteInfo.ownerClassName == info.oldClassName - if (objectConstructsItself) { - // inline fun f() -> new f$1 -> fun something() in class f$1 -> new f$1 - // ^-- fetch the info that was created for this instruction - info = inliningContext.parent?.transformationInfo as? AnonymousObjectTransformationInfo - ?: throw AssertionError("anonymous object $owner constructs itself, but we have no info on in") - } + // inline fun f() -> new f$1 -> fun something() in class f$1 -> new f$1 + // ^-- fetch the info that was created for this instruction + // Currently, this self-reference pattern only happens in coroutine objects, which construct + // copies of themselves in `create` or `invoke` (not `invokeSuspend`). + val existingInfo = inliningContext.parent?.transformationInfo?.takeIf { it.oldClassName == newInfo.oldClassName } + as AnonymousObjectTransformationInfo? + val info = existingInfo ?: newInfo if (info.shouldRegenerate(isSameModule)) { for (capturedParamDesc in info.allRecapturedParameters) { - val realDesc = if (objectConstructsItself && capturedParamDesc.fieldName == AsmUtil.THIS) { + val realDesc = if (existingInfo != null && capturedParamDesc.fieldName == AsmUtil.THIS) { // The captures in `info` are relative to the parent context, so a normal `this` there // is a captured outer `this` here. CapturedParamDesc(Type.getObjectType(owner), AsmUtil.CAPTURED_THIS_FIELD, capturedParamDesc.type) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TransformationInfo.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TransformationInfo.kt index ef093536e94..23b847547e9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TransformationInfo.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/TransformationInfo.kt @@ -26,10 +26,6 @@ interface TransformationInfo { val nameGenerator: NameGenerator - val wasAlreadyRegenerated: Boolean - get() = false - - fun shouldRegenerate(sameModule: Boolean): Boolean fun canRemoveAfterTransformation(): Boolean @@ -86,9 +82,6 @@ class AnonymousObjectTransformationInfo internal constructor( lateinit var capturedLambdasToInline: Map - override val wasAlreadyRegenerated: Boolean - get() = alreadyRegenerated - constructor( ownerInternalName: String, needReification: Boolean, @@ -97,9 +90,14 @@ class AnonymousObjectTransformationInfo internal constructor( nameGenerator: NameGenerator ) : this(ownerInternalName, needReification, hashMapOf(), false, alreadyRegenerated, null, isStaticOrigin, nameGenerator) - override fun shouldRegenerate(sameModule: Boolean): Boolean = !alreadyRegenerated && - (!sameModule || capturedOuterRegenerated || needReification || capturesAnonymousObjectThatMustBeRegenerated || - functionalArguments.values.any { it != NonInlineableArgumentForInlineableParameterCalledInSuspend }) + // TODO: unconditionally regenerating an object if it has previously been regenerated is a hack that works around + // the fact that TypeRemapper cannot differentiate between different references to the same object. See the test + // boxInline/anonymousObject/constructOriginalInRegenerated.kt for an example where a single anonymous object + // is referenced twice with otherwise different `shouldRegenerate` results and the inliner gets confused, trying + // to map the inner reference to the outer regenerated type and producing an infinite recursion. + override fun shouldRegenerate(sameModule: Boolean): Boolean = alreadyRegenerated || + !sameModule || capturedOuterRegenerated || needReification || capturesAnonymousObjectThatMustBeRegenerated || + functionalArguments.values.any { it != NonInlineableArgumentForInlineableParameterCalledInSuspend } override fun canRemoveAfterTransformation(): Boolean { // Note: It is unsafe to remove anonymous class that is referenced by GETSTATIC within lambda diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java index 765f6d542d7..83d79e91a01 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java @@ -102,6 +102,11 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt new file mode 100644 index 00000000000..ac3178a5c69 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt @@ -0,0 +1,15 @@ +// FILE: 1.kt +// Intentionally in the same package, as objects in other packages are always regenerated. + +fun f(x: () -> String) = x() + +inline fun g(crossinline x: () -> String) = f { x() } + +// FILE: 2.kt +// _1Kt$g$1 not regenerated because the original already does the same thing (invoking a functional object) +// \-v +fun h(x: () -> String) = g { g(x) } +// /-^ +// _1Kt$g$1 regenerated to inline the lambda + +fun box() = h { "OK" } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 8452fce8d1b..a1c375e4b7f 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -102,6 +102,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 84f33fa5110..d9bc3ce43a5 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -102,6 +102,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 64d54213a38..5db3b918dbf 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -102,6 +102,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index e3e8f6f2da4..50ee263b67e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -102,6 +102,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java index 9e053a8c5dc..7fbe2635784 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -102,6 +102,11 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java index b3298bf657d..f66d8be4f83 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -102,6 +102,11 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index a1d8520d3d9..11e204014bb 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -102,6 +102,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 8e2b513129f..0d6fbc8db9c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -102,6 +102,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 11821520f20..ac312ac3401 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -102,6 +102,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/anonymousObject/changingReturnType.kt"); } + @TestMetadata("constructOriginalInRegenerated.kt") + public void testConstructOriginalInRegenerated() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/constructOriginalInRegenerated.kt"); + } + @TestMetadata("constructorVisibility.kt") public void testConstructorVisibility() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.kt"); From 7934853c8ef44817d961f75c8934f5535bef905d Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 18 Jan 2021 15:42:07 +0300 Subject: [PATCH 097/122] Set ABI stability to JVM modules which are built with FIR --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index 7e7c53af5b7..0666366b22b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -466,6 +466,7 @@ allprojects { if (useJvmFir) { freeCompilerArgs += "-Xuse-fir" + freeCompilerArgs += "-Xabi-stability=stable" } } } From 4fd4f504d0dc99c0258515fc6302912dd2ec9548 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 18 Jan 2021 16:55:50 +0300 Subject: [PATCH 098/122] FIR: make componentX functions operator --- .../testData/resolve/constantValues.fir.txt | 8 ++-- .../testData/resolve/copy.fir.txt | 4 +- .../diagnostics/incompatibleModifiers.fir.txt | 8 ++-- .../nullable2.fir.txt | 2 +- .../safeString2.fir.txt | 2 +- .../RedundantReturnUnitTypeChecker.fir.txt | 2 +- ...gleExpressionStringTemplateChecker.fir.txt | 4 +- .../testData/resolve/problems2.fir.txt | 6 +-- .../lambdas/lambdaInWhenBranch.fir.txt | 2 +- .../resolveWithStdlib/components.fir.txt | 4 +- .../expressions/destructuring.lazyBodies.txt | 6 +-- .../rawBuilder/expressions/destructuring.txt | 6 +-- .../rawBuilder/expressions/for.lazyBodies.txt | 4 +- .../testData/rawBuilder/expressions/for.txt | 4 +- .../expressions/lambda.lazyBodies.txt | 4 +- .../rawBuilder/expressions/lambda.txt | 4 +- .../kotlin/fir/builder/BaseFirBuilder.kt | 4 +- .../dataClassWithArrayMembers.fir.kt.txt | 23 +++++----- .../classes/dataClassWithArrayMembers.fir.txt | 44 +++++++++---------- .../ir/irText/classes/dataClasses.fir.kt.txt | 16 +++---- .../ir/irText/classes/dataClasses.fir.txt | 32 +++++++------- .../classes/dataClassesGeneric.fir.kt.txt | 8 ++-- .../irText/classes/dataClassesGeneric.fir.txt | 16 +++---- .../ir/irText/classes/kt31649.fir.kt.txt | 2 +- .../ir/irText/classes/kt31649.fir.txt | 4 +- ...mbdaInDataClassDefaultParameter.fir.kt.txt | 4 +- .../lambdaInDataClassDefaultParameter.fir.txt | 8 ++-- .../irText/classes/openDataClass.fir.kt.txt | 4 +- .../ir/irText/classes/openDataClass.fir.txt | 8 ++-- .../parameters/dataClassMembers.fir.kt.txt | 4 +- .../parameters/dataClassMembers.fir.txt | 8 ++-- .../irText/firProblems/MultiList.fir.kt.txt | 2 +- .../ir/irText/firProblems/MultiList.fir.txt | 4 +- .../firProblems/SignatureClash.fir.kt.txt | 2 +- .../irText/firProblems/SignatureClash.fir.txt | 4 +- .../lambdas/destructuringInLambda.fir.kt.txt | 4 +- .../lambdas/destructuringInLambda.fir.txt | 10 ++--- .../enhancedNullabilityInForLoop.fir.kt.txt | 4 +- .../enhancedNullabilityInForLoop.fir.txt | 12 ++--- .../typeAliasWithUnsafeVariance.fir.kt.txt | 2 +- .../types/typeAliasWithUnsafeVariance.fir.txt | 4 +- 41 files changed, 153 insertions(+), 150 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt b/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt index d4ece21144a..81bbe2a4f85 100644 --- a/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/constantValues.fir.txt @@ -19,9 +19,9 @@ FILE: constantValues.kt public final val arrayNestedness: R|kotlin/Int| = R|/arrayNestedness| public get(): R|kotlin/Int| - public final fun component1(): R|ClassId| + public final operator fun component1(): R|ClassId| - public final fun component2(): R|kotlin/Int| + public final operator fun component2(): R|kotlin/Int| public final fun copy(classId: R|ClassId| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.classId|, arrayNestedness: R|kotlin/Int| = this@R|/ClassLiteralValue|.R|/ClassLiteralValue.arrayNestedness|): R|ClassLiteralValue| @@ -62,7 +62,7 @@ FILE: constantValues.kt public final val arrayDimensions: R|kotlin/Int| public get(): R|kotlin/Int| - public final fun component1(): R|ClassLiteralValue| + public final operator fun component1(): R|ClassLiteralValue| public final fun copy(value: R|ClassLiteralValue| = this@R|/KClassValue.Value.NormalClass|.R|/KClassValue.Value.NormalClass.value|): R|KClassValue.Value.NormalClass| @@ -76,7 +76,7 @@ FILE: constantValues.kt public final val type: R|KotlinType| = R|/type| public get(): R|KotlinType| - public final fun component1(): R|KotlinType| + public final operator fun component1(): R|KotlinType| public final fun copy(type: R|KotlinType| = this@R|/KClassValue.Value.LocalClass|.R|/KClassValue.Value.LocalClass.type|): R|KClassValue.Value.LocalClass| diff --git a/compiler/fir/analysis-tests/testData/resolve/copy.fir.txt b/compiler/fir/analysis-tests/testData/resolve/copy.fir.txt index a6bbbc6e633..a2fcf1d8146 100644 --- a/compiler/fir/analysis-tests/testData/resolve/copy.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/copy.fir.txt @@ -10,9 +10,9 @@ FILE: copy.kt public final val y: R|kotlin/String| = R|/y| public get(): R|kotlin/String| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| - public final fun component2(): R|kotlin/String| + public final operator fun component2(): R|kotlin/String| public final fun copy(x: R|kotlin/Int| = this@R|/Some|.R|/Some.x|, y: R|kotlin/String| = this@R|/Some|.R|/Some.y|): R|Some| diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt index 8612d5498d2..823b6488df7 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/incompatibleModifiers.fir.txt @@ -51,7 +51,7 @@ FILE: incompatibleModifiers.kt public final val i: R|kotlin/Int| = R|/i| public get(): R|kotlin/Int| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| public final fun copy(i: R|kotlin/Int| = this@R|/H|.R|/H.i|): R|H| @@ -64,7 +64,7 @@ FILE: incompatibleModifiers.kt public final val i: R|kotlin/Int| = R|/i| public get(): R|kotlin/Int| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| public final fun copy(i: R|kotlin/Int| = this@R|/I|.R|/I.i|): R|I| @@ -77,7 +77,7 @@ FILE: incompatibleModifiers.kt public final val i: R|kotlin/Int| = R|/i| public get(): R|kotlin/Int| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| public final fun copy(i: R|kotlin/Int| = this@R|/J|.R|/J.i|): R|J| @@ -119,7 +119,7 @@ FILE: incompatibleModifiers.kt public final val i: R|kotlin/Int| = R|/i| public get(): R|kotlin/Int| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| public final fun copy(i: R|kotlin/Int| = this@R|/X.Y|.R|/X.Y.i|): R|X.Y| diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/nullable2.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/nullable2.fir.txt index 65ce0bd6660..2cc9689d21d 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/nullable2.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/nullable2.fir.txt @@ -7,7 +7,7 @@ FILE: nullable2.kt public final val name: R|kotlin/String| = R|/name| public get(): R|kotlin/String| - public final fun component1(): R|kotlin/String| + public final operator fun component1(): R|kotlin/String| public final fun copy(name: R|kotlin/String| = this@R|/Foo|.R|/Foo.name|): R|Foo| diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/safeString2.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/safeString2.fir.txt index 0e76b7f9b95..0916f69024b 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/safeString2.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantCallOfConversionMethod/safeString2.fir.txt @@ -7,7 +7,7 @@ FILE: safeString2.kt public final val name: R|kotlin/String| = R|/name| public get(): R|kotlin/String| - public final fun component1(): R|kotlin/String| + public final operator fun component1(): R|kotlin/String| public final fun copy(name: R|kotlin/String| = this@R|/Foo|.R|/Foo.name|): R|Foo| diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt index 58e4524988a..b1bd68e22fe 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt @@ -7,7 +7,7 @@ FILE: RedundantReturnUnitTypeChecker.kt public final val x: R|kotlin/Unit| = R|/x| public get(): R|kotlin/Unit| - public final fun component1(): R|kotlin/Unit| + public final operator fun component1(): R|kotlin/Unit| public final fun copy(x: R|kotlin/Unit| = this@R|/My|.R|/My.x|): R|My| diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSingleExpressionStringTemplateChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSingleExpressionStringTemplateChecker.fir.txt index 9c66c0fa4b3..07ba2f8bba6 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSingleExpressionStringTemplateChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSingleExpressionStringTemplateChecker.fir.txt @@ -30,9 +30,9 @@ FILE: RedundantSingleExpressionStringTemplateChecker.kt public get(): R|kotlin/String| - public final fun component1(): R|kotlin/String| + public final operator fun component1(): R|kotlin/String| - public final fun component2(): R|ProductGroup?| + public final operator fun component2(): R|ProductGroup?| public final fun copy(short_name: R|kotlin/String| = this@R|/ProductGroup|.R|/ProductGroup.short_name|, parent: R|ProductGroup?| = this@R|/ProductGroup|.R|/ProductGroup.parent|): R|ProductGroup| diff --git a/compiler/fir/analysis-tests/testData/resolve/problems2.fir.txt b/compiler/fir/analysis-tests/testData/resolve/problems2.fir.txt index 0d4d591ad3b..87c323b2568 100644 --- a/compiler/fir/analysis-tests/testData/resolve/problems2.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/problems2.fir.txt @@ -42,11 +42,11 @@ FILE: problems2.kt public final val s: R|kotlin/String?| = R|/s| public get(): R|kotlin/String?| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| - public final fun component2(): R|kotlin/Array?| + public final operator fun component2(): R|kotlin/Array?| - public final fun component3(): R|kotlin/String?| + public final operator fun component3(): R|kotlin/String?| public final fun copy(x: R|kotlin/Int| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.x|, arr: R|kotlin/Array?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.arr|, s: R|kotlin/String?| = this@R|/Some.WithPrimary|.R|/Some.WithPrimary.s|): R|Some.WithPrimary| diff --git a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt index ce5a47d0a8f..30d59e0510e 100644 --- a/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/smartcasts/lambdas/lambdaInWhenBranch.fir.txt @@ -13,7 +13,7 @@ FILE: lambdaInWhenBranch.kt public final val t: R|kotlin/String| = R|/t| public get(): R|kotlin/String| - public final fun component1(): R|kotlin/String| + public final operator fun component1(): R|kotlin/String| public final fun copy(t: R|kotlin/String| = this@R|/SubClass1|.R|/SubClass1.t|): R|SubClass1| diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.fir.txt index beb03d83f97..d503171be06 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/components.fir.txt @@ -10,9 +10,9 @@ FILE: components.kt public final val y: R|kotlin/String| = R|/y| public get(): R|kotlin/String| - public final fun component1(): R|kotlin/Int| + public final operator fun component1(): R|kotlin/Int| - public final fun component2(): R|kotlin/String| + public final operator fun component2(): R|kotlin/String| public final fun copy(x: R|kotlin/Int| = this@R|/D|.R|/D.x|, y: R|kotlin/String| = this@R|/D|.R|/D.y|): R|D| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt index be3cbea5662..3e478c47f88 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.lazyBodies.txt @@ -13,11 +13,11 @@ FILE: destructuring.kt public? final? val third: String = R|/third| public? get(): String - public final fun component1(): Int + public final operator fun component1(): Int - public final fun component2(): Double + public final operator fun component2(): Double - public final fun component3(): String + public final operator fun component3(): String public final fun copy(first: Int = this@R|/Some|.R|/Some.first|, second: Double = this@R|/Some|.R|/Some.second|, third: String = this@R|/Some|.R|/Some.third|): R|Some| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt index e912e0574ac..ee4f8490435 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.txt @@ -13,11 +13,11 @@ FILE: destructuring.kt public? final? val third: String = R|/third| public? get(): String - public final fun component1(): Int + public final operator fun component1(): Int - public final fun component2(): Double + public final operator fun component2(): Double - public final fun component3(): String + public final operator fun component3(): String public final fun copy(first: Int = this@R|/Some|.R|/Some.first|, second: Double = this@R|/Some|.R|/Some.second|, third: String = this@R|/Some|.R|/Some.third|): R|Some| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt index 1d9267964c8..7cd142a462a 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.lazyBodies.txt @@ -13,9 +13,9 @@ FILE: for.kt public? final? val y: Int = R|/y| public? get(): Int - public final fun component1(): Int + public final operator fun component1(): Int - public final fun component2(): Int + public final operator fun component2(): Int public final fun copy(x: Int = this@R|/Some|.R|/Some.x|, y: Int = this@R|/Some|.R|/Some.y|): R|Some| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt index 6ed4d975f0b..d5b38a79842 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.txt @@ -48,9 +48,9 @@ FILE: for.kt public? final? val y: Int = R|/y| public? get(): Int - public final fun component1(): Int + public final operator fun component1(): Int - public final fun component2(): Int + public final operator fun component2(): Int public final fun copy(x: Int = this@R|/Some|.R|/Some.x|, y: Int = this@R|/Some|.R|/Some.y|): R|Some| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt index 19adef109f1..7c646906766 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.lazyBodies.txt @@ -10,9 +10,9 @@ FILE: lambda.kt public? final? val y: Int = R|/y| public? get(): Int - public final fun component1(): Int + public final operator fun component1(): Int - public final fun component2(): Int + public final operator fun component2(): Int public final fun copy(x: Int = this@R|/Tuple|.R|/Tuple.x|, y: Int = this@R|/Tuple|.R|/Tuple.y|): R|Tuple| diff --git a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt index da65537ecce..9780696c942 100644 --- a/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt +++ b/compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.txt @@ -10,9 +10,9 @@ FILE: lambda.kt public? final? val y: Int = R|/y| public? get(): Int - public final fun component1(): Int + public final operator fun component1(): Int - public final fun component2(): Int + public final operator fun component2(): Int public final fun copy(x: Int = this@R|/Tuple|.R|/Tuple.x|, y: Int = this@R|/Tuple|.R|/Tuple.y|): R|Tuple| diff --git a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt index 00499bafcf2..66697d1d9ac 100644 --- a/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt +++ b/compiler/fir/raw-fir/raw-fir.common/src/org/jetbrains/kotlin/fir/builder/BaseFirBuilder.kt @@ -1089,7 +1089,9 @@ abstract class BaseFirBuilder(val baseSession: FirSession, val context: Conte returnTypeRef = firProperty.returnTypeRef receiverTypeRef = null this.name = name - status = FirDeclarationStatusImpl(Visibilities.Public, Modality.FINAL) + status = FirDeclarationStatusImpl(Visibilities.Public, Modality.FINAL).apply { + isOperator = true + } symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, name)) dispatchReceiverType = currentDispatchReceiverType() // Refer to FIR backend ClassMemberGenerator for body generation. diff --git a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.kt.txt b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.kt.txt index 065d0ceeae6..4fc9e7c7b4f 100644 --- a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.kt.txt @@ -41,39 +41,39 @@ data class Test1 { field = doubleArray get - fun component1(): Array { + operator fun component1(): Array { return .#stringArray } - fun component2(): CharArray { + operator fun component2(): CharArray { return .#charArray } - fun component3(): BooleanArray { + operator fun component3(): BooleanArray { return .#booleanArray } - fun component4(): ByteArray { + operator fun component4(): ByteArray { return .#byteArray } - fun component5(): ShortArray { + operator fun component5(): ShortArray { return .#shortArray } - fun component6(): IntArray { + operator fun component6(): IntArray { return .#intArray } - fun component7(): LongArray { + operator fun component7(): LongArray { return .#longArray } - fun component8(): FloatArray { + operator fun component8(): FloatArray { return .#floatArray } - fun component9(): DoubleArray { + operator fun component9(): DoubleArray { return .#doubleArray } @@ -149,7 +149,7 @@ data class Test2 { field = genericArray get - fun component1(): Array { + operator fun component1(): Array { return .#genericArray } @@ -192,7 +192,7 @@ data class Test3 { field = anyArrayN get - fun component1(): Array? { + operator fun component1(): Array? { return .#anyArrayN } @@ -226,3 +226,4 @@ data class Test3 { } } + diff --git a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt index 29be395b658..e71a6efdfe4 100644 --- a/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClassWithArrayMembers.fir.txt @@ -113,58 +113,58 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.DoubleArray declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:doubleArray type:kotlin.DoubleArray visibility:private [final]' type=kotlin.DoubleArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.' type=.Test1 origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Array + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Array [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:stringArray type:kotlin.Array visibility:private [final]' type=kotlin.Array origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component1' type=.Test1 origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.CharArray + FUN name:component2 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.CharArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.CharArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.CharArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:charArray type:kotlin.CharArray visibility:private [final]' type=kotlin.CharArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component2' type=.Test1 origin=null - FUN name:component3 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.BooleanArray + FUN name:component3 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.BooleanArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.BooleanArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.BooleanArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:booleanArray type:kotlin.BooleanArray visibility:private [final]' type=kotlin.BooleanArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component3' type=.Test1 origin=null - FUN name:component4 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.ByteArray + FUN name:component4 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.ByteArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component4 (): kotlin.ByteArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component4 (): kotlin.ByteArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:byteArray type:kotlin.ByteArray visibility:private [final]' type=kotlin.ByteArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component4' type=.Test1 origin=null - FUN name:component5 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.ShortArray + FUN name:component5 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.ShortArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component5 (): kotlin.ShortArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component5 (): kotlin.ShortArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:shortArray type:kotlin.ShortArray visibility:private [final]' type=kotlin.ShortArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component5' type=.Test1 origin=null - FUN name:component6 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.IntArray + FUN name:component6 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.IntArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component6 (): kotlin.IntArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component6 (): kotlin.IntArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:intArray type:kotlin.IntArray visibility:private [final]' type=kotlin.IntArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component6' type=.Test1 origin=null - FUN name:component7 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.LongArray + FUN name:component7 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.LongArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component7 (): kotlin.LongArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component7 (): kotlin.LongArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:longArray type:kotlin.LongArray visibility:private [final]' type=kotlin.LongArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component7' type=.Test1 origin=null - FUN name:component8 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.FloatArray + FUN name:component8 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.FloatArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component8 (): kotlin.FloatArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component8 (): kotlin.FloatArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:floatArray type:kotlin.FloatArray visibility:private [final]' type=kotlin.FloatArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component8' type=.Test1 origin=null - FUN name:component9 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.DoubleArray + FUN name:component9 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.DoubleArray [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component9 (): kotlin.DoubleArray declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component9 (): kotlin.DoubleArray [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:doubleArray type:kotlin.DoubleArray visibility:private [final]' type=kotlin.DoubleArray origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component9' type=.Test1 origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test1, stringArray:kotlin.Array, charArray:kotlin.CharArray, booleanArray:kotlin.BooleanArray, byteArray:kotlin.ByteArray, shortArray:kotlin.ShortArray, intArray:kotlin.IntArray, longArray:kotlin.LongArray, floatArray:kotlin.FloatArray, doubleArray:kotlin.DoubleArray) returnType:.Test1 @@ -478,10 +478,10 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array.Test2> declared in .Test2' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:genericArray type:kotlin.Array.Test2> visibility:private [final]' type=kotlin.Array.Test2> origin=null receiver: GET_VAR ': .Test2.Test2> declared in .Test2.' type=.Test2.Test2> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test2.Test2>) returnType:kotlin.Array.Test2> + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test2.Test2>) returnType:kotlin.Array.Test2> [operator] $this: VALUE_PARAMETER name: type:.Test2.Test2> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array.Test2> declared in .Test2' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array.Test2> [operator] declared in .Test2' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:genericArray type:kotlin.Array.Test2> visibility:private [final]' type=kotlin.Array.Test2> origin=null receiver: GET_VAR ': .Test2.Test2> declared in .Test2.component1' type=.Test2.Test2> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test2.Test2>, genericArray:kotlin.Array.Test2>) returnType:.Test2.Test2> @@ -569,10 +569,10 @@ FILE fqName: fileName:/dataClassWithArrayMembers.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array? declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anyArrayN type:kotlin.Array? visibility:private [final]' type=kotlin.Array? origin=null receiver: GET_VAR ': .Test3 declared in .Test3.' type=.Test3 origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Array? + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Array? [operator] $this: VALUE_PARAMETER name: type:.Test3 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array? declared in .Test3' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array? [operator] declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:anyArrayN type:kotlin.Array? visibility:private [final]' type=kotlin.Array? origin=null receiver: GET_VAR ': .Test3 declared in .Test3.component1' type=.Test3 origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test3, anyArrayN:kotlin.Array?) returnType:.Test3 diff --git a/compiler/testData/ir/irText/classes/dataClasses.fir.kt.txt b/compiler/testData/ir/irText/classes/dataClasses.fir.kt.txt index 9203bc4657f..fbba8285987 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.fir.kt.txt @@ -17,15 +17,15 @@ data class Test1 { field = z get - fun component1(): Int { + operator fun component1(): Int { return .#x } - fun component2(): String { + operator fun component2(): String { return .#y } - fun component3(): Any { + operator fun component3(): Any { return .#z } @@ -77,7 +77,7 @@ data class Test2 { field = x get - fun component1(): Any? { + operator fun component1(): Any? { return .#x } @@ -135,19 +135,19 @@ data class Test3 { field = df get - fun component1(): Double { + operator fun component1(): Double { return .#d } - fun component2(): Double? { + operator fun component2(): Double? { return .#dn } - fun component3(): Float { + operator fun component3(): Float { return .#f } - fun component4(): Float? { + operator fun component4(): Float? { return .#df } diff --git a/compiler/testData/ir/irText/classes/dataClasses.fir.txt b/compiler/testData/ir/irText/classes/dataClasses.fir.txt index df172c33a01..5b85b83a7cf 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.fir.txt @@ -41,22 +41,22 @@ FILE fqName: fileName:/dataClasses.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .Test1 declared in .Test1.' type=.Test1 origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Int + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Int [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component1' type=.Test1 origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.String + FUN name:component2 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.String [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component2' type=.Test1 origin=null - FUN name:component3 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Any + FUN name:component3 visibility:public modality:FINAL <> ($this:.Test1) returnType:kotlin.Any [operator] $this: VALUE_PARAMETER name: type:.Test1 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Any declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Any [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .Test1 declared in .Test1.component3' type=.Test1 origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test1, x:kotlin.Int, y:kotlin.String, z:kotlin.Any) returnType:.Test1 @@ -198,10 +198,10 @@ FILE fqName: fileName:/dataClasses.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any? declared in .Test2' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test2) returnType:kotlin.Any? + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test2) returnType:kotlin.Any? [operator] $this: VALUE_PARAMETER name: type:.Test2 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Any? declared in .Test2' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Any? [operator] declared in .Test2' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any? visibility:private [final]' type=kotlin.Any? origin=null receiver: GET_VAR ': .Test2 declared in .Test2.component1' type=.Test2 origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test2, x:kotlin.Any?) returnType:.Test2 @@ -332,28 +332,28 @@ FILE fqName: fileName:/dataClasses.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Float? declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:df type:kotlin.Float? visibility:private [final]' type=kotlin.Float? origin=null receiver: GET_VAR ': .Test3 declared in .Test3.' type=.Test3 origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Double + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Double [operator] $this: VALUE_PARAMETER name: type:.Test3 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Double declared in .Test3' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Double [operator] declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:d type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null receiver: GET_VAR ': .Test3 declared in .Test3.component1' type=.Test3 origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Double? + FUN name:component2 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Double? [operator] $this: VALUE_PARAMETER name: type:.Test3 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Double? declared in .Test3' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Double? [operator] declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:dn type:kotlin.Double? visibility:private [final]' type=kotlin.Double? origin=null receiver: GET_VAR ': .Test3 declared in .Test3.component2' type=.Test3 origin=null - FUN name:component3 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Float + FUN name:component3 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Float [operator] $this: VALUE_PARAMETER name: type:.Test3 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Float declared in .Test3' + RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Float [operator] declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:f type:kotlin.Float visibility:private [final]' type=kotlin.Float origin=null receiver: GET_VAR ': .Test3 declared in .Test3.component3' type=.Test3 origin=null - FUN name:component4 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Float? + FUN name:component4 visibility:public modality:FINAL <> ($this:.Test3) returnType:kotlin.Float? [operator] $this: VALUE_PARAMETER name: type:.Test3 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component4 (): kotlin.Float? declared in .Test3' + RETURN type=kotlin.Nothing from='public final fun component4 (): kotlin.Float? [operator] declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:df type:kotlin.Float? visibility:private [final]' type=kotlin.Float? origin=null receiver: GET_VAR ': .Test3 declared in .Test3.component4' type=.Test3 origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test3, d:kotlin.Double, dn:kotlin.Double?, f:kotlin.Float, df:kotlin.Float?) returnType:.Test3 diff --git a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.kt.txt b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.kt.txt index d932e4fc785..9a8e39bb9d2 100644 --- a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.kt.txt @@ -9,7 +9,7 @@ data class Test1 { field = x get - fun component1(): T { + operator fun component1(): T { return .#x } @@ -55,7 +55,7 @@ data class Test2 { field = x get - fun component1(): T { + operator fun component1(): T { return .#x } @@ -98,7 +98,7 @@ data class Test3 { field = x get - fun component1(): List { + operator fun component1(): List { return .#x } @@ -141,7 +141,7 @@ data class Test4 { field = x get - fun component1(): List { + operator fun component1(): List { return .#x } diff --git a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt index 53f24fef139..fa5d743a162 100644 --- a/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt +++ b/compiler/testData/ir/irText/classes/dataClassesGeneric.fir.txt @@ -18,10 +18,10 @@ FILE fqName: fileName:/dataClassesGeneric.kt RETURN type=kotlin.Nothing from='public final fun (): T of .Test1 declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test1 visibility:private [final]' type=T of .Test1 origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test1.Test1>) returnType:T of .Test1 + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test1.Test1>) returnType:T of .Test1 [operator] $this: VALUE_PARAMETER name: type:.Test1.Test1> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test1 declared in .Test1' + RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test1 [operator] declared in .Test1' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test1 visibility:private [final]' type=T of .Test1 origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.component1' type=.Test1.Test1> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test1.Test1>, x:T of .Test1) returnType:.Test1.Test1> @@ -118,10 +118,10 @@ FILE fqName: fileName:/dataClassesGeneric.kt RETURN type=kotlin.Nothing from='public final fun (): T of .Test2 declared in .Test2' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test2 visibility:private [final]' type=T of .Test2 origin=null receiver: GET_VAR ': .Test2.Test2> declared in .Test2.' type=.Test2.Test2> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test2.Test2>) returnType:T of .Test2 + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test2.Test2>) returnType:T of .Test2 [operator] $this: VALUE_PARAMETER name: type:.Test2.Test2> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test2 declared in .Test2' + RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test2 [operator] declared in .Test2' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test2 visibility:private [final]' type=T of .Test2 origin=null receiver: GET_VAR ': .Test2.Test2> declared in .Test2.component1' type=.Test2.Test2> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test2.Test2>, x:T of .Test2) returnType:.Test2.Test2> @@ -209,10 +209,10 @@ FILE fqName: fileName:/dataClassesGeneric.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.List.Test3> declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.collections.List.Test3> visibility:private [final]' type=kotlin.collections.List.Test3> origin=null receiver: GET_VAR ': .Test3.Test3> declared in .Test3.' type=.Test3.Test3> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test3.Test3>) returnType:kotlin.collections.List.Test3> + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test3.Test3>) returnType:kotlin.collections.List.Test3> [operator] $this: VALUE_PARAMETER name: type:.Test3.Test3> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List.Test3> declared in .Test3' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List.Test3> [operator] declared in .Test3' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.collections.List.Test3> visibility:private [final]' type=kotlin.collections.List.Test3> origin=null receiver: GET_VAR ': .Test3.Test3> declared in .Test3.component1' type=.Test3.Test3> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test3.Test3>, x:kotlin.collections.List.Test3>) returnType:.Test3.Test3> @@ -299,10 +299,10 @@ FILE fqName: fileName:/dataClassesGeneric.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.collections.List declared in .Test4' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.collections.List visibility:private [final]' type=kotlin.collections.List origin=null receiver: GET_VAR ': .Test4 declared in .Test4.' type=.Test4 origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test4) returnType:kotlin.collections.List + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test4) returnType:kotlin.collections.List [operator] $this: VALUE_PARAMETER name: type:.Test4 BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List declared in .Test4' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List [operator] declared in .Test4' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.collections.List visibility:private [final]' type=kotlin.collections.List origin=null receiver: GET_VAR ': .Test4 declared in .Test4.component1' type=.Test4 origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test4, x:kotlin.collections.List) returnType:.Test4 diff --git a/compiler/testData/ir/irText/classes/kt31649.fir.kt.txt b/compiler/testData/ir/irText/classes/kt31649.fir.kt.txt index 0947f7f3e7e..6940b09c3f7 100644 --- a/compiler/testData/ir/irText/classes/kt31649.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/kt31649.fir.kt.txt @@ -9,7 +9,7 @@ data class TestData { field = nn get - fun component1(): Nothing? { + operator fun component1(): Nothing? { return .#nn } diff --git a/compiler/testData/ir/irText/classes/kt31649.fir.txt b/compiler/testData/ir/irText/classes/kt31649.fir.txt index 30d6ffb8a4e..894dc1d62f1 100644 --- a/compiler/testData/ir/irText/classes/kt31649.fir.txt +++ b/compiler/testData/ir/irText/classes/kt31649.fir.txt @@ -17,10 +17,10 @@ FILE fqName: fileName:/kt31649.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Nothing? declared in .TestData' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:nn type:kotlin.Nothing? visibility:private [final]' type=kotlin.Nothing? origin=null receiver: GET_VAR ': .TestData declared in .TestData.' type=.TestData origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.TestData) returnType:kotlin.Nothing? + FUN name:component1 visibility:public modality:FINAL <> ($this:.TestData) returnType:kotlin.Nothing? [operator] $this: VALUE_PARAMETER name: type:.TestData BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Nothing? declared in .TestData' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Nothing? [operator] declared in .TestData' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:nn type:kotlin.Nothing? visibility:private [final]' type=kotlin.Nothing? origin=null receiver: GET_VAR ': .TestData declared in .TestData.component1' type=.TestData origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.TestData, nn:kotlin.Nothing?) returnType:.TestData diff --git a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.kt.txt b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.kt.txt index 22448fd726c..275779bf357 100644 --- a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.kt.txt @@ -12,7 +12,7 @@ data class A { field = runA get - fun component1(): @ExtensionFunctionType Function2 { + operator fun component1(): @ExtensionFunctionType Function2 { return .#runA } @@ -66,7 +66,7 @@ data class B { field = x get - fun component1(): Any { + operator fun component1(): Any { return .#x } diff --git a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt index 41833762667..43d469be2e7 100644 --- a/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt +++ b/compiler/testData/ir/irText/classes/lambdaInDataClassDefaultParameter.fir.txt @@ -25,10 +25,10 @@ FILE fqName: fileName:/lambdaInDataClassDefaultParameter.kt RETURN type=kotlin.Nothing from='public final fun (): @[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:runA type:@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> visibility:private [final]' type=@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> origin=null receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.A) returnType:@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> + FUN name:component1 visibility:public modality:FINAL <> ($this:.A) returnType:@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> [operator] $this: VALUE_PARAMETER name: type:.A BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): @[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> declared in .A' + RETURN type=kotlin.Nothing from='public final fun component1 (): @[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> [operator] declared in .A' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:runA type:@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> visibility:private [final]' type=@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit> origin=null receiver: GET_VAR ': .A declared in .A.component1' type=.A origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.A, runA:@[ExtensionFunctionType] kotlin.Function2<.A, kotlin.String, kotlin.Unit>) returnType:.A @@ -136,10 +136,10 @@ FILE fqName: fileName:/lambdaInDataClassDefaultParameter.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .B' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .B declared in .B.' type=.B origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.B) returnType:kotlin.Any + FUN name:component1 visibility:public modality:FINAL <> ($this:.B) returnType:kotlin.Any [operator] $this: VALUE_PARAMETER name: type:.B BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Any declared in .B' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Any [operator] declared in .B' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null receiver: GET_VAR ': .B declared in .B.component1' type=.B origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.B, x:kotlin.Any) returnType:.B diff --git a/compiler/testData/ir/irText/classes/openDataClass.fir.kt.txt b/compiler/testData/ir/irText/classes/openDataClass.fir.kt.txt index 0a475797811..9531a7e5269 100644 --- a/compiler/testData/ir/irText/classes/openDataClass.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/openDataClass.fir.kt.txt @@ -14,11 +14,11 @@ open data class ValidatedProperties { field = test2 open get - fun component1(): String { + operator fun component1(): String { return .() } - fun component2(): String { + operator fun component2(): String { return .() } diff --git a/compiler/testData/ir/irText/classes/openDataClass.fir.txt b/compiler/testData/ir/irText/classes/openDataClass.fir.txt index 445e2927336..895c66ee370 100644 --- a/compiler/testData/ir/irText/classes/openDataClass.fir.txt +++ b/compiler/testData/ir/irText/classes/openDataClass.fir.txt @@ -31,16 +31,16 @@ FILE fqName: fileName:/openDataClass.kt RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .ValidatedProperties' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.String visibility:private [final]' type=kotlin.String origin=null receiver: GET_VAR ': .ValidatedProperties declared in .ValidatedProperties.' type=.ValidatedProperties origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.ValidatedProperties) returnType:kotlin.String + FUN name:component1 visibility:public modality:FINAL <> ($this:.ValidatedProperties) returnType:kotlin.String [operator] $this: VALUE_PARAMETER name: type:.ValidatedProperties BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String declared in .ValidatedProperties' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String [operator] declared in .ValidatedProperties' CALL 'public open fun (): kotlin.String declared in .ValidatedProperties' type=kotlin.String origin=null $this: GET_VAR ': .ValidatedProperties declared in .ValidatedProperties.component1' type=.ValidatedProperties origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.ValidatedProperties) returnType:kotlin.String + FUN name:component2 visibility:public modality:FINAL <> ($this:.ValidatedProperties) returnType:kotlin.String [operator] $this: VALUE_PARAMETER name: type:.ValidatedProperties BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String declared in .ValidatedProperties' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String [operator] declared in .ValidatedProperties' CALL 'public open fun (): kotlin.String declared in .ValidatedProperties' type=kotlin.String origin=null $this: GET_VAR ': .ValidatedProperties declared in .ValidatedProperties.component2' type=.ValidatedProperties origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.ValidatedProperties, test1:kotlin.String, test2:kotlin.String) returnType:.ValidatedProperties diff --git a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.kt.txt b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.kt.txt index c60bd70017d..99ac9bd8cf6 100644 --- a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.kt.txt @@ -13,11 +13,11 @@ data class Test { field = y get - fun component1(): T { + operator fun component1(): T { return .#x } - fun component2(): String { + operator fun component2(): String { return .#y } diff --git a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt index edd9a6f028b..b0b5bdc6aa5 100644 --- a/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt +++ b/compiler/testData/ir/irText/declarations/parameters/dataClassMembers.fir.txt @@ -32,16 +32,16 @@ FILE fqName: fileName:/dataClassMembers.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Test' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.' type=.Test.Test> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Test.Test>) returnType:T of .Test + FUN name:component1 visibility:public modality:FINAL <> ($this:.Test.Test>) returnType:T of .Test [operator] $this: VALUE_PARAMETER name: type:.Test.Test> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test declared in .Test' + RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Test [operator] declared in .Test' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of .Test visibility:private [final]' type=T of .Test origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.component1' type=.Test.Test> origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.Test.Test>) returnType:kotlin.String + FUN name:component2 visibility:public modality:FINAL <> ($this:.Test.Test>) returnType:kotlin.String [operator] $this: VALUE_PARAMETER name: type:.Test.Test> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String declared in .Test' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String [operator] declared in .Test' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.String visibility:private [final]' type=kotlin.String origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.component2' type=.Test.Test> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Test.Test>, x:T of .Test, y:kotlin.String) returnType:.Test.Test> diff --git a/compiler/testData/ir/irText/firProblems/MultiList.fir.kt.txt b/compiler/testData/ir/irText/firProblems/MultiList.fir.kt.txt index 7a96913bc62..c3cc6eda24c 100644 --- a/compiler/testData/ir/irText/firProblems/MultiList.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/MultiList.fir.kt.txt @@ -9,7 +9,7 @@ data class Some { field = value get - fun component1(): T { + operator fun component1(): T { return .#value } diff --git a/compiler/testData/ir/irText/firProblems/MultiList.fir.txt b/compiler/testData/ir/irText/firProblems/MultiList.fir.txt index c682c9524ee..8d210d28fb8 100644 --- a/compiler/testData/ir/irText/firProblems/MultiList.fir.txt +++ b/compiler/testData/ir/irText/firProblems/MultiList.fir.txt @@ -18,10 +18,10 @@ FILE fqName: fileName:/MultiList.kt RETURN type=kotlin.Nothing from='public final fun (): T of .Some declared in .Some' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:T of .Some visibility:private [final]' type=T of .Some origin=null receiver: GET_VAR ': .Some.Some> declared in .Some.' type=.Some.Some> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Some.Some>) returnType:T of .Some + FUN name:component1 visibility:public modality:FINAL <> ($this:.Some.Some>) returnType:T of .Some [operator] $this: VALUE_PARAMETER name: type:.Some.Some> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Some declared in .Some' + RETURN type=kotlin.Nothing from='public final fun component1 (): T of .Some [operator] declared in .Some' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:T of .Some visibility:private [final]' type=T of .Some origin=null receiver: GET_VAR ': .Some.Some> declared in .Some.component1' type=.Some.Some> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Some.Some>, value:T of .Some) returnType:.Some.Some> diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt index cf0380f32ae..885315add8f 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt @@ -41,7 +41,7 @@ data class DataClass : Derived, Delegate { field = delegate get - fun component1(): Delegate { + operator fun component1(): Delegate { return .#delegate } diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt index c2fbb9ed3f7..eee7eb43a0e 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.txt @@ -104,10 +104,10 @@ FILE fqName: fileName:/SignatureClash.kt RETURN type=kotlin.Nothing from='public final fun (): .Delegate declared in .DataClass' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegate type:.Delegate visibility:private [final]' type=.Delegate origin=null receiver: GET_VAR ': .DataClass declared in .DataClass.' type=.DataClass origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.DataClass) returnType:.Delegate + FUN name:component1 visibility:public modality:FINAL <> ($this:.DataClass) returnType:.Delegate [operator] $this: VALUE_PARAMETER name: type:.DataClass BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): .Delegate declared in .DataClass' + RETURN type=kotlin.Nothing from='public final fun component1 (): .Delegate [operator] declared in .DataClass' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegate type:.Delegate visibility:private [final]' type=.Delegate origin=null receiver: GET_VAR ': .DataClass declared in .DataClass.component1' type=.DataClass origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.DataClass, delegate:.Delegate) returnType:.DataClass diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt index 23eb3ba3ee1..0cd20cbde77 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.kt.txt @@ -13,11 +13,11 @@ data class A { field = y get - fun component1(): Int { + operator fun component1(): Int { return .#x } - fun component2(): Int { + operator fun component2(): Int { return .#y } diff --git a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt index f47ca804e57..4dfedbe9ffb 100644 --- a/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt +++ b/compiler/testData/ir/irText/lambdas/destructuringInLambda.fir.txt @@ -29,16 +29,16 @@ FILE fqName: fileName:/destructuringInLambda.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .A' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .A declared in .A.' type=.A origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int + FUN name:component1 visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int [operator] $this: VALUE_PARAMETER name: type:.A BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in .A' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .A' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .A declared in .A.component1' type=.A origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int + FUN name:component2 visibility:public modality:FINAL <> ($this:.A) returnType:kotlin.Int [operator] $this: VALUE_PARAMETER name: type:.A BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int declared in .A' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int [operator] declared in .A' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .A declared in .A.component2' type=.A origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.A, x:kotlin.Int, y:kotlin.Int) returnType:.A @@ -143,7 +143,7 @@ FILE fqName: fileName:/destructuringInLambda.kt VALUE_PARAMETER name: index:0 type:.A BLOCK_BODY VAR name:y type:kotlin.Int [val] - CALL 'public final fun component2 (): kotlin.Int declared in .A' type=kotlin.Int origin=null + CALL 'public final fun component2 (): kotlin.Int [operator] declared in .A' type=kotlin.Int origin=null $this: GET_VAR ': .A declared in .fn.' type=.A origin=null RETURN type=kotlin.Nothing from='local final fun (: .A): kotlin.Int declared in .fn' CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.kt.txt index d450046e42d..74cbc9be0fa 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.kt.txt @@ -79,11 +79,11 @@ data class P { field = y get - fun component1(): Int { + operator fun component1(): Int { return .#x } - fun component2(): Int { + operator fun component2(): Int { return .#y } diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt index 9cf32cd3d9e..b8b589952e9 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt @@ -29,10 +29,10 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=.P? origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P?> origin=null VAR name:x type:kotlin.Int [val] - CALL 'public final fun component1 (): kotlin.Int declared in .P' type=kotlin.Int origin=null + CALL 'public final fun component1 (): kotlin.Int [operator] declared in .P' type=kotlin.Int origin=null $this: GET_VAR 'val : .P? [val] declared in .testForInListDestructured' type=.P? origin=null VAR name:y type:kotlin.Int [val] - CALL 'public final fun component2 (): kotlin.Int declared in .P' type=kotlin.Int origin=null + CALL 'public final fun component2 (): kotlin.Int [operator] declared in .P' type=kotlin.Int origin=null $this: GET_VAR 'val : .P? [val] declared in .testForInListDestructured' type=.P? origin=null FUN name:testDesugaredForInList visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY @@ -146,16 +146,16 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .P' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .P declared in .P.' type=.P origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.P) returnType:kotlin.Int + FUN name:component1 visibility:public modality:FINAL <> ($this:.P) returnType:kotlin.Int [operator] $this: VALUE_PARAMETER name: type:.P BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in .P' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .P' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .P declared in .P.component1' type=.P origin=null - FUN name:component2 visibility:public modality:FINAL <> ($this:.P) returnType:kotlin.Int + FUN name:component2 visibility:public modality:FINAL <> ($this:.P) returnType:kotlin.Int [operator] $this: VALUE_PARAMETER name: type:.P BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int declared in .P' + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int [operator] declared in .P' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': .P declared in .P.component2' type=.P origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.P, x:kotlin.Int, y:kotlin.Int) returnType:.P diff --git a/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.kt.txt b/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.kt.txt index ad11ecd704c..93b2be28f4f 100644 --- a/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.kt.txt +++ b/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.kt.txt @@ -10,7 +10,7 @@ data class Tag { field = action get - fun component1(): Function1 { + operator fun component1(): Function1 { return .#action } diff --git a/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.txt b/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.txt index 66300117be1..02643aef73c 100644 --- a/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.txt +++ b/compiler/testData/ir/irText/types/typeAliasWithUnsafeVariance.fir.txt @@ -20,10 +20,10 @@ FILE fqName: fileName:/typeAliasWithUnsafeVariance.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Function1.Tag, kotlin.Unit> declared in .Tag' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:action type:kotlin.Function1.Tag, kotlin.Unit> visibility:private [final]' type=kotlin.Function1.Tag, kotlin.Unit> origin=null receiver: GET_VAR ': .Tag.Tag> declared in .Tag.' type=.Tag.Tag> origin=null - FUN name:component1 visibility:public modality:FINAL <> ($this:.Tag.Tag>) returnType:kotlin.Function1.Tag, kotlin.Unit> + FUN name:component1 visibility:public modality:FINAL <> ($this:.Tag.Tag>) returnType:kotlin.Function1.Tag, kotlin.Unit> [operator] $this: VALUE_PARAMETER name: type:.Tag.Tag> BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Function1.Tag, kotlin.Unit> declared in .Tag' + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Function1.Tag, kotlin.Unit> [operator] declared in .Tag' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:action type:kotlin.Function1.Tag, kotlin.Unit> visibility:private [final]' type=kotlin.Function1.Tag, kotlin.Unit> origin=null receiver: GET_VAR ': .Tag.Tag> declared in .Tag.component1' type=.Tag.Tag> origin=null FUN name:copy visibility:public modality:FINAL <> ($this:.Tag.Tag>, action:kotlin.Function1.Tag, kotlin.Unit>) returnType:.Tag.Tag> From 06ee768c6adf381ee23b3681409223c14e892e6c Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 19 Jan 2021 18:19:45 +0300 Subject: [PATCH 099/122] FIR: in case of smart cast, use original type for FirThisRcvrExpression Before this commit, we used type after smart cast both for original FirThisReceiverExpression and for wrapping FirExpressionWithSmartCast. However, this makes FIR2IR implicit cast generator work incorrectly (it decides not to insert implicit cast because original type is the same). After this commit, expressions have different types and implicit cast generator works properly. --- .../runners/ir/Fir2IrTextTestGenerated.java | 6 + .../kotlin/fir/resolve/calls/FirReceivers.kt | 2 + .../FirExpressionsResolveTransformer.kt | 2 +- .../implicitCastToTypeParameter.fir.kt.txt | 35 - .../implicitCastToTypeParameter.fir.txt | 81 -- .../implicitCastToTypeParameter.kt | 1 + .../firProblems/SimpleTypeMarker.fir.kt.txt | 39 + .../firProblems/SimpleTypeMarker.fir.txt | 96 ++ .../ir/irText/firProblems/SimpleTypeMarker.kt | 22 + .../firProblems/SimpleTypeMarker.kt.txt | 39 + .../irText/firProblems/SimpleTypeMarker.txt | 96 ++ .../test/runners/ir/IrTextTestGenerated.java | 6 + .../diagnostics/notLinked/dfa/neg/28.fir.kt | 4 +- .../diagnostics/notLinked/dfa/pos/11.fir.kt | 112 +- .../diagnostics/notLinked/dfa/pos/12.fir.kt | 1192 ++++++++--------- .../diagnostics/notLinked/dfa/pos/14.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/44.fir.kt | 8 +- .../diagnostics/notLinked/dfa/pos/50.fir.kt | 36 +- 18 files changed, 988 insertions(+), 797 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt create mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/SimpleTypeMarker.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index bb8072a0083..3fc97204f64 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -2176,6 +2176,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/firProblems/SignatureClash.kt"); } + @Test + @TestMetadata("SimpleTypeMarker.kt") + public void testSimpleTypeMarker() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt"); + } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt index a8eb72f0d49..d0a0e3c4dab 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt @@ -67,6 +67,8 @@ sealed class ImplicitReceiverValue>( final override var type: ConeKotlinType = type private set + val originalType: ConeKotlinType = type + var implicitScope: FirTypeScope? = type.scope(useSiteSession, scopeSession, FakeOverrideTypeCalculator.DoNothing) private set diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt index 786b7c061d2..6db37b3e083 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirExpressionsResolveTransformer.kt @@ -78,7 +78,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform implicitReceiver?.boundSymbol?.let { callee.replaceBoundSymbol(it) } - val implicitType = implicitReceiver?.type + val implicitType = implicitReceiver?.originalType qualifiedAccessExpression.resultType = when { implicitReceiver is InaccessibleImplicitReceiverValue -> buildErrorTypeRef { source = qualifiedAccessExpression.source diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt deleted file mode 100644 index 8afcaf303af..00000000000 --- a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.kt.txt +++ /dev/null @@ -1,35 +0,0 @@ -inline fun Any.test1(): T? { - return when { - is T -> - else -> null - } -} - -interface Foo { - -} - -val Foo.asT: T? - inline get(): T? { - return when { - is T -> /*as T */ - else -> null - } - } - -class Bar { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun test(arg: Any) { - arg as T /*~> Unit */ - .useT(t = arg /*as T */) - } - - fun useT(t: T) { - } - -} diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.txt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.txt deleted file mode 100644 index ff627c5d41f..00000000000 --- a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.fir.txt +++ /dev/null @@ -1,81 +0,0 @@ -FILE fqName: fileName:/implicitCastToTypeParameter.kt - FUN name:test1 visibility:public modality:FINAL ($receiver:kotlin.Any) returnType:T of .test1? [inline] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] - $receiver: VALUE_PARAMETER name: type:kotlin.Any - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (): T of .test1? [inline] declared in ' - WHEN type=T of .test1? origin=IF - BRANCH - if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of .test1 - GET_VAR ': kotlin.Any declared in .test1' type=kotlin.Any origin=null - then: GET_VAR ': kotlin.Any declared in .test1' type=T of .test1 origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Null type=kotlin.Nothing? value=null - CLASS INTERFACE name:Foo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Foo.Foo> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - PROPERTY name:asT visibility:public modality:FINAL [val] - FUN name: visibility:public modality:FINAL ($receiver:.Foo.>) returnType:T of .? [inline] - correspondingProperty: PROPERTY name:asT visibility:public modality:FINAL [val] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] - $receiver: VALUE_PARAMETER name: type:.Foo.> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): T of .? [inline] declared in ' - WHEN type=T of .? origin=IF - BRANCH - if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=T of . - GET_VAR ': .Foo.> declared in .' type=.Foo.> origin=null - then: TYPE_OP type=T of . origin=IMPLICIT_CAST typeOperand=T of . - GET_VAR ': .Foo.> declared in .' type=.Foo.> origin=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Null type=kotlin.Nothing? value=null - CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Bar.Bar> - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - CONSTRUCTOR visibility:public <> () returnType:.Bar.Bar> [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Bar modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:test visibility:public modality:FINAL <> ($this:.Bar.Bar>, arg:kotlin.Any) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Bar.Bar> - VALUE_PARAMETER name:arg index:0 type:kotlin.Any - BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - TYPE_OP type=T of .Bar origin=CAST typeOperand=T of .Bar - GET_VAR 'arg: kotlin.Any declared in .Bar.test' type=kotlin.Any origin=null - CALL 'public final fun useT (t: T of .Bar): kotlin.Unit declared in .Bar' type=kotlin.Unit origin=null - $this: GET_VAR ': .Bar.Bar> declared in .Bar.test' type=.Bar.Bar> origin=null - t: TYPE_OP type=T of .Bar origin=IMPLICIT_CAST typeOperand=T of .Bar - GET_VAR 'arg: kotlin.Any declared in .Bar.test' type=kotlin.Any origin=null - FUN name:useT visibility:public modality:FINAL <> ($this:.Bar.Bar>, t:T of .Bar) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Bar.Bar> - VALUE_PARAMETER name:t index:0 type:T of .Bar - BLOCK_BODY - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] - overridden: - public open fun hashCode (): kotlin.Int declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any - FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] - overridden: - public open fun toString (): kotlin.String declared in kotlin.Any - $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt index 5e9a09ea788..3c87e7b8455 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt +++ b/compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL inline fun Any.test1(): T? = if (this is T) this else null diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt new file mode 100644 index 00000000000..f58c86deb73 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.kt.txt @@ -0,0 +1,39 @@ +interface SimpleTypeMarker { + +} + +class SimpleType : SimpleTypeMarker { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun foo(): String { + return "OK" + } + +} + +interface User { + fun SimpleTypeMarker.bar(): String { + require(value = is SimpleType) + return /*as SimpleType */.foo() + } + +} + +class UserImpl { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun SimpleTypeMarker.bar(): String { + require(value = is SimpleType) + return /*as SimpleType */.foo() + } + +} + diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt new file mode 100644 index 00000000000..43d658ac456 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.fir.txt @@ -0,0 +1,96 @@ +FILE fqName: fileName:/SimpleTypeMarker.kt + CLASS INTERFACE name:SimpleTypeMarker modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SimpleTypeMarker + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:SimpleType modality:FINAL visibility:public superTypes:[.SimpleTypeMarker] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SimpleType + CONSTRUCTOR visibility:public <> () returnType:.SimpleType [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:SimpleType modality:FINAL visibility:public superTypes:[.SimpleTypeMarker]' + FUN name:foo visibility:public modality:FINAL <> ($this:.SimpleType) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.SimpleType + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in .SimpleType' + CONST String type=kotlin.String value="OK" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:User modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.User + FUN name:bar visibility:public modality:OPEN <> ($this:.User, $receiver:.SimpleTypeMarker) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.User + $receiver: VALUE_PARAMETER name: type:.SimpleTypeMarker + BLOCK_BODY + CALL 'public final fun require (value: kotlin.Boolean): kotlin.Unit [inline] declared in kotlin.PreconditionsKt' type=kotlin.Unit origin=null + value: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .User.bar' type=.SimpleTypeMarker origin=null + RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.String declared in .User' + CALL 'public final fun foo (): kotlin.String declared in .SimpleType' type=kotlin.String origin=null + $this: TYPE_OP type=.SimpleType origin=IMPLICIT_CAST typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .User.bar' type=.SimpleTypeMarker origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:UserImpl modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.UserImpl + CONSTRUCTOR visibility:public <> () returnType:.UserImpl [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:UserImpl modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:bar visibility:public modality:FINAL <> ($this:.UserImpl, $receiver:.SimpleTypeMarker) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.UserImpl + $receiver: VALUE_PARAMETER name: type:.SimpleTypeMarker + BLOCK_BODY + CALL 'public final fun require (value: kotlin.Boolean): kotlin.Unit [inline] declared in kotlin.PreconditionsKt' type=kotlin.Unit origin=null + value: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .UserImpl.bar' type=.SimpleTypeMarker origin=null + RETURN type=kotlin.Nothing from='public final fun bar (): kotlin.String declared in .UserImpl' + CALL 'public final fun foo (): kotlin.String declared in .SimpleType' type=kotlin.String origin=null + $this: TYPE_OP type=.SimpleType origin=IMPLICIT_CAST typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .UserImpl.bar' type=.SimpleTypeMarker origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt new file mode 100644 index 00000000000..efce8922b20 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt @@ -0,0 +1,22 @@ +// WITH_RUNTIME + +interface SimpleTypeMarker + +class SimpleType : SimpleTypeMarker { + fun foo() = "OK" +} + +interface User { + fun SimpleTypeMarker.bar(): String { + require(this is SimpleType) + return this.foo() + } +} + +class UserImpl { + fun SimpleTypeMarker.bar(): String { + require(this is SimpleType) + return this.foo() + } +} + diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt.txt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt.txt new file mode 100644 index 00000000000..f58c86deb73 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt.txt @@ -0,0 +1,39 @@ +interface SimpleTypeMarker { + +} + +class SimpleType : SimpleTypeMarker { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun foo(): String { + return "OK" + } + +} + +interface User { + fun SimpleTypeMarker.bar(): String { + require(value = is SimpleType) + return /*as SimpleType */.foo() + } + +} + +class UserImpl { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun SimpleTypeMarker.bar(): String { + require(value = is SimpleType) + return /*as SimpleType */.foo() + } + +} + diff --git a/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.txt b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.txt new file mode 100644 index 00000000000..2a1b44bf546 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/SimpleTypeMarker.txt @@ -0,0 +1,96 @@ +FILE fqName: fileName:/SimpleTypeMarker.kt + CLASS INTERFACE name:SimpleTypeMarker modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SimpleTypeMarker + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:SimpleType modality:FINAL visibility:public superTypes:[.SimpleTypeMarker] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.SimpleType + CONSTRUCTOR visibility:public <> () returnType:.SimpleType [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:SimpleType modality:FINAL visibility:public superTypes:[.SimpleTypeMarker]' + FUN name:foo visibility:public modality:FINAL <> ($this:.SimpleType) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.SimpleType + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.String declared in .SimpleType' + CONST String type=kotlin.String value="OK" + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .SimpleTypeMarker + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .SimpleTypeMarker + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .SimpleTypeMarker + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:User modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.User + FUN name:bar visibility:public modality:OPEN <> ($this:.User, $receiver:.SimpleTypeMarker) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.User + $receiver: VALUE_PARAMETER name: type:.SimpleTypeMarker + BLOCK_BODY + CALL 'public final fun require (value: kotlin.Boolean): kotlin.Unit [inline] declared in kotlin.PreconditionsKt' type=kotlin.Unit origin=null + value: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .User.bar' type=.SimpleTypeMarker origin=null + RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.String declared in .User' + CALL 'public final fun foo (): kotlin.String declared in .SimpleType' type=kotlin.String origin=null + $this: TYPE_OP type=.SimpleType origin=IMPLICIT_CAST typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .User.bar' type=.SimpleTypeMarker origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:UserImpl modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.UserImpl + CONSTRUCTOR visibility:public <> () returnType:.UserImpl [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:UserImpl modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:bar visibility:public modality:FINAL <> ($this:.UserImpl, $receiver:.SimpleTypeMarker) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.UserImpl + $receiver: VALUE_PARAMETER name: type:.SimpleTypeMarker + BLOCK_BODY + CALL 'public final fun require (value: kotlin.Boolean): kotlin.Unit [inline] declared in kotlin.PreconditionsKt' type=kotlin.Unit origin=null + value: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .UserImpl.bar' type=.SimpleTypeMarker origin=null + RETURN type=kotlin.Nothing from='public final fun bar (): kotlin.String declared in .UserImpl' + CALL 'public final fun foo (): kotlin.String declared in .SimpleType' type=kotlin.String origin=null + $this: TYPE_OP type=.SimpleType origin=IMPLICIT_CAST typeOperand=.SimpleType + GET_VAR ': .SimpleTypeMarker declared in .UserImpl.bar' type=.SimpleTypeMarker origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index 9a902176101..3f34ba8a394 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -2176,6 +2176,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/firProblems/SignatureClash.kt"); } + @Test + @TestMetadata("SimpleTypeMarker.kt") + public void testSimpleTypeMarker() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/SimpleTypeMarker.kt"); + } + @Test @TestMetadata("SyntheticSetterType.kt") public void testSyntheticSetterType() throws Exception { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt index bc4e2af6ba6..788f77ff66f 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/neg/28.fir.kt @@ -5,7 +5,7 @@ // TESTCASE NUMBER: 1 fun > Inv.case_1() { if (this is MutableList<*>) { - & Inv & kotlin.collections.MutableList<*> & Inv")!>this - & Inv & kotlin.collections.MutableList<*> & Inv")!>this[0] = & Inv & kotlin.collections.MutableList<*> & Inv")!>this[1] + & Inv & Inv")!>this + & Inv & Inv")!>this[0] = & Inv & Inv")!>this[1] } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt index f69f3a25738..578a5a62ed9 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.fir.kt @@ -54,16 +54,16 @@ fun case_3(a: Int?, b: Float?, c: Double?, d: Boolean?) { }.apply { ?")!>this if (this != null) { - & kotlin.Number & kotlin.Comparable<*>")!>this - & kotlin.Number & kotlin.Comparable<*>")!>this.equals(null) - & kotlin.Number & kotlin.Comparable<*>")!>this.propT - & kotlin.Number & kotlin.Comparable<*>")!>this.propAny - & kotlin.Number & kotlin.Comparable<*>")!>this.propNullableT - & kotlin.Number & kotlin.Comparable<*>")!>this.propNullableAny - & kotlin.Number & kotlin.Comparable<*>")!>this.funT() - & kotlin.Number & kotlin.Comparable<*>")!>this.funAny() - & kotlin.Number & kotlin.Comparable<*>")!>this.funNullableT() - & kotlin.Number & kotlin.Comparable<*>")!>this.funNullableAny() + & kotlin.Number? & kotlin.Comparable<*>?")!>this + & kotlin.Number? & kotlin.Comparable<*>?")!>this.equals(null) + & kotlin.Number? & kotlin.Comparable<*>?")!>this.propT + & kotlin.Number? & kotlin.Comparable<*>?")!>this.propAny + & kotlin.Number? & kotlin.Comparable<*>?")!>this.propNullableT + & kotlin.Number? & kotlin.Comparable<*>?")!>this.propNullableAny + & kotlin.Number? & kotlin.Comparable<*>?")!>this.funT() + & kotlin.Number? & kotlin.Comparable<*>?")!>this.funAny() + & kotlin.Number? & kotlin.Comparable<*>?")!>this.funNullableT() + & kotlin.Number? & kotlin.Comparable<*>?")!>this.funNullableAny() } }.let { ?")!>it @@ -97,16 +97,16 @@ fun case_4(a: Interface1?, b: Interface2?, c: Boolean) { x.apply { this if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } x.let { @@ -140,16 +140,16 @@ fun case_5(a: Interface1?, b: Interface2?, d: Boolean) { x.apply { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } x.let { @@ -182,20 +182,20 @@ fun case_6(a: Interface1?, b: Interface2, d: Boolean) { x.apply { this as Interface3 - this + this if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.itest2() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.itest2() } } x.let { @@ -232,20 +232,20 @@ fun case_7(a: Interface1?, b: Interface2?, d: Boolean) { x.apply { this as Interface3? - this + this if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.itest2() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.itest2() } } x.let { diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt index 1bebdfc9a4f..d4e97b770a2 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.fir.kt @@ -55,32 +55,32 @@ fun T?.case_2() { // TESTCASE NUMBER: 3 fun T.case_3() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } // TESTCASE NUMBER: 4 fun T?.case_4() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() } } @@ -88,17 +88,17 @@ fun T?.case_4() { fun T?.case_5() { if (this is Interface1) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -148,17 +148,17 @@ fun T?.case_5() { fun T?.case_6() { if (this is Interface1?) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -263,17 +263,17 @@ fun T.case_7() { fun T.case_8() { if (this != null) { if (this is Interface1?) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -392,17 +392,17 @@ fun T.case_9() { // TESTCASE NUMBER: 10 fun T.case_10() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.toByte() equals(this) toByte() @@ -449,17 +449,17 @@ fun T.case_10() { fun T?.case_11() { if (this is Interface1?) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -506,18 +506,18 @@ fun T?.case_11() { // TESTCASE NUMBER: 12 fun T.case_12() where T : Number?, T: Interface1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.toByte() equals(this) itest1() @@ -648,17 +648,17 @@ fun T.case_13() where T : Out<*>?, T: Comparable { */ fun ?> T.case_14() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() equals(this) get() @@ -708,17 +708,17 @@ fun ?> T.case_14() { */ fun ?> T.case_15() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() equals(this) itest1() @@ -768,17 +768,17 @@ fun ?> T.case_15() { */ fun ?> T.case_16() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -828,17 +828,17 @@ fun ?> T.case_16() { */ fun ?> T.case_17() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -942,17 +942,17 @@ fun ?> T.case_18() { */ fun ?> T.case_19() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -1002,18 +1002,18 @@ fun ?> T.case_19() { */ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWithTypeParameter2? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() - this.ip1test2() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() + this.ip1test2() equals(this) ip1test1() @@ -1067,19 +1067,19 @@ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWit */ fun T.case_21() where T: InterfaceWithTypeParameter1?, T: InterfaceWithTypeParameter2?, T: InterfaceWithTypeParameter3? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() - this.ip1test2() - this.ip1test3() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() + this.ip1test2() + this.ip1test3() equals(this) ip1test1() @@ -1187,17 +1187,17 @@ fun >?> T.case // TESTCASE NUMBER: 23 fun >?> T.case_23() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -1243,17 +1243,17 @@ fun >?> T.case // TESTCASE NUMBER: 24 fun > InterfaceWithTypeParameter1?.case_24() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(this) ip1test1() @@ -1299,17 +1299,17 @@ fun > InterfaceWithTypeParameter1?.case // TESTCASE NUMBER: 25 fun > InterfaceWithTypeParameter1?.case_25() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(this) ip1test1() @@ -1355,17 +1355,17 @@ fun > InterfaceWithTypeParameter1?.cas // TESTCASE NUMBER: 26 fun > InterfaceWithTypeParameter1?.case_26() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -1427,17 +1427,17 @@ fun > InterfaceWithTypeParameter1?.case // TESTCASE NUMBER: 27 fun > InterfaceWithTypeParameter1?.case_27() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -1499,17 +1499,17 @@ fun > InterfaceWithTypeParameter1?.cas // TESTCASE NUMBER: 28 fun > InterfaceWithTypeParameter1?.case_28() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -1571,17 +1571,17 @@ fun > InterfaceWithTypeParameter1?. // TESTCASE NUMBER: 29 fun > InterfaceWithTypeParameter1?.case_29() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -1643,17 +1643,17 @@ fun > InterfaceWithTypeParameter1?. // TESTCASE NUMBER: 30 fun > InterfaceWithTypeParameter1?.case_30() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -1715,17 +1715,17 @@ fun > InterfaceWithTypeParameter1?.c // TESTCASE NUMBER: 31 fun > InterfaceWithTypeParameter1?.case_31() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -1787,17 +1787,17 @@ fun > InterfaceWithTypeParameter1? // TESTCASE NUMBER: 32 fun Map?.case_32() { if (this != null) { - & kotlin.collections.Map")!>this - & kotlin.collections.Map")!>this.equals(null) - & kotlin.collections.Map")!>this.propT - & kotlin.collections.Map")!>this.propAny - & kotlin.collections.Map")!>this.propNullableT - & kotlin.collections.Map")!>this.propNullableAny - & kotlin.collections.Map")!>this.funT() - & kotlin.collections.Map")!>this.funAny() - & kotlin.collections.Map")!>this.funNullableT() - & kotlin.collections.Map")!>this.funNullableAny() - & kotlin.collections.Map")!>this.isEmpty() + & kotlin.collections.Map?")!>this + & kotlin.collections.Map?")!>this.equals(null) + & kotlin.collections.Map?")!>this.propT + & kotlin.collections.Map?")!>this.propAny + & kotlin.collections.Map?")!>this.propNullableT + & kotlin.collections.Map?")!>this.propNullableAny + & kotlin.collections.Map?")!>this.funT() + & kotlin.collections.Map?")!>this.funAny() + & kotlin.collections.Map?")!>this.funNullableT() + & kotlin.collections.Map?")!>this.funNullableAny() + & kotlin.collections.Map?")!>this.isEmpty() equals(null) @@ -1859,17 +1859,17 @@ fun Map?.case_32() { // TESTCASE NUMBER: 33 fun InterfaceWithFiveTypeParameters1?.case_33() { if (this != null) { - & InterfaceWithFiveTypeParameters1")!>this - & InterfaceWithFiveTypeParameters1")!>this.equals(null) - & InterfaceWithFiveTypeParameters1")!>this.propT - & InterfaceWithFiveTypeParameters1")!>this.propAny - & InterfaceWithFiveTypeParameters1")!>this.propNullableT - & InterfaceWithFiveTypeParameters1")!>this.propNullableAny - & InterfaceWithFiveTypeParameters1")!>this.funT() - & InterfaceWithFiveTypeParameters1")!>this.funAny() - & InterfaceWithFiveTypeParameters1")!>this.funNullableT() - & InterfaceWithFiveTypeParameters1")!>this.funNullableAny() - & InterfaceWithFiveTypeParameters1")!>this.itest() + & InterfaceWithFiveTypeParameters1?")!>this + & InterfaceWithFiveTypeParameters1?")!>this.equals(null) + & InterfaceWithFiveTypeParameters1?")!>this.propT + & InterfaceWithFiveTypeParameters1?")!>this.propAny + & InterfaceWithFiveTypeParameters1?")!>this.propNullableT + & InterfaceWithFiveTypeParameters1?")!>this.propNullableAny + & InterfaceWithFiveTypeParameters1?")!>this.funT() + & InterfaceWithFiveTypeParameters1?")!>this.funAny() + & InterfaceWithFiveTypeParameters1?")!>this.funNullableT() + & InterfaceWithFiveTypeParameters1?")!>this.funNullableAny() + & InterfaceWithFiveTypeParameters1?")!>this.itest() equals(null) @@ -1931,17 +1931,17 @@ fun InterfaceWithFiveTypeParameters1?.case_33() { // TESTCASE NUMBER: 34 fun InterfaceWithTypeParameter1?.case_34() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -2003,17 +2003,17 @@ fun InterfaceWithTypeParameter1?.case_34() { // TESTCASE NUMBER: 35 fun InterfaceWithTypeParameter1?.case_35() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -2075,17 +2075,17 @@ fun InterfaceWithTypeParameter1?.case_35() { // TESTCASE NUMBER: 36 fun InterfaceWithTypeParameter1?.case_36() { if (this != null) { - & InterfaceWithTypeParameter1")!>this - & InterfaceWithTypeParameter1")!>this.equals(null) - & InterfaceWithTypeParameter1")!>this.propT - & InterfaceWithTypeParameter1")!>this.propAny - & InterfaceWithTypeParameter1")!>this.propNullableT - & InterfaceWithTypeParameter1")!>this.propNullableAny - & InterfaceWithTypeParameter1")!>this.funT() - & InterfaceWithTypeParameter1")!>this.funAny() - & InterfaceWithTypeParameter1")!>this.funNullableT() - & InterfaceWithTypeParameter1")!>this.funNullableAny() - & InterfaceWithTypeParameter1")!>this.ip1test1() + & InterfaceWithTypeParameter1?")!>this + & InterfaceWithTypeParameter1?")!>this.equals(null) + & InterfaceWithTypeParameter1?")!>this.propT + & InterfaceWithTypeParameter1?")!>this.propAny + & InterfaceWithTypeParameter1?")!>this.propNullableT + & InterfaceWithTypeParameter1?")!>this.propNullableAny + & InterfaceWithTypeParameter1?")!>this.funT() + & InterfaceWithTypeParameter1?")!>this.funAny() + & InterfaceWithTypeParameter1?")!>this.funNullableT() + & InterfaceWithTypeParameter1?")!>this.funNullableAny() + & InterfaceWithTypeParameter1?")!>this.ip1test1() equals(null) @@ -2147,17 +2147,17 @@ fun InterfaceWithTypeParameter1?.case_36() { // TESTCASE NUMBER: 37 fun Map?.case_37() { if (this != null) { - & kotlin.collections.Map")!>this - & kotlin.collections.Map")!>this.equals(null) - & kotlin.collections.Map")!>this.propT - & kotlin.collections.Map")!>this.propAny - & kotlin.collections.Map")!>this.propNullableT - & kotlin.collections.Map")!>this.propNullableAny - & kotlin.collections.Map")!>this.funT() - & kotlin.collections.Map")!>this.funAny() - & kotlin.collections.Map")!>this.funNullableT() - & kotlin.collections.Map")!>this.funNullableAny() - & kotlin.collections.Map")!>this.isEmpty() + & kotlin.collections.Map?")!>this + & kotlin.collections.Map?")!>this.equals(null) + & kotlin.collections.Map?")!>this.propT + & kotlin.collections.Map?")!>this.propAny + & kotlin.collections.Map?")!>this.propNullableT + & kotlin.collections.Map?")!>this.propNullableAny + & kotlin.collections.Map?")!>this.funT() + & kotlin.collections.Map?")!>this.funAny() + & kotlin.collections.Map?")!>this.funNullableT() + & kotlin.collections.Map?")!>this.funNullableAny() + & kotlin.collections.Map?")!>this.isEmpty() equals(null) @@ -2219,17 +2219,17 @@ fun Map?.case_37() { // TESTCASE NUMBER: 38 fun Map<*, out T>?.case_38() { if (this != null) { - & kotlin.collections.Map<*, out T>")!>this - & kotlin.collections.Map<*, out T>")!>this.equals(null) - & kotlin.collections.Map<*, out T>")!>this.propT - & kotlin.collections.Map<*, out T>")!>this.propAny - & kotlin.collections.Map<*, out T>")!>this.propNullableT - & kotlin.collections.Map<*, out T>")!>this.propNullableAny - & kotlin.collections.Map<*, out T>")!>this.funT() - & kotlin.collections.Map<*, out T>")!>this.funAny() - & kotlin.collections.Map<*, out T>")!>this.funNullableT() - & kotlin.collections.Map<*, out T>")!>this.funNullableAny() - & kotlin.collections.Map<*, out T>")!>this.isEmpty() + & kotlin.collections.Map<*, out T>?")!>this + & kotlin.collections.Map<*, out T>?")!>this.equals(null) + & kotlin.collections.Map<*, out T>?")!>this.propT + & kotlin.collections.Map<*, out T>?")!>this.propAny + & kotlin.collections.Map<*, out T>?")!>this.propNullableT + & kotlin.collections.Map<*, out T>?")!>this.propNullableAny + & kotlin.collections.Map<*, out T>?")!>this.funT() + & kotlin.collections.Map<*, out T>?")!>this.funAny() + & kotlin.collections.Map<*, out T>?")!>this.funNullableT() + & kotlin.collections.Map<*, out T>?")!>this.funNullableAny() + & kotlin.collections.Map<*, out T>?")!>this.isEmpty() equals(null) @@ -2291,16 +2291,16 @@ fun Map<*, out T>?.case_38() { // TESTCASE NUMBER: 39 fun InterfaceWithTwoTypeParameters?.case_39() { if (this != null) { - & InterfaceWithTwoTypeParameters")!>this - & InterfaceWithTwoTypeParameters")!>this.equals(null) - & InterfaceWithTwoTypeParameters")!>this.propT - & InterfaceWithTwoTypeParameters")!>this.propAny - & InterfaceWithTwoTypeParameters")!>this.propNullableT - & InterfaceWithTwoTypeParameters")!>this.propNullableAny - & InterfaceWithTwoTypeParameters")!>this.funT() - & InterfaceWithTwoTypeParameters")!>this.funAny() - & InterfaceWithTwoTypeParameters")!>this.funNullableT() - & InterfaceWithTwoTypeParameters")!>this.funNullableAny() + & InterfaceWithTwoTypeParameters?")!>this + & InterfaceWithTwoTypeParameters?")!>this.equals(null) + & InterfaceWithTwoTypeParameters?")!>this.propT + & InterfaceWithTwoTypeParameters?")!>this.propAny + & InterfaceWithTwoTypeParameters?")!>this.propNullableT + & InterfaceWithTwoTypeParameters?")!>this.propNullableAny + & InterfaceWithTwoTypeParameters?")!>this.funT() + & InterfaceWithTwoTypeParameters?")!>this.funAny() + & InterfaceWithTwoTypeParameters?")!>this.funNullableT() + & InterfaceWithTwoTypeParameters?")!>this.funNullableAny() equals(null) @@ -2358,16 +2358,16 @@ fun InterfaceWithTwoTypeParameters?.case_39() { // TESTCASE NUMBER: 40 fun InterfaceWithTwoTypeParameters?.case_40() { if (this != null) { - & InterfaceWithTwoTypeParameters")!>this - & InterfaceWithTwoTypeParameters")!>this.equals(null) - & InterfaceWithTwoTypeParameters")!>this.propT - & InterfaceWithTwoTypeParameters")!>this.propAny - & InterfaceWithTwoTypeParameters")!>this.propNullableT - & InterfaceWithTwoTypeParameters")!>this.propNullableAny - & InterfaceWithTwoTypeParameters")!>this.funT() - & InterfaceWithTwoTypeParameters")!>this.funAny() - & InterfaceWithTwoTypeParameters")!>this.funNullableT() - & InterfaceWithTwoTypeParameters")!>this.funNullableAny() + & InterfaceWithTwoTypeParameters?")!>this + & InterfaceWithTwoTypeParameters?")!>this.equals(null) + & InterfaceWithTwoTypeParameters?")!>this.propT + & InterfaceWithTwoTypeParameters?")!>this.propAny + & InterfaceWithTwoTypeParameters?")!>this.propNullableT + & InterfaceWithTwoTypeParameters?")!>this.propNullableAny + & InterfaceWithTwoTypeParameters?")!>this.funT() + & InterfaceWithTwoTypeParameters?")!>this.funAny() + & InterfaceWithTwoTypeParameters?")!>this.funNullableT() + & InterfaceWithTwoTypeParameters?")!>this.funNullableAny() equals(null) @@ -2425,17 +2425,17 @@ fun InterfaceWithTwoTypeParameters?.case_40() { // TESTCASE NUMBER: 41 fun Map?.case_41() { if (this != null) { - & kotlin.collections.Map")!>this - & kotlin.collections.Map")!>this.equals(null) - & kotlin.collections.Map")!>this.propT - & kotlin.collections.Map")!>this.propAny - & kotlin.collections.Map")!>this.propNullableT - & kotlin.collections.Map")!>this.propNullableAny - & kotlin.collections.Map")!>this.funT() - & kotlin.collections.Map")!>this.funAny() - & kotlin.collections.Map")!>this.funNullableT() - & kotlin.collections.Map")!>this.funNullableAny() - & kotlin.collections.Map")!>this.isEmpty() + & kotlin.collections.Map?")!>this + & kotlin.collections.Map?")!>this.equals(null) + & kotlin.collections.Map?")!>this.propT + & kotlin.collections.Map?")!>this.propAny + & kotlin.collections.Map?")!>this.propNullableT + & kotlin.collections.Map?")!>this.propNullableAny + & kotlin.collections.Map?")!>this.funT() + & kotlin.collections.Map?")!>this.funAny() + & kotlin.collections.Map?")!>this.funNullableT() + & kotlin.collections.Map?")!>this.funNullableAny() + & kotlin.collections.Map?")!>this.isEmpty() equals(null) @@ -2497,17 +2497,17 @@ fun Map?.case_41() { // TESTCASE NUMBER: 42 fun Map?.case_42() { if (this != null) { - & kotlin.collections.Map")!>this - & kotlin.collections.Map")!>this.equals(null) - & kotlin.collections.Map")!>this.propT - & kotlin.collections.Map")!>this.propAny - & kotlin.collections.Map")!>this.propNullableT - & kotlin.collections.Map")!>this.propNullableAny - & kotlin.collections.Map")!>this.funT() - & kotlin.collections.Map")!>this.funAny() - & kotlin.collections.Map")!>this.funNullableT() - & kotlin.collections.Map")!>this.funNullableAny() - & kotlin.collections.Map")!>this.isEmpty() + & kotlin.collections.Map?")!>this + & kotlin.collections.Map?")!>this.equals(null) + & kotlin.collections.Map?")!>this.propT + & kotlin.collections.Map?")!>this.propAny + & kotlin.collections.Map?")!>this.propNullableT + & kotlin.collections.Map?")!>this.propNullableAny + & kotlin.collections.Map?")!>this.funT() + & kotlin.collections.Map?")!>this.funAny() + & kotlin.collections.Map?")!>this.funNullableT() + & kotlin.collections.Map?")!>this.funNullableAny() + & kotlin.collections.Map?")!>this.isEmpty() equals(null) @@ -2569,17 +2569,17 @@ fun Map?.case_42() { // TESTCASE NUMBER: 43 fun Map?.case_43() { if (this != null) { - & kotlin.collections.Map")!>this - & kotlin.collections.Map")!>this.equals(null) - & kotlin.collections.Map")!>this.propT - & kotlin.collections.Map")!>this.propAny - & kotlin.collections.Map")!>this.propNullableT - & kotlin.collections.Map")!>this.propNullableAny - & kotlin.collections.Map")!>this.funT() - & kotlin.collections.Map")!>this.funAny() - & kotlin.collections.Map")!>this.funNullableT() - & kotlin.collections.Map")!>this.funNullableAny() - & kotlin.collections.Map")!>this.isEmpty() + & kotlin.collections.Map?")!>this + & kotlin.collections.Map?")!>this.equals(null) + & kotlin.collections.Map?")!>this.propT + & kotlin.collections.Map?")!>this.propAny + & kotlin.collections.Map?")!>this.propNullableT + & kotlin.collections.Map?")!>this.propNullableAny + & kotlin.collections.Map?")!>this.funT() + & kotlin.collections.Map?")!>this.funAny() + & kotlin.collections.Map?")!>this.funNullableT() + & kotlin.collections.Map?")!>this.funNullableAny() + & kotlin.collections.Map?")!>this.isEmpty() equals(null) @@ -2641,17 +2641,17 @@ fun Map?.case_43() { // TESTCASE NUMBER: 44 fun InterfaceWithFiveTypeParameters1?.case_44() { if (this != null) { - & InterfaceWithFiveTypeParameters1")!>this - & InterfaceWithFiveTypeParameters1")!>this.equals(null) - & InterfaceWithFiveTypeParameters1")!>this.propT - & InterfaceWithFiveTypeParameters1")!>this.propAny - & InterfaceWithFiveTypeParameters1")!>this.propNullableT - & InterfaceWithFiveTypeParameters1")!>this.propNullableAny - & InterfaceWithFiveTypeParameters1")!>this.funT() - & InterfaceWithFiveTypeParameters1")!>this.funAny() - & InterfaceWithFiveTypeParameters1")!>this.funNullableT() - & InterfaceWithFiveTypeParameters1")!>this.funNullableAny() - & InterfaceWithFiveTypeParameters1")!>this.itest() + & InterfaceWithFiveTypeParameters1?")!>this + & InterfaceWithFiveTypeParameters1?")!>this.equals(null) + & InterfaceWithFiveTypeParameters1?")!>this.propT + & InterfaceWithFiveTypeParameters1?")!>this.propAny + & InterfaceWithFiveTypeParameters1?")!>this.propNullableT + & InterfaceWithFiveTypeParameters1?")!>this.propNullableAny + & InterfaceWithFiveTypeParameters1?")!>this.funT() + & InterfaceWithFiveTypeParameters1?")!>this.funAny() + & InterfaceWithFiveTypeParameters1?")!>this.funNullableT() + & InterfaceWithFiveTypeParameters1?")!>this.funNullableAny() + & InterfaceWithFiveTypeParameters1?")!>this.itest() equals(null) @@ -2713,18 +2713,18 @@ fun InterfaceWithFiveTypeParameters1?.case_44() { // TESTCASE NUMBER: 45 fun T.case_45() where T : Number?, T: Comparable? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.toByte() - this.compareTo(this) + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.toByte() + this.compareTo(this) equals(this) toByte() @@ -2774,19 +2774,19 @@ fun T.case_45() where T : Number?, T: Comparable? { // TESTCASE NUMBER: 46 fun T.case_46() where T : CharSequence?, T: Comparable?, T: Iterable<*>? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.compareTo(this) - this.get(0) - this.iterator() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.compareTo(this) + this.get(0) + this.iterator() equals(this) compareTo(this) @@ -2844,18 +2844,18 @@ fun T.case_46() where T : CharSequence?, T: Comparable?, T: Iterable<*>? */ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -2900,7 +2900,7 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa it.ip1test1() } - this.compareTo(return) + this.compareTo(return) compareTo(return) apply { @@ -2921,18 +2921,18 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa */ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -2986,18 +2986,18 @@ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? */ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3051,18 +3051,18 @@ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? */ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3116,18 +3116,18 @@ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1 */ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3177,18 +3177,18 @@ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 52 fun T?.case_52() where T : Inv, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3242,18 +3242,18 @@ fun T?.case_52() where T : Inv, T: InterfaceWithTypeParameter1? { */ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3307,18 +3307,18 @@ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { */ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3368,18 +3368,18 @@ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 55 fun T?.case_55() where T : Inv<*>, T: InterfaceWithTypeParameter1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.get() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.get() + this.ip1test1() equals(this) get() @@ -3429,18 +3429,18 @@ fun T?.case_55() where T : Inv<*>, T: InterfaceWithTypeParameter1? { // TESTCASE NUMBER: 56 fun T.case_56() where T : Number?, T: Interface1? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest() - this.toByte() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest() + this.toByte() equals(this) itest() @@ -3571,17 +3571,17 @@ fun T.case_57() where T : Out<*>?, T: Comparable { // TESTCASE NUMBER: 58 fun >>>>>>>>>?> T.case_59() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -3631,19 +3631,19 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1?, T: InterfaceWithFiveTypeParameters2?, T: InterfaceWithFiveTypeParameters3? { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.itest1() - this.itest2() - this.itest3() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.itest1() + this.itest2() + this.itest3() equals(this) itest1() @@ -3701,17 +3701,17 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1?> T.case_60() { if (this != null) { - this - this.equals(null) - this.propT - this.propAny - this.propNullableT - this.propNullableAny - this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() - this.ip1test1() + this + this.equals(null) + this.propT + this.propAny + this.propNullableT + this.propNullableAny + this.funT() + this.funAny() + this.funNullableT() + this.funNullableAny() + this.ip1test1() equals(this) ip1test1() @@ -3766,10 +3766,10 @@ class Case61_3: InterfaceWithTypeParameter1, Case61_1, Case61_2 { fun T.case_61() where T : InterfaceWithTypeParameter1?, T: Case61_3?, T: Case61_1?, T: Case61_2? { if (this != null) { - this.test1() - this.test2() - this.ip1test1() - this.test4() + this.test1() + this.test2() + this.ip1test1() + this.test4() test1() test2() @@ -3799,8 +3799,8 @@ fun T.case_61() where T : InterfaceWithTypeParameter1?, T: Case61_3?, // TESTCASE NUMBER: 62 fun Nothing?.case_62() { if (this != null) { - this - this.hashCode() + this + this.hashCode() hashCode() apply { @@ -3840,8 +3840,8 @@ fun Nothing.case_63() { */ fun T.case_64() { if (this != null) { - this - this.hashCode() + this + this.hashCode() hashCode() apply { @@ -3865,16 +3865,16 @@ fun T.case_65() { if (this is Interface1?) { if (this is Interface2?) { if (this != null) { - this - this.equals(null) + this + this.equals(null) this.propT - this.propAny - this.propNullableT - this.propNullableAny + this.propAny + this.propNullableT + this.propNullableAny this.funT() - this.funAny() - this.funNullableT() - this.funNullableAny() + this.funAny() + this.funNullableT() + this.funNullableAny() apply { this this.equals(null) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt index 9d62f586de0..da8354f4c68 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/14.fir.kt @@ -14,8 +14,8 @@ fun case_1(vararg x: Int?) { fun case_2(vararg x: Int?) { x[0].apply { if (this != null) { - this - this.inv() + this + this.inv() } } @@ -39,8 +39,8 @@ fun case_3(vararg x: T?) { fun case_4(vararg x: T?) { x[0].apply { if (this != null) { - this - this.toByte() + this + this.toByte() } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt index 59ab61c5657..7535afb3fb3 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/44.fir.kt @@ -10,8 +10,8 @@ fun Int?.case_1() { val x = this if (x != null) { - this - this.inv() + this + this.inv() } } @@ -48,6 +48,6 @@ fun Int?.case_3() { fun Int?.case_4() { val x = this x!! - this - this.inv() + this + this.inv() } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt index 31942a1c5bf..033dd38d297 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/50.fir.kt @@ -5,9 +5,9 @@ // TESTCASE NUMBER: 1 fun Any.case_1() { if (this is Inv<*>) { - & Inv<*>")!>this.test() - & Inv<*>")!>this.prop_4 - & Inv<*>")!>this.prop_4.inv() + & kotlin.Any")!>this.test() + & kotlin.Any")!>this.prop_4 + & kotlin.Any")!>this.prop_4.inv() prop_4 prop_4.inv() } @@ -16,9 +16,9 @@ fun Any.case_1() { // TESTCASE NUMBER: 2 fun Any.case_2() { if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) { - & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>this.test() - & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>this.x - & ClassWithSixTypeParameters<*, *, *, *, *, *>")!>this.y + & kotlin.Any")!>this.test() + & kotlin.Any")!>this.x + & kotlin.Any")!>this.y x y } @@ -27,9 +27,9 @@ fun Any.case_2() { // TESTCASE NUMBER: 3 fun T.case_3() { if (this is Inv<*>) { - & T!! & Inv<*> & T!!")!>this.test() - & T!! & Inv<*> & T!!")!>this.prop_4 - & T!! & Inv<*> & T!!")!>this.prop_4.inv() + & T!! & T")!>this.test() + & T!! & T")!>this.prop_4 + & T!! & T")!>this.prop_4.inv() prop_4 prop_4.inv() } @@ -38,9 +38,9 @@ fun T.case_3() { // TESTCASE NUMBER: 4 fun T?.case_4() { if (this is ClassWithSixTypeParameters<*, *, *, *, *, *>) { - & T?!! & ClassWithSixTypeParameters<*, *, *, *, *, *> & T?!!")!>this.test() - & T?!! & ClassWithSixTypeParameters<*, *, *, *, *, *> & T?!!")!>this.x - & T?!! & ClassWithSixTypeParameters<*, *, *, *, *, *> & T?!!")!>this.y + & T?!! & T?")!>this.test() + & T?!! & T?")!>this.x + & T?!! & T?")!>this.y x y } @@ -49,11 +49,11 @@ fun T?.case_4() { // TESTCASE NUMBER: 5 fun ClassWithSixTypeParameters.case_5() { if (this is InterfaceWithFiveTypeParameters1<*, *, *, *, *>) { - & ClassWithSixTypeParameters & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.itest1() + & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.itest1() itest1() - & ClassWithSixTypeParameters & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.test() - & ClassWithSixTypeParameters & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.x - & ClassWithSixTypeParameters & InterfaceWithFiveTypeParameters1<*, *, *, *, *> & ClassWithSixTypeParameters")!>this.y + & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.test() + & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.x + & ClassWithSixTypeParameters & ClassWithSixTypeParameters")!>this.y x y } @@ -98,8 +98,8 @@ fun T.case_8() { */ fun T.case_9() { if (this is String) { - this - this.length + this + this.length length } } From 9e5c9efadf397e6f91342b76876b080fa45cae28 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jan 2021 11:49:39 +0300 Subject: [PATCH 100/122] FIR2IR: don't generate IrGetObject for anonymous objects --- .../runners/ir/Fir2IrTextTestGenerated.java | 6 + .../kotlin/fir/backend/Fir2IrVisitor.kt | 3 +- .../firProblems/AnnotationLoader.fir.kt.txt | 90 +++++++++ .../firProblems/AnnotationLoader.fir.txt | 181 ++++++++++++++++++ .../ir/irText/firProblems/AnnotationLoader.kt | 32 ++++ .../firProblems/AnnotationLoader.kt.txt | 88 +++++++++ .../irText/firProblems/AnnotationLoader.txt | 180 +++++++++++++++++ .../test/runners/ir/IrTextTestGenerated.java | 6 + 8 files changed, 585 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt create mode 100644 compiler/testData/ir/irText/firProblems/AnnotationLoader.kt create mode 100644 compiler/testData/ir/irText/firProblems/AnnotationLoader.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/AnnotationLoader.txt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 3fc97204f64..7271c45b46c 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -2074,6 +2074,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt"); } + @Test + @TestMetadata("AnnotationLoader.kt") + public void testAnnotationLoader() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/AnnotationLoader.kt"); + } + @Test @TestMetadata("candidateSymbol.kt") public void testCandidateSymbol() throws Exception { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index d450a6b19ee..8427a0e5a48 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -385,7 +385,8 @@ class Fir2IrVisitor( // Object case val firClass = boundSymbol.fir as FirClass val irClass = classifierStorage.getCachedIrClass(firClass)!! - if (firClass.classKind == ClassKind.OBJECT && !isThisForClassPhysicallyAvailable(irClass)) { + // NB: IR generates anonymous objects as classes, not singleton objects + if (firClass is FirRegularClass && firClass.classKind == ClassKind.OBJECT && !isThisForClassPhysicallyAvailable(irClass)) { return thisReceiverExpression.convertWithOffsets { startOffset, endOffset -> IrGetObjectValueImpl(startOffset, endOffset, irClass.defaultType, irClass.symbol) } diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.kt.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.kt.txt new file mode 100644 index 00000000000..d5b69b11743 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.kt.txt @@ -0,0 +1,90 @@ +interface Visitor { + abstract fun visit() + fun visitArray(): Visitor? { + return null + } + + fun visitAnnotation(): Visitor? { + return null + } + +} + +class AnnotationLoader { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun loadAnnotation(): Visitor? { + return { // BLOCK + local class : Visitor { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun visit() { + } + + override fun visitArray(): Visitor? { + return { // BLOCK + local class : Visitor { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun visit() { + .foo() + } + + } + + () + } + } + + override fun visitAnnotation(): Visitor? { + val visitor: Visitor = CHECK_NOT_NULL(arg0 = .loadAnnotation()) + return { // BLOCK + local class : Visitor { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + .#<$$delegate_0> = visitor + } + + override fun visit() { + } + + override fun visitArray(): Visitor? { + return .#<$$delegate_0>.visitArray() + } + + override fun visitAnnotation(): Visitor? { + return .#<$$delegate_0>.visitAnnotation() + } + + local /* final field */ val <$$delegate_0>: Visitor + + } + + () + } + } + + private fun foo() { + } + + } + + () + } + } + +} diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt new file mode 100644 index 00000000000..4a4e4fe278c --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.fir.txt @@ -0,0 +1,181 @@ +FILE fqName: fileName:/AnnotationLoader.kt + CLASS INTERFACE name:Visitor modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visitor + FUN name:visit visibility:public modality:ABSTRACT <> ($this:.Visitor) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.Visitor + FUN name:visitArray visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? + $this: VALUE_PARAMETER name: type:.Visitor + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitArray (): .Visitor? declared in .Visitor' + CONST Null type=kotlin.Nothing? value=null + FUN name:visitAnnotation visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? + $this: VALUE_PARAMETER name: type:.Visitor + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitAnnotation (): .Visitor? declared in .Visitor' + CONST Null type=kotlin.Nothing? value=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:AnnotationLoader modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader + CONSTRUCTOR visibility:public <> () returnType:.AnnotationLoader [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:AnnotationLoader modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:loadAnnotation visibility:public modality:FINAL <> ($this:.AnnotationLoader) returnType:.Visitor? + $this: VALUE_PARAMETER name: type:.AnnotationLoader + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun loadAnnotation (): .Visitor? declared in .AnnotationLoader' + BLOCK type=.AnnotationLoader.loadAnnotation. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader.loadAnnotation. + CONSTRUCTOR visibility:private <> () returnType:.AnnotationLoader.loadAnnotation. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor]' + FUN name:visit visibility:public modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:kotlin.Unit + overridden: + public abstract fun visit (): kotlin.Unit declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + FUN name:visitArray visibility:public modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:.Visitor? + overridden: + public open fun visitArray (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun visitArray (): .Visitor? declared in .AnnotationLoader.loadAnnotation.' + BLOCK type=.AnnotationLoader.loadAnnotation..visitArray. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader.loadAnnotation..visitArray. + CONSTRUCTOR visibility:private <> () returnType:.AnnotationLoader.loadAnnotation..visitArray. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor]' + FUN name:visit visibility:public modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation..visitArray.) returnType:kotlin.Unit + overridden: + public abstract fun visit (): kotlin.Unit declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitArray. + BLOCK_BODY + CALL 'private final fun foo (): kotlin.Unit declared in .AnnotationLoader.loadAnnotation.' type=kotlin.Unit origin=null + $this: GET_VAR ': .AnnotationLoader.loadAnnotation. declared in .AnnotationLoader.loadAnnotation..visitArray' type=.AnnotationLoader.loadAnnotation. origin=null + FUN FAKE_OVERRIDE name:visitArray visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? [fake_override] + overridden: + public open fun visitArray (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.Visitor + FUN FAKE_OVERRIDE name:visitAnnotation visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? [fake_override] + overridden: + public open fun visitAnnotation (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.Visitor + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'private constructor () [primary] declared in .AnnotationLoader.loadAnnotation..visitArray.' type=.AnnotationLoader.loadAnnotation..visitArray. origin=OBJECT_LITERAL + FUN name:visitAnnotation visibility:public modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:.Visitor? + overridden: + public open fun visitAnnotation (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + VAR name:visitor type:.Visitor [val] + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=.Visitor origin=EXCLEXCL + : .Visitor + arg0: CALL 'public final fun loadAnnotation (): .Visitor? declared in .AnnotationLoader' type=.Visitor? origin=null + $this: GET_VAR ': .AnnotationLoader declared in .AnnotationLoader.loadAnnotation' type=.AnnotationLoader origin=null + RETURN type=kotlin.Nothing from='public final fun visitAnnotation (): .Visitor? declared in .AnnotationLoader.loadAnnotation.' + BLOCK type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + CONSTRUCTOR visibility:private <> () returnType:.AnnotationLoader.loadAnnotation..visitAnnotation. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor]' + SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.Visitor visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .AnnotationLoader.loadAnnotation..visitAnnotation. declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=null + value: GET_VAR 'val visitor: .Visitor [val] declared in .AnnotationLoader.loadAnnotation..visitAnnotation' type=.Visitor origin=null + FUN name:visit visibility:public modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation..visitAnnotation.) returnType:kotlin.Unit + overridden: + public abstract fun visit (): kotlin.Unit declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + BLOCK_BODY + FUN DELEGATED_MEMBER name:visitArray visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation..visitAnnotation.) returnType:.Visitor? + overridden: + public open fun visitArray (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitArray (): .Visitor? declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' + CALL 'public open fun visitArray (): .Visitor? declared in .Visitor' type=.Visitor? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.Visitor visibility:local [final]' type=.Visitor origin=null + receiver: GET_VAR ': .AnnotationLoader.loadAnnotation..visitAnnotation. declared in .AnnotationLoader.loadAnnotation..visitAnnotation..visitArray' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=null + FUN DELEGATED_MEMBER name:visitAnnotation visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation..visitAnnotation.) returnType:.Visitor? + overridden: + public open fun visitAnnotation (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitAnnotation (): .Visitor? declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' + CALL 'public open fun visitAnnotation (): .Visitor? declared in .Visitor' type=.Visitor? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.Visitor visibility:local [final]' type=.Visitor origin=null + receiver: GET_VAR ': .AnnotationLoader.loadAnnotation..visitAnnotation. declared in .AnnotationLoader.loadAnnotation..visitAnnotation..visitAnnotation' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=null + FIELD DELEGATE name:<$$delegate_0> type:.Visitor visibility:local [final] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'private constructor () [primary] declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=OBJECT_LITERAL + FUN name:foo visibility:private modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'private constructor () [primary] declared in .AnnotationLoader.loadAnnotation.' type=.AnnotationLoader.loadAnnotation. origin=OBJECT_LITERAL + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.kt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.kt new file mode 100644 index 00000000000..46e7250cdea --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.kt @@ -0,0 +1,32 @@ +interface Visitor { + fun visit() + + fun visitArray(): Visitor? = null + + fun visitAnnotation(): Visitor? = null +} + +class AnnotationLoader { + fun loadAnnotation(): Visitor? { + return object : Visitor { + override fun visit() {} + + override fun visitArray(): Visitor? { + return object : Visitor { + override fun visit() { + foo() + } + } + } + + override fun visitAnnotation(): Visitor? { + val visitor = loadAnnotation()!! + return object : Visitor by visitor { + override fun visit() {} + } + } + + private fun foo() {} + } + } +} diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.kt.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.kt.txt new file mode 100644 index 00000000000..4e20960ab55 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.kt.txt @@ -0,0 +1,88 @@ +interface Visitor { + abstract fun visit() + fun visitArray(): Visitor? { + return null + } + + fun visitAnnotation(): Visitor? { + return null + } + +} + +class AnnotationLoader { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun loadAnnotation(): Visitor? { + return { // BLOCK + local class : Visitor { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun visit() { + } + + override fun visitArray(): Visitor? { + return { // BLOCK + local class : Visitor { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun visit() { + .foo() + } + + } + + () + } + } + + override fun visitAnnotation(): Visitor? { + val visitor: Visitor = CHECK_NOT_NULL(arg0 = .loadAnnotation()) + return { // BLOCK + local class : Visitor { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Visitor = visitor + override fun visitAnnotation(): Visitor? { + return .#$$delegate_0.visitAnnotation() + } + + override fun visitArray(): Visitor? { + return .#$$delegate_0.visitArray() + } + + override fun visit() { + } + + } + + () + } + } + + private fun foo() { + } + + } + + () + } + } + +} diff --git a/compiler/testData/ir/irText/firProblems/AnnotationLoader.txt b/compiler/testData/ir/irText/firProblems/AnnotationLoader.txt new file mode 100644 index 00000000000..ef5d0e7b1a9 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/AnnotationLoader.txt @@ -0,0 +1,180 @@ +FILE fqName: fileName:/AnnotationLoader.kt + CLASS INTERFACE name:Visitor modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Visitor + FUN name:visit visibility:public modality:ABSTRACT <> ($this:.Visitor) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.Visitor + FUN name:visitArray visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? + $this: VALUE_PARAMETER name: type:.Visitor + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitArray (): .Visitor? declared in .Visitor' + CONST Null type=kotlin.Nothing? value=null + FUN name:visitAnnotation visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? + $this: VALUE_PARAMETER name: type:.Visitor + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitAnnotation (): .Visitor? declared in .Visitor' + CONST Null type=kotlin.Nothing? value=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:AnnotationLoader modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader + CONSTRUCTOR visibility:public <> () returnType:.AnnotationLoader [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:AnnotationLoader modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:loadAnnotation visibility:public modality:FINAL <> ($this:.AnnotationLoader) returnType:.Visitor? + $this: VALUE_PARAMETER name: type:.AnnotationLoader + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun loadAnnotation (): .Visitor? declared in .AnnotationLoader' + BLOCK type=.AnnotationLoader.loadAnnotation. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader.loadAnnotation. + CONSTRUCTOR visibility:public <> () returnType:.AnnotationLoader.loadAnnotation. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor]' + FUN name:visit visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation.) returnType:kotlin.Unit + overridden: + public abstract fun visit (): kotlin.Unit declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + FUN name:visitArray visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation.) returnType:.Visitor? + overridden: + public open fun visitArray (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitArray (): .Visitor? declared in .AnnotationLoader.loadAnnotation.' + BLOCK type=.AnnotationLoader.loadAnnotation..visitArray. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader.loadAnnotation..visitArray. + CONSTRUCTOR visibility:public <> () returnType:.AnnotationLoader.loadAnnotation..visitArray. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor]' + FUN name:visit visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation..visitArray.) returnType:kotlin.Unit + overridden: + public abstract fun visit (): kotlin.Unit declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitArray. + BLOCK_BODY + CALL 'private final fun foo (): kotlin.Unit declared in .AnnotationLoader.loadAnnotation.' type=kotlin.Unit origin=null + $this: GET_VAR ': .AnnotationLoader.loadAnnotation. declared in .AnnotationLoader.loadAnnotation..visitArray' type=.AnnotationLoader.loadAnnotation. origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:visitAnnotation visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? [fake_override] + overridden: + public open fun visitAnnotation (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.Visitor + FUN FAKE_OVERRIDE name:visitArray visibility:public modality:OPEN <> ($this:.Visitor) returnType:.Visitor? [fake_override] + overridden: + public open fun visitArray (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.Visitor + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .AnnotationLoader.loadAnnotation..visitArray.' type=.AnnotationLoader.loadAnnotation..visitArray. origin=OBJECT_LITERAL + FUN name:visitAnnotation visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation.) returnType:.Visitor? + overridden: + public open fun visitAnnotation (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + VAR name:visitor type:.Visitor [val] + CALL 'public final fun CHECK_NOT_NULL (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): T0 of kotlin.internal.ir.CHECK_NOT_NULL declared in kotlin.internal.ir' type=.Visitor origin=EXCLEXCL + : .Visitor + arg0: CALL 'public final fun loadAnnotation (): .Visitor? declared in .AnnotationLoader' type=.Visitor? origin=null + $this: GET_VAR ': .AnnotationLoader declared in .AnnotationLoader.loadAnnotation' type=.AnnotationLoader origin=null + RETURN type=kotlin.Nothing from='public open fun visitAnnotation (): .Visitor? declared in .AnnotationLoader.loadAnnotation.' + BLOCK type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=OBJECT_LITERAL + CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + CONSTRUCTOR visibility:public <> () returnType:.AnnotationLoader.loadAnnotation..visitAnnotation. [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name: modality:FINAL visibility:local superTypes:[.Visitor]' + FIELD DELEGATE name:$$delegate_0 type:.Visitor visibility:private [final] + EXPRESSION_BODY + GET_VAR 'val visitor: .Visitor [val] declared in .AnnotationLoader.loadAnnotation..visitAnnotation' type=.Visitor origin=null + FUN DELEGATED_MEMBER name:visitAnnotation visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation..visitAnnotation.) returnType:.Visitor? + overridden: + public open fun visitAnnotation (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitAnnotation (): .Visitor? declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' + CALL 'public open fun visitAnnotation (): .Visitor? declared in .Visitor' type=.Visitor? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Visitor visibility:private [final]' type=.Visitor origin=null + receiver: GET_VAR ': .AnnotationLoader.loadAnnotation..visitAnnotation. declared in .AnnotationLoader.loadAnnotation..visitAnnotation..visitAnnotation' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=null + FUN DELEGATED_MEMBER name:visitArray visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation..visitAnnotation.) returnType:.Visitor? + overridden: + public open fun visitArray (): .Visitor? declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun visitArray (): .Visitor? declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' + CALL 'public open fun visitArray (): .Visitor? declared in .Visitor' type=.Visitor? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Visitor visibility:private [final]' type=.Visitor origin=null + receiver: GET_VAR ': .AnnotationLoader.loadAnnotation..visitAnnotation. declared in .AnnotationLoader.loadAnnotation..visitAnnotation..visitArray' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=null + FUN name:visit visibility:public modality:OPEN <> ($this:.AnnotationLoader.loadAnnotation..visitAnnotation.) returnType:kotlin.Unit + overridden: + public abstract fun visit (): kotlin.Unit declared in .Visitor + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation..visitAnnotation. + BLOCK_BODY + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .AnnotationLoader.loadAnnotation..visitAnnotation.' type=.AnnotationLoader.loadAnnotation..visitAnnotation. origin=OBJECT_LITERAL + FUN name:foo visibility:private modality:FINAL <> ($this:.AnnotationLoader.loadAnnotation.) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.AnnotationLoader.loadAnnotation. + BLOCK_BODY + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Visitor + $this: VALUE_PARAMETER name: type:kotlin.Any + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .AnnotationLoader.loadAnnotation.' type=.AnnotationLoader.loadAnnotation. origin=OBJECT_LITERAL + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index 3f34ba8a394..5d7d7842cbd 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -2074,6 +2074,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt"); } + @Test + @TestMetadata("AnnotationLoader.kt") + public void testAnnotationLoader() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/AnnotationLoader.kt"); + } + @Test @TestMetadata("candidateSymbol.kt") public void testCandidateSymbol() throws Exception { From afe335e5041ed4739d5995bde58b149dd29694fc Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 19 Jan 2021 10:11:09 +0300 Subject: [PATCH 101/122] FIR: serialize ExtensionFunctionType attribute --- .../FirBlackBoxCodegenTestGenerated.java | 16 +++++++++ .../fir/serialization/FirElementSerializer.kt | 35 +++++++++++++++++-- .../serialization/FirSerializerExtension.kt | 4 +-- .../backend/jvm/FirJvmSerializerExtension.kt | 9 +++-- .../codegen/box/fir/ExtensionAlias.kt | 24 +++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 16 +++++++++ .../IrBlackBoxCodegenTestGenerated.java | 16 +++++++++ .../LightAnalysisModeTestGenerated.java | 18 ++++++++++ .../IrJsCodegenBoxES6TestGenerated.java | 13 +++++++ .../IrJsCodegenBoxTestGenerated.java | 13 +++++++ .../semantics/JsCodegenBoxTestGenerated.java | 13 +++++++ .../IrCodegenBoxWasmTestGenerated.java | 13 +++++++ 12 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 compiler/testData/codegen/box/fir/ExtensionAlias.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index e45be44ded4..70037cfadb9 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -13697,6 +13697,22 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + public class Fir extends AbstractFirBlackBoxCodegenTest { + @Test + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("ExtensionAlias.kt") + public void testExtensionAlias() throws Exception { + runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index a39091afe37..c4ea60f4f85 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -21,6 +21,8 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirArgumentList import org.jetbrains.kotlin.fir.expressions.FirExpression import org.jetbrains.kotlin.fir.expressions.FirNamedArgumentExpression +import org.jetbrains.kotlin.fir.expressions.builder.buildAnnotationCall +import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations import org.jetbrains.kotlin.fir.render import org.jetbrains.kotlin.fir.resolve.calls.varargElementType import org.jetbrains.kotlin.fir.resolve.firSymbolProvider @@ -35,6 +37,7 @@ import org.jetbrains.kotlin.fir.serialization.constant.toConstantValue import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNullableAnyTypeRef import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.Flags @@ -548,12 +551,14 @@ class FirElementSerializer private constructor( fun typeId(type: ConeKotlinType): Int = typeTable[typeProto(type)] private fun typeProto(typeRef: FirTypeRef, toSuper: Boolean = false): ProtoBuf.Type.Builder { - return typeProto(typeRef.coneType, toSuper).also { - extension.serializeType(typeRef, it) + return typeProto(typeRef.coneType, toSuper, correspondingTypeRef = typeRef).also { + for (annotation in typeRef.annotations) { + extension.serializeTypeAnnotation(annotation, it) + } } } - private fun typeProto(type: ConeKotlinType, toSuper: Boolean = false): ProtoBuf.Type.Builder { + private fun typeProto(type: ConeKotlinType, toSuper: Boolean = false, correspondingTypeRef: FirTypeRef? = null): ProtoBuf.Type.Builder { val builder = ProtoBuf.Type.newBuilder() when (type) { @@ -580,6 +585,11 @@ class FirElementSerializer private constructor( return functionType } fillFromPossiblyInnerType(builder, type) + if (type.isExtensionFunctionType) { + serializeAnnotationFromAttribute( + correspondingTypeRef?.annotations, CompilerConeAttributes.ExtensionFunctionType.ANNOTATION_CLASS_ID, builder + ) + } } is ConeTypeParameterType -> { val typeParameter = type.lookupTag.typeParameterSymbol.fir @@ -629,6 +639,25 @@ class FirElementSerializer private constructor( return builder } + private fun serializeAnnotationFromAttribute( + existingAnnotations: List?, + classId: ClassId, + builder: ProtoBuf.Type.Builder + ) { + if (existingAnnotations?.any { it.annotationTypeRef.coneTypeSafe()?.classId == classId } != true) { + extension.serializeTypeAnnotation( + buildAnnotationCall { + calleeReference = FirReferencePlaceholderForResolvedAnnotations + annotationTypeRef = buildResolvedTypeRef { + this.type = CompilerConeAttributes.ExtensionFunctionType.ANNOTATION_CLASS_ID.constructClassLikeType( + emptyArray(), isNullable = false + ) + } + }, builder + ) + } + } + private fun transformSuspendFunctionToRuntimeFunctionType(type: ConeClassLikeType): ConeClassLikeType { val suspendClassId = type.classId!! val relativeClassName = suspendClassId.relativeClassName.asString() diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirSerializerExtension.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirSerializerExtension.kt index cf49979611c..c7e0847fe98 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirSerializerExtension.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirSerializerExtension.kt @@ -7,9 +7,9 @@ package org.jetbrains.kotlin.fir.serialization import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.types.ConeFlexibleType import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType -import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.metadata.ProtoBuf import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion import org.jetbrains.kotlin.metadata.serialization.MutableVersionRequirementTable @@ -74,7 +74,7 @@ abstract class FirSerializerExtension { open fun serializeFlexibleType(type: ConeFlexibleType, lowerProto: ProtoBuf.Type.Builder, upperProto: ProtoBuf.Type.Builder) { } - open fun serializeType(type: FirTypeRef, proto: ProtoBuf.Type.Builder) { + open fun serializeTypeAnnotation(annotation: FirAnnotationCall, proto: ProtoBuf.Type.Builder) { } open fun serializeTypeParameter(typeParameter: FirTypeParameter, proto: ProtoBuf.TypeParameter.Builder) { diff --git a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt index 80d41bf2e3d..57f53a79d03 100644 --- a/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt +++ b/compiler/fir/fir2ir/jvm-backend/src/org/jetbrains/kotlin/fir/backend/jvm/FirJvmSerializerExtension.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.backend.Fir2IrComponents import org.jetbrains.kotlin.fir.backend.FirMetadataSource import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.resolve.firProvider import org.jetbrains.kotlin.fir.resolve.inference.isBuiltinFunctionalType import org.jetbrains.kotlin.fir.serialization.FirElementSerializer @@ -173,13 +174,11 @@ class FirJvmSerializerExtension( } } - override fun serializeType(type: FirTypeRef, proto: ProtoBuf.Type.Builder) { - // TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead - for (annotation in type.annotations) { - proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation)) - } + override fun serializeTypeAnnotation(annotation: FirAnnotationCall, proto: ProtoBuf.Type.Builder) { + proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation)) } + override fun serializeTypeParameter(typeParameter: FirTypeParameter, proto: ProtoBuf.TypeParameter.Builder) { for (annotation in typeParameter.nonSourceAnnotations(session)) { proto.addExtension(JvmProtoBuf.typeParameterAnnotation, annotationSerializer.serializeAnnotation(annotation)) diff --git a/compiler/testData/codegen/box/fir/ExtensionAlias.kt b/compiler/testData/codegen/box/fir/ExtensionAlias.kt new file mode 100644 index 00000000000..befe45402d5 --- /dev/null +++ b/compiler/testData/codegen/box/fir/ExtensionAlias.kt @@ -0,0 +1,24 @@ +// TARGET_BACKEND: JVM +// MODULE: lib +// FILE: A.kt + +typealias ProcessOverriddenWithBaseScope = String.(D, (D, String) -> Boolean) -> Boolean + +// MODULE: main(lib) +// FILE: B.kt + +private data class NumberWithString(val n: N, val s: String) + +private fun use(ns: NumberWithString, process: ProcessOverriddenWithBaseScope): String { + val (n, s) = ns + val result = s.process(n) { _, s -> + s == "OK" + } + return if (result) "OK" else "FAIL" +} + +fun box(): String { + return use(NumberWithString(42, "OK")) { n, process -> + process(n, "OK") + } +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index de0bf7c0340..7dac22b9a70 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -13697,6 +13697,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + public class Fir extends AbstractBlackBoxCodegenTest { + @Test + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("ExtensionAlias.kt") + public void testExtensionAlias() throws Exception { + runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 1d4fcac0785..07e9c9bff98 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -13697,6 +13697,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + public class Fir extends AbstractIrBlackBoxCodegenTest { + @Test + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("ExtensionAlias.kt") + public void testExtensionAlias() throws Exception { + runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 8d42b316610..b5edeb1f535 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12030,6 +12030,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Fir extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("ExtensionAlias.kt") + public void testExtensionAlias() throws Exception { + runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 0ffa287b7ea..e46e1454e62 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -10295,6 +10295,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes } } + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Fir extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } + @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 24990b3bda6..79d643230e5 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -10295,6 +10295,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Fir extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index b0b919405af..30ef2e712cc 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -10295,6 +10295,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Fir extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index ad33bfcffb5..32c76383dda 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -5171,6 +5171,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/fir") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Fir extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInFir() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/fir"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @TestMetadata("compiler/testData/codegen/box/fullJdk") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) From 4cd6266bce848337a537dcd5b786f5fb757154f4 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jan 2021 17:21:08 +0300 Subject: [PATCH 102/122] FIR: fix suspend type serialization --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++++ .../fir/serialization/FirElementSerializer.kt | 24 ++++--------------- .../fir/resolve/inference/InferenceUtils.kt | 19 ++++++++++++++- .../codegen/box/fir/SuspendExtension.kt | 19 +++++++++++++++ .../coroutinesBinary.kt | 1 - .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++++ .../LightAnalysisModeTestGenerated.java | 5 ++++ 8 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 compiler/testData/codegen/box/fir/SuspendExtension.kt diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 70037cfadb9..0da9a2ee212 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -13711,6 +13711,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testExtensionAlias() throws Exception { runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); } + + @Test + @TestMetadata("SuspendExtension.kt") + public void testSuspendExtension() throws Exception { + runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt"); + } } @Nested diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index c4ea60f4f85..2787ce4a395 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.fir.serialization -import org.jetbrains.kotlin.builtins.functions.FunctionClassKind import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality @@ -28,6 +27,7 @@ import org.jetbrains.kotlin.fir.resolve.calls.varargElementType import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.inference.isSuspendFunctionType +import org.jetbrains.kotlin.fir.resolve.inference.suspendFunctionTypeToFunctionTypeWithContinuation import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.resolve.transformers.sealedInheritors import org.jetbrains.kotlin.fir.serialization.constant.EnumValue @@ -35,7 +35,6 @@ import org.jetbrains.kotlin.fir.serialization.constant.IntValue import org.jetbrains.kotlin.fir.serialization.constant.StringValue import org.jetbrains.kotlin.fir.serialization.constant.toConstantValue import org.jetbrains.kotlin.fir.symbols.StandardClassIds -import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitNullableAnyTypeRef @@ -579,7 +578,9 @@ class FirElementSerializer private constructor( } is ConeClassLikeType -> { if (type.isSuspendFunctionType(session)) { - val runtimeFunctionType = transformSuspendFunctionToRuntimeFunctionType(type) + val runtimeFunctionType = type.suspendFunctionTypeToFunctionTypeWithContinuation( + session, CONTINUATION_INTERFACE_CLASS_ID + ) val functionType = typeProto(runtimeFunctionType) functionType.flags = Flags.getTypeFlags(true) return functionType @@ -658,23 +659,6 @@ class FirElementSerializer private constructor( } } - private fun transformSuspendFunctionToRuntimeFunctionType(type: ConeClassLikeType): ConeClassLikeType { - val suspendClassId = type.classId!! - val relativeClassName = suspendClassId.relativeClassName.asString() - val kind = - if (relativeClassName.startsWith("K")) FunctionClassKind.KFunction - else FunctionClassKind.Function - val runtimeClassId = ClassId(kind.packageFqName, Name.identifier(relativeClassName.replaceFirst("Suspend", ""))) - val continuationClassId = CONTINUATION_INTERFACE_CLASS_ID - return ConeClassLikeLookupTagImpl(runtimeClassId).constructClassType( - (type.typeArguments.toList() + ConeClassLikeLookupTagImpl(continuationClassId).constructClassType( - arrayOf(type.typeArguments.last()), - isNullable = false - )).toTypedArray(), - type.isNullable - ) - } - private fun fillFromPossiblyInnerType(builder: ProtoBuf.Type.Builder, type: ConeClassLikeType) { val classifierSymbol = type.lookupTag.toSymbol(session) if (classifierSymbol != null) { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt index 602f1792166..ea7ebfaf344 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/inference/InferenceUtils.kt @@ -89,7 +89,24 @@ fun ConeKotlinType.suspendFunctionTypeToFunctionType(session: FirSession): ConeC if (isKFunctionType(session)) FunctionClassKind.KFunction else FunctionClassKind.Function val functionalTypeId = ClassId(kind.packageFqName, kind.numberedClassName(typeArguments.size - 1)) - return ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(functionalTypeId), typeArguments, isNullable = false) + return ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(functionalTypeId), typeArguments, isNullable = false, attributes = attributes) +} + +fun ConeKotlinType.suspendFunctionTypeToFunctionTypeWithContinuation(session: FirSession, continuationClassId: ClassId): ConeClassLikeType { + require(this.isSuspendFunctionType(session)) + val kind = + if (isKFunctionType(session)) FunctionClassKind.KFunction + else FunctionClassKind.Function + val functionalTypeId = ClassId(kind.packageFqName, kind.numberedClassName(typeArguments.size)) + return ConeClassLikeTypeImpl( + ConeClassLikeLookupTagImpl(functionalTypeId), + typeArguments = (type.typeArguments.dropLast(1) + ConeClassLikeLookupTagImpl(continuationClassId).constructClassType( + arrayOf(type.typeArguments.last()), + isNullable = false + ) + type.typeArguments.last()).toTypedArray(), + isNullable = false, + attributes = attributes + ) } fun ConeKotlinType.isSubtypeOfFunctionalType(session: FirSession, expectedFunctionalType: ConeClassLikeType): Boolean { diff --git a/compiler/testData/codegen/box/fir/SuspendExtension.kt b/compiler/testData/codegen/box/fir/SuspendExtension.kt new file mode 100644 index 00000000000..aed34a6a6e5 --- /dev/null +++ b/compiler/testData/codegen/box/fir/SuspendExtension.kt @@ -0,0 +1,19 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM +// MODULE: lib +// FILE: A.kt + +class CoroutineScope + +suspend fun runWithTimeout( + block: suspend CoroutineScope.() -> T +): T? = null + +// MODULE: main(lib) +// FILE: B.kt + +suspend fun foo(): Boolean = runWithTimeout { + false +} ?: true + +fun box(): String = "OK" \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt b/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt index 5d1626cbf08..d857af0cd9d 100644 --- a/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt +++ b/compiler/testData/compileKotlinAgainstKotlin/coroutinesBinary.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // FILE: A.kt // WITH_RUNTIME // WITH_COROUTINES diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 7dac22b9a70..3e005c6199c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -13711,6 +13711,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testExtensionAlias() throws Exception { runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); } + + @Test + @TestMetadata("SuspendExtension.kt") + public void testSuspendExtension() throws Exception { + runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt"); + } } @Nested diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 07e9c9bff98..3b5da1b20ab 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -13711,6 +13711,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testExtensionAlias() throws Exception { runTest("compiler/testData/codegen/box/fir/ExtensionAlias.kt"); } + + @Test + @TestMetadata("SuspendExtension.kt") + public void testSuspendExtension() throws Exception { + runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt"); + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index b5edeb1f535..93d7d5e89fa 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12034,6 +12034,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Fir extends AbstractLightAnalysisModeTest { + @TestMetadata("SuspendExtension.kt") + public void ignoreSuspendExtension() throws Exception { + runTest("compiler/testData/codegen/box/fir/SuspendExtension.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } From 94e613dd01d88211fe54cc0cf397a20db394d840 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jan 2021 13:56:00 +0300 Subject: [PATCH 103/122] FIR: support custom annotation-based type attributes --- .../RedundantReturnUnitTypeChecker.fir.txt | 2 +- .../delegates/delegateTypeMismatch.fir.txt | 2 +- .../kotlin/fir/symbols/StandardClassIds.kt | 2 +- .../kotlin/fir/backend/Fir2IrTypeConverter.kt | 5 ++++ .../types/CustomAnnotationTypeAttribute.kt | 27 +++++++++++++++++++ .../kotlin/fir/types/FirTypeUtils.kt | 12 ++++++++- ...ntOverrideWithDeclarationSiteProjection.kt | 1 - .../LoadIterableWithNullability.fir.txt | 8 +++--- 8 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt index b1bd68e22fe..598098cb0e4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantReturnUnitTypeChecker.fir.txt @@ -22,7 +22,7 @@ FILE: RedundantReturnUnitTypeChecker.kt super() } - public final fun too(): @R|kotlin/Annotation|() R|kotlin/Unit| { + public final fun too(): @R|kotlin/Annotation|() R|@R|kotlin/Annotation|() kotlin/Unit| { } public final fun foo(): R|kotlin/Unit| { diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateTypeMismatch.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateTypeMismatch.fir.txt index 72599548ac1..9d78be1a73a 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateTypeMismatch.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/delegates/delegateTypeMismatch.fir.txt @@ -19,7 +19,7 @@ FILE: delegateTypeMismatch.kt public get(): R|kotlin/Boolean| private final fun property(initialValue: R|T|): R|kotlin/properties/ReadWriteProperty| { - ^property Q|kotlin/properties/Delegates|.R|kotlin/properties/Delegates.vetoable|(R|/initialValue|, = vetoable@fun (_: R|kotlin/reflect/KProperty<*>|, _: R|T|, _: R|T|): R|kotlin/Boolean| { + ^property Q|kotlin/properties/Delegates|.R|kotlin/properties/Delegates.vetoable|(R|/initialValue|, = vetoable@fun (_: R|@R|kotlin/ParameterName|(name = String(property)) kotlin/reflect/KProperty<*>|, _: R|T|, _: R|T|): R|kotlin/Boolean| { ^ when () { this@R|/A|.R|/A.isLocked| -> { throw R|java/lang/IllegalStateException.IllegalStateException|(String(Cannot modify readonly DescriptorRendererOptions)) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt index 562e8cceb0b..bc5d111157c 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/symbols/StandardClassIds.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.name.Name object StandardClassIds { - private val BASE_KOTLIN_PACKAGE = FqName("kotlin") + val BASE_KOTLIN_PACKAGE = FqName("kotlin") val BASE_REFLECT_PACKAGE = BASE_KOTLIN_PACKAGE.child(Name.identifier("reflect")) private fun String.baseId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier(this)) private fun ClassId.unsignedId() = ClassId(BASE_KOTLIN_PACKAGE, Name.identifier("U" + shortClassName.identifier)) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index dd8028efa84..688e77225cd 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.backend import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.expressions.classId import org.jetbrains.kotlin.fir.resolve.fullyExpandedType import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.StandardClassIds @@ -100,6 +101,10 @@ class Fir2IrTypeConverter( typeAnnotations += it } } + for (attributeAnnotation in attributes.customAnnotations) { + if (annotations.any { it.classId == attributeAnnotation.classId }) continue + typeAnnotations += callGenerator.convertToIrConstructorCall(attributeAnnotation) as? IrConstructorCall ?: continue + } IrSimpleTypeImpl( irSymbol, !typeContext.definitelyNotNull && this.isMarkedNullable, fullyExpandedType(session).typeArguments.map { it.toIrTypeArgument(typeContext) }, diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt new file mode 100644 index 00000000000..25b6dd2b5d5 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.types + +import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall +import org.jetbrains.kotlin.fir.render +import kotlin.reflect.KClass + +class CustomAnnotationTypeAttribute(val annotations: List) : ConeAttribute() { + override fun union(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute? = null + + override fun intersect(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute? = null + + override fun isSubtypeOf(other: CustomAnnotationTypeAttribute?): Boolean = true + + override fun toString(): String = annotations.joinToString(separator = " ") { it.render() } + + override val key: KClass + get() = CustomAnnotationTypeAttribute::class +} + +private val ConeAttributes.custom: CustomAnnotationTypeAttribute? by ConeAttributes.attributeAccessor() + +val ConeAttributes.customAnnotations: List get() = custom?.annotations.orEmpty() diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt index 778e0845323..96dc289ab49 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt @@ -95,6 +95,7 @@ fun List.computeTypeAttributes( ): ConeAttributes { if (this.isEmpty()) return ConeAttributes.Empty val attributes = mutableListOf>() + val customAnnotations = mutableListOf() for (annotation in this) { val type = annotation.annotationTypeRef.coneTypeSafe() ?: continue when (val classId = type.lookupTag.classId) { @@ -102,9 +103,18 @@ fun List.computeTypeAttributes( CompilerConeAttributes.NoInfer.ANNOTATION_CLASS_ID -> attributes += CompilerConeAttributes.NoInfer CompilerConeAttributes.ExtensionFunctionType.ANNOTATION_CLASS_ID -> attributes += CompilerConeAttributes.ExtensionFunctionType CompilerConeAttributes.UnsafeVariance.ANNOTATION_CLASS_ID -> attributes += CompilerConeAttributes.UnsafeVariance - else -> additionalProcessor.invoke(attributes, classId) + else -> { + if (classId.startsWith(StandardClassIds.BASE_KOTLIN_PACKAGE.shortName())) { + // The check ^ is intended to leave only annotations which may be important for BE + customAnnotations += annotation + } + additionalProcessor.invoke(attributes, classId) + } } } + if (customAnnotations.isNotEmpty()) { + attributes += CustomAnnotationTypeAttribute(customAnnotations) + } return ConeAttributes.create(attributes) } diff --git a/compiler/testData/codegen/box/javaInterop/generics/covariantOverrideWithDeclarationSiteProjection.kt b/compiler/testData/codegen/box/javaInterop/generics/covariantOverrideWithDeclarationSiteProjection.kt index 3539ed036d0..8851929302f 100644 --- a/compiler/testData/codegen/box/javaInterop/generics/covariantOverrideWithDeclarationSiteProjection.kt +++ b/compiler/testData/codegen/box/javaInterop/generics/covariantOverrideWithDeclarationSiteProjection.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.fir.txt b/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.fir.txt index afffa9d149a..7bf69dc0146 100644 --- a/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.fir.txt +++ b/compiler/testData/loadJava/compiledJava/mutability/LoadIterableWithNullability.fir.txt @@ -1,10 +1,10 @@ public abstract interface LoadIterableWithNullability!|> : R|kotlin/Any| { - @R|org/jetbrains/annotations/NotNull|() @R|kotlin/annotations/jvm/Mutable|() public abstract fun getIterable(): R|@EnhancedNullability kotlin/collections/MutableIterable!>| + @R|org/jetbrains/annotations/NotNull|() @R|kotlin/annotations/jvm/Mutable|() public abstract fun getIterable(): R|@EnhancedNullability @R|kotlin/annotations/jvm/Mutable|() kotlin/collections/MutableIterable!>| - public abstract fun setIterable(@R|kotlin/annotations/jvm/Mutable|() @R|org/jetbrains/annotations/NotNull|() Iterable: R|@EnhancedNullability kotlin/collections/MutableIterable!>|): R|kotlin/Unit| + public abstract fun setIterable(@R|kotlin/annotations/jvm/Mutable|() @R|org/jetbrains/annotations/NotNull|() Iterable: R|@EnhancedNullability @R|kotlin/annotations/jvm/Mutable|() kotlin/collections/MutableIterable!>|): R|kotlin/Unit| - @R|org/jetbrains/annotations/NotNull|() @R|kotlin/annotations/jvm/ReadOnly|() public abstract fun getReadOnlyIterable(): R|@EnhancedNullability kotlin/collections/Iterable!>| + @R|org/jetbrains/annotations/NotNull|() @R|kotlin/annotations/jvm/ReadOnly|() public abstract fun getReadOnlyIterable(): R|@EnhancedNullability @R|kotlin/annotations/jvm/ReadOnly|() kotlin/collections/Iterable!>| - public abstract fun setReadOnlyIterable(@R|kotlin/annotations/jvm/ReadOnly|() @R|org/jetbrains/annotations/NotNull|() Iterable: R|@EnhancedNullability kotlin/collections/Iterable!>|): R|kotlin/Unit| + public abstract fun setReadOnlyIterable(@R|kotlin/annotations/jvm/ReadOnly|() @R|org/jetbrains/annotations/NotNull|() Iterable: R|@EnhancedNullability @R|kotlin/annotations/jvm/ReadOnly|() kotlin/collections/Iterable!>|): R|kotlin/Unit| } From eed0f50c5d08a34cf657df84826890e9a417b3d0 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jan 2021 12:26:36 +0300 Subject: [PATCH 104/122] Code cleanup: ConeAttributes --- .../jetbrains/kotlin/fir/types/CompilerConeAttributes.kt | 6 +++--- .../src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt | 7 ++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt index c58362c2d60..13fef591dc8 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/CompilerConeAttributes.kt @@ -39,7 +39,7 @@ object CompilerConeAttributes { val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin.jvm.internal"), Name.identifier("EnhancedNullability")) override fun union(other: EnhancedNullability?): EnhancedNullability? = other - override fun intersect(other: EnhancedNullability?): EnhancedNullability? = this + override fun intersect(other: EnhancedNullability?): EnhancedNullability = this override fun isSubtypeOf(other: EnhancedNullability?): Boolean = true override val key: KClass = EnhancedNullability::class @@ -51,7 +51,7 @@ object CompilerConeAttributes { val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin"), Name.identifier("ExtensionFunctionType")) override fun union(other: ExtensionFunctionType?): ExtensionFunctionType? = other - override fun intersect(other: ExtensionFunctionType?): ExtensionFunctionType? = this + override fun intersect(other: ExtensionFunctionType?): ExtensionFunctionType = this override fun isSubtypeOf(other: ExtensionFunctionType?): Boolean = true override val key: KClass = ExtensionFunctionType::class @@ -63,7 +63,7 @@ object CompilerConeAttributes { val ANNOTATION_CLASS_ID = ClassId(FqName("kotlin.internal.ir"), Name.identifier("FlexibleNullability")) override fun union(other: FlexibleNullability?): FlexibleNullability? = other - override fun intersect(other: FlexibleNullability?): FlexibleNullability? = this + override fun intersect(other: FlexibleNullability?): FlexibleNullability = this override fun isSubtypeOf(other: FlexibleNullability?): Boolean = true override val key: KClass = FlexibleNullability::class diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt index 378fb5d1b76..a2779ca5cba 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeAttributes.kt @@ -58,7 +58,7 @@ class ConeAttributes private constructor(attributes: List>) : A val hasEnhancedNullability: Boolean get() = enhancedNullability != null - val hasFlexibleNullability: Boolean + private val hasFlexibleNullability: Boolean get() = flexibleNullability != null fun union(other: ConeAttributes): ConeAttributes { @@ -79,10 +79,7 @@ class ConeAttributes private constructor(attributes: List>) : A for (index in indices) { val a = arrayMap[index] val b = other.arrayMap[index] - val res = when { - a == null -> b?.op(a) - else -> a.op(b) - } + val res = if (a == null) b?.op(a) else a.op(b) attributes.addIfNotNull(res) } return create(attributes) From 293f2f99503d4056795d3f77e774dde984b61b05 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 20 Jan 2021 20:52:13 +0300 Subject: [PATCH 105/122] Build: Replace Bintray with Space for kotlin-dependencies repository (KTI-466) --- build.gradle.kts | 2 +- buildSrc/build.gradle.kts | 6 ++--- buildSrc/settings.gradle | 4 ++-- .../kotlin/code/CodeConformanceTest.kt | 8 +++---- .../build.gradle.kts | 15 +++--------- dependencies/publishing.gradle.kts | 24 +++---------------- gradle/cacheRedirector.gradle.kts | 2 ++ settings.gradle | 8 +++---- 8 files changed, 21 insertions(+), 48 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0666366b22b..3b44f0ece96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -426,7 +426,7 @@ allprojects { jcenter() maven(protobufRepo) maven(intellijRepo) - maven("https://kotlin.bintray.com/kotlin-dependencies") + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") maven("https://jetbrains.bintray.com/intellij-third-party-dependencies") maven("https://dl.google.com/dl/android/maven2") bootstrapKotlinRepo?.let(::maven) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 2ae3bb8fe71..c8979e1aa73 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -12,10 +12,10 @@ buildscript { repositories { if (cacheRedirectorEnabled) { maven("https://cache-redirector.jetbrains.com/jcenter.bintray.com") - maven("https://cache-redirector.jetbrains.com/kotlin.bintray.com/kotlin-dependencies") + maven("https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") } else { jcenter() - maven("https://kotlin.bintray.com/kotlin-dependencies") + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") } project.bootstrapKotlinRepo?.let { @@ -88,7 +88,7 @@ extra["customDepsOrg"] = "kotlin.build" repositories { jcenter() maven("https://jetbrains.bintray.com/intellij-third-party-dependencies/") - maven("https://kotlin.bintray.com/kotlin-dependencies") + maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") gradlePluginPortal() extra["bootstrapKotlinRepo"]?.let { diff --git a/buildSrc/settings.gradle b/buildSrc/settings.gradle index 04df243f589..1bb5591b541 100644 --- a/buildSrc/settings.gradle +++ b/buildSrc/settings.gradle @@ -14,9 +14,9 @@ pluginManagement { buildscript { repositories { if (cacheRedirectorEnabled == 'true') { - maven { url "https://cache-redirector.jetbrains.com/kotlin.bintray.com/kotlin-dependencies" } + maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } } else { - maven { url "https://kotlin.bintray.com/kotlin-dependencies" } + maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } } } dependencies { diff --git a/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt b/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt index ad43a40c0c4..bf7ac274d12 100644 --- a/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/code/CodeConformanceTest.kt @@ -309,11 +309,9 @@ class CodeConformanceTest : TestCase() { RepoAllowList( "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/dev", root, setOf() ), - RepoAllowList( - "kotlin/ktor", root, setOf( - "gradle/cacheRedirector.gradle.kts" - ) - ), + RepoAllowList("kotlin/ktor", root, setOf("gradle/cacheRedirector.gradle.kts")), + RepoAllowList("bintray.com/kotlin-dependencies", root, setOf("gradle/cacheRedirector.gradle.kts")), + RepoAllowList("api.bintray.com/maven/kotlin/kotlin-dependencies", root, setOf()), RepoAllowList( // Please use cache-redirector for importing in tests "https://dl.bintray.com/kotlin/kotlin-dev", root, setOf( diff --git a/dependencies/kotlin-build-gradle-plugin/build.gradle.kts b/dependencies/kotlin-build-gradle-plugin/build.gradle.kts index 6a48f0c8e2c..6a45def015b 100644 --- a/dependencies/kotlin-build-gradle-plugin/build.gradle.kts +++ b/dependencies/kotlin-build-gradle-plugin/build.gradle.kts @@ -42,18 +42,9 @@ publishing { repositories { maven { - name = "bintray" - url = uri("https://api.bintray.com/maven/kotlin/kotlin-dependencies/kotlin-build-gradle-plugin") - authentication { - val mavenUser = findProperty("kotlin.bintray.user") as String? - val mavenPass = findProperty("kotlin.bintray.password") as String? - if (mavenUser != null && mavenPass != null) { - credentials { - username = mavenUser - password = mavenPass - } - } - } + name = "kotlinSpace" + url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + credentials(org.gradle.api.artifacts.repositories.PasswordCredentials::class) } } } diff --git a/dependencies/publishing.gradle.kts b/dependencies/publishing.gradle.kts index 99278f17b1a..a6125644c28 100644 --- a/dependencies/publishing.gradle.kts +++ b/dependencies/publishing.gradle.kts @@ -1,17 +1,10 @@ -import com.jfrog.bintray.gradle.BintrayExtension - buildscript { repositories { maven("https://plugins.gradle.org/m2") } - - dependencies { - classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4") - } } apply(plugin = "maven-publish") -apply(plugin = "com.jfrog.bintray") val archives by configurations @@ -24,20 +17,9 @@ configure { repositories { maven { - url = uri("${rootProject.buildDir}/internal/repo") + name = "kotlinSpace" + url = uri("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies") + credentials(org.gradle.api.artifacts.repositories.PasswordCredentials::class) } } -} - -configure { - user = findProperty("bintray.user") as String? - key = findProperty("bintray.apikey") as String? - - setPublications("maven") - - pkg.apply { - repo = "kotlin-dependencies" - name = project.name - userOrg = "kotlin" - } } \ No newline at end of file diff --git a/gradle/cacheRedirector.gradle.kts b/gradle/cacheRedirector.gradle.kts index c41cc504564..4f968d6c225 100644 --- a/gradle/cacheRedirector.gradle.kts +++ b/gradle/cacheRedirector.gradle.kts @@ -53,6 +53,8 @@ val mirroredUrls = listOf( "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/dev", "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap", "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/eap", + "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies", + "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide", "https://kotlin.bintray.com/dukat", "https://kotlin.bintray.com/kotlin-dependencies", "https://oss.sonatype.org/content/repositories/releases", diff --git a/settings.gradle b/settings.gradle index 761b6d7ab2d..65f5704ac74 100644 --- a/settings.gradle +++ b/settings.gradle @@ -10,10 +10,10 @@ pluginManagement { if (cacheRedirectorEnabled == 'true') { logger.info("Using cache redirector for settings.gradle pluginManagement") maven { url "https://cache-redirector.jetbrains.com/plugins.gradle.org/m2" } - maven { url "https://cache-redirector.jetbrains.com/kotlin.bintray.com/kotlin-dependencies" } + maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } } else { gradlePluginPortal() - maven { url "https://kotlin.bintray.com/kotlin-dependencies" } + maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } } } } @@ -21,9 +21,9 @@ pluginManagement { buildscript { repositories { if (cacheRedirectorEnabled == 'true') { - maven { url "https://cache-redirector.jetbrains.com/kotlin.bintray.com/kotlin-dependencies" } + maven { url "https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } } else { - maven { url "https://kotlin.bintray.com/kotlin-dependencies" } + maven { url "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-dependencies" } } } dependencies { From a403b9ff05344b16142b6fd42f2f5f4a538bbd7e Mon Sep 17 00:00:00 2001 From: LepilkinaElena Date: Mon, 18 Jan 2021 17:41:59 +0300 Subject: [PATCH 106/122] Support for stable and unstable benchmarks. Refactoring to get separate tables for metrics. (#4641) --- .../src/main/kotlin/analyzer/Statistics.kt | 13 +- .../analyzer/SummaryBenchmarksReport.kt | 303 ++++++++++-------- .../main/kotlin/report/BenchmarksReport.kt | 32 +- .../src/main/kotlin/main.kt | 24 +- .../org/jetbrains/renders/HTMLRender.kt | 208 ++++++++---- .../jetbrains/renders/MetricResultsRender.kt | 16 +- .../kotlin/org/jetbrains/renders/Render.kt | 88 +++-- .../org/jetbrains/renders/StatisticsRender.kt | 20 +- .../renders/TeamCityStatisticsRender.kt | 10 +- .../database/BenchmarksIndexesDispatcher.kt | 3 +- .../main/kotlin/database/DatabaseRequests.kt | 36 +++ .../src/main/kotlin/routes/route.kt | 12 + .../ui/src/main/kotlin/main.kt | 252 ++++++++------- 13 files changed, 646 insertions(+), 371 deletions(-) diff --git a/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/Statistics.kt b/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/Statistics.kt index fcde19c32d3..79859ecd9d9 100644 --- a/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/Statistics.kt +++ b/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/Statistics.kt @@ -25,10 +25,13 @@ val MeanVarianceBenchmark.description: String // Calculate difference in percentage compare to another. fun MeanVarianceBenchmark.calcPercentageDiff(other: MeanVarianceBenchmark): MeanVariance { + if (score == 0.0 && variance == 0.0 && other.score == 0.0 && other.variance == 0.0) + return MeanVariance(score, variance) assert(other.score >= 0 && other.variance >= 0 && - other.score - other.variance != 0.0, + (other.score - other.variance != 0.0 || other.score == 0.0), { "Mean and variance should be positive and not equal!" }) + // Analyze intervals. Calculate difference between border points. val (bigValue, smallValue) = if (score > other.score) Pair(this, other) else Pair(other, this) val bigValueIntervalStart = bigValue.score - bigValue.variance @@ -50,11 +53,13 @@ fun MeanVarianceBenchmark.calcPercentageDiff(other: MeanVarianceBenchmark): Mean // Calculate ratio value compare to another. fun MeanVarianceBenchmark.calcRatio(other: MeanVarianceBenchmark): MeanVariance { + if (other.score == 0.0 && other.variance == 0.0) + return MeanVariance(1.0, 0.0) assert(other.score >= 0 && other.variance >= 0 && - other.score - other.variance != 0.0, + (other.score - other.variance != 0.0 || other.score == 0.0), { "Mean and variance should be positive and not equal!" }) - val mean = score / other.score + val mean = if (other.score != 0.0) (score / other.score) else 0.0 val minRatio = (score - variance) / (other.score + other.variance) val maxRatio = (score + variance) / (other.score - other.variance) val ratioConfInt = min(abs(minRatio - mean), abs(maxRatio - mean)) @@ -63,7 +68,7 @@ fun MeanVarianceBenchmark.calcRatio(other: MeanVarianceBenchmark): MeanVariance fun geometricMean(values: Collection, totalNumber: Int = values.size) = with(values.asSequence().filter { it != 0.0 }) { - if (count() == 0) { + if (count() == 0 || totalNumber == 0) { 0.0 } else { map { it.pow(1.0 / totalNumber) }.reduce { a, b -> a * b } diff --git a/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/SummaryBenchmarksReport.kt b/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/SummaryBenchmarksReport.kt index 6048d975197..12c98cd070e 100644 --- a/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/SummaryBenchmarksReport.kt +++ b/kotlin-native/tools/benchmarks/shared/src/main/kotlin/analyzer/SummaryBenchmarksReport.kt @@ -18,13 +18,11 @@ typealias BenchmarksTable = Map typealias SummaryBenchmarksTable = Map typealias ScoreChange = Pair -// Summary report with comparasion of separate benchmarks results. -class SummaryBenchmarksReport(val currentReport: BenchmarksReport, - val previousReport: BenchmarksReport? = null, - val meaningfulChangesValue: Double = 0.5) { +class DetailedBenchmarksReport(currentBenchmarks: Map>, + previousBenchmarks: Map>? = null, + val meaningfulChangesValue: Double = 0.5) { // Report created by joining comparing reports. val mergedReport: Map - private val benchmarksDurations: Map> // Lists of benchmarks in different status. private val benchmarksWithChangedStatus = mutableListOf>() @@ -40,30 +38,6 @@ class SummaryBenchmarksReport(val currentReport: BenchmarksReport, var geoMeanScoreChange: ScoreChange? = null private set - // Environment and tools. - val environments: Pair - val compilers: Pair - - // Countable properties. - val failedBenchmarks: List - get() = mergedReport.filter { it.value.first?.status == BenchmarkResult.Status.FAILED } - .map { it.key } - - val addedBenchmarks: List - get() = mergedReport.filter { it.value.second == null }.map { it.key } - - val removedBenchmarks: List - get() = mergedReport.filter { it.value.first == null }.map { it.key } - - val benchmarksNumber: Int - get() = mergedReport.keys.size - - val currentMeanVarianceBenchmarks: List - get() = mergedReport.filter { it.value.first != null }.map { it.value.first!! } - - val currentBenchmarksDuration: Map - get() = benchmarksDurations.filter { it.value.first != null }.map { it.key to it.value.first!! }.toMap() - val maximumRegression: Double get() = getMaximumChange(regressions) @@ -76,90 +50,53 @@ class SummaryBenchmarksReport(val currentReport: BenchmarksReport, val improvementsGeometricMean: Double get() = getGeometricMeanOfChanges(improvements) - val envChanges: List> - get() { - val previousEnvironment = environments.second - val currentEnvironment = environments.first - return previousEnvironment?.let { - mutableListOf>().apply { - addFieldChange("Machine CPU", previousEnvironment.machine.cpu, currentEnvironment.machine.cpu) - addFieldChange("Machine OS", previousEnvironment.machine.os, currentEnvironment.machine.os) - addFieldChange("JDK version", previousEnvironment.jdk.version, currentEnvironment.jdk.version) - addFieldChange("JDK vendor", previousEnvironment.jdk.vendor, currentEnvironment.jdk.vendor) - } - } ?: listOf>() - } - - val kotlinChanges: List> - get() { - val previousCompiler = compilers.second - val currentCompiler = compilers.first - return previousCompiler?.let { - mutableListOf>().apply { - addFieldChange("Backend type", previousCompiler.backend.type.type, currentCompiler.backend.type.type) - addFieldChange("Backend version", previousCompiler.backend.version, currentCompiler.backend.version) - addFieldChange("Backend flags", previousCompiler.backend.flags.toString(), - currentCompiler.backend.flags.toString()) - addFieldChange("Kotlin version", previousCompiler.kotlinVersion, currentCompiler.kotlinVersion) - } - } ?: listOf>() - } + val benchmarksNumber: Int + get() = mergedReport.keys.size init { // Count avarage values for each benchmark. - val currentBenchmarksTable = collectMeanResults(currentReport.benchmarks) - val previousBenchmarksTable = previousReport?.let { - collectMeanResults(previousReport.benchmarks) + val currentBenchmarksTable = collectMeanResults(currentBenchmarks) + val previousBenchmarksTable = previousBenchmarks?.let { + collectMeanResults(previousBenchmarks) } mergedReport = createMergedReport(currentBenchmarksTable, previousBenchmarksTable) - benchmarksDurations = calculateBenchmarksDuration(currentReport, previousReport) geoMeanBenchmark = calculateGeoMeanBenchmark(currentBenchmarksTable, previousBenchmarksTable) - environments = Pair(currentReport.env, previousReport?.env) - compilers = Pair(currentReport.compiler, previousReport?.compiler) - if (previousReport != null) { + if (previousBenchmarks != null) { // Check changes in environment and tools. analyzePerformanceChanges() } } - // Get benchmark report. - fun getBenchmarksReport(takeMainReport: Boolean = true) = - if (takeMainReport) - BenchmarksReport(environments.first, mergedReport.map { (_, value) -> value.first!! }, compilers.first) - else - BenchmarksReport(environments.second!!, mergedReport.map { (_, value) -> value.second!! }, compilers.second!!) - - fun getResultsByMetric(metric: BenchmarkResult.Metric, getGeoMean: Boolean = true, filter: List? = null, - normalizeData: Map>? = null): List { - val benchmarks = filter?.let { - mergedReport.filter { entry -> - filter.find { - entry.key.startsWith(it) - } != null - } - } ?: mergedReport - val results = benchmarks.map { entry -> - val name = entry.key.removeSuffix(metric.suffix) - if (entry.value.first!!.metric == metric) { - val score = entry.value.first!!.score - val value = normalizeData?.let { - it.get(name)?.get("$metric")?.let { score / it } - ?: error("No normalization data for benchmark $name and metric $metric") - } ?: score - name to value - } else name to null - }.toMap() - if (getGeoMean) { - return listOf(geometricMean(results.values.filterNotNull())) - } - return filter?.let { it.map { results[it] }.toList() } ?: results.values.toList() - } - private fun getMaximumChange(bucket: Map): Double = // Maps of regressions and improvements are sorted. if (bucket.isEmpty()) 0.0 else bucket.values.map { it.first.mean }.first() + // Analyze and collect changes in performance between same becnhmarks. + private fun analyzePerformanceChanges() { + val performanceChanges = mergedReport.asSequence().map { (name, element) -> + getBenchmarkPerfomanceChange(name, element) + }.filterNotNull().groupBy { + if (it.second.first.mean > 0) "regressions" else "improvements" + } + + // Sort regressions and improvements. + regressions = performanceChanges["regressions"] + ?.sortedByDescending { it.second.first.mean }?.map { it.first to it.second } + ?.toMap() ?: mapOf() + improvements = performanceChanges["improvements"] + ?.sortedBy { it.second.first.mean }?.map { it.first to it.second } + ?.toMap() ?: mapOf() + + // Calculate change for geometric mean. + val (current, previous) = geoMeanBenchmark + geoMeanScoreChange = current?.let { + previous?.let { + Pair(current.calcPercentageDiff(previous), current.calcRatio(previous)) + } + } + } + private fun getGeometricMeanOfChanges(bucket: Map): Double { if (bucket.isEmpty()) return 0.0 @@ -175,25 +112,6 @@ class SummaryBenchmarksReport(val currentReport: BenchmarksReport, fun getBenchmarksWithChangedStatus(): List> = benchmarksWithChangedStatus - // Create geometric mean. - private fun createGeoMeanBenchmark(benchTable: BenchmarksTable): MeanVarianceBenchmark { - val geoMeanBenchmarkName = "Geometric mean" - val geoMean = geometricMean(benchTable.toList().map { (_, value) -> value.score }) - val varianceGeoMean = geometricMean(benchTable.toList().map { (_, value) -> value.variance }) - return MeanVarianceBenchmark(geoMeanBenchmarkName, geoMean, varianceGeoMean) - } - - // Generate map with summary durations of each benchmark. - private fun calculateBenchmarksDuration(currentReport: BenchmarksReport, previousReport: BenchmarksReport?): - Map> { - val currentDurations = collectBenchmarksDurations(currentReport.benchmarks) - val previousDurations = previousReport?.let { - collectBenchmarksDurations(previousReport.benchmarks) - } ?: mapOf() - return currentDurations.keys.union(previousDurations.keys) - .map { it to Pair(currentDurations[it], previousDurations[it]) }.toMap() - } - // Merge current and compare to report. private fun createMergedReport(currentBenchmarks: BenchmarksTable, previousBenchmarks: BenchmarksTable?): Map { @@ -249,29 +167,144 @@ class SummaryBenchmarksReport(val currentReport: BenchmarksReport, return null } - // Analyze and collect changes in performance between same becnhmarks. - private fun analyzePerformanceChanges() { - val performanceChanges = mergedReport.asSequence().map { (name, element) -> - getBenchmarkPerfomanceChange(name, element) - }.filterNotNull().groupBy { - if (it.second.first.mean > 0) "regressions" else "improvements" + // Create geometric mean. + private fun createGeoMeanBenchmark(benchTable: BenchmarksTable): MeanVarianceBenchmark { + val geoMeanBenchmarkName = "Geometric mean" + val geoMean = geometricMean(benchTable.toList().map { (_, value) -> value.score }) + val varianceGeoMean = geometricMean(benchTable.toList().map { (_, value) -> value.variance }) + return MeanVarianceBenchmark(geoMeanBenchmarkName, geoMean, varianceGeoMean) + } +} + +// Summary report with comparasion of separate benchmarks results. +class SummaryBenchmarksReport(val currentReport: BenchmarksReport, + val previousReport: BenchmarksReport? = null, + val meaningfulChangesValue: Double = 0.5, + private val unstableBenchmarks: List = emptyList()) { + + val detailedMetricReports: Map + + private val benchmarksDurations: Map> + + // Lists of benchmarks in different status. + val benchmarksWithChangedStatus + get() = getReducedResult { report -> + report.getBenchmarksWithChangedStatus() } - // Sort regressions and improvements. - regressions = performanceChanges["regressions"] - ?.sortedByDescending { it.second.first.mean }?.map { it.first to it.second } - ?.toMap() ?: mapOf() - improvements = performanceChanges["improvements"] - ?.sortedBy { it.second.first.mean }?.map { it.first to it.second } - ?.toMap() ?: mapOf() + // Environment and tools. + val environments: Pair + val compilers: Pair - // Calculate change for geometric mean. - val (current, previous) = geoMeanBenchmark - geoMeanScoreChange = current?.let { - previous?.let { - Pair(current.calcPercentageDiff(previous), current.calcRatio(previous)) - } + private fun getReducedResult(convertor: (DetailedBenchmarksReport) -> List): List { + return detailedMetricReports.values.map { + convertor(it) + }.flatten() + } + + // Countable properties. + val failedBenchmarks: List + get() = getReducedResult { report -> + report.mergedReport.filter { it.value.first?.status == BenchmarkResult.Status.FAILED }.map { it.key } } + + val addedBenchmarks: List + get() = getReducedResult { report -> + report.mergedReport.filter { it.value.second == null }.map { it.key } + } + + val removedBenchmarks: List + get() = getReducedResult { report -> + report.mergedReport.filter { it.value.first == null }.map { it.key } + } + + val currentMeanVarianceBenchmarks: List + get() = getReducedResult { report -> + report.mergedReport.filter { it.value.first != null }.map { it.value.first!! } + } + + val benchmarksNumber: Int + get() = detailedMetricReports.values.fold(0) { acc, it -> acc + it.benchmarksNumber } + + val currentBenchmarksDuration: Map + get() = benchmarksDurations.filter { it.value.first != null }.map { it.key to it.value.first!! }.toMap() + + val envChanges: List> + get() { + val previousEnvironment = environments.second + val currentEnvironment = environments.first + return previousEnvironment?.let { + mutableListOf>().apply { + addFieldChange("Machine CPU", previousEnvironment.machine.cpu, currentEnvironment.machine.cpu) + addFieldChange("Machine OS", previousEnvironment.machine.os, currentEnvironment.machine.os) + addFieldChange("JDK version", previousEnvironment.jdk.version, currentEnvironment.jdk.version) + addFieldChange("JDK vendor", previousEnvironment.jdk.vendor, currentEnvironment.jdk.vendor) + } + } ?: listOf>() + } + + val kotlinChanges: List> + get() { + val previousCompiler = compilers.second + val currentCompiler = compilers.first + return previousCompiler?.let { + mutableListOf>().apply { + addFieldChange("Backend type", previousCompiler.backend.type.type, currentCompiler.backend.type.type) + addFieldChange("Backend version", previousCompiler.backend.version, currentCompiler.backend.version) + addFieldChange("Backend flags", previousCompiler.backend.flags.toString(), + currentCompiler.backend.flags.toString()) + addFieldChange("Kotlin version", previousCompiler.kotlinVersion, currentCompiler.kotlinVersion) + } + } ?: listOf>() + } + + init { + // Count avarage values for each benchmark. + detailedMetricReports = BenchmarkResult.Metric.values().map { metric -> + val currentBenchmarks = currentReport.benchmarks.map { (name, benchmarks) -> + name to benchmarks.filter { it.metric == metric } + }.filter { it.second.isNotEmpty() }.toMap() + val previousBenchmarks = previousReport?.benchmarks?.map { (name, benchmarks) -> + name to benchmarks.filter { it.metric == metric } + }?.filter { it.second.isNotEmpty() }?.toMap() + metric to DetailedBenchmarksReport( + currentReport.benchmarks.map { (name, benchmarks) -> + name to benchmarks.filter { it.metric == metric } + }.filter { it.second.isNotEmpty() }.toMap(), + previousReport?.benchmarks?.map { (name, benchmarks) -> + name to benchmarks.filter { it.metric == metric } + }?.filter { it.second.isNotEmpty() }?.toMap(), + meaningfulChangesValue + ) + }.toMap() + benchmarksDurations = calculateBenchmarksDuration(currentReport, previousReport) + environments = Pair(currentReport.env, previousReport?.env) + compilers = Pair(currentReport.compiler, previousReport?.compiler) + } + + // Get benchmark report. + fun getBenchmarksReport(takeMainReport: Boolean = true) = + if (takeMainReport) + BenchmarksReport(environments.first, getReducedResult { report -> + report.mergedReport.map { (_, value) -> value.first!! } + }, compilers.first) + else + BenchmarksReport(environments.second!!, getReducedResult { report -> + report.mergedReport.map { (_, value) -> value.second!! } + }, compilers.second!!) + + fun getUnstableBenchmarksForMetric(metric: BenchmarkResult.Metric) = + if (metric == BenchmarkResult.Metric.EXECUTION_TIME) unstableBenchmarks else emptyList() + + // Generate map with summary durations of each benchmark. + private fun calculateBenchmarksDuration(currentReport: BenchmarksReport, previousReport: BenchmarksReport?): + Map> { + val currentDurations = collectBenchmarksDurations(currentReport.benchmarks) + val previousDurations = previousReport?.let { + collectBenchmarksDurations(previousReport.benchmarks) + } ?: mapOf() + return currentDurations.keys.union(previousDurations.keys) + .map { it to Pair(currentDurations[it], previousDurations[it]) }.toMap() } private fun MutableList>.addFieldChange(field: String, previous: T, current: T) { diff --git a/kotlin-native/tools/benchmarks/shared/src/main/kotlin/report/BenchmarksReport.kt b/kotlin-native/tools/benchmarks/shared/src/main/kotlin/report/BenchmarksReport.kt index 7448d89117b..7323ab9cafe 100644 --- a/kotlin-native/tools/benchmarks/shared/src/main/kotlin/report/BenchmarksReport.kt +++ b/kotlin-native/tools/benchmarks/shared/src/main/kotlin/report/BenchmarksReport.kt @@ -270,7 +270,6 @@ open class BenchmarkResult(val name: String, val status: Status, val metric = if (metricElement != null && metricElement is JsonLiteral) metricFromString(metricElement.unquoted()) ?: Metric.EXECUTION_TIME else Metric.EXECUTION_TIME - name += metric.suffix val statusElement = data.getRequiredField("status") if (statusElement is JsonLiteral) { val status = statusFromString(statusElement.unquoted()) @@ -348,4 +347,35 @@ open class MeanVarianceBenchmark(name: String, status: BenchmarkResult.Status, s "variance": $variance """ } +} + +// Benchmark with set results stability state. +open class BenchmarkWithStabilityState(name: String, status: BenchmarkResult.Status, score: Double, metric: BenchmarkResult.Metric, + runtimeInUs: Double, repeat: Int, warmup: Int, val unstable: Boolean) : + BenchmarkResult(name, status, score, metric, runtimeInUs, repeat, warmup) { + + constructor(benchmarkResult: BenchmarkResult, unstable: Boolean) : this(benchmarkResult.name, + benchmarkResult.status, benchmarkResult.score, benchmarkResult.metric, + benchmarkResult.runtimeInUs, benchmarkResult.repeat, benchmarkResult.warmup, unstable) + + override fun serializeFields(): String { + return """ + ${super.serializeFields()}, + "unstable": $unstable + """ + } + + companion object : EntityFromJsonFactory { + override fun create(data: JsonElement): BenchmarkWithStabilityState { + val parsedObject = BenchmarkResult.create(data) + if (data is JsonObject) { + val unstableElement = data.getOptionalField("unstable") + val unstableFlag = if (unstableElement != null && unstableElement is JsonPrimitive) + unstableElement.boolean else false + return BenchmarkWithStabilityState(parsedObject, unstableFlag) + } else { + error("Benchmark entity is expected to be an object. Please, check origin files.") + } + } + } } \ No newline at end of file diff --git a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/main.kt b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/main.kt index 250ee8283b2..0e8b7e9b15a 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/main.kt +++ b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/main.kt @@ -79,6 +79,21 @@ object DBServerConnector : Connector() { val accessFileUrl = "$serverUrl/report/$target/$buildNumber" return sendGetRequest(accessFileUrl) } + + fun getUnstableBenchmarks(): List? { + try { + val unstableList = sendGetRequest("$serverUrl/unstable") + val data = JsonTreeParser.parse(unstableList) + if (data !is JsonArray) { + return null + } + return data.jsonArray.map { + (it as JsonPrimitive).content + } + } catch (e: Exception) { + return null + } + } } fun getFileContent(fileName: String, user: String? = null): String { @@ -155,6 +170,11 @@ fun main(args: Array) { val user by argParser.option(ArgType.String, shortName = "u", description = "User access information for authorization") argParser.parse(args) + // Get unstable benchmarks. + val unstableBenchmarks = DBServerConnector.getUnstableBenchmarks() + + unstableBenchmarks ?: println("Failed to get access to server and get unstable benchmarks list!") + // Read contents of file. val mainBenchsReport = mergeReportsWithDetailedFlags(getBenchmarkReport(mainReport, user)) @@ -164,8 +184,8 @@ fun main(args: Array) { // Generate comparasion report. val summaryReport = SummaryBenchmarksReport(mainBenchsReport, - compareToBenchsReport, - epsValue) + compareToBenchsReport, epsValue, + unstableBenchmarks ?: emptyList()) var outputFile = output renders.forEach { diff --git a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/HTMLRender.kt b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/HTMLRender.kt index d9423e3fc7d..a44d1f514ec 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/HTMLRender.kt +++ b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/HTMLRender.kt @@ -405,7 +405,7 @@ class HTMLRender: Render() { } } - val benchmarksWithChangedStatus = report.getBenchmarksWithChangedStatus() + val benchmarksWithChangedStatus = report.benchmarksWithChangedStatus val newFailures = benchmarksWithChangedStatus .filter { it.current == BenchmarkResult.Status.FAILED } val newPasses = benchmarksWithChangedStatus @@ -479,59 +479,86 @@ class HTMLRender: Render() { } private fun BodyTag.renderPerformanceSummary(report: SummaryBenchmarksReport) { - if (!report.improvements.isEmpty() || !report.regressions.isEmpty()) { + if (report.detailedMetricReports.values.any { it.improvements.isNotEmpty() } || + report.detailedMetricReports.values.any { it.regressions.isNotEmpty() }) { h4 { +"Performance Summary" } table { attributes["class"] = "table table-sm table-striped table-hover" attributes["style"] = "width:initial;" thead { tr { - th { +"Change" } - th { +"#" } - th { +"Maximum" } - th { +"Geometric mean" } - } - } - val maximumRegression = report.maximumRegression - val maximumImprovement = report.maximumImprovement - val regressionsGeometricMean = report.regressionsGeometricMean - val improvementsGeometricMean = report.improvementsGeometricMean - tbody { - if (!report.regressions.isEmpty()) { - tr { - th { +"Regressions" } - td { +"${report.regressions.size}" } - td { - attributes["bgcolor"] = ColoredCell( - maximumRegression/maxOf(maximumRegression, abs(maximumImprovement))) - .backgroundStyle - +formatValue(maximumRegression, true) - } - td { - attributes["bgcolor"] = ColoredCell( - regressionsGeometricMean/maxOf(regressionsGeometricMean, - abs(improvementsGeometricMean))) - .backgroundStyle - +formatValue(report.regressionsGeometricMean, true) - } + th(rowspan = Natural(2)) { +"Change" } + report.detailedMetricReports.forEach { (metric, _) -> + th(colspan = Natural(3)) { +metric.value } } } - if (!report.improvements.isEmpty()) { + tr { + report.detailedMetricReports.forEach { _ -> + th { +"#" } + th { +"Maximum" } + th { +"Geometric mean" } + } + } + } + + tbody { + tr { + th { +"Regressions" } + report.detailedMetricReports.values.forEach { report -> + val maximumRegression = report.maximumRegression + val regressionsGeometricMean = report.regressionsGeometricMean + val maximumImprovement = report.maximumImprovement + val improvementsGeometricMean = report.improvementsGeometricMean + val maximumChange = maxOf(maximumRegression, abs(maximumImprovement)) + val maximumChangeGeoMean = maxOf(regressionsGeometricMean, + abs(improvementsGeometricMean)) + if (!report.regressions.isEmpty()) { + td { +"${report.regressions.size}" } + td { + attributes["bgcolor"] = ColoredCell( + (maximumRegression/maximumChange).takeIf{ maximumChange > 0.0 } + ).backgroundStyle + +formatValue(maximumRegression, true) + } + td { + attributes["bgcolor"] = ColoredCell( + (regressionsGeometricMean/maximumChangeGeoMean).takeIf{ maximumChangeGeoMean > 0.0 } + ).backgroundStyle + +formatValue(report.regressionsGeometricMean, true) + } + } else { + repeat(3) { td { +"-" } } + } + } + tr { th { +"Improvements" } - td { +"${report.improvements.size}" } - td { - attributes["bgcolor"] = ColoredCell( - maximumImprovement/maxOf(maximumRegression, abs(maximumImprovement))) - .backgroundStyle - +formatValue(report.maximumImprovement, true) - } - td { - attributes["bgcolor"] = ColoredCell( - improvementsGeometricMean/maxOf(regressionsGeometricMean, - abs(improvementsGeometricMean))) - .backgroundStyle - +formatValue(report.improvementsGeometricMean, true) + report.detailedMetricReports.values.forEach { report -> + val maximumRegression = report.maximumRegression + val regressionsGeometricMean = report.regressionsGeometricMean + val maximumImprovement = report.maximumImprovement + val improvementsGeometricMean = report.improvementsGeometricMean + val maximumChange = maxOf(maximumRegression, abs(maximumImprovement)) + val maximumChangeGeoMean = maxOf(regressionsGeometricMean, + abs(improvementsGeometricMean)) + if (!report.improvements.isEmpty()) { + td { +"${report.improvements.size}" } + td { + attributes["bgcolor"] = ColoredCell( + (maximumImprovement / maximumChange).takeIf{ maximumChange > 0.0 } + ).backgroundStyle + +formatValue(report.maximumImprovement, true) + } + td { + attributes["bgcolor"] = ColoredCell( + (improvementsGeometricMean / maximumChangeGeoMean) + .takeIf{ maximumChangeGeoMean > 0.0 } + ).backgroundStyle + +formatValue(report.improvementsGeometricMean, true) + } + } else { + repeat(3) { td { +"-" } } + } } } } @@ -584,43 +611,84 @@ class HTMLRender: Render() { } } + private fun TableBlock.renderFilteredBenchmarks(detailedReport: DetailedBenchmarksReport, + onlyChanges: Boolean, unstableBenchmarks: List, + filterUnstable: Boolean) { + fun filterBenchmarks(bucket: Map) = + bucket.filter { (name, _) -> + if (filterUnstable) name in unstableBenchmarks else name !in unstableBenchmarks + } + + val filteredRegressions = filterBenchmarks(detailedReport.regressions) + val filteredImprovements = filterBenchmarks(detailedReport.improvements) + renderBenchmarksDetails(detailedReport.mergedReport, filteredRegressions) + renderBenchmarksDetails(detailedReport.mergedReport, filteredImprovements) + if (!onlyChanges) { + // Print all remaining results. + renderBenchmarksDetails(filterBenchmarks(detailedReport.mergedReport).filter { + it.key !in detailedReport.regressions.keys && + it.key !in detailedReport.improvements.keys + }) + } + } + private fun BodyTag.renderPerformanceDetails(report: SummaryBenchmarksReport, onlyChanges: Boolean) { if (onlyChanges) { - if (report.regressions.isEmpty() && report.improvements.isEmpty()) { + if (report.detailedMetricReports.values.all { it.improvements.isEmpty() } && + report.detailedMetricReports.values.all { it.regressions.isEmpty() }) { div("alert alert-success") { attributes["role"] = "alert" +"All becnhmarks are stable!" } } } + report.detailedMetricReports.forEach { (metric, detailedReport) -> + renderCollapsedData(metric.value, false) { + table { + attributes["id"] = "result" + attributes["class"] = "table table-striped table-bordered" + thead { + tr { + th { +"Benchmark" } + th { +"First score" } + th { +"Second score" } + th { +"Percent" } + th { +"Ratio" } + } + } + val geoMeanChangeMap = detailedReport.geoMeanScoreChange?.let { + mapOf(detailedReport.geoMeanBenchmark.first!!.name to detailedReport.geoMeanScoreChange!!) + } - table { - attributes["id"] = "result" - attributes["class"] = "table table-striped table-bordered" - thead { - tr { - th { +"Benchmark" } - th { +"First score" } - th { +"Second score" } - th { +"Percent" } - th { +"Ratio" } - } - } - val geoMeanChangeMap = report.geoMeanScoreChange?. - let { mapOf(report.geoMeanBenchmark.first!!.name to report.geoMeanScoreChange!!) } - - tbody { - renderBenchmarksDetails( - mutableMapOf(report.geoMeanBenchmark.first!!.name to report.geoMeanBenchmark), - geoMeanChangeMap, "border-bottom: 2.3pt solid black; border-top: 2.3pt solid black") - renderBenchmarksDetails(report.mergedReport, report.regressions) - renderBenchmarksDetails(report.mergedReport, report.improvements) - if (!onlyChanges) { - // Print all remaining results. - renderBenchmarksDetails(report.mergedReport.filter { it.key !in report.regressions.keys && - it.key !in report.improvements.keys }) + tbody { + val boldRowStyle = "border-bottom: 2.3pt solid black; border-top: 2.3pt solid black" + renderBenchmarksDetails( + mutableMapOf(detailedReport.geoMeanBenchmark.first!!.name to detailedReport.geoMeanBenchmark), + geoMeanChangeMap, boldRowStyle) + + val unstableBenchmarks = report.getUnstableBenchmarksForMetric(metric) + + if (unstableBenchmarks.isNotEmpty()) { + tr { + attributes["style"] = boldRowStyle + th(colspan = Natural(5)) { +"Stable" } + } + } + + renderFilteredBenchmarks(detailedReport, onlyChanges, unstableBenchmarks, false) + + if (unstableBenchmarks.isNotEmpty()) { + tr { + attributes["style"] = boldRowStyle + th(colspan = Natural(5)) { +"Unstable" } + } + } + + renderFilteredBenchmarks(detailedReport, onlyChanges, unstableBenchmarks, true) + } } } + hr {} } } diff --git a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/MetricResultsRender.kt b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/MetricResultsRender.kt index bab962287c6..b73a302d4dc 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/MetricResultsRender.kt +++ b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/MetricResultsRender.kt @@ -14,14 +14,16 @@ class MetricResultsRender: Render() { get() = "metrics" override fun render(report: SummaryBenchmarksReport, onlyChanges: Boolean): String { - val results = report.mergedReport.map { entry -> - buildString { - val metric = entry.value.first!!.metric - append("{ \"benchmarkName\": \"${entry.key.removeSuffix(metric.suffix)}\",") - append("\"metric\": \"${metric}\",") - append("\"value\": \"${entry.value.first!!.score}\" }") + val results = report.detailedMetricReports.values.map { it.mergedReport }.map { report -> + report.map { entry -> + buildString { + val metric = entry.value.first!!.metric + append("{ \"benchmarkName\": \"${entry.key.removeSuffix(metric.suffix)}\",") + append("\"metric\": \"${metric}\",") + append("\"value\": \"${entry.value.first!!.score}\" }") + } } - }.joinToString(", ") + }.flatten().joinToString(", ") return "[ $results ]" } diff --git a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/Render.kt b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/Render.kt index eda8ddb085e..e1920fa4ca3 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/Render.kt +++ b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/Render.kt @@ -54,7 +54,7 @@ class TextRender: Render() { renderEnvChanges(report.envChanges, "Environment") renderEnvChanges(report.kotlinChanges, "Compiler") renderStatusSummary(report) - renderStatusChangesDetails(report.getBenchmarksWithChangedStatus()) + renderStatusChangesDetails(report.benchmarksWithChangedStatus) renderPerformanceSummary(report) renderPerformanceDetails(report, onlyChanges) return content.toString() @@ -113,18 +113,27 @@ class TextRender: Render() { } fun renderPerformanceSummary(report: SummaryBenchmarksReport) { - if (!report.regressions.isEmpty() || !report.improvements.isEmpty()) { + if (report.detailedMetricReports.values.any { it.improvements.isNotEmpty() } || + report.detailedMetricReports.values.any { it.regressions.isNotEmpty() }) { append("Performance summary") append(headerSeparator) - if (!report.regressions.isEmpty()) { - append("Regressions: Maximum = ${formatValue(report.maximumRegression, true)}," + - " Geometric mean = ${formatValue(report.regressionsGeometricMean, true)}") - } - if (!report.improvements.isEmpty()) { - append("Improvements: Maximum = ${formatValue(report.maximumImprovement, true)}," + - " Geometric mean = ${formatValue(report.improvementsGeometricMean, true)}") - } append() + report.detailedMetricReports.forEach { (metric, detailedReport) -> + if (detailedReport.regressions.isNotEmpty() || detailedReport.improvements.isNotEmpty()) { + append(metric.value) + append(headerSeparator) + if (!detailedReport.regressions.isEmpty()) { + append("Regressions: Maximum = ${formatValue(detailedReport.maximumRegression, true)}," + + " Geometric mean = ${formatValue(detailedReport.regressionsGeometricMean, true)}") + } + if (!detailedReport.improvements.isEmpty()) { + append("Improvements: Maximum = ${formatValue(detailedReport.maximumImprovement, true)}," + + " Geometric mean = ${formatValue(detailedReport.improvementsGeometricMean, true)}") + } + append() + } + } + } } @@ -176,25 +185,58 @@ class TextRender: Render() { append(headerSeparator) if (onlyChanges) { - if (report.regressions.isEmpty() && report.improvements.isEmpty()) { + if (report.detailedMetricReports.values.all { it.improvements.isEmpty() } && + report.detailedMetricReports.values.all { it.regressions.isEmpty() }) { append("All becnhmarks are stable.") } } - val tableWidth = printPerformanceTableHeader() - // Print geometric mean. - val geoMeanChangeMap = report.geoMeanScoreChange?. - let { mapOf(report.geoMeanBenchmark.first!!.name to report.geoMeanScoreChange!!) } - printBenchmarksDetails( - mutableMapOf(report.geoMeanBenchmark.first!!.name to report.geoMeanBenchmark), - geoMeanChangeMap) - printTableLineSeparator(tableWidth) - printBenchmarksDetails(report.mergedReport, report.regressions) - printBenchmarksDetails(report.mergedReport, report.improvements) + report.detailedMetricReports.forEach { (metric, detailedReport) -> + append() + append(metric.value) + append(headerSeparator) + val tableWidth = printPerformanceTableHeader() + // Print geometric mean. + val geoMeanChangeMap = detailedReport.geoMeanScoreChange?.let { + mapOf(detailedReport.geoMeanBenchmark.first!!.name to detailedReport.geoMeanScoreChange!!) + } + printBenchmarksDetails( + mutableMapOf(detailedReport.geoMeanBenchmark.first!!.name to detailedReport.geoMeanBenchmark), + geoMeanChangeMap) + printTableLineSeparator(tableWidth) + val unstableBenchmarks = report.getUnstableBenchmarksForMetric(metric) + if (unstableBenchmarks.isNotEmpty()) { + append("Stable") + printTableLineSeparator(tableWidth) + } + renderFilteredPerformanceDetails(detailedReport, onlyChanges, unstableBenchmarks, false) + if (unstableBenchmarks.isNotEmpty()) { + printTableLineSeparator(tableWidth) + append("Unstable") + printTableLineSeparator(tableWidth) + } + renderFilteredPerformanceDetails(detailedReport, onlyChanges, unstableBenchmarks,true) + } + } + + fun renderFilteredPerformanceDetails(detailedReport: DetailedBenchmarksReport, + onlyChanges: Boolean, unstableBenchmarks: List, + filterUnstable: Boolean) { + fun filterBenchmarks(bucket: Map) = + bucket.filter { (name, _) -> + if (filterUnstable) name in unstableBenchmarks else name !in unstableBenchmarks + } + + val filteredRegressions = filterBenchmarks(detailedReport.regressions) + val filteredImprovements = filterBenchmarks(detailedReport.improvements) + printBenchmarksDetails(detailedReport.mergedReport, filteredRegressions) + printBenchmarksDetails(detailedReport.mergedReport, filteredImprovements) if (!onlyChanges) { // Print all remaining results. - printBenchmarksDetails(report.mergedReport.filter { it.key !in report.regressions.keys && - it.key !in report.improvements.keys }) + printBenchmarksDetails(filterBenchmarks(detailedReport.mergedReport).filter { + it.key !in detailedReport.regressions.keys && + it.key !in detailedReport.improvements.keys + }) } } } diff --git a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/StatisticsRender.kt b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/StatisticsRender.kt index abccbb5808c..b8da8626516 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/StatisticsRender.kt +++ b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/StatisticsRender.kt @@ -20,7 +20,7 @@ class StatisticsRender: Render() { private var content = StringBuilder() override fun render(report: SummaryBenchmarksReport, onlyChanges: Boolean): String { - val benchmarksWithChangedStatus = report.getBenchmarksWithChangedStatus() + val benchmarksWithChangedStatus = report.benchmarksWithChangedStatus val newPasses = benchmarksWithChangedStatus .filter { it.current == BenchmarkResult.Status.PASSED } val newFailures = benchmarksWithChangedStatus @@ -28,6 +28,12 @@ class StatisticsRender: Render() { if (report.failedBenchmarks.isNotEmpty()) { content.append("failed: ${report.failedBenchmarks.size}\n") } + val regressionsSize = report.detailedMetricReports.values.fold(0) { acc, it -> + acc + it.regressions.size + } + val improvementsSize = report.detailedMetricReports.values.fold(0) { acc, it -> + acc + it.improvements.size + } val status = when { newFailures.isNotEmpty() -> { content.append("new failures: ${newFailures.size}\n") @@ -37,16 +43,16 @@ class StatisticsRender: Render() { content.append("new passes: ${newPasses.size}\n") Status.FIXED } - report.improvements.isNotEmpty() && report.regressions.isNotEmpty() -> { - content.append("regressions: ${report.regressions.size}\nimprovements: ${report.improvements.size}") + regressionsSize != 0 && improvementsSize != 0 -> { + content.append("regressions: $regressionsSize\nimprovements: $improvementsSize") Status.UNSTABLE } - report.improvements.isNotEmpty() && report.regressions.isEmpty() -> { - content.append("improvements: ${report.improvements.size}") + improvementsSize != 0 && regressionsSize == 0 -> { + content.append("improvements: $improvementsSize") Status.IMPROVED } - report.improvements.isEmpty() && report.regressions.isNotEmpty() -> { - content.append("regressions: ${report.regressions.size}") + improvementsSize == 0 && regressionsSize != 0 -> { + content.append("regressions: $regressionsSize") Status.REGRESSED } else -> Status.STABLE diff --git a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/TeamCityStatisticsRender.kt b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/TeamCityStatisticsRender.kt index 548a421a65d..81d44d782a7 100644 --- a/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/TeamCityStatisticsRender.kt +++ b/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin/org/jetbrains/renders/TeamCityStatisticsRender.kt @@ -29,7 +29,9 @@ class TeamCityStatisticsRender: Render() { content.append("##teamcity[testSuiteFinished name='Benchmarks']\n") // Report geometric mean as build statistic value - renderGeometricMean(report.geoMeanBenchmark.first!!) + report.detailedMetricReports.forEach { (metric, detailedReport) -> + renderGeometricMean(metric.value, detailedReport.geoMeanBenchmark.first!!) + } return content.toString() } @@ -51,8 +53,8 @@ class TeamCityStatisticsRender: Render() { content.append("##teamcity[testFinished name='${benchmark.name}' duration='${(duration / 1000).toInt()}']\n") } - private fun renderGeometricMean(geoMeanBenchmark: MeanVarianceBenchmark) { - content.append("##teamcity[buildStatisticValue key='Geometric mean' value='${geoMeanBenchmark.score}']\n") - content.append("##teamcity[buildStatisticValue key='Geometric mean variance' value='${geoMeanBenchmark.variance}']\n") + private fun renderGeometricMean(metricName: String, geoMeanBenchmark: MeanVarianceBenchmark) { + content.append("##teamcity[buildStatisticValue key='$metricName Geometric mean' value='${geoMeanBenchmark.score}']\n") + content.append("##teamcity[buildStatisticValue key='$metricName Geometric mean variance' value='${geoMeanBenchmark.variance}']\n") } } \ No newline at end of file diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt b/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt index 2ae964db6ba..d5927313b9c 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/database/BenchmarksIndexesDispatcher.kt @@ -256,6 +256,7 @@ class BenchmarksIndexesDispatcher(connector: ElasticSearchConnector, val feature fun getGeometricMean(metricName: String, featureValue: String = "", buildNumbers: Iterable? = null, normalize: Boolean = false, excludeNames: List = emptyList()): Promise>>> { + // Filter only with metric or also with names. val filterBenchmarks = if (excludeNames.isEmpty()) """ @@ -264,7 +265,7 @@ class BenchmarksIndexesDispatcher(connector: ElasticSearchConnector, val feature else """ "bool": { "must": { "match": { "benchmarks.metric": "$metricName" } }, - "must_not": { "terms" : { "benchmarks.name" : [${excludeNames.map { "\"$it\"" }.joinToString()}] } } + "must_not": [ ${excludeNames.map { """{ "match_phrase" : { "benchmarks.name" : "$it" } }"""}.joinToString() } ] } """.trimIndent() val queryDescription = """ diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt b/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt index 8d247aa221b..2d74ee2a81f 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/database/DatabaseRequests.kt @@ -131,6 +131,42 @@ fun getGoldenResults(goldenResultsIndex: GoldenResultsIndex): Promise> { + val queryDescription = """ + { + "_source": ["env"], + "query": { + "nested" : { + "path" : "benchmarks", + "query" : { + "match": { "benchmarks.unstable": true } + }, + "inner_hits": { + "size": 100, + "_source": ["benchmarks.name"] + } + } + } + } + """.trimIndent() + + return goldenResultsIndex.search(queryDescription, listOf("hits.hits.inner_hits")).then { responseString -> + val dbResponse = JsonTreeParser.parse(responseString).jsonObject + val results = dbResponse.getObjectOrNull("hits")?.getArrayOrNull("hits") + ?: error("Wrong response:\n$responseString") + results.getObjectOrNull(0)?.let { + it + .getObject("inner_hits") + .getObject("benchmarks") + .getObject("hits") + .getArray("hits").map { + (it as JsonObject).getObject("_source").getPrimitive("name").content + } + } ?: listOf() + } +} + // Get distinct values for needed field from database. fun distinctValues(field: String, index: ElasticSearchIndex): Promise> { val queryDescription = """ diff --git a/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt b/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt index da4e4db3c59..358334e0e38 100644 --- a/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt +++ b/kotlin-native/tools/performance-server/src/main/kotlin/routes/route.kt @@ -588,6 +588,18 @@ fun router() { } }) + // Get builds description with additional information. + router.get("/unstable", { request, response -> + CachableResponseDispatcher.getResponse(request, response) { success, reject -> + getUnstableResults(goldenIndex).then { unstableBenchmarks -> + success(unstableBenchmarks) + }.catch { + println("Error during getting unstable benchmarks") + reject() + } + } + }) + router.get("/report/:target/:buildNumber", { request, response -> val target = urlParameterToBaseFormat(request.params.target) val buildNumber = request.params.buildNumber.toString() diff --git a/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt b/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt index ce26fc3c05b..5cf3c8d58bd 100644 --- a/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt +++ b/kotlin-native/tools/performance-server/ui/src/main/kotlin/main.kt @@ -206,8 +206,8 @@ fun main(args: Array) { } buildsNumberToShow = parameters["count"]?.toInt() ?: buildsNumberToShow - beforeDate = parameters["before"]?.let{ decodeURIComponent(it)} - afterDate = parameters["after"]?.let{ decodeURIComponent(it)} + beforeDate = parameters["before"]?.let { decodeURIComponent(it) } + afterDate = parameters["after"]?.let { decodeURIComponent(it) } // Get branches. val branchesUrl = "$serverUrl/branches" @@ -285,30 +285,6 @@ fun main(args: Array) { val platformSpecificBenchs = if (parameters["target"] == "Mac_OS_X") ",FrameworkBenchmarksAnalyzer,SpaceFramework_iosX64" else if (parameters["target"] == "Linux") ",kotlinx.coroutines" else "" - // Collect information for charts library. - val valuesToShow = mapOf("EXECUTION_TIME" to listOf(mapOf( - "normalize" to "true" - )), - "COMPILE_TIME" to listOf(mapOf( - "samples" to "HelloWorld,Videoplayer$platformSpecificBenchs", - "agr" to "samples" - )), - "CODE_SIZE" to listOf(mapOf( - "normalize" to "true", - "exclude" to if (parameters["target"] == "Linux") - "kotlinx.coroutines" - else if (parameters["target"] == "Mac_OS_X") - "SpaceFramework_iosX64" - else "" - ), if (platformSpecificBenchs.isNotEmpty()) mapOf( - "normalize" to "true", - "agr" to "samples", - "samples" to platformSpecificBenchs.removePrefix(",") - ) else null).filterNotNull(), - "BUNDLE_SIZE" to listOf(mapOf("samples" to "KotlinNative", - "agr" to "samples")) - ) - var execData = listOf() to listOf>() var compileData = listOf() to listOf>() var codeSizeData = listOf() to listOf>() @@ -328,6 +304,17 @@ fun main(args: Array) { val metricUrl = "$serverUrl/metricValue/${parameters["target"]}/" + val unstableBenchmarksPromise = sendGetRequest("$serverUrl/unstable").then { response -> + val unstableList = response as String + val data = JsonTreeParser.parse(unstableList) + if (data !is JsonArray) { + error("Response is expected to be an array.") + } + data.jsonArray.map { + (it as JsonPrimitive).content + } + } + // Get builds description. val buildsInfoPromise = sendGetRequest(descriptionUrl).then { response -> val buildsInfo = response as String @@ -341,100 +328,131 @@ fun main(args: Array) { } } - // Send requests to get all needed metric values. - valuesToShow.map { (metric, listOfSettings) -> - val resultValues = listOfSettings.map { settings -> - val getParameters = with(StringBuilder()) { - if (settings.isNotEmpty()) { - append("?") - } - var prefix = "" - settings.forEach { (key, value) -> - if (value.isNotEmpty()) { - append("$prefix$key=$value") - prefix = "&" + unstableBenchmarksPromise.then { unstableBenchmarks -> + // Collect information for charts library. + val valuesToShow = mapOf("EXECUTION_TIME" to listOf(mapOf( + "normalize" to "true" + ), + mapOf( + "normalize" to "true", + "exclude" to unstableBenchmarks.joinToString(",") + )), + "COMPILE_TIME" to listOf(mapOf( + "samples" to "HelloWorld,Videoplayer$platformSpecificBenchs", + "agr" to "samples" + )), + "CODE_SIZE" to listOf(mapOf( + "normalize" to "true", + "exclude" to if (parameters["target"] == "Linux") + "kotlinx.coroutines" + else if (parameters["target"] == "Mac_OS_X") + "SpaceFramework_iosX64" + else "" + ), if (platformSpecificBenchs.isNotEmpty()) mapOf( + "normalize" to "true", + "agr" to "samples", + "samples" to platformSpecificBenchs.removePrefix(",") + ) else null).filterNotNull(), + "BUNDLE_SIZE" to listOf(mapOf("samples" to "KotlinNative", + "agr" to "samples")) + ) + // Send requests to get all needed metric values. + valuesToShow.map { (metric, listOfSettings) -> + val resultValues = listOfSettings.map { settings -> + val getParameters = with(StringBuilder()) { + if (settings.isNotEmpty()) { + append("?") } + var prefix = "" + settings.forEach { (key, value) -> + if (value.isNotEmpty()) { + append("$prefix$key=$value") + prefix = "&" + } + } + toString() } - toString() + val branchParameter = if (parameters["branch"] != "all") + (if (getParameters.isEmpty()) "?" else "&") + "branch=${parameters["branch"]}" + else "" + + val url = "$metricUrl$metric$getParameters$branchParameter${ + if (parameters["type"] != "all") + (if (getParameters.isEmpty() && branchParameter.isEmpty()) "?" else "&") + "type=${parameters["type"]}" + else "" + }&count=$buildsNumberToShow${getDatesComponents()}" + sendGetRequest(url) + }.toTypedArray() + + // Get metrics values for charts. + Promise.all(resultValues).then { responses -> + val valuesList = responses.map { response -> + val results = (JsonTreeParser.parse(response) as JsonArray).map { + (it as JsonObject).getPrimitive("first").content to + it.getArray("second").map { (it as JsonPrimitive).doubleOrNull } + } + + val labels = results.map { it.first } + val values = results[0]?.second?.size?.let { (0..it - 1).map { i -> results.map { it.second[i] } } } + ?: emptyList() + labels to values + } + val labels = valuesList[0].first + + val values = valuesList.map { it.second }.reduce { acc, valuesPart -> acc + valuesPart } + + when (metric) { + // Update chart with gotten data. + "COMPILE_TIME" -> { + compileData = labels to values.map { it.map { it?.let { it / 1000 } } } + compileChart = Chartist.Line("#compile_chart", + getChartData(labels, compileData.second), + getChartOptions(valuesToShow["COMPILE_TIME"]!![0]!!["samples"]!!.split(',').toTypedArray(), + "Time, milliseconds")) + buildsInfoPromise.then { builds -> + customizeChart(compileChart, "compile_chart", js("$(\"#compile_chart\")"), builds, parameters) + compileChart.update(getChartData(compileData.first, compileData.second)) + } + } + "EXECUTION_TIME" -> { + execData = labels to values + execChart = Chartist.Line("#exec_chart", + getChartData(labels, execData.second), + getChartOptions(arrayOf("Geometric Mean (All)", "Geometric mean (Stable)"), + "Normalized time")) + buildsInfoPromise.then { builds -> + customizeChart(execChart, "exec_chart", js("$(\"#exec_chart\")"), builds, parameters) + execChart.update(getChartData(execData.first, execData.second)) + } + } + "CODE_SIZE" -> { + codeSizeData = labels to values + codeSizeChart = Chartist.Line("#codesize_chart", + getChartData(labels, codeSizeData.second), + getChartOptions(arrayOf("Geometric Mean") + platformSpecificBenchs.split(',') + .filter { it.isNotEmpty() }, + "Normalized size", + arrayOf("ct-series-4", "ct-series-5", "ct-series-6"))) + buildsInfoPromise.then { builds -> + customizeChart(codeSizeChart, "codesize_chart", js("$(\"#codesize_chart\")"), builds, parameters) + codeSizeChart.update(getChartData(codeSizeData.first, codeSizeData.second, sizeClassNames)) + } + } + "BUNDLE_SIZE" -> { + bundleSizeData = labels to values.map { it.map { it?.let { it.toInt() / 1024 / 1024 } } } + bundleSizeChart = Chartist.Line("#bundlesize_chart", + getChartData(labels, + bundleSizeData.second, sizeClassNames), + getChartOptions(arrayOf("Bundle size"), "Size, MB", arrayOf("ct-series-4"))) + buildsInfoPromise.then { builds -> + customizeChart(bundleSizeChart, "bundlesize_chart", js("$(\"#bundlesize_chart\")"), builds, parameters) + bundleSizeChart.update(getChartData(bundleSizeData.first, bundleSizeData.second, sizeClassNames)) + } + } + else -> error("No chart for metric $metric") + } + true } - val branchParameter = if (parameters["branch"] != "all") - (if (getParameters.isEmpty()) "?" else "&") + "branch=${parameters["branch"]}" - else "" - - val url = "$metricUrl$metric$getParameters$branchParameter${ - if (parameters["type"] != "all") - (if (getParameters.isEmpty() && branchParameter.isEmpty()) "?" else "&") + "type=${parameters["type"]}" - else "" - }&count=$buildsNumberToShow${getDatesComponents()}" - sendGetRequest(url) - }.toTypedArray() - - // Get metrics values for charts. - Promise.all(resultValues).then { responses -> - val valuesList = responses.map { response -> - val results = (JsonTreeParser.parse(response) as JsonArray).map { - (it as JsonObject).getPrimitive("first").content to - it.getArray("second").map { (it as JsonPrimitive).doubleOrNull } - } - - val labels = results.map { it.first } - val values = results[0]?.second?.size?.let { (0..it - 1).map { i -> results.map { it.second[i] } } } - ?: emptyList() - labels to values - } - val labels = valuesList[0].first - val values = valuesList.map { it.second }.reduce { acc, valuesPart -> acc + valuesPart } - - when (metric) { - // Update chart with gotten data. - "COMPILE_TIME" -> { - compileData = labels to values.map { it.map { it?.let { it / 1000 } } } - compileChart = Chartist.Line("#compile_chart", - getChartData(labels, compileData.second), - getChartOptions(valuesToShow["COMPILE_TIME"]!![0]!!["samples"]!!.split(',').toTypedArray(), - "Time, milliseconds")) - buildsInfoPromise.then { builds -> - customizeChart(compileChart, "compile_chart", js("$(\"#compile_chart\")"), builds, parameters) - compileChart.update(getChartData(compileData.first, compileData.second)) - } - } - "EXECUTION_TIME" -> { - execData = labels to values - execChart = Chartist.Line("#exec_chart", - getChartData(labels, execData.second), - getChartOptions(arrayOf("Geometric Mean"), "Normalized time")) - buildsInfoPromise.then { builds -> - customizeChart(execChart, "exec_chart", js("$(\"#exec_chart\")"), builds, parameters) - execChart.update(getChartData(execData.first, execData.second)) - } - } - "CODE_SIZE" -> { - codeSizeData = labels to values - codeSizeChart = Chartist.Line("#codesize_chart", - getChartData(labels, codeSizeData.second), - getChartOptions(arrayOf("Geometric Mean") + platformSpecificBenchs.split(',') - .filter { it.isNotEmpty() }, - "Normalized size", - arrayOf("ct-series-4", "ct-series-5", "ct-series-6"))) - buildsInfoPromise.then { builds -> - customizeChart(codeSizeChart, "codesize_chart", js("$(\"#codesize_chart\")"), builds, parameters) - codeSizeChart.update(getChartData(codeSizeData.first, codeSizeData.second, sizeClassNames)) - } - } - "BUNDLE_SIZE" -> { - bundleSizeData = labels to values.map { it.map { it?.let { it.toInt() / 1024 / 1024 } } } - bundleSizeChart = Chartist.Line("#bundlesize_chart", - getChartData(labels, - bundleSizeData.second, sizeClassNames), - getChartOptions(arrayOf("Bundle size"), "Size, MB", arrayOf("ct-series-4"))) - buildsInfoPromise.then { builds -> - customizeChart(bundleSizeChart, "bundlesize_chart", js("$(\"#bundlesize_chart\")"), builds, parameters) - bundleSizeChart.update(getChartData(bundleSizeData.first, bundleSizeData.second, sizeClassNames)) - } - } - else -> error("No chart for metric $metric") - } - true } } From e8804dc53d3a41f0114cf24185125edd398b7e6d Mon Sep 17 00:00:00 2001 From: SaintMalik <37118134+saintmalik@users.noreply.github.com> Date: Mon, 18 Jan 2021 15:08:48 +0100 Subject: [PATCH 107/122] Fix broken url in docs ## Summary Easy navigation and easy reading for others --- kotlin-native/GRADLE_PLUGIN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/GRADLE_PLUGIN.md b/kotlin-native/GRADLE_PLUGIN.md index 55f61364383..68b8e05771a 100644 --- a/kotlin-native/GRADLE_PLUGIN.md +++ b/kotlin-native/GRADLE_PLUGIN.md @@ -459,7 +459,7 @@ dependencies { It's possible to depend on a Kotlin/Native library published earlier in a maven repo. The plugin relies on Gradle's -[metadata](https://github.com/gradle/gradle/blob/master/subprojects/docs/src/docs/design/gradle-module-metadata-specification.md) +[metadata](https://github.com/gradle/gradle/blob/master/subprojects/docs/src/docs/design/gradle-module-metadata-latest-specification.md) support so the corresponding feature must be enabled. Add the following line in your `settings.gradle`:
From 26248bb9b181c562d61673ac7b6ade6c15503853 Mon Sep 17 00:00:00 2001 From: Ying Li Date: Tue, 19 Jan 2021 17:50:07 +0900 Subject: [PATCH 108/122] fix minor typo (#4629) * fix minor typo * fix sample code format --- kotlin-native/COCOAPODS.md | 12 ++++++++++-- kotlin-native/GRADLE_PLUGIN.md | 2 +- kotlin-native/LIBRARIES.md | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/kotlin-native/COCOAPODS.md b/kotlin-native/COCOAPODS.md index 3481f465267..a6356a2081f 100644 --- a/kotlin-native/COCOAPODS.md +++ b/kotlin-native/COCOAPODS.md @@ -330,7 +330,7 @@ You can add dependencies on a Pod library from `zip`, `tar`, or `jar` archive wi 1. Specify the name of a Pod library in the `pod()` function. In the configuration block specify the path to the archive: use the `url()` function with an arbitrary HTTP address in the `source` parameter value. - Additionally, you can specify the boolean `flatten` parameter as a second argument for the `url()` function + Additionally, you can specify the boolean `flatten` parameter as a second argument for the `url()` function. This parameter indicates that all the Pod files are located in the root directory of the archive. 2. Specify the minimum deployment target version for the Pod library. @@ -430,7 +430,15 @@ You can add dependencies on a Pod library from a custom Podspec repository with 4. Re-import the project. > To work correctly with Xcode, you should specify the location of specs at the beginning of your Podfile. -> For example, `source 'https://github.com/Kotlin/kotlin-cocoapods-spec.git'` +> For example: +> +>
+> +> ```ruby +> source 'https://github.com/Kotlin/kotlin-cocoapods-spec.git' +> ``` +> +>
> > You should also specify the path to the Podspec in your Podfile. > For example: diff --git a/kotlin-native/GRADLE_PLUGIN.md b/kotlin-native/GRADLE_PLUGIN.md index 68b8e05771a..38deb1bb44f 100644 --- a/kotlin-native/GRADLE_PLUGIN.md +++ b/kotlin-native/GRADLE_PLUGIN.md @@ -170,7 +170,7 @@ kotlin.sourceSets { // Configure all native platform sources sets to use it as a common one. linuxX64Main.dependsOn(nativeMain) macosX64Main.dependsOn(nativeMain) - //... + // ... } ``` diff --git a/kotlin-native/LIBRARIES.md b/kotlin-native/LIBRARIES.md index 72d9c005776..4539e6c3e0d 100644 --- a/kotlin-native/LIBRARIES.md +++ b/kotlin-native/LIBRARIES.md @@ -225,7 +225,7 @@ directory structure, with the following layout: - foo/ - $component_name/ - ir/ - - Seriaized Kotlin IR. + - Serialized Kotlin IR. - targets/ - $platform/ - kotlin/ From 3ee8d98726a21177f95583f15827ec5ab53b4d15 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Tue, 12 Jan 2021 13:34:04 +0700 Subject: [PATCH 109/122] Mention new per-target cache setting in error message. --- .../src/org/jetbrains/kotlin/backend/konan/Linker.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Linker.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Linker.kt index e4f5ca41f73..9c536afb26a 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Linker.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Linker.kt @@ -3,11 +3,8 @@ package org.jetbrains.kotlin.backend.konan import org.jetbrains.kotlin.konan.KonanExternalToolFailure import org.jetbrains.kotlin.konan.exec.Command import org.jetbrains.kotlin.konan.file.File -import org.jetbrains.kotlin.konan.target.CompilerOutputKind -import org.jetbrains.kotlin.konan.target.Family -import org.jetbrains.kotlin.konan.target.LinkerOutputKind import org.jetbrains.kotlin.konan.library.KonanLibrary -import org.jetbrains.kotlin.konan.target.supportsMimallocAllocator +import org.jetbrains.kotlin.konan.target.* import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder import org.jetbrains.kotlin.library.uniqueName import org.jetbrains.kotlin.utils.addToStdlib.cast @@ -169,7 +166,7 @@ internal class Linker(val context: Context) { """ Please try to disable compiler caches and rerun the build. To disable compiler caches, add the following line to the gradle.properties file in the project's root directory: - kotlin.native.cacheKind=none + kotlin.native.cacheKind.${target.presetName}=none Also, consider filing an issue with full Gradle log here: https://kotl.in/issue """.trimIndent() From 6cc60ad6a2388b61efc77b1a609f5a1cfef57a4d Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Wed, 20 Jan 2021 19:42:09 +0300 Subject: [PATCH 110/122] Support sanitizers in runtime tests (#4622) --- .../kotlin/bitcode/CompileToBitcode.kt | 32 +++++-- .../kotlin/bitcode/CompileToBitcodePlugin.kt | 39 ++++++-- .../kotlin/testing/native/NativeTest.kt | 73 ++++++++++---- kotlin-native/runtime/build.gradle.kts | 35 +++---- .../runtime/src/main/cpp/AllocTest.cpp | 4 +- .../runtime/src/main/cpp/TestSupport.hpp | 3 + .../runtime/src/mm/cpp/ExtraObjectData.cpp | 20 +++- .../konan/target/KonanTargetExtenstions.kt | 11 +++ .../jetbrains/kotlin/konan/target/Linker.kt | 94 +++++++++++++++---- .../kotlin/konan/target/Sanitizer.kt | 11 +++ 10 files changed, 256 insertions(+), 66 deletions(-) create mode 100644 kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Sanitizer.kt diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt index 039fb2f39f5..1ef5d444f5b 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcode.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.ExecClang import org.jetbrains.kotlin.konan.target.Family import org.jetbrains.kotlin.konan.target.HostManager import org.jetbrains.kotlin.konan.target.KonanTarget +import org.jetbrains.kotlin.konan.target.SanitizerKind import java.io.File import javax.inject.Inject @@ -19,7 +20,7 @@ open class CompileToBitcode @Inject constructor( val srcRoot: File, val folderName: String, val target: String, - val outputGroup: String + val outputGroup: String, ) : DefaultTask() { enum class Language { @@ -46,9 +47,22 @@ open class CompileToBitcode @Inject constructor( @Input var language = Language.CPP - private val targetDir by lazy { project.buildDir.resolve("bitcode/$outputGroup/$target") } + @Input @Optional + var sanitizer: SanitizerKind? = null - val objDir by lazy { File(targetDir, folderName) } + private val targetDir: File + get() { + val sanitizerSuffix = when (sanitizer) { + null -> "" + SanitizerKind.ADDRESS -> "-asan" + SanitizerKind.THREAD -> "-tsan" + } + return project.buildDir.resolve("bitcode/$outputGroup/$target$sanitizerSuffix") + } + + @get:Input + val objDir + get() = File(targetDir, folderName) private val KonanTarget.isMINGW get() = this.family == Family.MINGW @@ -63,6 +77,11 @@ open class CompileToBitcode @Inject constructor( val compilerFlags: List get() { val commonFlags = listOf("-c", "-emit-llvm") + headersDirs.map { "-I$it" } + val sanitizerFlags = when (sanitizer) { + null -> listOf() + SanitizerKind.ADDRESS -> listOf("-fsanitize=address") + SanitizerKind.THREAD -> listOf("-fsanitize=thread") + } val languageFlags = when (language) { Language.C -> // Used flags provided by original build of allocator C code. @@ -73,7 +92,7 @@ open class CompileToBitcode @Inject constructor( "-Wno-unused-parameter", // False positives with polymorphic functions. "-fPIC".takeIf { !HostManager().targetByName(target).isMINGW }) } - return commonFlags + languageFlags + compilerArgs + return commonFlags + sanitizerFlags + languageFlags + compilerArgs } @get:SkipWhenEmpty @@ -127,8 +146,9 @@ open class CompileToBitcode @Inject constructor( } } - @OutputFile - val outFile = File(targetDir, "${folderName}.bc") + @get:OutputFile + val outFile: File + get() = File(targetDir, "${folderName}.bc") @TaskAction fun compile() { diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt index 349ce47ea22..86233499e43 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/bitcode/CompileToBitcodePlugin.kt @@ -9,6 +9,9 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.BasePlugin import org.jetbrains.kotlin.createCompilationDatabasesFromCompileToBitcodeTasks +import org.jetbrains.kotlin.konan.target.PlatformManager +import org.jetbrains.kotlin.konan.target.SanitizerKind +import org.jetbrains.kotlin.konan.target.supportedSanitizers import java.io.File import javax.inject.Inject @@ -45,20 +48,40 @@ open class CompileToBitcodeExtension @Inject constructor(val project: Project) { configurationBlock: CompileToBitcode.() -> Unit = {} ) { targetList.get().forEach { targetName -> - project.tasks.register( - "${targetName}${name.snakeCaseToCamelCase().capitalize()}", - CompileToBitcode::class.java, - srcDir, name, targetName, outputGroup - ).configure { - it.group = BasePlugin.BUILD_GROUP - it.description = "Compiles '$name' to bitcode for $targetName" - it.configurationBlock() + val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager + val target = platformManager.targetByName(targetName) + val sanitizers: List = target.supportedSanitizers() + listOf(null) + sanitizers.forEach { sanitizer -> + project.tasks.register( + "${targetName}${name.snakeCaseToCamelCase().capitalize()}${suffixForSanitizer(sanitizer)}", + CompileToBitcode::class.java, + srcDir, name, targetName, outputGroup + ).configure { + it.sanitizer = sanitizer + it.group = BasePlugin.BUILD_GROUP + val sanitizerDescription = when (sanitizer) { + null -> "" + SanitizerKind.ADDRESS -> " with ASAN" + SanitizerKind.THREAD -> " with TSAN" + } + it.description = "Compiles '$name' to bitcode for $targetName$sanitizerDescription" + it.configurationBlock() + } } } } companion object { + private fun String.snakeCaseToCamelCase() = split('_').joinToString(separator = "") { it.capitalize() } + + fun suffixForSanitizer(sanitizer: SanitizerKind?) = + when (sanitizer) { + null -> "" + SanitizerKind.ADDRESS -> "_ASAN" + SanitizerKind.THREAD -> "_TSAN" + } + } } diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt index 017500775d9..97ae40ed586 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt @@ -13,6 +13,7 @@ import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.tasks.* import org.jetbrains.kotlin.ExecClang import org.jetbrains.kotlin.bitcode.CompileToBitcode +import org.jetbrains.kotlin.bitcode.CompileToBitcodeExtension import org.jetbrains.kotlin.konan.target.* open class CompileNativeTest @Inject constructor( @@ -25,18 +26,29 @@ open class CompileNativeTest @Inject constructor( @Input val clangArgs = mutableListOf() + @Input @Optional + var sanitizer: SanitizerKind? = null + + @Input + private val sanitizerFlags = when (sanitizer) { + null -> listOf() + SanitizerKind.ADDRESS -> listOf("-fsanitize=address") + SanitizerKind.THREAD -> listOf("-fsanitize=thread") + } + @TaskAction fun compile() { val plugin = project.convention.getPlugin(ExecClang::class.java) + val args = clangArgs + sanitizerFlags + listOf(inputFile.absolutePath, "-o", outputFile.absolutePath) if (target.family.isAppleFamily) { plugin.execToolchainClang(target) { it.executable = "clang++" - it.args = clangArgs + listOf(inputFile.absolutePath, "-o", outputFile.absolutePath) + it.args = args } } else { plugin.execBareClang { it.executable = "clang++" - it.args = clangArgs + listOf(inputFile.absolutePath, "-o", outputFile.absolutePath) + it.args = args } } } @@ -92,7 +104,7 @@ open class LinkNativeTest @Inject constructor( @Internal val target: String, @Internal val linkerArgs: List, private val platformManager: PlatformManager, - private val mimallocEnabled: Boolean + private val mimallocEnabled: Boolean, ) : DefaultTask () { companion object { fun create( @@ -103,7 +115,7 @@ open class LinkNativeTest @Inject constructor( target: String, outputFile: File, linkerArgs: List, - mimallocEnabled: Boolean + mimallocEnabled: Boolean, ): LinkNativeTest = project.tasks.create( taskName, LinkNativeTest::class.java, @@ -133,6 +145,9 @@ open class LinkNativeTest @Inject constructor( linkerArgs, mimallocEnabled) } + @Input @Optional + var sanitizer: SanitizerKind? = null + @get:Input val commands: List> get() { @@ -149,7 +164,8 @@ open class LinkNativeTest @Inject constructor( kind = LinkerOutputKind.EXECUTABLE, outputDsymBundle = "", needsProfileLibrary = false, - mimallocEnabled = mimallocEnabled + mimallocEnabled = mimallocEnabled, + sanitizer = sanitizer, ).map { it.argsWithExecutable } } @@ -163,11 +179,11 @@ open class LinkNativeTest @Inject constructor( } } -fun createTestTask( +private fun createTestTask( project: Project, testName: String, - testTaskName: String, testedTaskNames: List, + sanitizer: SanitizerKind?, configureCompileToBitcode: CompileToBitcode.() -> Unit = {}, ): Task { val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager @@ -188,6 +204,7 @@ fun createTestTask( "${it.folderName}Tests", target, "test" ).apply { + this.sanitizer = sanitizer excludeFiles = emptyList() includeFiles = listOf("**/*Test.cpp", "**/*Test.mm") dependsOn(it) @@ -201,18 +218,19 @@ fun createTestTask( else task } + // TODO: Consider using sanitized versions. val testFrameworkTasks = listOf( project.tasks.getByName("${target}Googletest") as CompileToBitcode, project.tasks.getByName("${target}Googlemock") as CompileToBitcode ) - val testSupportTask = project.tasks.getByName("${target}TestSupport") as CompileToBitcode + val testSupportTask = project.tasks.getByName("${target}TestSupport${CompileToBitcodeExtension.suffixForSanitizer(sanitizer)}") as CompileToBitcode // TODO: It may make sense to merge llvm-link, compile and link to a single task. val llvmLinkTask = project.tasks.create( - "${testTaskName}LlvmLink", + "${testName}LlvmLink", LlvmLinkNativeTest::class.java, - testTaskName, target, testSupportTask.outFile + testName, target, testSupportTask.outFile ).apply { val tasksToLink = (compileToBitcodeTasks + testedTasks + testFrameworkTasks) inputFiles = project.files(tasksToLink.map { it.outFile }) @@ -222,11 +240,12 @@ fun createTestTask( val clangFlags = platformManager.platform(konanTarget).configurables as ClangFlags val compileTask = project.tasks.create( - "${testTaskName}Compile", + "${testName}Compile", CompileNativeTest::class.java, llvmLinkTask.outputFile, konanTarget, ).apply { + this.sanitizer = sanitizer dependsOn(llvmLinkTask) clangArgs.addAll(clangFlags.clangFlags) clangArgs.addAll(clangFlags.clangNooptFlags) @@ -236,19 +255,20 @@ fun createTestTask( val linkTask = LinkNativeTest.create( project, platformManager, - "${testTaskName}Link", + "${testName}Link${CompileToBitcodeExtension.suffixForSanitizer(sanitizer)}", listOf(compileTask.outputFile), target, - testTaskName, - mimallocEnabled + testName, + mimallocEnabled, ).apply { + this.sanitizer = sanitizer dependsOn(compileTask) } - return project.tasks.create(testTaskName, Exec::class.java).apply { + return project.tasks.create(testName, Exec::class.java).apply { dependsOn(linkTask) - workingDir = project.buildDir.resolve("testReports/$testTaskName") + workingDir = project.buildDir.resolve("testReports/$testName") val xmlReport = workingDir.resolve("report.xml") executable(linkTask.outputFile) args("--gtest_output=xml:${xmlReport.absoluteFile}") @@ -267,3 +287,24 @@ fun createTestTask( } } } + +// TODO: These tests should be created by `CompileToBitcodeExtension` +fun createTestTasks( + project: Project, + targetName: String, + testTaskName: String, + testedTaskNames: List, + configureCompileToBitcode: CompileToBitcode.() -> Unit = {}, +): List { + val platformManager = project.rootProject.findProperty("platformManager") as PlatformManager + val target = platformManager.targetByName(targetName) + val sanitizers: List = target.supportedSanitizers() + listOf(null) + return sanitizers.map { sanitizer -> + val suffix = CompileToBitcodeExtension.suffixForSanitizer(sanitizer) + val name = testTaskName + suffix + val testedNames = testedTaskNames.map { + it + suffix + } + createTestTask(project, name, testedNames, sanitizer, configureCompileToBitcode) + } +} diff --git a/kotlin-native/runtime/build.gradle.kts b/kotlin-native/runtime/build.gradle.kts index 1d7ffe5b032..bfdedff0eb5 100644 --- a/kotlin-native/runtime/build.gradle.kts +++ b/kotlin-native/runtime/build.gradle.kts @@ -5,6 +5,8 @@ import org.jetbrains.kotlin.* import org.jetbrains.kotlin.testing.native.* import org.jetbrains.kotlin.bitcode.CompileToBitcode +import org.jetbrains.kotlin.bitcode.CompileToBitcodeExtension +import org.jetbrains.kotlin.konan.target.* plugins { id("compile-to-bitcode") @@ -42,6 +44,7 @@ bitcode { "${target}ExperimentalMemoryManager" ) includeRuntime() + // TODO: Should depend on the sanitizer. linkerArgs.add(project.file("../common/build/bitcode/main/$target/hash.bc").path) } @@ -107,9 +110,11 @@ bitcode { } targetList.forEach { targetName -> - createTestTask( + val allTests = mutableListOf() + + allTests.addAll(createTestTasks( project, - "StdAlloc", + targetName, "${targetName}StdAllocRuntimeTests", listOf( "${targetName}Runtime", @@ -120,11 +125,11 @@ targetList.forEach { targetName -> ) ) { includeRuntime() - } + }) - createTestTask( + allTests.addAll(createTestTasks( project, - "Mimalloc", + targetName, "${targetName}MimallocRuntimeTests", listOf( "${targetName}Runtime", @@ -136,11 +141,11 @@ targetList.forEach { targetName -> ) ) { includeRuntime() - } + }) - createTestTask( + allTests.addAll(createTestTasks( project, - "ExperimentalMMMimalloc", + targetName, "${targetName}ExperimentalMMMimallocRuntimeTests", listOf( "${targetName}Runtime", @@ -151,11 +156,11 @@ targetList.forEach { targetName -> ) ) { includeRuntime() - } + }) - createTestTask( + allTests.addAll(createTestTasks( project, - "ExperimentalMMStdAlloc", + targetName, "${targetName}ExperimentalMMStdAllocRuntimeTests", listOf( "${targetName}Runtime", @@ -165,13 +170,11 @@ targetList.forEach { targetName -> ) ) { includeRuntime() - } + }) + // TODO: This "all tests" tasks should be provided by `CompileToBitcodeExtension` tasks.register("${targetName}RuntimeTests") { - dependsOn("${targetName}StdAllocRuntimeTests") - dependsOn("${targetName}MimallocRuntimeTests") - dependsOn("${targetName}ExperimentalMMStdAllocRuntimeTests") - dependsOn("${targetName}ExperimentalMMMimallocRuntimeTests") + dependsOn(allTests) } } diff --git a/kotlin-native/runtime/src/main/cpp/AllocTest.cpp b/kotlin-native/runtime/src/main/cpp/AllocTest.cpp index 7ba0fb9be48..e9b58dc6c59 100644 --- a/kotlin-native/runtime/src/main/cpp/AllocTest.cpp +++ b/kotlin-native/runtime/src/main/cpp/AllocTest.cpp @@ -112,7 +112,9 @@ TEST_F(KonanAllocatorAwareTest, PlacementAllocated) { TEST_F(KonanAllocatorAwareTest, PlacementConstructedArray) { constexpr size_t kCount = 5; - std::array buffer; + // TODO: Consider removing support for placement new[] altogether, since there's no + // portable way to know needed storage size ahead of time. + alignas(A) std::array buffer; A* as = new (buffer.data()) A[kCount]; std::vector actual; diff --git a/kotlin-native/runtime/src/main/cpp/TestSupport.hpp b/kotlin-native/runtime/src/main/cpp/TestSupport.hpp index 521a7d93951..f2e7b2ade92 100644 --- a/kotlin-native/runtime/src/main/cpp/TestSupport.hpp +++ b/kotlin-native/runtime/src/main/cpp/TestSupport.hpp @@ -8,6 +8,9 @@ namespace kotlin { #if KONAN_WINDOWS // TODO: Figure out why creating many threads on windows is so slow. constexpr int kDefaultThreadCount = 10; +#elif __has_feature(thread_sanitizer) +// TSAN has a huge overhead. +constexpr int kDefaultThreadCount = 10; #else constexpr int kDefaultThreadCount = 100; #endif diff --git a/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp b/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp index 4fc9b1a4914..61959c6a32c 100644 --- a/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp +++ b/kotlin-native/runtime/src/mm/cpp/ExtraObjectData.cpp @@ -14,9 +14,27 @@ using namespace kotlin; +namespace { + +template +ALWAYS_INLINE T UnsafeRead(T* location) noexcept { +#if __has_feature(thread_sanitizer) + // Make TSAN think that this load is fine. + return __atomic_load_n(location, __ATOMIC_ACQUIRE); +#else + return *location; +#endif +} + +} // namespace + // static mm::ExtraObjectData& mm::ExtraObjectData::Install(ObjHeader* object) noexcept { - TypeInfo* typeInfo = object->typeInfoOrMeta_; + // TODO: Consider extracting initialization scheme with speculative load. + // `object->typeInfoOrMeta_` is assigned at most once. If we read some old value (i.e. not a meta object), + // we will fail at CAS below. If we read the new value, we will immediately return it. + TypeInfo* typeInfo = UnsafeRead(&object->typeInfoOrMeta_); + if (auto* metaObject = ObjHeader::AsMetaObject(typeInfo)) { return mm::ExtraObjectData::FromMetaObjHeader(metaObject); } diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt index 1d6a0aefbe7..3320f1397f5 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/KonanTargetExtenstions.kt @@ -30,3 +30,14 @@ fun KonanTarget.supportsThreads(): Boolean = is KonanTarget.ZEPHYR -> false else -> true } + +fun KonanTarget.supportedSanitizers(): List = + when(this) { + is KonanTarget.LINUX_X64 -> listOf(SanitizerKind.ADDRESS) + is KonanTarget.MACOS_X64 -> listOf(SanitizerKind.THREAD) + // TODO: Enable ASAN on macOS. Currently there's an incompatibility between clang frontend version and clang_rt.asan version. + // TODO: Enable TSAN on linux. Currently there's a link error between clang_rt.tsan and libstdc++. + // TODO: Consider supporting mingw. + // TODO: Support macOS arm64 + else -> listOf() + } diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt index aac5339b34e..81c0fc403c8 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt @@ -76,7 +76,8 @@ abstract class LinkerFlags(val configurables: Configurables) { libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind? = null): List /** * Returns list of commands that link object files into a single one. @@ -93,7 +94,7 @@ abstract class LinkerFlags(val configurables: Configurables) { return libraries } - protected open fun provideCompilerRtLibrary(libraryName: String): String? { + protected open fun provideCompilerRtLibrary(libraryName: String, isDynamic: Boolean = false): String? { System.err.println("Can't provide $libraryName.") return null } @@ -123,7 +124,11 @@ class AndroidLinker(targetProperties: AndroidConfigurables) libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List { + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind?): List { + require(sanitizer == null) { + "Sanitizers are unsupported" + } if (kind == LinkerOutputKind.STATIC_LIBRARY) return staticGnuArCommands(ar, executable, objectFiles, libraries) @@ -170,7 +175,12 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) get() = this == KonanTarget.TVOS_X64 || this == KonanTarget.IOS_X64 || this == KonanTarget.WATCHOS_X86 || this == KonanTarget.WATCHOS_X64 - override fun provideCompilerRtLibrary(libraryName: String): String? { + private val compilerRtDir: String? by lazy { + val dir = File("$absoluteTargetToolchain/usr/lib/clang/").listFiles.firstOrNull()?.absolutePath + if (dir != null) "$dir/lib/darwin/" else null + } + + override fun provideCompilerRtLibrary(libraryName: String, isDynamic: Boolean): String? { val prefix = when (target.family) { Family.IOS -> "ios" Family.WATCHOS -> "watchos" @@ -184,10 +194,11 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) "" } - val dir = File("$absoluteTargetToolchain/usr/lib/clang/").listFiles.firstOrNull()?.absolutePath + val dir = compilerRtDir val mangledLibraryName = if (libraryName.isEmpty()) "" else "${libraryName}_" + val extension = if (isDynamic) "_dynamic.dylib" else ".a" - return if (dir != null) "$dir/lib/darwin/libclang_rt.$mangledLibraryName$prefix$suffix.a" else null + return if (dir != null) "$dir/libclang_rt.$mangledLibraryName$prefix$suffix$extension" else null } private val osVersionMinFlags: List by lazy { @@ -210,14 +221,19 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List { - if (kind == LinkerOutputKind.STATIC_LIBRARY) + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind?): List { + if (kind == LinkerOutputKind.STATIC_LIBRARY) { + require(sanitizer == null) { + "Sanitizers are unsupported" + } return listOf(Command(libtool).apply { +"-static" +listOf("-o", executable) +objectFiles +libraries }) + } val dynamic = kind == LinkerOutputKind.DYNAMIC_LIBRARY val result = mutableListOf() @@ -237,7 +253,12 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) if (needsProfileLibrary) +profileLibrary!! +libraries +linkerArgs - +rpath(dynamic) + +rpath(dynamic, sanitizer) + when (sanitizer) { + null -> {} + SanitizerKind.ADDRESS -> +provideCompilerRtLibrary("asan", isDynamic=true)!! + SanitizerKind.THREAD -> +provideCompilerRtLibrary("tsan", isDynamic=true)!! + } } // TODO: revise debug information handling. @@ -255,7 +276,7 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) provideCompilerRtLibrary("") } - private fun rpath(dynamic: Boolean): List = listOfNotNull( + private fun rpath(dynamic: Boolean, sanitizer: SanitizerKind?): List = listOfNotNull( when (target.family) { Family.OSX -> "@executable_path/../Frameworks" Family.IOS, @@ -263,7 +284,8 @@ class MacOSBasedLinker(targetProperties: AppleConfigurables) Family.TVOS -> "@executable_path/Frameworks" else -> error(target) }, - "@loader_path/Frameworks".takeIf { dynamic } + "@loader_path/Frameworks".takeIf { dynamic }, + compilerRtDir.takeIf { sanitizer != null }, ).flatMap { listOf("-rpath", it) } fun dsymUtilCommand(executable: ExecutableFile, outputDsymBundle: String) = @@ -319,7 +341,10 @@ class GccBasedLinker(targetProperties: GccConfigurables) private val specificLibs = abiSpecificLibraries.map { "-L${absoluteTargetSysRoot}/$it" } - override fun provideCompilerRtLibrary(libraryName: String): String? { + override fun provideCompilerRtLibrary(libraryName: String, isDynamic: Boolean): String? { + require(!isDynamic) { + "Dynamic compiler rt librares are unsupported" + } val targetSuffix = when (target) { KonanTarget.LINUX_X64 -> "x86_64" else -> error("$target is not supported.") @@ -334,9 +359,14 @@ class GccBasedLinker(targetProperties: GccConfigurables) libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List { - if (kind == LinkerOutputKind.STATIC_LIBRARY) + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind?): List { + if (kind == LinkerOutputKind.STATIC_LIBRARY) { + require(sanitizer == null) { + "Sanitizers are unsupported" + } return staticGnuArCommands(ar, executable, objectFiles, libraries) + } val isMips = target == KonanTarget.LINUX_MIPS32 || target == KonanTarget.LINUX_MIPSEL32 val dynamic = kind == LinkerOutputKind.DYNAMIC_LIBRARY val crtPrefix = "$absoluteTargetSysRoot/$crtFilesLocation" @@ -373,6 +403,19 @@ class GccBasedLinker(targetProperties: GccConfigurables) +linkerGccFlags +if (dynamic) "$libGcc/crtendS.o" else "$libGcc/crtend.o" +"$crtPrefix/crtn.o" + when (sanitizer) { + null -> {} + SanitizerKind.ADDRESS -> { + +"-lrt" + +provideCompilerRtLibrary("asan")!! + +provideCompilerRtLibrary("asan_cxx")!! + } + SanitizerKind.THREAD -> { + +"-lrt" + +provideCompilerRtLibrary("tsan")!! + +provideCompilerRtLibrary("tsan_cxx")!! + } + } }) } } @@ -387,7 +430,10 @@ class MingwLinker(targetProperties: MingwConfigurables) override fun filterStaticLibraries(binaries: List) = binaries.filter { it.isWindowsStaticLib || it.isUnixStaticLib } - override fun provideCompilerRtLibrary(libraryName: String): String? { + override fun provideCompilerRtLibrary(libraryName: String, isDynamic: Boolean): String? { + require(!isDynamic) { + "Dynamic compiler rt librares are unsupported" + } val targetSuffix = when (target) { KonanTarget.MINGW_X64 -> "x86_64" else -> error("$target is not supported.") @@ -400,7 +446,11 @@ class MingwLinker(targetProperties: MingwConfigurables) libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List { + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind?): List { + require(sanitizer == null) { + "Sanitizers are unsupported" + } if (kind == LinkerOutputKind.STATIC_LIBRARY) return staticGnuArCommands(ar, executable, objectFiles, libraries) @@ -437,8 +487,12 @@ class WasmLinker(targetProperties: WasmConfigurables) libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List { + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind?): List { if (kind != LinkerOutputKind.EXECUTABLE) throw Error("Unsupported linker output kind") + require(sanitizer == null) { + "Sanitizers are unsupported" + } val linkage = Command("$llvmBin/wasm-ld").apply { +objectFiles @@ -489,8 +543,12 @@ open class ZephyrLinker(targetProperties: ZephyrConfigurables) libraries: List, linkerArgs: List, optimize: Boolean, debug: Boolean, kind: LinkerOutputKind, outputDsymBundle: String, - needsProfileLibrary: Boolean, mimallocEnabled: Boolean): List { + needsProfileLibrary: Boolean, mimallocEnabled: Boolean, + sanitizer: SanitizerKind?): List { if (kind != LinkerOutputKind.EXECUTABLE) throw Error("Unsupported linker output kind: $kind") + require(sanitizer == null) { + "Sanitizers are unsupported" + } return listOf(Command(linker).apply { +listOf("-r", "--gc-sections", "--entry", "main") +listOf("-o", executable) diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Sanitizer.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Sanitizer.kt new file mode 100644 index 00000000000..3ab83ccfaed --- /dev/null +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Sanitizer.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.konan.target + +enum class SanitizerKind { + ADDRESS, + THREAD, +} From e241d1249c6c0f2a04b8f803e33ee6c3132801b7 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Thu, 24 Dec 2020 15:50:56 +0300 Subject: [PATCH 111/122] Fix NSUInteger size for Watchos x64 --- .../objcexport/ObjCExportCodeGenerator.kt | 20 ++++--------------- .../tests/interop/objc/smoke.kt | 7 ++++--- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index 825d82046c1..39c31b87612 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -1586,34 +1586,22 @@ internal fun ObjCExportCodeGenerator.getEncoding(methodBridge: MethodBridge): St } } - val targetFamily = context.config.target.family - val returnTypeEncoding = methodBridge.returnBridge.getObjCEncoding(targetFamily) + val returnTypeEncoding = methodBridge.returnBridge.getObjCEncoding(context) val paramSize = paramOffset return "$returnTypeEncoding$paramSize$params" } -// https://developer.apple.com/documentation/objectivec/nsuinteger?language=objc -// `typedef unsigned long NSUInteger` on iOS, macOS, tvOS. -// `typedef unsigned int NSInteger` on watchOS. -private val Family.nsUIntegerEncoding: String get() = when (this) { - Family.OSX, - Family.IOS, - Family.TVOS -> "L" - Family.WATCHOS -> "I" - else -> error("Unexpected target platform: $this") -} - -private fun MethodBridge.ReturnValue.getObjCEncoding(targetFamily: Family): String = when (this) { +private fun MethodBridge.ReturnValue.getObjCEncoding(context: Context): String = when (this) { MethodBridge.ReturnValue.Suspend, MethodBridge.ReturnValue.Void -> "v" - MethodBridge.ReturnValue.HashCode -> targetFamily.nsUIntegerEncoding + MethodBridge.ReturnValue.HashCode -> if (context.is64BitNSInteger()) "L" else "I" is MethodBridge.ReturnValue.Mapped -> this.bridge.objCEncoding MethodBridge.ReturnValue.WithError.Success -> ObjCValueType.BOOL.encoding MethodBridge.ReturnValue.Instance.InitResult, MethodBridge.ReturnValue.Instance.FactoryResult -> ReferenceBridge.objCEncoding - is MethodBridge.ReturnValue.WithError.ZeroForError -> this.successBridge.getObjCEncoding(targetFamily) + is MethodBridge.ReturnValue.WithError.ZeroForError -> this.successBridge.getObjCEncoding(context) } private val MethodBridgeParameter.objCEncoding: String get() = when (this) { diff --git a/kotlin-native/backend.native/tests/interop/objc/smoke.kt b/kotlin-native/backend.native/tests/interop/objc/smoke.kt index b01f0680854..9bcb39c394b 100644 --- a/kotlin-native/backend.native/tests/interop/objc/smoke.kt +++ b/kotlin-native/backend.native/tests/interop/objc/smoke.kt @@ -67,11 +67,12 @@ fun run() { // hashCode (directly): // hash() returns value of NSUInteger type. - val hash = when (Platform.osFamily) { + val hash = if (Platform.osFamily == OsFamily.WATCHOS && Platform.cpuArchitecture.bitness == 32) { // `typedef unsigned int NSInteger` on watchOS. - OsFamily.WATCHOS -> foo.hash().toInt() + foo.hash().toInt() + } else { // `typedef unsigned long NSUInteger` on iOS, macOS, tvOS. - else -> foo.hash().let { it.toInt() xor (it shr 32).toInt() } + foo.hash().let { it.toInt() xor (it shr 32).toInt() } } if (foo.hashCode() == hash) { // toString (virtually): From b565562a1f7f2263b7b9baa2b7408323f0291fb2 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Mon, 11 Jan 2021 16:39:31 +0300 Subject: [PATCH 112/122] Fix architecture check in the test --- kotlin-native/backend.native/tests/interop/objc/smoke.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/tests/interop/objc/smoke.kt b/kotlin-native/backend.native/tests/interop/objc/smoke.kt index 9bcb39c394b..0016018d84d 100644 --- a/kotlin-native/backend.native/tests/interop/objc/smoke.kt +++ b/kotlin-native/backend.native/tests/interop/objc/smoke.kt @@ -67,7 +67,7 @@ fun run() { // hashCode (directly): // hash() returns value of NSUInteger type. - val hash = if (Platform.osFamily == OsFamily.WATCHOS && Platform.cpuArchitecture.bitness == 32) { + val hash = if (Platform.osFamily == OsFamily.WATCHOS && Platform.cpuArchitecture != CpuArchitecture.X64) { // `typedef unsigned int NSInteger` on watchOS. foo.hash().toInt() } else { From 9807a92fa741db595f7a5fa489f1f05c96f781ee Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Tue, 12 Jan 2021 12:13:45 +0300 Subject: [PATCH 113/122] Fix Unsigned long type encoding according to the ObjC encode rules --- .../backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index 39c31b87612..77a6b2c0cec 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -1595,7 +1595,7 @@ internal fun ObjCExportCodeGenerator.getEncoding(methodBridge: MethodBridge): St private fun MethodBridge.ReturnValue.getObjCEncoding(context: Context): String = when (this) { MethodBridge.ReturnValue.Suspend, MethodBridge.ReturnValue.Void -> "v" - MethodBridge.ReturnValue.HashCode -> if (context.is64BitNSInteger()) "L" else "I" + MethodBridge.ReturnValue.HashCode -> if (context.is64BitNSInteger()) "Q" else "I" is MethodBridge.ReturnValue.Mapped -> this.bridge.objCEncoding MethodBridge.ReturnValue.WithError.Success -> ObjCValueType.BOOL.encoding From 6cc74a1b665c5b27bca3660dad516ca41a591915 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Tue, 12 Jan 2021 13:43:14 +0300 Subject: [PATCH 114/122] Better fix for the test: check for NUSInteger size --- kotlin-native/backend.native/tests/interop/objc/smoke.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kotlin-native/backend.native/tests/interop/objc/smoke.kt b/kotlin-native/backend.native/tests/interop/objc/smoke.kt index 0016018d84d..aac1156ba30 100644 --- a/kotlin-native/backend.native/tests/interop/objc/smoke.kt +++ b/kotlin-native/backend.native/tests/interop/objc/smoke.kt @@ -67,7 +67,7 @@ fun run() { // hashCode (directly): // hash() returns value of NSUInteger type. - val hash = if (Platform.osFamily == OsFamily.WATCHOS && Platform.cpuArchitecture != CpuArchitecture.X64) { + val hash = if (sizeOf() == 4L) { // `typedef unsigned int NSInteger` on watchOS. foo.hash().toInt() } else { From 73297a4ef35672594797fd83a54f2cf2c38d2895 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Wed, 20 Jan 2021 19:26:33 +0300 Subject: [PATCH 115/122] Remove obsolete comments in the test --- kotlin-native/backend.native/tests/interop/objc/smoke.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/kotlin-native/backend.native/tests/interop/objc/smoke.kt b/kotlin-native/backend.native/tests/interop/objc/smoke.kt index aac1156ba30..4bad1609993 100644 --- a/kotlin-native/backend.native/tests/interop/objc/smoke.kt +++ b/kotlin-native/backend.native/tests/interop/objc/smoke.kt @@ -68,10 +68,8 @@ fun run() { // hashCode (directly): // hash() returns value of NSUInteger type. val hash = if (sizeOf() == 4L) { - // `typedef unsigned int NSInteger` on watchOS. foo.hash().toInt() } else { - // `typedef unsigned long NSUInteger` on iOS, macOS, tvOS. foo.hash().let { it.toInt() xor (it shr 32).toInt() } } if (foo.hashCode() == hash) { From 71f44dce0f9cffdb01bfc23ba650383bea7000ca Mon Sep 17 00:00:00 2001 From: LepilkinaElena Date: Thu, 21 Jan 2021 19:53:08 +0300 Subject: [PATCH 116/122] Added StringTrimLowering to pipeline (#4647) --- .../backend/konan/KonanLoweringPhases.kt | 6 ++++ .../kotlin/backend/konan/ToplevelPhases.kt | 1 + .../backend.native/tests/build.gradle | 4 +++ .../tests/codegen/stringTrim/stringTrim.kt | 30 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 kotlin-native/backend.native/tests/codegen/stringTrim/stringTrim.kt diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt index d445332e8a5..8c4587e6225 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanLoweringPhases.kt @@ -379,4 +379,10 @@ internal val foldConstantLoweringPhase = makeKonanFileOpPhase( name = "FoldConstantLowering", description = "Constant Folding", prerequisite = setOf(flattenStringConcatenationPhase) +) + +internal val computeStringTrimPhase = makeKonanFileLoweringPhase( + ::StringTrimLowering, + name = "StringTrimLowering", + description = "Compute trimIndent and trimMargin operations on constant strings" ) \ No newline at end of file diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt index c4f94887680..4b71fd2dc53 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt @@ -221,6 +221,7 @@ internal val allLoweringsPhase = NamedCompilerPhase( forLoopsPhase, flattenStringConcatenationPhase, foldConstantLoweringPhase, + computeStringTrimPhase, stringConcatenationPhase, enumConstructorsPhase, initializersPhase, diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index d59f61e18d6..ee9a2b1b614 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -813,6 +813,10 @@ task hello0(type: KonanLocalTest) { source = "runtime/basic/hello0.kt" } +task stringTrim(type: KonanLocalTest) { + source = "codegen/stringTrim/stringTrim.kt" +} + standaloneTest("hello1") { goldValue = "Hello World" testData = "Hello World\n" diff --git a/kotlin-native/backend.native/tests/codegen/stringTrim/stringTrim.kt b/kotlin-native/backend.native/tests/codegen/stringTrim/stringTrim.kt new file mode 100644 index 00000000000..50deb484e89 --- /dev/null +++ b/kotlin-native/backend.native/tests/codegen/stringTrim/stringTrim.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package codegen.stringTrim.stringTrim + +import kotlin.test.* + +// TODO: check IR +fun constantIndent(): String { + return """ + Hello, + World + """.trimIndent() +} + +fun constantMargin(): String { + return """ + |Hello, + |World + """.trimMargin() +} + +@Test +fun runTest() { + assertTrue(constantIndent() === constantIndent()) + assertTrue(constantMargin() === constantMargin()) +} + From 77e2b9f9a0872c1548d6bd9ae88ba5af9afcbc50 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Fri, 22 Jan 2021 12:23:53 +0300 Subject: [PATCH 117/122] Disable running checkers by default (#4644) * Make checkers be disabled by default * Allow running checkers in test launcher --- .../backend.native/tests/build.gradle | 49 +++++-------------- .../tests/framework/kt42397/knlibrary.kt | 6 +++ .../tests/framework/kt42397/test.swift | 1 + .../tests/interop/kt42397/knlibrary.kt | 6 +++ .../tests/interop/kt42397/test.cpp | 2 + .../leakMemoryWithRunningThread/checked.kt | 2 + .../leakMemoryWithRunningThread/unchecked.kt | 2 + .../tests/interop/memory_leaks/lib.kt | 5 ++ .../tests/interop/memory_leaks/main.cpp | 1 + .../objc_with_initializer/objc_test.kt | 4 +- .../tests/runtime/basic/cleaner_leak.kt | 24 --------- .../basic/cleaner_leak_with_checker.kt | 4 -- .../basic/cleaner_leak_without_checker.kt | 5 -- .../tests/runtime/memory/cycle_collector.kt | 4 +- .../tests/runtime/memory/cycle_detector.kt | 6 +++ .../tests/runtime/memory/leak_memory.kt | 2 + .../runtime/memory/leak_memory_test_runner.kt | 14 ++++++ .../leak_memory_with_worker_termination.kt | 2 + .../tests/runtime/workers/leak_worker.kt | 2 + .../workers/worker_threadlocal_no_leak.kt | 2 + .../runtime/src/main/cpp/Runtime.cpp | 4 +- .../kotlin/native/internal/test/Launcher.kt | 11 +++-- 22 files changed, 82 insertions(+), 76 deletions(-) delete mode 100644 kotlin-native/backend.native/tests/runtime/basic/cleaner_leak.kt create mode 100644 kotlin-native/backend.native/tests/runtime/memory/leak_memory_test_runner.kt diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index ee9a2b1b614..b21012613d8 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -783,9 +783,7 @@ task array_to_any(type: KonanLocalTest) { } standaloneTest("runtime_basic_init") { - disabled = (project.testTarget == 'wasm32') // -g not yet properly works for WASM. source = "runtime/basic/init.kt" - flags = ['-g'] expectedExitStatus = 0 } @@ -941,20 +939,6 @@ standaloneTest("cleaner_in_main_without_checker") { goldValue = "" } -standaloneTest("cleaner_leak_release") { - enabled = !project.globalTestArgs.contains('-g') && (project.testTarget != 'wasm32') // Cleaners need workers - source = "runtime/basic/cleaner_leak.kt" - goldValue = "" -} - -standaloneTest("cleaner_leak_debug") { - enabled = !project.globalTestArgs.contains('-opt') && (project.testTarget != 'wasm32') // Cleaners need workers - source = "runtime/basic/cleaner_leak.kt" - flags = ['-g'] - expectedExitStatusChecker = { it != 0 } - outputChecker = { s -> (s =~ /Cleaner (0x)?[0-9a-fA-F]+ was disposed during program exit/).find() } -} - standaloneTest("cleaner_leak_without_checker") { enabled = (project.testTarget != 'wasm32') // Cleaners need workers source = "runtime/basic/cleaner_leak_without_checker.kt" @@ -1066,9 +1050,8 @@ task worker11(type: KonanLocalTest) { } standaloneTest("worker_threadlocal_no_leak") { - disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build and pthreads. + disabled = (project.testTarget == 'wasm32') // Needs pthreads. source = "runtime/workers/worker_threadlocal_no_leak.kt" - flags = ['-g'] } task freeze0(type: KonanLocalTest) { @@ -1168,17 +1151,15 @@ task enumIdentity(type: KonanLocalTest) { } standaloneTest("leakWorker") { - disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build and pthreads. + disabled = (project.testTarget == 'wasm32') // Needs pthreads. source = "runtime/workers/leak_worker.kt" - flags = ['-g'] expectedExitStatusChecker = { it != 0 } outputChecker = { s -> s.contains("Unfinished workers detected, 1 workers leaked!") } } standaloneTest("leakMemoryWithWorkerTermination") { - disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build and pthreads. + disabled = (project.testTarget == 'wasm32') // Needs pthreads. source = "runtime/workers/leak_memory_with_worker_termination.kt" - flags = ['-g'] expectedExitStatusChecker = { it != 0 } outputChecker = { s -> s.contains("Memory leaks detected, 1 objects leaked!") } } @@ -2965,7 +2946,6 @@ standaloneTest("cycle_detector") { standaloneTest("cycle_collector") { disabled = true // Needs USE_CYCLIC_GC, which is disabled. - flags = ['-g'] source = "runtime/memory/cycle_collector.kt" } @@ -2975,9 +2955,14 @@ standaloneTest("cycle_collector_deadlock1") { } standaloneTest("leakMemory") { - disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build. source = "runtime/memory/leak_memory.kt" - flags = ['-g'] + expectedExitStatusChecker = { it != 0 } + outputChecker = { s -> s.contains("Memory leaks detected, 1 objects leaked!") } +} + +standaloneTest("leakMemoryWithTestRunner") { + source = "runtime/memory/leak_memory_test_runner.kt" + flags = ['-tr'] expectedExitStatusChecker = { it != 0 } outputChecker = { s -> s.contains("Memory leaks detected, 1 objects leaked!") } } @@ -4084,17 +4069,13 @@ interopTest("interop_kt43265") { } interopTest("interop_leakMemoryWithRunningThreadUnchecked") { - disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build. interop = 'leakMemoryWithRunningThread' source = "interop/leakMemoryWithRunningThread/unchecked.kt" - flags = ['-g'] } interopTest("interop_leakMemoryWithRunningThreadChecked") { - disabled = project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build. interop = 'leakMemoryWithRunningThread' source = "interop/leakMemoryWithRunningThread/checked.kt" - flags = ['-g'] expectedExitStatusChecker = { it != 0 } outputChecker = { s -> s.contains("Cannot run checkers when there are 1 alive runtimes at the shutdown") } } @@ -4192,7 +4173,6 @@ if (PlatformInfo.isAppleTarget(project)) { goldValue = "OK\n" source = "interop/objc_with_initializer/objc_test.kt" interop = 'objcMisc' - flags = ['-g'] doBeforeBuild { mkdir(buildDir) @@ -4395,11 +4375,10 @@ dynamicTest("interop_concurrentRuntime") { } dynamicTest("interop_kt42397") { - disabled = project.target.name != project.hostName || project.globalTestArgs.contains('-opt') + disabled = project.target.name != project.hostName source = "interop/kt42397/knlibrary.kt" cSource = "$projectDir/interop/kt42397/test.cpp" clangTool = "clang++" - flags = ['-g'] } dynamicTest("interop_cleaners_main_thread") { @@ -4447,12 +4426,11 @@ dynamicTest("interop_migrating_main_thread") { } dynamicTest("interop_memory_leaks") { - disabled = (project.target.name != project.hostName) || - project.globalTestArgs.contains('-opt') || (project.testTarget == 'wasm32') // Needs debug build. + disabled = (project.target.name != project.hostName) source = "interop/memory_leaks/lib.kt" cSource = "$projectDir/interop/memory_leaks/main.cpp" clangTool = "clang++" - flags = ['-g', '-Xdestroy-runtime-mode=legacy'] // Runtime cannot be destroyed with interop with on-shutdown. + flags = ['-Xdestroy-runtime-mode=legacy'] // Runtime cannot be destroyed with interop with on-shutdown. expectedExitStatusChecker = { it != 0 } outputChecker = { s -> s.contains("Memory leaks detected, 1 objects leaked!") } } @@ -4732,7 +4710,6 @@ if (isAppleTarget(project)) { enabled = !project.globalTestArgs.contains('-opt') framework("Kt42397") { sources = ['framework/kt42397'] - opts = ['-g'] } swiftSources = ['framework/kt42397'] } diff --git a/kotlin-native/backend.native/tests/framework/kt42397/knlibrary.kt b/kotlin-native/backend.native/tests/framework/kt42397/knlibrary.kt index 3d4a4d25cb0..06efdf7daca 100644 --- a/kotlin-native/backend.native/tests/framework/kt42397/knlibrary.kt +++ b/kotlin-native/backend.native/tests/framework/kt42397/knlibrary.kt @@ -1,3 +1,5 @@ +import kotlin.native.Platform + // The following 2 singletons are unused. However, since we are generating ObjC bindings for them, // they should be marked as used, so that the code generator emits their deinitialization. @@ -10,3 +12,7 @@ class B { fun foo() = 2 } } + +fun enableMemoryChecker() { + Platform.isMemoryLeakCheckerActive = true +} diff --git a/kotlin-native/backend.native/tests/framework/kt42397/test.swift b/kotlin-native/backend.native/tests/framework/kt42397/test.swift index e154ca1c476..f1456a18ebc 100644 --- a/kotlin-native/backend.native/tests/framework/kt42397/test.swift +++ b/kotlin-native/backend.native/tests/framework/kt42397/test.swift @@ -7,6 +7,7 @@ class Results { func runTestKt42397(pointer: UnsafeMutableRawPointer) -> UnsafeMutableRawPointer? { autoreleasepool { + KnlibraryKt.enableMemoryChecker() let results = pointer.bindMemory(to: Results.self, capacity: 1).pointee results.aFoo = A().foo() results.bFoo = B.Companion().foo() diff --git a/kotlin-native/backend.native/tests/interop/kt42397/knlibrary.kt b/kotlin-native/backend.native/tests/interop/kt42397/knlibrary.kt index eaefd5a1ad6..f58807bc0c1 100644 --- a/kotlin-native/backend.native/tests/interop/kt42397/knlibrary.kt +++ b/kotlin-native/backend.native/tests/interop/kt42397/knlibrary.kt @@ -1,5 +1,7 @@ package knlibrary +import kotlin.native.Platform + // The following 2 singletons are unused. However, since we are generating C bindings for them, // they should be marked as used, so that the code generator emits their deinitialization. @@ -8,3 +10,7 @@ object A {} class B { companion object {} } + +fun enableMemoryChecker() { + Platform.isMemoryLeakCheckerActive = true +} diff --git a/kotlin-native/backend.native/tests/interop/kt42397/test.cpp b/kotlin-native/backend.native/tests/interop/kt42397/test.cpp index 2bd5cc286db..983f6684961 100644 --- a/kotlin-native/backend.native/tests/interop/kt42397/test.cpp +++ b/kotlin-native/backend.native/tests/interop/kt42397/test.cpp @@ -6,6 +6,8 @@ int main() { auto t = std::thread([] { auto lib = testlib_symbols(); + lib->kotlin.root.knlibrary.enableMemoryChecker(); + // Initialize A and B.Companion and get their stable pointers. auto a = lib->kotlin.root.knlibrary.A._instance(); auto bCompanion = lib->kotlin.root.knlibrary.B.Companion._instance(); diff --git a/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/checked.kt b/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/checked.kt index 309fce99f4a..d3e429b105a 100644 --- a/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/checked.kt +++ b/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/checked.kt @@ -1,5 +1,6 @@ import leakMemory.* import kotlin.native.concurrent.* +import kotlin.native.Platform import kotlin.test.* import kotlinx.cinterop.* @@ -13,6 +14,7 @@ fun ensureInititalized() { } fun main() { + Platform.isMemoryLeakCheckerActive = true kotlin.native.internal.Debugging.forceCheckedShutdown = true assertTrue(global.value == 0) // Created a thread, made sure Kotlin is initialized there. diff --git a/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/unchecked.kt b/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/unchecked.kt index db770cabe48..ab569d77530 100644 --- a/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/unchecked.kt +++ b/kotlin-native/backend.native/tests/interop/leakMemoryWithRunningThread/unchecked.kt @@ -1,5 +1,6 @@ import leakMemory.* import kotlin.native.concurrent.* +import kotlin.native.Platform import kotlin.test.* import kotlinx.cinterop.* @@ -13,6 +14,7 @@ fun ensureInititalized() { } fun main() { + Platform.isMemoryLeakCheckerActive = true kotlin.native.internal.Debugging.forceCheckedShutdown = false assertTrue(global.value == 0) // Created a thread, made sure Kotlin is initialized there. diff --git a/kotlin-native/backend.native/tests/interop/memory_leaks/lib.kt b/kotlin-native/backend.native/tests/interop/memory_leaks/lib.kt index cfab7ec7202..f02b04d9368 100644 --- a/kotlin-native/backend.native/tests/interop/memory_leaks/lib.kt +++ b/kotlin-native/backend.native/tests/interop/memory_leaks/lib.kt @@ -4,6 +4,11 @@ */ import kotlinx.cinterop.* +import kotlin.native.Platform + +fun enableMemoryChecker() { + Platform.isMemoryLeakCheckerActive = true +} fun leakMemory() { StableRef.create(Any()) diff --git a/kotlin-native/backend.native/tests/interop/memory_leaks/main.cpp b/kotlin-native/backend.native/tests/interop/memory_leaks/main.cpp index ee9bbfc3613..e2fb6c8358f 100644 --- a/kotlin-native/backend.native/tests/interop/memory_leaks/main.cpp +++ b/kotlin-native/backend.native/tests/interop/memory_leaks/main.cpp @@ -9,6 +9,7 @@ int main() { std::thread t([]() { + testlib_symbols()->kotlin.root.enableMemoryChecker(); testlib_symbols()->kotlin.root.leakMemory(); }); t.join(); diff --git a/kotlin-native/backend.native/tests/interop/objc_with_initializer/objc_test.kt b/kotlin-native/backend.native/tests/interop/objc_with_initializer/objc_test.kt index fdce20d8a3f..fc7dd5e1de7 100644 --- a/kotlin-native/backend.native/tests/interop/objc_with_initializer/objc_test.kt +++ b/kotlin-native/backend.native/tests/interop/objc_with_initializer/objc_test.kt @@ -1,7 +1,9 @@ import objc_misc.* +import kotlin.native.Platform val a = B.giveC()!! as C fun main() { + Platform.isMemoryLeakCheckerActive = true println("OK") -} \ No newline at end of file +} diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak.kt b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak.kt deleted file mode 100644 index 01f2a5277a2..00000000000 --- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ -@file:OptIn(ExperimentalStdlibApi::class) - -import kotlin.test.* - -import kotlin.native.internal.* - -// This cleaner won't be run, because it's deinitialized with globals after -// cleaners are disabled. -val globalCleaner = createCleaner(42) { - println(it) -} - -fun main() { - // Cleaner holds onto a finalization lambda. If it doesn't get executed, - // the memory will leak. Suppress memory leak checker to check for cleaners - // leak only. - Platform.isMemoryLeakCheckerActive = false - // Make sure cleaner is initialized. - assertNotNull(globalCleaner) -} diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt index 053c1146d7c..b0bd8060574 100644 --- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt +++ b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_with_checker.kt @@ -16,10 +16,6 @@ val globalCleaner = createCleaner(42) { } fun main() { - // Cleaner holds onto a finalization lambda. If it doesn't get executed, - // the memory will leak. Suppress memory leak checker to check for cleaners - // leak only. - Platform.isMemoryLeakCheckerActive = false Platform.isCleanersLeakCheckerActive = true // Make sure cleaner is initialized. assertNotNull(globalCleaner) diff --git a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt index 7391ef50de0..76eb9c1e461 100644 --- a/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt +++ b/kotlin-native/backend.native/tests/runtime/basic/cleaner_leak_without_checker.kt @@ -16,11 +16,6 @@ val globalCleaner = createCleaner(42) { } fun main() { - // Cleaner holds onto a finalization lambda. If it doesn't get executed, - // the memory will leak. Suppress memory leak checker to check for cleaners - // leak only. - Platform.isMemoryLeakCheckerActive = false - Platform.isCleanersLeakCheckerActive = false // Make sure cleaner is initialized. assertNotNull(globalCleaner) } diff --git a/kotlin-native/backend.native/tests/runtime/memory/cycle_collector.kt b/kotlin-native/backend.native/tests/runtime/memory/cycle_collector.kt index 88ec23dcce7..484e560e3cb 100644 --- a/kotlin-native/backend.native/tests/runtime/memory/cycle_collector.kt +++ b/kotlin-native/backend.native/tests/runtime/memory/cycle_collector.kt @@ -1,5 +1,6 @@ import kotlin.native.concurrent.* import kotlin.native.internal.GC +import kotlin.native.Platform import kotlin.test.* fun test1() { @@ -175,6 +176,7 @@ fun test9() { } fun main() { + Platform.isMemoryLeakCheckerActive = true kotlin.native.internal.GC.cyclicCollectorEnabled = true test1() test2() @@ -187,4 +189,4 @@ fun main() { test7() test8() test9() -} \ No newline at end of file +} diff --git a/kotlin-native/backend.native/tests/runtime/memory/cycle_detector.kt b/kotlin-native/backend.native/tests/runtime/memory/cycle_detector.kt index 0f4113856e7..668c9241db3 100644 --- a/kotlin-native/backend.native/tests/runtime/memory/cycle_detector.kt +++ b/kotlin-native/backend.native/tests/runtime/memory/cycle_detector.kt @@ -1,5 +1,6 @@ import kotlin.native.concurrent.* import kotlin.native.internal.GC +import kotlin.native.Platform import kotlin.test.* class Holder(var other: Any?) @@ -32,6 +33,11 @@ fun assertArrayEquals( } } +@BeforeTest +fun enableMemoryChecker() { + Platform.isMemoryLeakCheckerActive = true +} + @Test fun noCycles() { val atomic1 = AtomicReference(null) diff --git a/kotlin-native/backend.native/tests/runtime/memory/leak_memory.kt b/kotlin-native/backend.native/tests/runtime/memory/leak_memory.kt index 487662fff28..0d6351cfaa5 100644 --- a/kotlin-native/backend.native/tests/runtime/memory/leak_memory.kt +++ b/kotlin-native/backend.native/tests/runtime/memory/leak_memory.kt @@ -1,5 +1,7 @@ import kotlinx.cinterop.* +import kotlin.native.Platform fun main() { + Platform.isMemoryLeakCheckerActive = true StableRef.create(Any()) } diff --git a/kotlin-native/backend.native/tests/runtime/memory/leak_memory_test_runner.kt b/kotlin-native/backend.native/tests/runtime/memory/leak_memory_test_runner.kt new file mode 100644 index 00000000000..5facc72141b --- /dev/null +++ b/kotlin-native/backend.native/tests/runtime/memory/leak_memory_test_runner.kt @@ -0,0 +1,14 @@ +import kotlin.test.* + +import kotlinx.cinterop.* +import kotlin.native.Platform + +@BeforeTest +fun enableMemoryChecker() { + Platform.isMemoryLeakCheckerActive = true +} + +@Test +fun test() { + StableRef.create(Any()) +} diff --git a/kotlin-native/backend.native/tests/runtime/workers/leak_memory_with_worker_termination.kt b/kotlin-native/backend.native/tests/runtime/workers/leak_memory_with_worker_termination.kt index 32a9d0a3a69..00262efbe68 100644 --- a/kotlin-native/backend.native/tests/runtime/workers/leak_memory_with_worker_termination.kt +++ b/kotlin-native/backend.native/tests/runtime/workers/leak_memory_with_worker_termination.kt @@ -1,7 +1,9 @@ import kotlin.native.concurrent.* +import kotlin.native.Platform import kotlinx.cinterop.* fun main() { + Platform.isMemoryLeakCheckerActive = true val worker = Worker.start() // Make sure worker is initialized. worker.execute(TransferMode.SAFE, {}, {}).result; diff --git a/kotlin-native/backend.native/tests/runtime/workers/leak_worker.kt b/kotlin-native/backend.native/tests/runtime/workers/leak_worker.kt index 1df5bfac135..1afd59ebb20 100644 --- a/kotlin-native/backend.native/tests/runtime/workers/leak_worker.kt +++ b/kotlin-native/backend.native/tests/runtime/workers/leak_worker.kt @@ -1,7 +1,9 @@ import kotlin.native.concurrent.* +import kotlin.native.Platform import kotlinx.cinterop.* fun main() { + Platform.isMemoryLeakCheckerActive = true val worker = Worker.start() // Make sure worker is initialized. worker.execute(TransferMode.SAFE, {}, {}).result; diff --git a/kotlin-native/backend.native/tests/runtime/workers/worker_threadlocal_no_leak.kt b/kotlin-native/backend.native/tests/runtime/workers/worker_threadlocal_no_leak.kt index 567e6d1f185..edf615d9d5a 100644 --- a/kotlin-native/backend.native/tests/runtime/workers/worker_threadlocal_no_leak.kt +++ b/kotlin-native/backend.native/tests/runtime/workers/worker_threadlocal_no_leak.kt @@ -4,11 +4,13 @@ */ import kotlin.native.concurrent.* +import kotlin.native.Platform @ThreadLocal var x = Any() fun main() { + Platform.isMemoryLeakCheckerActive = true val worker = Worker.start() worker.execute(TransferMode.SAFE, {}) { diff --git a/kotlin-native/runtime/src/main/cpp/Runtime.cpp b/kotlin-native/runtime/src/main/cpp/Runtime.cpp index 88ebcdf8e60..93d7bccf9e7 100644 --- a/kotlin-native/runtime/src/main/cpp/Runtime.cpp +++ b/kotlin-native/runtime/src/main/cpp/Runtime.cpp @@ -71,8 +71,8 @@ void InitOrDeinitGlobalVariables(int initialize, MemoryState* memory) { } } -KBoolean g_checkLeaks = KonanNeedDebugInfo; -KBoolean g_checkLeakedCleaners = KonanNeedDebugInfo; +KBoolean g_checkLeaks = false; +KBoolean g_checkLeakedCleaners = false; KBoolean g_forceCheckedShutdown = false; constexpr RuntimeState* kInvalidRuntime = nullptr; diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt index 5f11161fff1..22420b5141d 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/internal/test/Launcher.kt @@ -23,16 +23,21 @@ fun testLauncherEntryPoint(args: Array): Int { } fun main(args: Array) { - exitProcess(testLauncherEntryPoint(args)) + val exitCode = testLauncherEntryPoint(args) + if (exitCode != 0) { + exitProcess(exitCode) + } } fun worker(args: Array) { val worker = Worker.start() - val result = worker.execute(TransferMode.SAFE, { args.freeze() }) { + val exitCode = worker.execute(TransferMode.SAFE, { args.freeze() }) { it -> testLauncherEntryPoint(it) }.result worker.requestTermination().result - exitProcess(result) + if (exitCode != 0) { + exitProcess(exitCode) + } } fun mainNoExit(args: Array) { From 687cf20d7d6750a55ebf240a86ca78bbe52544b7 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Fri, 22 Jan 2021 16:05:51 +0300 Subject: [PATCH 118/122] Deal with FrameOverlay in the new mm (#4646) --- kotlin-native/runtime/src/mm/cpp/Memory.cpp | 10 ++ .../runtime/src/mm/cpp/ShadowStack.cpp | 37 ++++++ .../runtime/src/mm/cpp/ShadowStack.hpp | 67 ++++++++++ .../runtime/src/mm/cpp/ShadowStackTest.cpp | 121 ++++++++++++++++++ kotlin-native/runtime/src/mm/cpp/Stubs.cpp | 8 -- .../runtime/src/mm/cpp/ThreadData.hpp | 4 + 6 files changed, 239 insertions(+), 8 deletions(-) create mode 100644 kotlin-native/runtime/src/mm/cpp/ShadowStack.cpp create mode 100644 kotlin-native/runtime/src/mm/cpp/ShadowStack.hpp create mode 100644 kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp diff --git a/kotlin-native/runtime/src/mm/cpp/Memory.cpp b/kotlin-native/runtime/src/mm/cpp/Memory.cpp index 84a47c0512f..75a76239c1b 100644 --- a/kotlin-native/runtime/src/mm/cpp/Memory.cpp +++ b/kotlin-native/runtime/src/mm/cpp/Memory.cpp @@ -142,6 +142,16 @@ extern "C" RUNTIME_NOTHROW void InitAndRegisterGlobal(ObjHeader** location, cons extern "C" const MemoryModel CurrentMemoryModel = MemoryModel::kExperimental; +extern "C" RUNTIME_NOTHROW void EnterFrame(ObjHeader** start, int parameters, int count) { + auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData(); + threadData->shadowStack().EnterFrame(start, parameters, count); +} + +extern "C" RUNTIME_NOTHROW void LeaveFrame(ObjHeader** start, int parameters, int count) { + auto* threadData = mm::ThreadRegistry::Instance().CurrentThreadData(); + threadData->shadowStack().LeaveFrame(start, parameters, count); +} + extern "C" RUNTIME_NOTHROW void AddTLSRecord(MemoryState* memory, void** key, int size) { GetThreadData(memory)->tls().AddRecord(key, size); } diff --git a/kotlin-native/runtime/src/mm/cpp/ShadowStack.cpp b/kotlin-native/runtime/src/mm/cpp/ShadowStack.cpp new file mode 100644 index 00000000000..02bebb9cd4f --- /dev/null +++ b/kotlin-native/runtime/src/mm/cpp/ShadowStack.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +#include "ShadowStack.hpp" + +using namespace kotlin; + +mm::ShadowStack::Iterator& mm::ShadowStack::Iterator::operator++() noexcept { + ++object_; + Init(); + return *this; +} + +void mm::ShadowStack::Iterator::Init() noexcept { + while (frame_) { + if (object_ < end_) return; + frame_ = frame_->previous; + object_ = begin(); + end_ = end(); + } +} + +void mm::ShadowStack::EnterFrame(ObjHeader** start, int parameters, int count) noexcept { + FrameOverlay* frame = reinterpret_cast(start); + frame->previous = currentFrame_; + currentFrame_ = frame; + // TODO: maybe compress in single value somehow. + frame->parameters = parameters; + frame->count = count; +} + +void mm::ShadowStack::LeaveFrame(ObjHeader** start, int parameters, int count) noexcept { + FrameOverlay* frame = reinterpret_cast(start); + currentFrame_ = frame->previous; +} diff --git a/kotlin-native/runtime/src/mm/cpp/ShadowStack.hpp b/kotlin-native/runtime/src/mm/cpp/ShadowStack.hpp new file mode 100644 index 00000000000..41f4901c89b --- /dev/null +++ b/kotlin-native/runtime/src/mm/cpp/ShadowStack.hpp @@ -0,0 +1,67 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +#ifndef RUNTIME_MM_SHADOW_STACK +#define RUNTIME_MM_SHADOW_STACK + +#include "Memory.h" +#include "Utils.hpp" + +struct FrameOverlay; +struct ObjHeader; + +namespace kotlin { +namespace mm { + +// Accessing current stack as provided by K/N compiler. The compiler calls `EnterFrame` when +// it has allocated and zeroed stack space in the function prologue. And it calls `LeaveFrame` in +// the function epilogue (both for regular return and for exception unwinding). +// +// Stack scanning does not lock anything and so must either be done while the mutator is stopped (or is +// running code outside Kotlin), or by the mutator itself. So, in concurrent collection case, make sure +// to do as little as possible while scanning the stack to free the mutator as soon as possible. +// +// TODO: This is currently incompatible with stack-allocated objects. Fix it. +class ShadowStack : private Pinned { +public: + class Iterator { + public: + explicit Iterator(FrameOverlay* frame) noexcept : frame_(frame), object_(begin()), end_(end()) { Init(); } + + ObjHeader*& operator*() noexcept { return *object_; } + Iterator& operator++() noexcept; + + bool operator==(const Iterator& rhs) const noexcept { return frame_ == rhs.frame_ && object_ == rhs.object_; } + bool operator!=(const Iterator& rhs) const noexcept { return !(*this == rhs); } + + private: + void Init() noexcept; + + // TODO: This copies the approach in the old MM. Do we need to also traverse function parameters in the new MM? + ObjHeader** begin() noexcept { return frame_ ? reinterpret_cast(frame_ + 1) + frame_->parameters : nullptr; } + ObjHeader** end() noexcept { + constexpr int kFrameOverlaySlots = sizeof(FrameOverlay) / sizeof(ObjHeader**); + return frame_ ? begin() + frame_->count - kFrameOverlaySlots - frame_->parameters : nullptr; + } + + FrameOverlay* frame_; + ObjHeader** object_ = nullptr; + ObjHeader** end_ = nullptr; + }; + + void EnterFrame(ObjHeader** start, int parameters, int count) noexcept; + void LeaveFrame(ObjHeader** start, int parameters, int count) noexcept; + + Iterator begin() noexcept { return Iterator(currentFrame_); } + Iterator end() noexcept { return Iterator(nullptr); } + +private: + FrameOverlay* currentFrame_ = nullptr; +}; + +} // namespace mm +} // namespace kotlin + +#endif // RUNTIME_MM_SHADOW_STACK diff --git a/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp b/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp new file mode 100644 index 00000000000..771961e533e --- /dev/null +++ b/kotlin-native/runtime/src/mm/cpp/ShadowStackTest.cpp @@ -0,0 +1,121 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +#include "ShadowStack.hpp" + +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +#include "Memory.h" +#include "Types.h" +#include "Utils.hpp" + +using namespace kotlin; + +namespace { + +template +class StackEntry : private Pinned { +public: + static_assert(ParametersCount + LocalsCount > 0, "Must have at least 1 object on stack"); + + explicit StackEntry(mm::ShadowStack& shadowStack) : shadowStack_(shadowStack), value_(make_unique()) { + // Fill `locals_` with some values. + for (size_t i = 0; i < LocalsCount; ++i) { + (*this)[i] = value_.get() + i; + } + + shadowStack_.EnterFrame(data_.data(), ParametersCount, kTotalCount); + } + + ~StackEntry() { shadowStack_.LeaveFrame(data_.data(), ParametersCount, kTotalCount); } + + ObjHeader*& operator[](size_t index) { return data_[kFrameOverlayCount + ParametersCount + index]; } + +private: + mm::ShadowStack& shadowStack_; + KStdUniquePtr value_; + + // The following is what the compiler creates on the stack. + static inline constexpr int kFrameOverlayCount = sizeof(FrameOverlay) / sizeof(ObjHeader**); + static inline constexpr int kTotalCount = kFrameOverlayCount + ParametersCount + LocalsCount; + std::array data_; +}; + +KStdVector Collect(mm::ShadowStack& shadowStack) { + KStdVector result; + for (ObjHeader* local : shadowStack) { + result.push_back(local); + } + return result; +} + +} // namespace + +TEST(ShadowStackTest, Empty) { + mm::ShadowStack shadowStack; + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::IsEmpty()); +} + +TEST(ShadowStackTest, OneLocal) { + mm::ShadowStack shadowStack; + StackEntry<0, 1> frame1(shadowStack); + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::ElementsAre(frame1[0])); +} + +TEST(ShadowStackTest, ThreeLocals) { + mm::ShadowStack shadowStack; + StackEntry<0, 3> frame1(shadowStack); + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::ElementsAre(frame1[0], frame1[1], frame1[2])); +} + +TEST(ShadowStackTest, OneParameter) { + mm::ShadowStack shadowStack; + StackEntry<1, 0> frame1(shadowStack); + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::IsEmpty()); +} + +TEST(ShadowStackTest, ThreeLocalsAndOneParameter) { + mm::ShadowStack shadowStack; + StackEntry<1, 3> frame1(shadowStack); + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::ElementsAre(frame1[0], frame1[1], frame1[2])); +} + +TEST(ShadowStackTest, TwoStackFrames) { + mm::ShadowStack shadowStack; + StackEntry<1, 3> frame1(shadowStack); + StackEntry<1, 3> frame2(shadowStack); + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::ElementsAre(frame2[0], frame2[1], frame2[2], frame1[0], frame1[1], frame1[2])); +} + +TEST(ShadowStackTest, ManyStackFrames) { + mm::ShadowStack shadowStack; + StackEntry<0, 3> frame1(shadowStack); + StackEntry<1, 0> frame2(shadowStack); + StackEntry<3, 1> frame3(shadowStack); + StackEntry<3, 3> frame4(shadowStack); + + auto actual = Collect(shadowStack); + + EXPECT_THAT(actual, testing::ElementsAre(frame4[0], frame4[1], frame4[2], frame3[0], frame1[0], frame1[1], frame1[2])); +} diff --git a/kotlin-native/runtime/src/mm/cpp/Stubs.cpp b/kotlin-native/runtime/src/mm/cpp/Stubs.cpp index 869760b745a..549636cc3dd 100644 --- a/kotlin-native/runtime/src/mm/cpp/Stubs.cpp +++ b/kotlin-native/runtime/src/mm/cpp/Stubs.cpp @@ -70,14 +70,6 @@ RUNTIME_NOTHROW OBJ_GETTER(ReadHeapRefLocked, ObjHeader** location, int32_t* spi TODO(); } -RUNTIME_NOTHROW void EnterFrame(ObjHeader** start, int parameters, int count) { - TODO(); -} - -RUNTIME_NOTHROW void LeaveFrame(ObjHeader** start, int parameters, int count) { - TODO(); -} - void MutationCheck(ObjHeader* obj) { TODO(); } diff --git a/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp b/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp index 5e09933297f..07292b26237 100644 --- a/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp +++ b/kotlin-native/runtime/src/mm/cpp/ThreadData.hpp @@ -11,6 +11,7 @@ #include "ObjectFactory.hpp" #include "GlobalsRegistry.hpp" +#include "ShadowStack.hpp" #include "StableRefRegistry.hpp" #include "ThreadLocalStorage.hpp" #include "Utils.hpp" @@ -46,6 +47,8 @@ public: ObjectFactory::ThreadQueue& objectFactoryThreadQueue() noexcept { return objectFactoryThreadQueue_; } + ShadowStack& shadowStack() noexcept { return shadowStack_; } + private: const pthread_t threadId_; GlobalsRegistry::ThreadQueue globalsThreadQueue_; @@ -53,6 +56,7 @@ private: StableRefRegistry::ThreadQueue stableRefThreadQueue_; std::atomic state_; ObjectFactory::ThreadQueue objectFactoryThreadQueue_; + ShadowStack shadowStack_; }; } // namespace mm From 9e62134ea052fd11ab15ccc476bf802b1d87ec29 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Fri, 22 Jan 2021 13:56:39 +0300 Subject: [PATCH 119/122] 1.4.30-RC changelog --- kotlin-native/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kotlin-native/CHANGELOG.md b/kotlin-native/CHANGELOG.md index c73d219d7b8..77a281379e3 100644 --- a/kotlin-native/CHANGELOG.md +++ b/kotlin-native/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.4.30-RC (Jan 2021) + * [KT-44271](https://youtrack.jetbrains.com/issue/KT-44271) Incorrect linking when targeting linux_x64 from mingw_x64 host + * [KT-44219](https://youtrack.jetbrains.com/issue/KT-44219) Non-reified type parameters with recursive bounds are not supported yet + * [KT-43599](https://youtrack.jetbrains.com/issue/KT-43599) K/N: Unbound symbols not allowed + * [KT-42172](https://youtrack.jetbrains.com/issue/KT-42172) Kotlin/Native: StableRef.dispose race condition on Kotlin deinitRuntime + * [KT-42482](https://youtrack.jetbrains.com/issue/KT-42482) Kotlin subclasses of Obj-C classes are incompatible with ISA swizzling (it causes crashes) + # 1.4.30-M1 (Dec 2020) * [KT-43597](https://youtrack.jetbrains.com/issue/KT-43597) Xcode 12.2 support * [KT-43276](https://youtrack.jetbrains.com/issue/KT-43276) Add watchos_x64 target From d633b1c545d055fc2252f7981ac016226922c0d2 Mon Sep 17 00:00:00 2001 From: Alexander Shabalin Date: Fri, 22 Jan 2021 16:35:45 +0300 Subject: [PATCH 120/122] Mark safe points in code generator (#4640) --- .../kotlin/backend/konan/llvm/CodeGenerator.kt | 6 ++++++ .../kotlin/backend/konan/llvm/ContextUtils.kt | 4 ++++ .../kotlin/backend/konan/llvm/IrToBitcode.kt | 8 ++++++-- kotlin-native/runtime/src/legacymm/cpp/Memory.cpp | 12 ++++++++++++ .../runtime/src/main/cpp/CompilerExport.cpp | 3 +++ kotlin-native/runtime/src/main/cpp/Memory.h | 5 +++++ kotlin-native/runtime/src/mm/cpp/Stubs.cpp | 12 ++++++++++++ 7 files changed, 48 insertions(+), 2 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt index 932fbbe8866..40ff28394a7 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/CodeGenerator.kt @@ -1251,6 +1251,8 @@ internal class FunctionGenerationContext(val function: LLVMValueRef, returnType == voidType -> { releaseVars() assert(returnSlot == null) + if (context.memoryModel == MemoryModel.EXPERIMENTAL) + call(context.llvm.Kotlin_mm_safePointFunctionEpilogue, emptyList()) LLVMBuildRetVoid(builder) } returns.isNotEmpty() -> { @@ -1260,6 +1262,8 @@ internal class FunctionGenerationContext(val function: LLVMValueRef, updateReturnRef(returnPhi, returnSlot!!) } releaseVars() + if (context.memoryModel == MemoryModel.EXPERIMENTAL) + call(context.llvm.Kotlin_mm_safePointFunctionEpilogue, emptyList()) LLVMBuildRet(builder, returnPhi) } // Do nothing, all paths throw. @@ -1300,6 +1304,8 @@ internal class FunctionGenerationContext(val function: LLVMValueRef, } releaseVars() + if (context.memoryModel == MemoryModel.EXPERIMENTAL) + call(context.llvm.Kotlin_mm_safePointExceptionUnwind, emptyList()) LLVMBuildResume(builder, landingpad) } diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt index 42fe7820d25..680ba5e927b 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/ContextUtils.kt @@ -546,6 +546,10 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) { val Kotlin_ObjCExport_createContinuationArgument by lazyRtFunction val Kotlin_ObjCExport_resumeContinuation by lazyRtFunction + val Kotlin_mm_safePointFunctionEpilogue by lazyRtFunction + val Kotlin_mm_safePointWhileLoopBody by lazyRtFunction + val Kotlin_mm_safePointExceptionUnwind by lazyRtFunction + val tlsMode by lazy { when (target) { KonanTarget.WASM32, diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt index d4cd2c4626c..5c032c67613 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt @@ -534,9 +534,9 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map Date: Fri, 22 Jan 2021 16:46:03 +0300 Subject: [PATCH 121/122] Trust mimalloc to be thread safe (#4649) --- .../org/jetbrains/kotlin/testing/native/NativeTest.kt | 8 ++++++++ kotlin-native/runtime/tsan_suppressions.txt | 3 +++ 2 files changed, 11 insertions(+) create mode 100644 kotlin-native/runtime/tsan_suppressions.txt diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt index 97ae40ed586..3c0a4c1c376 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/testing/native/NativeTest.kt @@ -272,6 +272,14 @@ private fun createTestTask( val xmlReport = workingDir.resolve("report.xml") executable(linkTask.outputFile) args("--gtest_output=xml:${xmlReport.absoluteFile}") + when (sanitizer) { + SanitizerKind.THREAD -> { + val file = project.file("tsan_suppressions.txt") + inputs.file(file) + environment("TSAN_OPTIONS", "suppressions=${file.absolutePath}") + } + else -> {} // no action required + } doFirst { workingDir.mkdirs() diff --git a/kotlin-native/runtime/tsan_suppressions.txt b/kotlin-native/runtime/tsan_suppressions.txt new file mode 100644 index 00000000000..7805285b034 --- /dev/null +++ b/kotlin-native/runtime/tsan_suppressions.txt @@ -0,0 +1,3 @@ +# Trust mimalloc to be thread safe. +race:^mi_ +race:^_mi_ From e9501e82ccf4fff1020f551fa1feda4b7427f098 Mon Sep 17 00:00:00 2001 From: Vasily Levchenko Date: Mon, 25 Jan 2021 08:28:31 +0100 Subject: [PATCH 122/122] [kotlin compiler][update] 1.5.0-dev-1963 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 293f2f99503 - (HEAD -> master, tag: build-1.5.0-dev-1963, origin/push/nk/all, origin/master, origin/HEAD) Build: Replace Bintray with Space for kotlin-dependencies repository (KTI-466) (vor 20 Stunden) * eed0f50c5d0 - (tag: build-1.5.0-dev-1955) Code cleanup: ConeAttributes (vor 2 Tagen) * 94e613dd01d - FIR: support custom annotation-based type attributes (vor 2 Tagen) * 4cd6266bce8 - FIR: fix suspend type serialization (vor 2 Tagen) * afe335e5041 - FIR: serialize ExtensionFunctionType attribute (vor 2 Tagen) * 9e5c9efadf3 - FIR2IR: don't generate IrGetObject for anonymous objects (vor 2 Tagen) * 06ee768c6ad - FIR: in case of smart cast, use original type for FirThisRcvrExpression (vor 2 Tagen) * 4fd4f504d0d - FIR: make componentX functions operator (vor 3 Tagen) * 7934853c8ef - Set ABI stability to JVM modules which are built with FIR (vor 3 Tagen) * 4a76ea6ecb0 - (tag: build-1.5.0-dev-1927) JVM: regenerate objects if they have been regenerated in parent contexts (vor 3 Tagen) * ef36b81c676 - (tag: build-1.5.0-dev-1924) [JVM_IR] Reduce the amount of `super` suffixes on accesibility bridges. (vor 3 Tagen) * a33877a9b97 - (tag: build-1.5.0-dev-1914) Fix add import quick fix for unresolved conventional invoke operator (vor 3 Tagen) * d2ce73853da - Report more specific diagnostic for variable + invoke calls (vor 3 Tagen) * c4237509621 - (tag: build-1.5.0-dev-1913) [TD] Fix incorrect module structure directives in test data file (vor 3 Tagen) * 0d058c7c8ce - [Test] Allow parse FILE and MODULE directives with other strings between them in old tests (vor 3 Tagen) * b9e9620ab59 - [TD] Unmute passing Fir2Ir text test (vor 3 Tagen) * 842ed624a7b - [TD] Remove some outdated dumps in FIR_IDENTICAL tests (vor 3 Tagen) * 77115cea92b - [TD] Union ir dumps of different test files (vor 3 Tagen) * 4752924b131 - [TD] Update FQN's in testdata of IR text tests (vor 3 Tagen) * 8286a160bdb - [TD] Update order of directives (vor 3 Tagen) * bdcb8aecab1 - [Test] Migrate AbstractFir2IrTextTest to new infrastructure (vor 3 Tagen) * aba029237dd - [Test] Add handler for comparing pretty kt ir dumps (vor 3 Tagen) * 87ffbd82063 - [IR] Collect all dependencies of module recursively (vor 3 Tagen) * aaa3fa58452 - [Test] Migrate IrTextTestGenerated to new infrastructure (vor 3 Tagen) * 5ae5f660f66 - [Test] Add ability to explicitly declare default binary kind for test (vor 3 Tagen) * a2ae6181858 - [Test] Introduce IGNORE_ERRORS diagnostic to suppressing backend errors (vor 3 Tagen) * acb6d2e1966 - [Test] Allow facades to return null which indicates that facade can't complete it's job (vor 3 Tagen) * 6a7cd0c8114 - [Test] Add ability to specify applicability of diagnostic to module or file (vor 3 Tagen) * 28cff22cd02 - [Test] Add ability to specify directive for test file (vor 3 Tagen) * e17153fab93 - (tag: build-1896, tag: build-1.5.0-dev-1901) Minor, improve Ant test on includeRuntime (vor 4 Tagen) * a13eb4c8e62 - Ant task: do not include runtime by default if destination is a jar (vor 4 Tagen) * b0b7f39c75e - (tag: build-1893) FIR: Do not use return statement for type of a block expression (vor 4 Tagen) * 4dc2653736e - FIR: Do not complete finally parts of try-finally (vor 4 Tagen) * 7df4f67f7cf - FIR: Minor. Drop unused parameter (vor 4 Tagen) * 9493e685843 - FIR: Do not run completion for lambda's explicit return too early (vor 4 Tagen) * 5afebb4e789 - FIR: Transform synthetic calls children even without incomplete candidate (vor 4 Tagen) * 5f0d00a83f9 - FIR: Use proper tower data contexts for postponed callable references (vor 4 Tagen) * ad30c6c3802 - FIR: Fix callable references resolution when they're being returned from lambdas (vor 4 Tagen) * 0e368cc2372 - FIR: Analyze return statements for implicit lambda with independent context (vor 4 Tagen) * 5e83e10a72d - FIR: Add callable references nodes to CFG (vor 4 Tagen) * 6dc0440cd00 - (tag: build-1.5.0-dev-1889) Remove commented code in previous commit (vor 4 Tagen) * 71e74497b55 - (tag: build-1.5.0-dev-1888) Use `addTestJdk`&`removeTestJdk` methods instead `addJdk`&`removeJdk` (vor 4 Tagen) * 20843b68947 - (tag: build-1.5.0-dev-1887) Remove error suppression in KotlinChangeSignatureDialog (vor 4 Tagen) * 628d6a9c30a - (tag: build-1.5.0-dev-1880) Don't store logger in instance field (vor 4 Tagen) * 5003738d29c - Fix: use idea caches correctly (vor 4 Tagen) * 87c6b6bffce - (tag: build-1.5.0-dev-1878) Revert "Set canBeConsumed = false on the deprecated configurations like compile" (vor 4 Tagen) * 2e660ef62aa - (tag: build-1.5.0-dev-1875) Raw FIR: use lambda parameter type if available (vor 4 Tagen) * fa0b933bc81 - FIR checker: add diagnostics for missing/ambiguous component calls (vor 4 Tagen) * 83b9c29495b - FIR checker: relocate sealed class ctor call checker (vor 4 Tagen) * 5f0eb8a4012 - FIR checker: minor cleanups (vor 4 Tagen) * be29b6d64d4 - FIR checker: use aliased checker when possible (part 2) (vor 4 Tagen) * de592f4f676 - FIR checker: introduce FunctionChecker alias (vor 4 Tagen) * 40bec30393d - FIR: implement LT positioning in diagnostic tests, fix LT strategies (vor 4 Tagen) * f1d8a6e5d1c - FIR checker: introduce DECLARATION_SIGNATURE_OR_DEFAULT positioning strategy (vor 4 Tagen) * 2e4daee1d46 - (tag: build-1.5.0-dev-1874) [FIR] Fix invalid diagnostic fir node sites and improved invalid type parameters count diagnostic report (vor 4 Tagen) * b7d3469819a - [FIR] Remove transform/accept from FirResolvedTypeRef.delegateTypeRef (vor 4 Tagen) * 243f85a4d69 - [FIR IDE] Add base support for FIR incomplete types resolve (vor 4 Tagen) * 704366e5312 - (tag: build-1.5.0-dev-1869) JVM: Mark suspend lambda receiver as used if callable reference (vor 4 Tagen) * de00f72fa31 - (tag: build-1.5.0-dev-1863) Generate linenumber for inline call site in case of implicit iterator/hasNext/next calls in for loop (vor 4 Tagen) * dfacccf84fd - (tag: build-1.5.0-dev-1862) Set canBeConsumed = false on the deprecated configurations like compile (vor 4 Tagen) * 6e913e16adb - Add integration tests for Kapt + Android Gradle plugin 7.0 (vor 4 Tagen) * 341b87fad0d - Use `implementation` instead of `compile` in GradleIT, fix versions (vor 4 Tagen) * 17b71555e0d - KT-43944: Don't access Android test source sets' API configurations (vor 4 Tagen) * 77ffc318f2c - (tag: build-1.5.0-dev-1860) KT-44250 [Sealed interfaces]: completion fails for 'when' with sealed (vor 4 Tagen) * 14108011eef - (tag: build-1.5.0-dev-1853) [FIR] Fix inferring arguments of bare types in different situations (vor 4 Tagen) * b99f1a1512c - (tag: build-1.5.0-dev-1847) FIR checker: error messages for function diagnostics (vor 4 Tagen) * 021395ce397 - FIR checker: error message for destructuring declaration diagnostic (vor 4 Tagen) * 35093e0958f - FIR checker: error messages for properties/accessors diagnostics (vor 4 Tagen) * 952576e98f4 - (tag: build-1.5.0-dev-1837) JVM_IR: Do not unbox Result parameter if it not only one inline class (vor 5 Tagen) * d48f92775bd - JVM_IR: Do not unbox Result parameter in invoke if there is a bridge (vor 5 Tagen) * 0ddb603eaa4 - (tag: build-1.5.0-dev-1836) [JS IR] Fix of test with method in abstract class calling extension on super type (vor 5 Tagen) * 9c4f8f7e542 - (tag: build-1.5.0-dev-1835) JVM IR: Fix signature mapping for inline classes using new mangling (vor 5 Tagen) * 91717cdcdd3 - (tag: build-1.5.0-dev-1822) Perform inline checks in IR tests (vor 5 Tagen) * 216b775095a - Remove obsolete code (vor 5 Tagen) * 147d60523df - Generate inline function arguments with parameters types (vor 5 Tagen) * 50ab9ed0545 - [JS IR] Add test on interface with default method calling extension method on super-interface (vor 5 Tagen) * 5c28762c02d - (tag: build-1.5.0-dev-1765, tag: build-1.5.0-dev-1760) Fix check for local classes in approximating string table (vor 5 Tagen) * b66f5c81801 - Drop type aliases for JS and KLIB string tables (vor 5 Tagen) * 2f3f75b5120 - Fix local anonymous class name error in K2MetadataCompiler (vor 5 Tagen) * b82a44fa63a - Add test for KT-20996 (vor 5 Tagen) * cce9469e6a0 - (tag: build-1.5.0-dev-1753) JVM_IR: Do not unbox Result parameter in Result methods (vor 5 Tagen) * 10d9259df53 - (tag: build-1.5.0-dev-1738) Returned support for nullable types by not null serializers (vor 6 Tagen) * b476f1cc3e7 - (tag: build-1.5.0-dev-1727) Minor. Change test to use the feature instead of suppressing error (vor 6 Tagen) * d1ee45b5184 - Add language feature for suspend functions in fun interfaces (vor 6 Tagen) * 6aa6f82c47c - (tag: build-1.5.0-dev-1723) Fix MultiplatformModelImportingContextImpl#isOrphanSourceSet predicate (vor 6 Tagen) * cf228bebc3f - (tag: build-1.5.0-dev-1722) Use static year range in copyright of generated FIR and tests (vor 6 Tagen) * ba8223218fa - [Wasm] Add inline property accessors optimization (vor 6 Tagen) * 2aa3c197a30 - [Wasm] Use non-persistent IR to speed up tests (vor 6 Tagen) * 11a3126c8ce - (tag: build-1.5.0-dev-1719) FIR: copy class supertypes list on iterating while calculating supertypes (vor 6 Tagen) * a0ad85e20d3 - (tag: build-1.5.0-dev-1716, origin/rr/4u7/wip) Build: Disable caching of test tasks (vor 6 Tagen) * 284d42fd2b7 - (tag: build-1.5.0-dev-1710) Use camelCase for cacheKind control property (vor 6 Tagen) * 29f95c7df27 - (tag: build-1.5.0-dev-1690) FIR: improve inference of implicit type arguments in casts (vor 7 Tagen) * acdc1f532b9 - (tag: build-1.5.0-dev-1682) Rewrite CommonizerTask params to fix ^KT-42098 (vor 7 Tagen) * 23332bac139 - (tag: build-1.5.0-dev-1665) More precise message for "this test can be unmuted" (vor 7 Tagen) * 6331a135c8c - (tag: build-1.5.0-dev-1662) Add LightClassUtil.getLightClassMethodsByName to avoid resolving all lightClassMethods and filtration later on (vor 7 Tagen) * 167bfcf6eaa - (tag: build-1.5.0-dev-1658) Minor. Remove accidentally added bunch file (vor 7 Tagen) * bf5feb1b4a7 - (tag: build-1.5.0-dev-1657) Remove KotlinMetadataTarget's KotlinTargetComponent in favour of KotlinSoftwareComponent.kt ^KT-44322 fixed (vor 7 Tagen) * 9a5791ad6d8 - (tag: build-1.5.0-dev-1654) FIR: use correct context for enum entry resolve (vor 7 Tagen) * f85fc47383b - FIR: introduce separate companion object resolve context (vor 7 Tagen) * f282c3e5474 - Cleanup: FirTowerResolveTask (vor 7 Tagen) * 9f06c1a500a - FIR cleanup: runResolverForDelegatingConstructor (vor 7 Tagen) * 6cee4e968e6 - [FIR] Don't call componentX for anonymous destructuring entry (vor 7 Tagen) * 795bd26eaf9 - FIR bootstrap: don't use -Werror in useFIR mode (vor 7 Tagen) * 3787018e40b - [FIR] Fix parameter index storage in contract serializer (vor 7 Tagen) * 12caf5d7435 - Fix test BE JvmBoxRunner to be able to see FIR BB tests exceptions (vor 7 Tagen) --- kotlin-native/gradle.properties | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kotlin-native/gradle.properties b/kotlin-native/gradle.properties index 11c8059ed08..1016992cd84 100644 --- a/kotlin-native/gradle.properties +++ b/kotlin-native/gradle.properties @@ -18,12 +18,12 @@ buildKotlinVersion=1.4.20-dev-2167 buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.4.20-dev-2167,branch:default:any,pinned:true/artifacts/content/maven remoteRoot=konan_tests -kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.0-dev-1616,branch:default:any,pinned:true/artifacts/content/maven -kotlinVersion=1.5.0-dev-1616 -kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.0-dev-1616,branch:default:any,pinned:true/artifacts/content/maven -kotlinStdlibVersion=1.5.0-dev-1616 -kotlinStdlibTestsVersion=1.5.0-dev-1616 -testKotlinCompilerVersion=1.5.0-dev-1616 +kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.0-dev-1963,branch:default:any,pinned:true/artifacts/content/maven +kotlinVersion=1.5.0-dev-1963 +kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.5.0-dev-1963,branch:default:any,pinned:true/artifacts/content/maven +kotlinStdlibVersion=1.5.0-dev-1963 +kotlinStdlibTestsVersion=1.5.0-dev-1963 +testKotlinCompilerVersion=1.5.0-dev-1963 konanVersion=1.5.0 # A version of Xcode required to build the Kotlin/Native compiler.