[FIR] Generate an error primary constructor when super call is invalid
Merge-request: KT-MR-11026 Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
+5
-1
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.diagnostics.SingleNonLoca
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.correspondingProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirErrorConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPrimaryConstructor
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
@@ -148,7 +149,10 @@ internal class NonReanalyzableClassDeclarationStructureElement(
|
||||
}
|
||||
|
||||
override fun visitConstructor(constructor: FirConstructor, data: MutableMap<KtElement, FirElement>) {
|
||||
if (constructor is FirPrimaryConstructor && constructor.source?.kind == KtFakeSourceElementKind.ImplicitConstructor) {
|
||||
if (
|
||||
(constructor is FirPrimaryConstructor || constructor is FirErrorConstructor) &&
|
||||
constructor.source?.kind == KtFakeSourceElementKind.ImplicitConstructor
|
||||
) {
|
||||
NonReanalyzableNonClassDeclarationStructureElement.Recorder.visitConstructor(constructor, data)
|
||||
}
|
||||
}
|
||||
|
||||
+17
-12
@@ -1,14 +1,9 @@
|
||||
KT element: KtNameReferenceExpression
|
||||
FIR element: FirRegularClassImpl
|
||||
FIR element: FirResolvedNamedReferenceImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
public final [ResolvedTo(BODY_RESOLVE)] object C : R|A| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=C] constructor(): R|C| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
}
|
||||
R|/A.prop|
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall3.kt
|
||||
@@ -18,17 +13,27 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall3.kt
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public final [ResolvedTo(STATUS)] val prop: R|kotlin/String| = LAZY_EXPRESSION
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=A] get(): R|kotlin/String|
|
||||
public final [ResolvedTo(CONTRACTS)] val prop: R|kotlin/String| = String()
|
||||
public [ResolvedTo(CONTRACTS)] [ContainingClassKey=A] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] object B : A {
|
||||
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=B] constructor(): R|B| {
|
||||
LAZY_super<A>
|
||||
public final [ResolvedTo(STATUS)] object B : R|A| {
|
||||
private [ResolvedTo(STATUS)] [ContainingClassKey=B] constructor(): R|B| {
|
||||
LAZY_super<R|A|>
|
||||
}
|
||||
|
||||
}
|
||||
public final [ResolvedTo(BODY_RESOLVE)] object C : R|A| {
|
||||
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=C] error_constructor(): R|C| {
|
||||
super<R|A|>([ResolvedTo(RAW_FIR)] fun R|A|.<anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
local final [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/String| {
|
||||
^foo Q|B|.R|/A.prop|.R|kotlin/String.toString|()
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=C] constructor(): R|C| {
|
||||
super<R|A|>()
|
||||
}
|
||||
|
||||
+16
-17
@@ -1,20 +1,9 @@
|
||||
KT element: KtNameReferenceExpression
|
||||
FIR element: FirRegularClassImpl
|
||||
FIR element: FirResolvedNamedReferenceImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
public final [ResolvedTo(BODY_RESOLVE)] class G : R|A| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=G] constructor(): R|G| {
|
||||
super<R|A|>([ResolvedTo(RAW_FIR)] fun R|A|.<anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
local final [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/String| {
|
||||
^foo Q|C|.R|/A.prop|.R|kotlin/String.toString|()
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
R|/A.prop|
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall4.kt
|
||||
@@ -28,9 +17,9 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall4.kt
|
||||
public [ResolvedTo(CONTRACTS)] [ContainingClassKey=A] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] object B : A {
|
||||
private [ResolvedTo(RAW_FIR)] [ContainingClassKey=B] constructor(): R|B| {
|
||||
LAZY_super<A>
|
||||
public final [ResolvedTo(STATUS)] object B : R|A| {
|
||||
private [ResolvedTo(STATUS)] [ContainingClassKey=B] constructor(): R|B| {
|
||||
LAZY_super<R|A|>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +30,16 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall4.kt
|
||||
|
||||
}
|
||||
public final [ResolvedTo(BODY_RESOLVE)] class G : R|A| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=G] error_constructor(): R|G| {
|
||||
super<R|A|>([ResolvedTo(RAW_FIR)] fun R|A|.<anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
local final [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/String| {
|
||||
^foo Q|B|.R|/A.prop|.R|kotlin/String.toString|()
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=G] constructor(): R|G| {
|
||||
super<R|A|>([ResolvedTo(RAW_FIR)] fun R|A|.<anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
local final [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/String| {
|
||||
@@ -51,4 +50,4 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall4.kt
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+4
@@ -30,6 +30,10 @@ FILE: [ResolvedTo(IMPORTS)] qualifiedCallInsideSuperCall5.kt
|
||||
|
||||
}
|
||||
public final [ResolvedTo(STATUS)] class G : R|A| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=G] error_constructor(): R|G| {
|
||||
LAZY_super<R|A|>
|
||||
}
|
||||
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=G] constructor(): R|G| {
|
||||
super<R|A|>([ResolvedTo(RAW_FIR)] fun R|A|.<anonymous>(): R|kotlin/Unit| <inline=Unknown> {
|
||||
local final [ResolvedTo(RAW_FIR)] fun foo(): R|kotlin/String| {
|
||||
|
||||
+6
@@ -5990,6 +5990,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/constructorConsistency/derivedProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorInsideDelegationCallNoPrimary.kt")
|
||||
public void testErrorInsideDelegationCallNoPrimary() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/constructorConsistency/errorInsideDelegationCallNoPrimary.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("getset.kt")
|
||||
public void testGetset() throws Exception {
|
||||
|
||||
+6
@@ -5990,6 +5990,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/constructorConsistency/derivedProperty.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("errorInsideDelegationCallNoPrimary.kt")
|
||||
public void testErrorInsideDelegationCallNoPrimary() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/constructorConsistency/errorInsideDelegationCallNoPrimary.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("getset.kt")
|
||||
public void testGetset() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user