[FIR] Fix type alias handling in qualifier position
This commit is contained in:
@@ -208,7 +208,7 @@ class FirCallResolver(
|
||||
val classId = referencedSymbol.classId
|
||||
return FirResolvedQualifierImpl(nameReference.source, classId.packageFqName, classId.relativeClassName).apply {
|
||||
resultType = if (classId.isLocal) {
|
||||
typeForQualifierByDeclaration(referencedSymbol.fir, resultType)
|
||||
typeForQualifierByDeclaration(referencedSymbol.fir, resultType, session)
|
||||
?: resultType.resolvedTypeFromPrototype(
|
||||
session.builtinTypes.unitType.type//StandardClassIds.Unit(symbolProvider).constructType(emptyArray(), isNullable = false)
|
||||
)
|
||||
|
||||
@@ -320,7 +320,7 @@ fun BodyResolveComponents.typeForQualifier(resolvedQualifier: FirResolvedQualifi
|
||||
val classSymbol = symbolProvider.getClassLikeSymbolByFqName(classId)
|
||||
?: return FirErrorTypeRefImpl(source = null, diagnostic = FirSimpleDiagnostic("No type for qualifier", DiagnosticKind.Other))
|
||||
val declaration = classSymbol.phasedFir
|
||||
typeForQualifierByDeclaration(declaration, resultType)?.let { return it }
|
||||
typeForQualifierByDeclaration(declaration, resultType, session)?.let { return it }
|
||||
}
|
||||
// TODO: Handle no value type here
|
||||
return resultType.resolvedTypeFromPrototype(
|
||||
@@ -334,7 +334,11 @@ internal fun typeForReifiedParameterReference(parameterReference: FirResolvedRei
|
||||
return resultType.resolvedTypeFromPrototype(typeParameterSymbol.constructType(emptyArray(), false))
|
||||
}
|
||||
|
||||
internal fun typeForQualifierByDeclaration(declaration: FirDeclaration, resultType: FirTypeRef): FirTypeRef? {
|
||||
internal fun typeForQualifierByDeclaration(declaration: FirDeclaration, resultType: FirTypeRef, session: FirSession): FirTypeRef? {
|
||||
if (declaration is FirTypeAlias) {
|
||||
val expandedDeclaration = declaration.expandedConeType?.lookupTag?.toSymbol(session)?.fir ?: return null
|
||||
return typeForQualifierByDeclaration(expandedDeclaration, resultType, session)
|
||||
}
|
||||
if (declaration is FirRegularClass) {
|
||||
if (declaration.classKind == ClassKind.OBJECT) {
|
||||
return resultType.resolvedTypeFromPrototype(
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
class A {
|
||||
companion object {
|
||||
val result = "OK"
|
||||
|
||||
+1
-1
@@ -8,5 +8,5 @@ class Relevant {
|
||||
typealias Obsolete = Relevant
|
||||
|
||||
fun test1() = Obsolete
|
||||
fun test2() = Obsolete.<!UNRESOLVED_REFERENCE!>value<!>
|
||||
fun test2() = Obsolete.value
|
||||
fun test3() = Obsolete.toString()
|
||||
|
||||
+1
-1
@@ -11,5 +11,5 @@ typealias CA = C
|
||||
|
||||
val test1 = CA
|
||||
val test2 = CA.Companion
|
||||
val test3 = CA.<!UNRESOLVED_REFERENCE!>x<!>
|
||||
val test3 = CA.x
|
||||
val test4 = CA.Companion.x
|
||||
|
||||
+2
-2
@@ -21,5 +21,5 @@ typealias TestGCWC<T> = GenericClassWithCompanion<T>
|
||||
|
||||
val test25: GenericClassWithCompanion.Companion = TestGCWC
|
||||
val test26 = TestGCWC
|
||||
val test27: String = TestGCWC.<!UNRESOLVED_REFERENCE!>ok<!>
|
||||
val test28: String = TestGCWC.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
val test27: String = TestGCWC.ok
|
||||
val test28: String = TestGCWC.foo()
|
||||
|
||||
+2
-2
@@ -6,5 +6,5 @@ class C<T1, T2> {
|
||||
|
||||
typealias C2<T> = C<T, T>
|
||||
|
||||
val test1: String = C2<String>.<!UNRESOLVED_REFERENCE!>OK<!>
|
||||
val test2: String = C2.<!UNRESOLVED_REFERENCE!>OK<!>
|
||||
val test1: String = C2<String>.OK
|
||||
val test2: String = C2.OK
|
||||
|
||||
@@ -28,5 +28,5 @@ typealias TestCWC = ClassWithCompanion
|
||||
|
||||
val test35: ClassWithCompanion.Companion = TestCWC
|
||||
val test36 = TestCWC
|
||||
val test37: String = TestCWC.<!UNRESOLVED_REFERENCE!>ok<!>
|
||||
val test38: String = TestCWC.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
val test37: String = TestCWC.ok
|
||||
val test38: String = TestCWC.foo()
|
||||
|
||||
Reference in New Issue
Block a user