FIR: add a boolean tracking if a class ref resolves to the companion object

This commit is contained in:
Tianyu Geng
2021-06-08 17:58:29 -07:00
committed by Ilya Kirillov
parent 45ccec3b64
commit a537074e1e
12 changed files with 82 additions and 0 deletions
@@ -469,6 +469,27 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
useTypes(expressionType)
}
impl(resolvedQualifier) {
// Initialize the value to true if only the companion object is present. This makes a standalone class reference expression
// correctly resolve to the companion object. For example
// ```
// class A {
// companion object
// }
//
// val companionOfA = A // This standalone class reference `A` here should resolve to the companion object.
// ```
//
// If this `FirResolvedQualifier` is a receiver expression of some other qualified access, the value is updated in
// `FirCallResolver` according to the resolution result.
default("resolvedToCompanionObject", "(symbol?.fir as? FirRegularClass)?.companionObject != null")
useTypes(regularClass)
}
impl(errorResolvedQualifier) {
defaultFalse("resolvedToCompanionObject", withGetter = true)
}
noImpl(userTypeRef)
}
@@ -516,6 +516,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
+field("classId", classIdType, nullable = true)
+field("symbol", classLikeSymbolType, nullable = true)
+booleanField("isNullableLHSForCallableReference", withReplace = true)
+booleanField("resolvedToCompanionObject", withReplace = true)
+typeArguments.withTransform()
}