[FIR] Make resolution of classes in FirProvider more reasonable.
See the `privateInFile.fir.kt` test. Type mismatches are simply confusing. `inheritorOfExpectSealedClass.out` reports unresolved reference probably because now it resolves into the expect declaration, rather than the actual one. K1 doesn't report UNRESOLVED_REFERENCE in this case. But this is red code anyway. And this behavior still depends on the order in which the compiler receives both the declarations. ^KT-59927 ^KT-62567
This commit is contained in:
committed by
Space Team
parent
a9ceae9667
commit
41c3f98419
+12
-4
@@ -123,8 +123,12 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli
|
||||
override fun visitRegularClass(regularClass: FirRegularClass, data: FirRecorderData) {
|
||||
val classId = regularClass.symbol.classId
|
||||
val prevFile = data.state.classifierContainerFileMap.put(classId, data.file)
|
||||
data.state.classifierMap.put(classId, regularClass)?.let {
|
||||
data.nameConflictsTracker?.registerClassifierRedeclaration(classId, regularClass.symbol, data.file, it.symbol, prevFile)
|
||||
val storedClassifier = data.state.classifierMap.getOrPut(classId) { regularClass }
|
||||
|
||||
if (storedClassifier != regularClass) {
|
||||
data.nameConflictsTracker?.registerClassifierRedeclaration(
|
||||
classId, regularClass.symbol, data.file, storedClassifier.symbol, prevFile,
|
||||
)
|
||||
}
|
||||
|
||||
if (!classId.isNestedClass && !classId.isLocal) {
|
||||
@@ -138,8 +142,12 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli
|
||||
override fun visitTypeAlias(typeAlias: FirTypeAlias, data: FirRecorderData) {
|
||||
val classId = typeAlias.symbol.classId
|
||||
val prevFile = data.state.classifierContainerFileMap.put(classId, data.file)
|
||||
data.state.classifierMap.put(classId, typeAlias)?.let {
|
||||
data.nameConflictsTracker?.registerClassifierRedeclaration(classId, typeAlias.symbol, data.file, it.symbol, prevFile)
|
||||
val storedClassifier = data.state.classifierMap.getOrPut(classId) { typeAlias }
|
||||
|
||||
if (storedClassifier != typeAlias) {
|
||||
data.nameConflictsTracker?.registerClassifierRedeclaration(
|
||||
classId, typeAlias.symbol, data.file, storedClassifier.symbol, prevFile,
|
||||
)
|
||||
}
|
||||
|
||||
data.state.classifierInPackage.getOrPut(classId.packageFqName, ::mutableSetOf).add(classId.shortClassName)
|
||||
|
||||
Reference in New Issue
Block a user