Raw FIR: add Any/Enum/Annotation to supertypes iff no supertypes exists
This commit is contained in:
@@ -44,6 +44,8 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
|
||||
private val implicitEnumType = FirImplicitEnumTypeRef(session, null)
|
||||
|
||||
private val implicitAnnotationType = FirImplicitAnnotationTypeRef(session, null)
|
||||
|
||||
fun buildFirFile(file: KtFile): FirFile {
|
||||
return file.accept(Visitor(), Unit) as FirFile
|
||||
}
|
||||
@@ -339,13 +341,18 @@ class RawFirBuilder(val session: FirSession, val stubMode: Boolean) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this is KtClass && this.isInterface()) return delegatedSuperTypeRef
|
||||
|
||||
fun isEnum() = this is KtClass && this.isEnum()
|
||||
val defaultDelegatedSuperTypeRef = if (isEnum()) implicitEnumType else implicitAnyType
|
||||
if (delegatedSuperTypeRef == null && this.hasPrimaryConstructor()) {
|
||||
val defaultDelegatedSuperTypeRef = when {
|
||||
this is KtClass && this.isEnum() -> implicitEnumType
|
||||
this is KtClass && this.isAnnotation() -> implicitAnnotationType
|
||||
else -> implicitAnyType
|
||||
}
|
||||
// TODO: for enum / annotations, it *should* be empty
|
||||
if (container.superTypeRefs.isEmpty()) {
|
||||
container.superTypeRefs += defaultDelegatedSuperTypeRef
|
||||
}
|
||||
if (this is KtClass && this.isInterface()) return delegatedSuperTypeRef
|
||||
|
||||
// TODO: in case we have no primary constructor,
|
||||
// it may be not possible to determine delegated super type right here
|
||||
delegatedSuperTypeRef = delegatedSuperTypeRef ?: defaultDelegatedSuperTypeRef
|
||||
|
||||
@@ -3,7 +3,7 @@ FILE: F.kt
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
public? final? class B : A, kotlin/Any {
|
||||
public? final? class B : A {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ FILE: complexTypes.kt
|
||||
}
|
||||
|
||||
}
|
||||
public? final? interface Test {
|
||||
public? final? interface Test : kotlin/Any {
|
||||
public? final? val x: a.b.C<out CharSequence, *>.D<in List<*>, *>
|
||||
public? get(): a.b.C<out CharSequence, *>.D<in List<*>, *>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
FILE: enums2.kt
|
||||
public? final? interface Some {
|
||||
public? final? interface Some : kotlin/Any {
|
||||
}
|
||||
public? final? object O1 : Some, kotlin/Any {
|
||||
public? final? object O1 : Some {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
public? final? object O2 : Some, kotlin/Any {
|
||||
public? final? object O2 : Some {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: genericFunctions.kt
|
||||
public? final? interface Any {
|
||||
public? final? interface Any : kotlin/Any {
|
||||
}
|
||||
<reified T : Any> public? final? inline fun Any.safeAs(): T? {
|
||||
^safeAs (this# as? T)
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
FILE: noPrimaryConstructor.kt
|
||||
public? final? class NoPrimary {
|
||||
public? final? class NoPrimary : kotlin/Any {
|
||||
public? final? val x: String
|
||||
public? get(): String
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
FILE: simpleClass.kt
|
||||
public? final? interface SomeInterface {
|
||||
public? final? interface SomeInterface : kotlin/Any {
|
||||
public? final? fun foo(x: Int, y: String): String
|
||||
|
||||
public? final? val bar: Boolean
|
||||
public? get(): Boolean
|
||||
|
||||
}
|
||||
public? final? class SomeClass : SomeInterface, kotlin/Any {
|
||||
public? final? class SomeClass : SomeInterface {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
private final? val baz: <implicit> = Int(42)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
FILE: simpleTypeAlias.kt
|
||||
public? final? interface B {
|
||||
public? final? interface B : kotlin/Any {
|
||||
}
|
||||
public? final typealias C = B
|
||||
public? final? class D : C, kotlin/Any {
|
||||
public? final? class D : C {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ FILE: typeAliasWithGeneric.kt
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
<S, T : A> public? final? interface B {
|
||||
<S, T : A> public? final? interface B : kotlin/Any {
|
||||
}
|
||||
<T> public? final typealias C = B<T, A>
|
||||
public? final? class D : C<A>, kotlin/Any {
|
||||
public? final? class D : C<A> {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
FILE: typeParameterVsNested.kt
|
||||
public? final? interface Some {
|
||||
public? final? interface Some : kotlin/Any {
|
||||
}
|
||||
<T : Some> public? abstract class My : kotlin/Any {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: typeParameters.kt
|
||||
<out T : Any> public? final? interface List {
|
||||
<out T : Any> public? final? interface List : kotlin/Any {
|
||||
public? final? operator fun get(index: Int): T
|
||||
|
||||
public? final? infix fun concat(other: List<T>): List<T>
|
||||
@@ -7,7 +7,7 @@ FILE: typeParameters.kt
|
||||
}
|
||||
public? final typealias StringList = List<out String>
|
||||
public? final typealias AnyList = List<*>
|
||||
<out T : Any> public? abstract class AbstractList : List<T>, kotlin/Any {
|
||||
<out T : Any> public? abstract class AbstractList : List<T> {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FILE: where.kt
|
||||
public? final? interface A {
|
||||
public? final? interface A : kotlin/Any {
|
||||
}
|
||||
public? final? interface B {
|
||||
public? final? interface B : kotlin/Any {
|
||||
}
|
||||
<T : A, B> public? final? class C : kotlin/Any {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
FILE: annotated.kt
|
||||
@Target(AnnotationTarget#.EXPRESSION#) @Retention(AnnotationRetention#.SOURCE#) public? final? annotation class Ann : kotlin/Any {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
@Target(AnnotationTarget#.EXPRESSION#) @Retention(AnnotationRetention#.SOURCE#) public? final? annotation class Ann : kotlin/Annotation {
|
||||
public? constructor(): super<kotlin/Annotation>()
|
||||
|
||||
}
|
||||
public? final? fun foo(arg: Int): Int {
|
||||
|
||||
+6
-6
@@ -1,20 +1,20 @@
|
||||
FILE: collectionLiterals.kt
|
||||
public? final? annotation class Ann1 : kotlin/Any {
|
||||
public? constructor(arr: IntArray): super<kotlin/Any>()
|
||||
public? final? annotation class Ann1 : kotlin/Annotation {
|
||||
public? constructor(arr: IntArray): super<kotlin/Annotation>()
|
||||
|
||||
public? final? val arr: IntArray = R|<local>/arr|
|
||||
public? get(): IntArray
|
||||
|
||||
}
|
||||
public? final? annotation class Ann2 : kotlin/Any {
|
||||
public? constructor(arr: DoubleArray): super<kotlin/Any>()
|
||||
public? final? annotation class Ann2 : kotlin/Annotation {
|
||||
public? constructor(arr: DoubleArray): super<kotlin/Annotation>()
|
||||
|
||||
public? final? val arr: DoubleArray = R|<local>/arr|
|
||||
public? get(): DoubleArray
|
||||
|
||||
}
|
||||
public? final? annotation class Ann3 : kotlin/Any {
|
||||
public? constructor(arr: Array<String>): super<kotlin/Any>()
|
||||
public? final? annotation class Ann3 : kotlin/Annotation {
|
||||
public? constructor(arr: Array<String>): super<kotlin/Annotation>()
|
||||
|
||||
public? final? val arr: Array<String> = R|<local>/arr|
|
||||
public? get(): Array<String>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
FILE: super.kt
|
||||
public? final? interface A {
|
||||
public? final? interface A : kotlin/Any {
|
||||
public? final? fun foo(): kotlin/Unit {
|
||||
}
|
||||
|
||||
}
|
||||
public? final? interface B {
|
||||
public? final? interface B : kotlin/Any {
|
||||
public? final? fun foo(): kotlin/Unit {
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ FILE: super.kt
|
||||
}
|
||||
|
||||
}
|
||||
public? final? class C : A, B, kotlin/Any {
|
||||
public? final? class C : A, B {
|
||||
public? constructor(): super<kotlin/Any>()
|
||||
|
||||
public? open? override fun bar(): kotlin/Unit {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: typeOperators.kt
|
||||
public? final? interface IThing {
|
||||
public? final? interface IThing : kotlin/Any {
|
||||
}
|
||||
public? final? fun test1(x: Any): <implicit> {
|
||||
^test1 (x# is IThing)
|
||||
|
||||
Reference in New Issue
Block a user