[LL FIR] FileStructure: process super class calls correctly

^KT-56543
^KT-57793
This commit is contained in:
Dmitrii Gridin
2023-04-04 20:13:41 +02:00
committed by Space Team
parent d0e801054c
commit 26f8147a8c
22 changed files with 326 additions and 2 deletions
@@ -244,7 +244,7 @@ internal class NonReanalyzableClassDeclarationStructureElement(
override fun visitConstructor(constructor: FirConstructor, data: MutableMap<KtElement, FirElement>) {
if (constructor is FirPrimaryConstructor && constructor.source?.kind == KtFakeSourceElementKind.ImplicitConstructor) {
super.visitConstructor(constructor, data)
NonReanalyzableNonClassDeclarationStructureElement.Recorder.visitConstructor(constructor, data)
}
}
@@ -276,7 +276,7 @@ internal class NonReanalyzableNonClassDeclarationStructureElement(
moduleComponents,
)
private object Recorder : FirElementsRecorder()
internal object Recorder : FirElementsRecorder()
}
internal class DanglingTopLevelModifierListStructureElement(
@@ -0,0 +1,51 @@
open class A(init: A.() -> Unit) {
val prop: String = ""
}
object B : A({})
object C : A(
{
fun foo() = B.prop.toString()
}
)
class D : A(
{
fun foo() = B.prop.toString()
}
)
class E() : A(
{
fun foo() = B.prop.toString()
}
)
class F : A(
{
fun foo() = B.prop.toString()
}
) {
constructor()
}
class G : A(
{
fun foo() = B.prop.toString()
}
) {
constructor() : super(
{
fun foo() = B.prop.toString()
}
)
}
class H : A {
constructor() : super(
{
fun foo() = B.prop.toString()
}
)
}
@@ -0,0 +1,35 @@
open class A
(init: A.() -> Unit)/* NonReanalyzableNonClassDeclarationStructureElement */
{/* NonReanalyzableClassDeclarationStructureElement */
val prop: String = ""/* ReanalyzablePropertyStructureElement */
}
class B()/* NonReanalyzableNonClassDeclarationStructureElement */ : A()/* NonReanalyzableClassDeclarationStructureElement */
object C : A(
{
fun foo() = B.prop.toString()
}
) {/* NonReanalyzableClassDeclarationStructureElement */
}
val f = object : A(
{
fun bar() = B.prop.toString()
}
) {
}/* NonReanalyzableNonClassDeclarationStructureElement */
class D : A(
{
fun foo() = B.prop.toString()
}
) {/* NonReanalyzableClassDeclarationStructureElement */
constructor(): super(
{
fun boo() = prop.toString()
}
)/* NonReanalyzableNonClassDeclarationStructureElement */
}
@@ -0,0 +1,6 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtSimpleNameExpression
class A(
val i: () -> Unit = {
fun foo() = B.<expr>prop</expr>.toString()
}
)
@@ -0,0 +1,6 @@
KT element: KtNameReferenceExpression
FIR element: FirErrorNamedReferenceImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
<Unresolved name: prop>#
@@ -0,0 +1,12 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtSimpleNameExpression
open class A(init: A.() -> Unit) {
val prop: String = ""
}
object B : A({})
object C : A(
{
fun foo() = B.<expr>prop</expr>.toString()
}
)
@@ -0,0 +1,6 @@
KT element: KtNameReferenceExpression
FIR element: FirResolvedNamedReferenceImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
R|/A.prop|
@@ -0,0 +1,12 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtCallExpression
open class A(init: A.() -> Unit) {
val prop: String = ""
}
object B : A({})
object C : A(
{
fun foo() = B.prop.<expr>toString()</expr>
}
)
@@ -0,0 +1,6 @@
KT element: KtCallExpression
FIR element: FirFunctionCallImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
Q|B|.R|/A.prop|.R|kotlin/String.toString|()
@@ -0,0 +1,14 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtSimpleNameExpression
open class A(init: A.() -> Unit) {
val prop: String = ""
}
object B : A({})
object C : A(
{
fun foo() = B.<expr>prop</expr>.toString()
}
) {
constructor()
}
@@ -0,0 +1,11 @@
KT element: KtNameReferenceExpression
FIR element: FirRegularClassImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
public final [ResolvedTo(BODY_RESOLVE)] object C : R|A| {
public [ResolvedTo(BODY_RESOLVE)] constructor(): R|C| {
super<R|A|>()
}
}
@@ -0,0 +1,20 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtSimpleNameExpression
open class A(init: A.() -> Unit) {
val prop: String = ""
}
object B : A({})
object C : A({})
class G : A(
{
fun foo() = B.<expr>prop</expr>.toString()
}
) {
constructor() : super(
{
fun foo() = C.prop.toString()
}
)
}
@@ -0,0 +1,17 @@
KT element: KtNameReferenceExpression
FIR element: FirRegularClassImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
public final [ResolvedTo(BODY_RESOLVE)] class G : R|A| {
public [ResolvedTo(BODY_RESOLVE)] 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|()
}
}
)
}
}
@@ -0,0 +1,20 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtSimpleNameExpression
open class A(init: A.() -> Unit) {
val prop: String = ""
}
object B : A({})
object C : A({})
class G : A(
{
fun foo() = B.prop.toString()
}
) {
constructor() : super(
{
fun foo() = C.<expr>prop</expr>.toString()
}
)
}
@@ -0,0 +1,6 @@
KT element: KtNameReferenceExpression
FIR element: FirResolvedNamedReferenceImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
R|/A.prop|
@@ -305,6 +305,42 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/invokeCallArgumentList.kt");
}
@Test
@TestMetadata("qualifiedCallInsidePropertyInsideConstructor.kt")
public void testQualifiedCallInsidePropertyInsideConstructor() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsidePropertyInsideConstructor.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall.kt")
public void testQualifiedCallInsideSuperCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall2.kt")
public void testQualifiedCallInsideSuperCall2() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall2.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall3.kt")
public void testQualifiedCallInsideSuperCall3() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall3.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall4.kt")
public void testQualifiedCallInsideSuperCall4() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall4.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall5.kt")
public void testQualifiedCallInsideSuperCall5() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall5.kt");
}
@Test
@TestMetadata("qualifiedCallSelector.kt")
public void testQualifiedCallSelector() throws Exception {
@@ -305,6 +305,42 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/invokeCallArgumentList.kt");
}
@Test
@TestMetadata("qualifiedCallInsidePropertyInsideConstructor.kt")
public void testQualifiedCallInsidePropertyInsideConstructor() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsidePropertyInsideConstructor.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall.kt")
public void testQualifiedCallInsideSuperCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall2.kt")
public void testQualifiedCallInsideSuperCall2() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall2.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall3.kt")
public void testQualifiedCallInsideSuperCall3() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall3.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall4.kt")
public void testQualifiedCallInsideSuperCall4() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall4.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall5.kt")
public void testQualifiedCallInsideSuperCall5() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/calls/qualifiedCallInsideSuperCall5.kt");
}
@Test
@TestMetadata("qualifiedCallSelector.kt")
public void testQualifiedCallSelector() throws Exception {
@@ -168,6 +168,12 @@ public class DiagnosticTraversalCounterTestGenerated extends AbstractDiagnosticT
runTest("analysis/low-level-api-fir/testdata/diagnosticTraversalCounter/propertyWithGetterAndSetter.kt");
}
@Test
@TestMetadata("qualifiedCallInsideSuperCall.kt")
public void testQualifiedCallInsideSuperCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/diagnosticTraversalCounter/qualifiedCallInsideSuperCall.kt");
}
@Test
@TestMetadata("secondaryConstructor.kt")
public void testSecondaryConstructor() throws Exception {
@@ -114,6 +114,12 @@ public class FirOutOfContentRootContextCollectionTestGenerated extends AbstractF
runTest("analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt");
}
@Test
@TestMetadata("superClassCall.kt")
public void testSuperClassCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt");
}
@Test
@TestMetadata("topLevelExpressionBodyFunWithType.kt")
public void testTopLevelExpressionBodyFunWithType() throws Exception {
@@ -114,6 +114,12 @@ public class FirSourceContextCollectionTestGenerated extends AbstractFirSourceCo
runTest("analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt");
}
@Test
@TestMetadata("superClassCall.kt")
public void testSuperClassCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt");
}
@Test
@TestMetadata("topLevelExpressionBodyFunWithType.kt")
public void testTopLevelExpressionBodyFunWithType() throws Exception {
@@ -114,6 +114,12 @@ public class OutOfContentRootFileStructureTestGenerated extends AbstractOutOfCon
runTest("analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt");
}
@Test
@TestMetadata("superClassCall.kt")
public void testSuperClassCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt");
}
@Test
@TestMetadata("topLevelExpressionBodyFunWithType.kt")
public void testTopLevelExpressionBodyFunWithType() throws Exception {
@@ -114,6 +114,12 @@ public class SourceFileStructureTestGenerated extends AbstractSourceFileStructur
runTest("analysis/low-level-api-fir/testdata/fileStructure/propertyAccessors.kt");
}
@Test
@TestMetadata("superClassCall.kt")
public void testSuperClassCall() throws Exception {
runTest("analysis/low-level-api-fir/testdata/fileStructure/superClassCall.kt");
}
@Test
@TestMetadata("topLevelExpressionBodyFunWithType.kt")
public void testTopLevelExpressionBodyFunWithType() throws Exception {