[FIR] Set implicit type for delegated constructor calls in fir builder
This commit is contained in:
+11
-5
@@ -427,11 +427,14 @@ class DeclarationsConverter(
|
||||
}
|
||||
modifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> {
|
||||
superTypeRefs += implicitAnnotationType
|
||||
delegatedSuperTypeRef = implicitAnyType
|
||||
}
|
||||
}
|
||||
val defaultDelegatedSuperTypeRef = implicitAnyType
|
||||
|
||||
superTypeRefs.ifEmpty { superTypeRefs += defaultDelegatedSuperTypeRef }
|
||||
superTypeRefs.ifEmpty {
|
||||
superTypeRefs += implicitAnyType
|
||||
delegatedSuperTypeRef = implicitAnyType
|
||||
}
|
||||
|
||||
this.superTypeRefs += superTypeRefs
|
||||
|
||||
@@ -443,7 +446,7 @@ class DeclarationsConverter(
|
||||
hasDefaultConstructor = if (primaryConstructor != null) !primaryConstructor!!.hasValueParameters()
|
||||
else secondaryConstructors.isEmpty() || secondaryConstructors.any { !it.hasValueParameters() },
|
||||
delegatedSelfTypeRef = selfType,
|
||||
delegatedSuperTypeRef = delegatedSuperTypeRef ?: defaultDelegatedSuperTypeRef,
|
||||
delegatedSuperTypeRef = delegatedSuperTypeRef ?: buildImplicitTypeRef(),
|
||||
superTypeCallEntry = superTypeCallEntry
|
||||
)
|
||||
//parse primary constructor
|
||||
@@ -514,8 +517,11 @@ class DeclarationsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
superTypeRefs.ifEmpty { superTypeRefs += implicitAnyType }
|
||||
val delegatedSuperType = delegatedSuperTypeRef ?: implicitAnyType
|
||||
superTypeRefs.ifEmpty {
|
||||
superTypeRefs += implicitAnyType
|
||||
delegatedSuperTypeRef = implicitAnyType
|
||||
}
|
||||
val delegatedSuperType = delegatedSuperTypeRef ?: buildImplicitTypeRef()
|
||||
|
||||
return withChildClassName(ANONYMOUS_OBJECT_NAME) {
|
||||
buildAnonymousObject {
|
||||
|
||||
+10
@@ -55,6 +55,11 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
||||
public void testConstructorOfAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("contractDescription.kt")
|
||||
public void testContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contractDescription.kt");
|
||||
@@ -65,6 +70,11 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyAnonymousObject.kt")
|
||||
public void testEmptyAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
||||
|
||||
@@ -479,18 +479,21 @@ class RawFirBuilder(
|
||||
}
|
||||
this is KtClass && classKind == ClassKind.ANNOTATION_CLASS -> {
|
||||
container.superTypeRefs += implicitAnnotationType
|
||||
delegatedSuperTypeRef = implicitAnyType
|
||||
}
|
||||
}
|
||||
|
||||
val defaultDelegatedSuperTypeRef =
|
||||
when {
|
||||
classKind == ClassKind.ENUM_ENTRY && this is KtClass -> delegatedEnumSuperTypeRef ?: implicitAnyType
|
||||
else -> implicitAnyType
|
||||
container.superTypeRefs.isEmpty() -> implicitAnyType
|
||||
else -> buildImplicitTypeRef()
|
||||
}
|
||||
|
||||
|
||||
if (container.superTypeRefs.isEmpty()) {
|
||||
container.superTypeRefs += defaultDelegatedSuperTypeRef
|
||||
container.superTypeRefs += implicitAnyType
|
||||
delegatedSuperTypeRef = implicitAnyType
|
||||
}
|
||||
if (this is KtClass && this.isInterface()) return delegatedSuperTypeRef ?: implicitAnyType
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ FILE: F.kt
|
||||
}
|
||||
public? final? class B : A {
|
||||
public? constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
private fun resolveAccessorCall(
|
||||
suspendPropertyDescriptor: PropertyDescriptor,
|
||||
context: TranslationContext
|
||||
): ResolvedCall<PropertyDescriptor> {
|
||||
return object : ResolvedCall<PropertyDescriptor> {
|
||||
override fun getStatus() = ResolutionStatus.SUCCESS
|
||||
|
||||
override fun getCandidateDescriptor() = suspendPropertyDescriptor
|
||||
override fun getResultingDescriptor() = suspendPropertyDescriptor
|
||||
}
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
FILE: constructorOfAnonymousObject.kt
|
||||
private final? fun resolveAccessorCall(suspendPropertyDescriptor: PropertyDescriptor, context: TranslationContext): ResolvedCall<PropertyDescriptor> {
|
||||
^resolveAccessorCall object : ResolvedCall<PropertyDescriptor> {
|
||||
private constructor(): R|anonymous| {
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
public? open? override fun getStatus(): <implicit> {
|
||||
^getStatus ResolutionStatus#.SUCCESS#
|
||||
}
|
||||
|
||||
public? open? override fun getCandidateDescriptor(): <implicit> {
|
||||
^getCandidateDescriptor suspendPropertyDescriptor#
|
||||
}
|
||||
|
||||
public? open? override fun getResultingDescriptor(): <implicit> {
|
||||
^getResultingDescriptor suspendPropertyDescriptor#
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
|
||||
fun test() {
|
||||
val x = object {}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
FILE: emptyAnonymousObject.kt
|
||||
public? final? fun test(): R|kotlin/Unit| {
|
||||
lval x: <implicit> = object : R|kotlin/Any| {
|
||||
private constructor(): R|anonymous| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,13 +3,13 @@ FILE: enums2.kt
|
||||
}
|
||||
public? final? object O1 : Some {
|
||||
private constructor(): R|O1| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
}
|
||||
public? final? object O2 : Some {
|
||||
private constructor(): R|O2| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ FILE: simpleClass.kt
|
||||
}
|
||||
public? final? class SomeClass : SomeInterface {
|
||||
public? constructor(): R|SomeClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
private final? val baz: <implicit> = IntegerLiteral(42)
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ FILE: simpleTypeAlias.kt
|
||||
public? final typealias C = B
|
||||
public? final? class D : C {
|
||||
public? constructor(): R|D| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ FILE: typeAliasWithGeneric.kt
|
||||
public? final typealias C<T> = B<T, A>
|
||||
public? final? class D : C<A> {
|
||||
public? constructor(): R|D| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ FILE: typeParameters.kt
|
||||
public? final typealias AnyList = List<*>
|
||||
public? abstract class AbstractList<out T : Any> : List<T> {
|
||||
public? constructor<out T : Any>(): R|AbstractList<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ FILE: super.kt
|
||||
}
|
||||
public? final? class C : A, B {
|
||||
public? constructor(): R|C| {
|
||||
super<R|kotlin/Any|>()
|
||||
super<<implicit>>()
|
||||
}
|
||||
|
||||
public? open? override fun bar(): R|kotlin/Unit| {
|
||||
|
||||
+10
@@ -55,6 +55,11 @@ public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCas
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
||||
public void testConstructorOfAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("contractDescription.kt")
|
||||
public void testContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contractDescription.kt");
|
||||
@@ -65,6 +70,11 @@ public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCas
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyAnonymousObject.kt")
|
||||
public void testEmptyAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
||||
|
||||
+10
@@ -55,6 +55,11 @@ public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizer {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
||||
public void testConstructorOfAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("contractDescription.kt")
|
||||
public void testContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contractDescription.kt");
|
||||
@@ -65,6 +70,11 @@ public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizer {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyAnonymousObject.kt")
|
||||
public void testEmptyAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
||||
|
||||
+10
@@ -55,6 +55,11 @@ public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizer {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
||||
public void testConstructorOfAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("contractDescription.kt")
|
||||
public void testContractDescription() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contractDescription.kt");
|
||||
@@ -65,6 +70,11 @@ public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizer {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyAnonymousObject.kt")
|
||||
public void testEmptyAnonymousObject() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
||||
|
||||
Reference in New Issue
Block a user