From 9d4d55b3ced8e30c80a67ea40a3b5a0e21ca4d93 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 18 Apr 2022 11:13:26 +0400 Subject: [PATCH] [LL API] Extract expect actual matching into separate phase --- ...esignatedExpectActualMatcherTransformer.kt | 69 +++++++++++++++++++ .../transformers/LazyTransformerFactory.kt | 7 +- .../lazyResolve/annotationParameters.txt | 36 ++++++++++ .../testdata/lazyResolve/annotations.txt | 6 ++ .../testdata/lazyResolve/classMembers.txt | 20 ++++++ .../testdata/lazyResolve/delegates.txt | 34 +++++++++ .../lazyResolve/functionWithParameter.txt | 8 +++ .../lazyResolve/parameterOfNonLocalSetter.txt | 15 ++++ .../lazyResolve/propertyWithGetter.txt | 9 +++ .../propertyWithGetterAndSetter.txt | 11 +++ .../lazyResolve/propertyWithInitializer.txt | 8 +++ .../lazyResolve/secondaryConstructor.txt | 14 ++++ .../testdata/lazyResolve/superTypes.txt | 21 ++++++ .../testdata/lazyResolve/superTypesLoop.txt | 27 ++++++++ .../lazyResolve/topLevelFunctions.txt | 8 +++ ...tionsWithExpressionBodyAndExplicitType.txt | 8 +++ .../topLevelFunctionsWithImplicitType.txt | 8 +++ .../typeParameterOfNonLocalFunction.txt | 12 ++++ .../typeParameterOfTopFunction.txt | 5 ++ .../lazyResolve/typeParameterOfTopSetter.txt | 8 +++ .../mpp/FirExpectActualMatcherTransformer.kt | 3 +- 21 files changed, 334 insertions(+), 3 deletions(-) create mode 100644 analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirDesignatedExpectActualMatcherTransformer.kt diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirDesignatedExpectActualMatcherTransformer.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirDesignatedExpectActualMatcherTransformer.kt new file mode 100644 index 00000000000..01be1d9ae65 --- /dev/null +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirDesignatedExpectActualMatcherTransformer.kt @@ -0,0 +1,69 @@ +/* + * Copyright 2010-2022 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.analysis.low.level.api.fir.transformers + +import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirPhaseRunner +import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDeclarationDesignationWithFile +import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.FirLazyBodiesCalculator +import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.ResolveTreeBuilder +import org.jetbrains.kotlin.analysis.low.level.api.fir.transformers.LLFirLazyTransformer.Companion.updatePhaseDeep +import org.jetbrains.kotlin.analysis.low.level.api.fir.util.ensurePhase +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.expressions.FirStatement +import org.jetbrains.kotlin.fir.resolve.ScopeSession +import org.jetbrains.kotlin.fir.resolve.transformers.mpp.FirExpectActualMatcherTransformer + +internal class LLFirDesignatedExpectActualMatcherTransformer( + private val designation: FirDeclarationDesignationWithFile, + session: FirSession, + scopeSession: ScopeSession, +) : LLFirLazyTransformer, FirExpectActualMatcherTransformer(session, scopeSession) { + + private val declarationTransformer = LLFirDeclarationTransformer(designation) + + override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): FirStatement { + return declarationTransformer.transformDeclarationContent(this, regularClass, data) { + super.transformRegularClass(regularClass, data) as FirDeclaration + } as FirStatement + } + + override fun transformFile(file: FirFile, data: Nothing?): FirFile { + return declarationTransformer.transformDeclarationContent(this, file, data) { + super.transformFile(file, data) + } as FirFile + } + + override fun transformDeclaration(phaseRunner: LLFirPhaseRunner) { + if (designation.declaration.resolvePhase >= FirResolvePhase.EXPECT_ACTUAL_MATCHING) return + designation.declaration.ensurePhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) + + FirLazyBodiesCalculator.calculateLazyBodiesInside(designation) + ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.EXPECT_ACTUAL_MATCHING) { + phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.EXPECT_ACTUAL_MATCHING) { + designation.firFile.transform(this, null) + } + } + + declarationTransformer.ensureDesignationPassed() + updatePhaseDeep(designation.declaration, FirResolvePhase.EXPECT_ACTUAL_MATCHING) + ensureResolved(designation.declaration) + ensureResolvedDeep(designation.declaration) + } + + override fun ensureResolved(declaration: FirDeclaration) { + when (declaration) { + is FirSimpleFunction, is FirConstructor, is FirAnonymousInitializer -> + declaration.ensurePhase(FirResolvePhase.EXPECT_ACTUAL_MATCHING) + is FirProperty -> { + declaration.ensurePhase(FirResolvePhase.EXPECT_ACTUAL_MATCHING) + } + is FirClass, is FirTypeAlias, is FirEnumEntry, is FirField -> Unit + else -> error("Unexpected type: ${declaration::class.simpleName}") + } + } +} + diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LazyTransformerFactory.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LazyTransformerFactory.kt index 763ee5db28a..026a5f2884c 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LazyTransformerFactory.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LazyTransformerFactory.kt @@ -75,6 +75,11 @@ internal object LazyTransformerFactory { towerDataContextCollector, firProviderInterceptor, ) + FirResolvePhase.EXPECT_ACTUAL_MATCHING -> LLFirDesignatedExpectActualMatcherTransformer( + designation, + designation.firFile.moduleData.session, + scopeSession + ) else -> error("Non-lazy phase $phase") } -} \ No newline at end of file +} diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/annotationParameters.txt b/analysis/low-level-api-fir/testdata/lazyResolve/annotationParameters.txt index 37b04046327..2b42b636c5c 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/annotationParameters.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/annotationParameters.txt @@ -351,6 +351,42 @@ FILE: annotationParameters.kt } +EXPECT_ACTUAL_MATCHING: +FILE: annotationParameters.kt + public final [STATUS] enum class X : R|kotlin/Enum| { + private [STATUS] [ContainingClassKey=X] constructor(): R|X| { + super|>() + } + + public final static [STATUS] [ContainingClassKey=X] enum entry A: R|X| + public final static [BODY_RESOLVE] [ContainingClassKey=X] fun values(): R|kotlin/Array| { + } + + public final static [BODY_RESOLVE] [ContainingClassKey=X] fun valueOf([BODY_RESOLVE] value: R|kotlin/String|): R|X| { + } + + } + public? final? [COMPILER_REQUIRED_ANNOTATIONS] annotation class Anno : R|kotlin/Annotation| { + public? [COMPILER_REQUIRED_ANNOTATIONS] [ContainingClassKey=Anno] constructor([RAW_FIR] [CorrespondingProperty=/Anno.args] args: A.X): R|Anno| { + super() + } + + public? final? [COMPILER_REQUIRED_ANNOTATIONS] [IsFromPrimaryConstructor=true] val args: A.X = R|/args| + [TYPES] [ContainingClassKey=Anno] public? get(): A.X + + } + public final [STATUS] class B : R|kotlin/Any| { + public [STATUS] [ContainingClassKey=B] constructor(): R|B| { + super() + } + + @R|Anno|(Q|X|.R|/X.A|) public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + } + + @R|Anno|(X#.A#) public final [STATUS] fun foo(): R|kotlin/Unit| { LAZY_BLOCK } + + } + BODY_RESOLVE: FILE: annotationParameters.kt public final [STATUS] enum class X : R|kotlin/Enum| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/annotations.txt b/analysis/low-level-api-fir/testdata/lazyResolve/annotations.txt index c321f573ae4..9015a84da75 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/annotations.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/annotations.txt @@ -51,6 +51,12 @@ FILE: annotations.kt @R|kotlin/Suppress|(String(2)) public final [IMPLICIT_TYPES_BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { } +EXPECT_ACTUAL_MATCHING: +FILE: annotations.kt + @FILE:Suppress(String(1)) + @R|kotlin/Suppress|(String(2)) public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + } + BODY_RESOLVE: FILE: annotations.kt @FILE:Suppress(String(1)) diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/classMembers.txt b/analysis/low-level-api-fir/testdata/lazyResolve/classMembers.txt index 9c1b335f0d4..7c984cc244e 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/classMembers.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/classMembers.txt @@ -183,6 +183,26 @@ FILE: classMembers.kt } +EXPECT_ACTUAL_MATCHING: +FILE: classMembers.kt + public final [STATUS] class A : R|kotlin/Any| { + public [STATUS] [ContainingClassKey=A] constructor(): R|A| { + super() + } + + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(functionWithLazyBody#()) + } + + public final [STATUS] val x: R|kotlin/Int| = LAZY_EXPRESSION + [STATUS] [ContainingClassKey=A] public get(): R|kotlin/Int| { LAZY_BLOCK } + + public final [STATUS] fun receive([RAW_FIR] value: R|kotlin/String|): R|kotlin/Unit| { LAZY_BLOCK } + + public final [STATUS] fun functionWithLazyBody(): R|kotlin/String| { LAZY_BLOCK } + + } + BODY_RESOLVE: FILE: classMembers.kt public final [STATUS] class A : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/delegates.txt b/analysis/low-level-api-fir/testdata/lazyResolve/delegates.txt index 440e678af9b..aadff41cb90 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/delegates.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/delegates.txt @@ -299,6 +299,40 @@ FILE: delegates.kt D|/variableWithImplicitType|.setValue#(Null(null), ::R|/variableWithImplicitType|, R|/variableWithImplicitType|) } +EXPECT_ACTUAL_MATCHING: +FILE: delegates.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(valueWithExplicitType#) + receive#(valueWithImplicitType#) + variableWithExplicitType# = IntegerLiteral(10) + variableWithImplicitType# = IntegerLiteral(10) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: Int): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] val delegate: = LAZY_EXPRESSION + [TYPES] public? get(): + public? final? [RAW_FIR] val valueWithExplicitType: Intby LAZY_EXPRESSION + [RAW_FIR] public? get(): { + ^ D|/valueWithExplicitType|.getValue#(Null(null), ::R|/valueWithExplicitType|) + } + public? final? [RAW_FIR] val valueWithImplicitType: by LAZY_EXPRESSION + [RAW_FIR] public? get(): { + ^ D|/valueWithImplicitType|.getValue#(Null(null), ::R|/valueWithImplicitType|) + } + public? final? [RAW_FIR] var variableWithExplicitType: Intby LAZY_EXPRESSION + [RAW_FIR] public? get(): { + ^ D|/variableWithExplicitType|.getValue#(Null(null), ::R|/variableWithExplicitType|) + } + [RAW_FIR] public? set([RAW_FIR] : ): R|kotlin/Unit| { + D|/variableWithExplicitType|.setValue#(Null(null), ::R|/variableWithExplicitType|, R|/variableWithExplicitType|) + } + public? final? [RAW_FIR] var variableWithImplicitType: by LAZY_EXPRESSION + [RAW_FIR] public? get(): { + ^ D|/variableWithImplicitType|.getValue#(Null(null), ::R|/variableWithImplicitType|) + } + [RAW_FIR] public? set([RAW_FIR] : ): R|kotlin/Unit| { + D|/variableWithImplicitType|.setValue#(Null(null), ::R|/variableWithImplicitType|, R|/variableWithImplicitType|) + } + BODY_RESOLVE: FILE: delegates.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/functionWithParameter.txt b/analysis/low-level-api-fir/testdata/lazyResolve/functionWithParameter.txt index 4e67f8321ca..cb3dbc573f3 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/functionWithParameter.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/functionWithParameter.txt @@ -63,6 +63,14 @@ FILE: functionWithParameter.kt ^resolveMe Q|kotlin/Unit| } +EXPECT_ACTUAL_MATCHING: +FILE: functionWithParameter.kt + public? final? [COMPILER_REQUIRED_ANNOTATIONS] interface I : R|kotlin/Any| { + } + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe([RAW_FIR] param: R|I|): R|kotlin/Unit| { + ^resolveMe Q|kotlin/Unit| + } + BODY_RESOLVE: FILE: functionWithParameter.kt public? final? [COMPILER_REQUIRED_ANNOTATIONS] interface I : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/parameterOfNonLocalSetter.txt b/analysis/low-level-api-fir/testdata/lazyResolve/parameterOfNonLocalSetter.txt index da744753757..9ac3afc80e8 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/parameterOfNonLocalSetter.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/parameterOfNonLocalSetter.txt @@ -133,6 +133,21 @@ FILE: parameterOfNonLocalSetter.kt } +EXPECT_ACTUAL_MATCHING: +FILE: parameterOfNonLocalSetter.kt + public final [STATUS] class X : R|kotlin/Any| { + public [STATUS] [ContainingClassKey=X] constructor(): R|X| { + super() + } + + public final [EXPECT_ACTUAL_MATCHING] var x: R|kotlin/Int| = IntegerLiteral(2) + [BODY_RESOLVE] [ContainingClassKey=X] public get(): R|kotlin/Int| + [EXPECT_ACTUAL_MATCHING] [ContainingClassKey=X] public set([RAW_FIR] resolveMe: R|kotlin/Int|): R|kotlin/Unit| { + ^ Unit# + } + + } + BODY_RESOLVE: FILE: parameterOfNonLocalSetter.kt public final [STATUS] class X : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetter.txt b/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetter.txt index 22ab33ea789..7f06dd133c4 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetter.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetter.txt @@ -73,6 +73,15 @@ FILE: propertyWithGetter.kt public? final? [RAW_FIR] val withGetter: Int [RAW_FIR] public? get(): Int { LAZY_BLOCK } +EXPECT_ACTUAL_MATCHING: +FILE: propertyWithGetter.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(withGetter#) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: Int): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] val withGetter: Int + [RAW_FIR] public? get(): Int { LAZY_BLOCK } + BODY_RESOLVE: FILE: propertyWithGetter.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetterAndSetter.txt b/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetterAndSetter.txt index 06680c13261..172634c0914 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetterAndSetter.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithGetterAndSetter.txt @@ -85,6 +85,17 @@ FILE: propertyWithGetterAndSetter.kt [RAW_FIR] public? get(): Int { LAZY_BLOCK } [RAW_FIR] public? set([RAW_FIR] value: Int): R|kotlin/Unit| { LAZY_BLOCK } +EXPECT_ACTUAL_MATCHING: +FILE: propertyWithGetterAndSetter.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(withGetterAndSetter#) + withGetterAndSetter# = IntegerLiteral(123) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: Int): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] var withGetterAndSetter: Int = LAZY_EXPRESSION + [RAW_FIR] public? get(): Int { LAZY_BLOCK } + [RAW_FIR] public? set([RAW_FIR] value: Int): R|kotlin/Unit| { LAZY_BLOCK } + BODY_RESOLVE: FILE: propertyWithGetterAndSetter.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithInitializer.txt b/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithInitializer.txt index 412c452f4d7..5c6bbcd0a6a 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithInitializer.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/propertyWithInitializer.txt @@ -63,6 +63,14 @@ FILE: propertyWithInitializer.kt public? final? [RAW_FIR] val property: Int = LAZY_EXPRESSION [TYPES] public? get(): Int +EXPECT_ACTUAL_MATCHING: +FILE: propertyWithInitializer.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(property#) + } + public? final? [RAW_FIR] val property: Int = LAZY_EXPRESSION + [TYPES] public? get(): Int + BODY_RESOLVE: FILE: propertyWithInitializer.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/secondaryConstructor.txt b/analysis/low-level-api-fir/testdata/lazyResolve/secondaryConstructor.txt index 116e5b818db..9698084f408 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/secondaryConstructor.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/secondaryConstructor.txt @@ -123,6 +123,20 @@ FILE: secondaryConstructor.kt } +EXPECT_ACTUAL_MATCHING: +FILE: secondaryConstructor.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(A#(IntegerLiteral(42))) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: A): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] class A : R|kotlin/Any| { + public? [RAW_FIR] [ContainingClassKey=A] constructor([RAW_FIR] x: Int): R|A| { + super() + [RAW_FIR] lval a: = x# + } + + } + BODY_RESOLVE: FILE: secondaryConstructor.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/superTypes.txt b/analysis/low-level-api-fir/testdata/lazyResolve/superTypes.txt index 253b00fc136..a05e71dd1d0 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/superTypes.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/superTypes.txt @@ -209,6 +209,27 @@ FILE: superTypes.kt } +EXPECT_ACTUAL_MATCHING: +FILE: superTypes.kt + public open [TYPES] class A : R|kotlin/Any| { + public [TYPES] [ContainingClassKey=A] constructor(): R|A| { + super() + } + + } + public? open [RAW_FIR] class B : A { + public? [RAW_FIR] [ContainingClassKey=B] constructor(): R|B| { + super() + } + + } + public open [EXPECT_ACTUAL_MATCHING] class resolveMe : R|A| { + public [EXPECT_ACTUAL_MATCHING] [ContainingClassKey=resolveMe] constructor(): R|resolveMe| { + super() + } + + } + BODY_RESOLVE: FILE: superTypes.kt public open [STATUS] class A : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/superTypesLoop.txt b/analysis/low-level-api-fir/testdata/lazyResolve/superTypesLoop.txt index 0223cae6bd8..c6f663b0afd 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/superTypesLoop.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/superTypesLoop.txt @@ -269,6 +269,33 @@ FILE: superTypesLoop.kt } +EXPECT_ACTUAL_MATCHING: +FILE: superTypesLoop.kt + public open [EXPECT_ACTUAL_MATCHING] class resolveMe : R|C| { + public [EXPECT_ACTUAL_MATCHING] [ContainingClassKey=resolveMe] constructor(): R|resolveMe| { + super() + } + + } + public? open [COMPILER_REQUIRED_ANNOTATIONS] class A : /B> { + public? [COMPILER_REQUIRED_ANNOTATIONS] [ContainingClassKey=A] constructor(): R|A| { + super() + } + + } + public? open [COMPILER_REQUIRED_ANNOTATIONS] class B : /C> { + public? [COMPILER_REQUIRED_ANNOTATIONS] [ContainingClassKey=B] constructor(): R|B| { + super() + } + + } + public open [TYPES] class C : /A> { + public [TYPES] [ContainingClassKey=C] constructor(): R|C| { + super() + } + + } + BODY_RESOLVE: FILE: superTypesLoop.kt public open [BODY_RESOLVE] class resolveMe : R|C| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctions.txt b/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctions.txt index 461719320fe..8df0be6154f 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctions.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctions.txt @@ -63,6 +63,14 @@ FILE: topLevelFunctions.kt public? final? [RAW_FIR] fun receive([RAW_FIR] value: String): R|kotlin/Unit| { LAZY_BLOCK } public? final? [RAW_FIR] fun functionWithLazyBody(): String { LAZY_BLOCK } +EXPECT_ACTUAL_MATCHING: +FILE: topLevelFunctions.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(functionWithLazyBody#()) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: String): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] fun functionWithLazyBody(): String { LAZY_BLOCK } + BODY_RESOLVE: FILE: topLevelFunctions.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt b/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt index cf51e962e91..5a14f4f8387 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithExpressionBodyAndExplicitType.txt @@ -63,6 +63,14 @@ FILE: topLevelFunctionsWithExpressionBodyAndExplicitType.kt public? final? [RAW_FIR] fun receive([RAW_FIR] value: String): R|kotlin/Unit| { LAZY_BLOCK } public? final? [RAW_FIR] fun functionWithLazyBody(): String { LAZY_BLOCK } +EXPECT_ACTUAL_MATCHING: +FILE: topLevelFunctionsWithExpressionBodyAndExplicitType.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(functionWithLazyBody#()) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: String): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] fun functionWithLazyBody(): String { LAZY_BLOCK } + BODY_RESOLVE: FILE: topLevelFunctionsWithExpressionBodyAndExplicitType.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt b/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt index 2480f8ad7b5..5aedc853076 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/topLevelFunctionsWithImplicitType.txt @@ -63,6 +63,14 @@ FILE: topLevelFunctionsWithImplicitType.kt public? final? [RAW_FIR] fun receive([RAW_FIR] value: String): R|kotlin/Unit| { LAZY_BLOCK } public? final? [RAW_FIR] fun functionWithLazyBody(): { LAZY_BLOCK } +EXPECT_ACTUAL_MATCHING: +FILE: topLevelFunctionsWithImplicitType.kt + public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| { + receive#(functionWithLazyBody#()) + } + public? final? [RAW_FIR] fun receive([RAW_FIR] value: String): R|kotlin/Unit| { LAZY_BLOCK } + public? final? [RAW_FIR] fun functionWithLazyBody(): { LAZY_BLOCK } + BODY_RESOLVE: FILE: topLevelFunctionsWithImplicitType.kt public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfNonLocalFunction.txt b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfNonLocalFunction.txt index ceb21d72333..bbb8d8f55b7 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfNonLocalFunction.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfNonLocalFunction.txt @@ -111,6 +111,18 @@ FILE: typeParameterOfNonLocalFunction.kt } +EXPECT_ACTUAL_MATCHING: +FILE: typeParameterOfNonLocalFunction.kt + public final [STATUS] class X : R|kotlin/Any| { + public [STATUS] [ContainingClassKey=X] constructor(): R|X| { + super() + } + + public final [EXPECT_ACTUAL_MATCHING] fun ddd(): R|kotlin/Unit| { + } + + } + BODY_RESOLVE: FILE: typeParameterOfNonLocalFunction.kt public final [STATUS] class X : R|kotlin/Any| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopFunction.txt b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopFunction.txt index 36c6b16b6fb..3b70d35322f 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopFunction.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopFunction.txt @@ -41,6 +41,11 @@ FILE: typeParameterOfTopFunction.kt public final [IMPLICIT_TYPES_BODY_RESOLVE] fun ddd(): R|kotlin/Unit| { } +EXPECT_ACTUAL_MATCHING: +FILE: typeParameterOfTopFunction.kt + public final [EXPECT_ACTUAL_MATCHING] fun ddd(): R|kotlin/Unit| { + } + BODY_RESOLVE: FILE: typeParameterOfTopFunction.kt public final [BODY_RESOLVE] fun ddd(): R|kotlin/Unit| { diff --git a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopSetter.txt b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopSetter.txt index eabf784c10f..e4794ca366a 100644 --- a/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopSetter.txt +++ b/analysis/low-level-api-fir/testdata/lazyResolve/typeParameterOfTopSetter.txt @@ -63,6 +63,14 @@ FILE: typeParameterOfTopSetter.kt ^ Unit# } +EXPECT_ACTUAL_MATCHING: +FILE: typeParameterOfTopSetter.kt + public final [EXPECT_ACTUAL_MATCHING] var x: R|kotlin/Int| = IntegerLiteral(2) + [BODY_RESOLVE] public get(): R|kotlin/Int| + [EXPECT_ACTUAL_MATCHING] public set([RAW_FIR] resolveMe: R|kotlin/Int|): R|kotlin/Unit| { + ^ Unit# + } + BODY_RESOLVE: FILE: typeParameterOfTopSetter.kt public final [BODY_RESOLVE] var x: R|kotlin/Int| = Int(2) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatcherTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatcherTransformer.kt index da8161e85c5..116e7ac076b 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatcherTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatcherTransformer.kt @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.transformers.FirAbstractTreeTransformer import org.jetbrains.kotlin.fir.resolve.transformers.FirTransformerBasedResolveProcessor import org.jetbrains.kotlin.fir.visitors.FirTransformer -import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility import org.jetbrains.kotlin.resolve.multiplatform.compatible class FirExpectActualMatcherProcessor( @@ -32,7 +31,7 @@ class FirExpectActualMatcherProcessor( } } -class FirExpectActualMatcherTransformer( +open class FirExpectActualMatcherTransformer( override val session: FirSession, private val scopeSession: ScopeSession ) : FirAbstractTreeTransformer(FirResolvePhase.EXPECT_ACTUAL_MATCHING) {