[FIR] Fix errors related to expect classes/delegated constructors
^KT-60384 fixed Merge-request: KT-MR-11835 Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
expect class F<caret>oo
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
RAW_FIR:
|
||||||
|
FILE: [ResolvedTo(RAW_FIR)] expectClass.kt
|
||||||
|
public? final? expect [ResolvedTo(RAW_FIR)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPORTS:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public? final? expect [ResolvedTo(RAW_FIR)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
COMPILER_REQUIRED_ANNOTATIONS:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public? final? expect [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
COMPANION_GENERATION:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public? final? expect [ResolvedTo(COMPANION_GENERATION)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
SUPER_TYPES:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public? final? expect [ResolvedTo(SUPER_TYPES)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPES:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public? final? expect [ResolvedTo(TYPES)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
STATUS:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(STATUS)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_ACTUAL_MATCHING:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(EXPECT_ACTUAL_MATCHING)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
ARGUMENTS_OF_ANNOTATIONS:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
CONTRACTS:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(CONTRACTS)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
ANNOTATIONS_ARGUMENTS_MAPPING:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
BODY_RESOLVE:
|
||||||
|
FILE: [ResolvedTo(IMPORTS)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(BODY_RESOLVE)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE RAW TO BODY:
|
||||||
|
FILE: [ResolvedTo(BODY_RESOLVE)] expectClass.kt
|
||||||
|
public final expect [ResolvedTo(BODY_RESOLVE)] class Foo : R|kotlin/Any| {
|
||||||
|
}
|
||||||
+6
@@ -147,6 +147,12 @@ public class FirOutOfContentRootLazyBodiesCalculatorTestGenerated extends Abstra
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
|
|||||||
+6
@@ -234,6 +234,12 @@ public class FirOutOfContentRootLazyDeclarationResolveTestGenerated extends Abst
|
|||||||
runTest("analysis/low-level-api-fir/testdata/lazyResolve/enumValues.kt");
|
runTest("analysis/low-level-api-fir/testdata/lazyResolve/enumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectClass.kt")
|
||||||
|
public void testExpectClass() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/lazyResolve/expectClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("fakeOverride.kt")
|
@TestMetadata("fakeOverride.kt")
|
||||||
public void testFakeOverride() throws Exception {
|
public void testFakeOverride() throws Exception {
|
||||||
|
|||||||
+6
@@ -147,6 +147,12 @@ public class FirSourceLazyBodiesCalculatorTestGenerated extends AbstractFirSourc
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
|
|||||||
+6
@@ -234,6 +234,12 @@ public class FirSourceLazyDeclarationResolveTestGenerated extends AbstractFirSou
|
|||||||
runTest("analysis/low-level-api-fir/testdata/lazyResolve/enumValues.kt");
|
runTest("analysis/low-level-api-fir/testdata/lazyResolve/enumValues.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectClass.kt")
|
||||||
|
public void testExpectClass() throws Exception {
|
||||||
|
runTest("analysis/low-level-api-fir/testdata/lazyResolve/expectClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("fakeOverride.kt")
|
@TestMetadata("fakeOverride.kt")
|
||||||
public void testFakeOverride() throws Exception {
|
public void testFakeOverride() throws Exception {
|
||||||
|
|||||||
+5
@@ -136,6 +136,11 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
||||||
|
|||||||
+25
-24
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
|||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.runUnless
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
|
import org.jetbrains.kotlin.utils.addToStdlib.shouldNotBeCalled
|
||||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||||
import org.jetbrains.kotlin.utils.exceptions.requireWithAttachment
|
import org.jetbrains.kotlin.utils.exceptions.requireWithAttachment
|
||||||
@@ -1033,34 +1034,34 @@ open class PsiRawFirBuilder(
|
|||||||
?: owner.toKtPsiSourceElement(KtFakeSourceElementKind.ImplicitConstructor)
|
?: owner.toKtPsiSourceElement(KtFakeSourceElementKind.ImplicitConstructor)
|
||||||
fun buildDelegatedCall(superTypeCallEntry: KtSuperTypeCallEntry?, delegatedTypeRef: FirTypeRef): FirDelegatedConstructorCall? {
|
fun buildDelegatedCall(superTypeCallEntry: KtSuperTypeCallEntry?, delegatedTypeRef: FirTypeRef): FirDelegatedConstructorCall? {
|
||||||
val constructorCall = superTypeCallEntry?.toFirSourceElement()
|
val constructorCall = superTypeCallEntry?.toFirSourceElement()
|
||||||
return if (containingClassIsExpectClass) null else {
|
val constructedTypeRef = if (copyConstructedTypeRefWithImplicitSource) {
|
||||||
val constructedTypeRef = if (copyConstructedTypeRefWithImplicitSource) {
|
delegatedTypeRef.copyWithNewSourceKind(KtFakeSourceElementKind.ImplicitTypeRef)
|
||||||
delegatedTypeRef.copyWithNewSourceKind(KtFakeSourceElementKind.ImplicitTypeRef)
|
} else {
|
||||||
} else {
|
delegatedTypeRef
|
||||||
delegatedTypeRef
|
}
|
||||||
}
|
return buildOrLazyDelegatedConstructorCall(isThis = false, constructedTypeRef) {
|
||||||
buildOrLazyDelegatedConstructorCall(isThis = false, constructedTypeRef) {
|
buildDelegatedConstructorCall {
|
||||||
buildDelegatedConstructorCall {
|
source = constructorCall ?: constructorSource.fakeElement(KtFakeSourceElementKind.DelegatingConstructorCall)
|
||||||
source = constructorCall ?: constructorSource.fakeElement(KtFakeSourceElementKind.DelegatingConstructorCall)
|
this.constructedTypeRef = constructedTypeRef
|
||||||
this.constructedTypeRef = constructedTypeRef
|
isThis = false
|
||||||
isThis = false
|
calleeReference = buildExplicitSuperReference {
|
||||||
calleeReference = buildExplicitSuperReference {
|
source =
|
||||||
source =
|
superTypeCallEntry?.calleeExpression?.toFirSourceElement(KtFakeSourceElementKind.DelegatingConstructorCall)
|
||||||
superTypeCallEntry?.calleeExpression?.toFirSourceElement(KtFakeSourceElementKind.DelegatingConstructorCall)
|
?: this@buildDelegatedConstructorCall.source?.fakeElement(KtFakeSourceElementKind.DelegatingConstructorCall)
|
||||||
?: this@buildDelegatedConstructorCall.source?.fakeElement(KtFakeSourceElementKind.DelegatingConstructorCall)
|
superTypeRef = this@buildDelegatedConstructorCall.constructedTypeRef
|
||||||
superTypeRef = this@buildDelegatedConstructorCall.constructedTypeRef
|
|
||||||
}
|
|
||||||
superTypeCallEntry?.extractArgumentsTo(this)
|
|
||||||
}
|
}
|
||||||
|
superTypeCallEntry?.extractArgumentsTo(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val firDelegatedCall = if (allSuperTypeCallEntries.size <= 1 ) {
|
val firDelegatedCall = runUnless(containingClassIsExpectClass) {
|
||||||
buildDelegatedCall(superTypeCallEntry, delegatedSuperTypeRef!!)
|
if (allSuperTypeCallEntries.size <= 1) {
|
||||||
} else {
|
buildDelegatedCall(superTypeCallEntry, delegatedSuperTypeRef!!)
|
||||||
buildMultiDelegatedConstructorCall {
|
} else {
|
||||||
allSuperTypeCallEntries.mapTo(delegatedConstructorCalls) { (superTypeCallEntry, delegatedTypeRef) ->
|
buildMultiDelegatedConstructorCall {
|
||||||
buildDelegatedCall(superTypeCallEntry, delegatedTypeRef)!!
|
allSuperTypeCallEntries.mapTo(delegatedConstructorCalls) { (superTypeCallEntry, delegatedTypeRef) ->
|
||||||
|
buildDelegatedCall(superTypeCallEntry, delegatedTypeRef)!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
expect class A
|
||||||
|
|
||||||
|
open class B
|
||||||
|
|
||||||
|
open class C
|
||||||
|
|
||||||
|
expect class D: B()
|
||||||
|
|
||||||
|
expect class E: B(), C()
|
||||||
|
|
||||||
|
expect fun f()
|
||||||
|
|
||||||
|
expect annotation class G
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
FILE: expectClassesAndFunctions.kt
|
||||||
|
public? final? expect class A : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public? open class B : R|kotlin/Any| {
|
||||||
|
public? constructor(): R|B| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public? open class C : R|kotlin/Any| {
|
||||||
|
public? constructor(): R|C| {
|
||||||
|
LAZY_super<R|kotlin/Any|>
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? expect class D : B {
|
||||||
|
public? expect error_constructor(): R|D|
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? expect class E : B, C {
|
||||||
|
public? expect error_constructor(): R|E|
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? expect fun f(): R|kotlin/Unit|
|
||||||
|
public? final? expect annotation class G : R|kotlin/Annotation| {
|
||||||
|
}
|
||||||
Vendored
+26
@@ -0,0 +1,26 @@
|
|||||||
|
FILE: expectClassesAndFunctions.kt
|
||||||
|
public? final? expect class A : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public? open class B : R|kotlin/Any| {
|
||||||
|
public? [ContainingClassKey=B] constructor(): R|B| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public? open class C : R|kotlin/Any| {
|
||||||
|
public? [ContainingClassKey=C] constructor(): R|C| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? expect class D : B {
|
||||||
|
public? expect [ContainingClassKey=D] error_constructor(): R|D|
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? expect class E : B, C {
|
||||||
|
public? expect [ContainingClassKey=E] error_constructor(): R|E|
|
||||||
|
|
||||||
|
}
|
||||||
|
public? final? expect fun f(): R|kotlin/Unit|
|
||||||
|
public? final? expect annotation class G : R|kotlin/Annotation| {
|
||||||
|
}
|
||||||
+5
@@ -136,6 +136,11 @@ public class RawFirBuilderLazyBodiesTestCaseGenerated extends AbstractRawFirBuil
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
||||||
|
|||||||
+5
@@ -136,6 +136,11 @@ public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCas
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
||||||
|
|||||||
+6
@@ -147,6 +147,12 @@ public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizerTe
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
|
|||||||
+6
@@ -147,6 +147,12 @@ public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizerTe
|
|||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("expectClassesAndFunctions.kt")
|
||||||
|
public void testExpectClassesAndFunctions() throws Exception {
|
||||||
|
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("external.kt")
|
@TestMetadata("external.kt")
|
||||||
public void testExternal() throws Exception {
|
public void testExternal() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user