[FIR] KT-58719: Check all imported declarations for visibility
Unfortunately, we have to check callables even if the class is inaccessible. ^KT-58719 Fixed
This commit is contained in:
committed by
Space Team
parent
f446fc4154
commit
710a8f4e0f
+18
-10
@@ -103,25 +103,33 @@ object FirImportsChecker : FirFileChecker() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val resolvedClassSymbol = ClassId.topLevel(importedFqName).resolveToClass(context)
|
var resolvedDeclaration: FirMemberDeclaration? = null
|
||||||
|
|
||||||
if (resolvedClassSymbol != null) {
|
ClassId.topLevel(importedFqName).resolveToClass(context)?.let {
|
||||||
if (!resolvedClassSymbol.fir.isVisible(context)) {
|
resolvedDeclaration = it.fir
|
||||||
reporter.reportOn(import.getSourceForImportSegment(0), FirErrors.INVISIBLE_REFERENCE, resolvedClassSymbol, context)
|
|
||||||
|
if (it.fir.isVisible(context)) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: two checks below are both heavyweight, so we should do them lazily!
|
// Note: two checks below are both heavyweight, so we should do them lazily!
|
||||||
|
|
||||||
val topLevelCallableSymbol = symbolProvider.getTopLevelCallableSymbols(importedFqName.parent(), importedName)
|
val topLevelCallableSymbol = symbolProvider.getTopLevelCallableSymbols(importedFqName.parent(), importedName)
|
||||||
if (topLevelCallableSymbol.isNotEmpty()) {
|
|
||||||
if (topLevelCallableSymbol.none { it.fir.isVisible(context) }) {
|
for (it in topLevelCallableSymbol) {
|
||||||
val source = import.getSourceForImportSegment(0)
|
if (it.fir.isVisible(context)) {
|
||||||
reporter.reportOn(source, FirErrors.INVISIBLE_REFERENCE, topLevelCallableSymbol.first(), context)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (resolvedDeclaration == null) {
|
||||||
|
resolvedDeclaration = it.fir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resolvedDeclaration?.let {
|
||||||
|
val source = import.getSourceForImportSegment(0)
|
||||||
|
reporter.reportOn(source, FirErrors.INVISIBLE_REFERENCE, it.symbol, context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fun <RowType : Any> QueryPagingSource(randomParam: Int) {}
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import pagind.<!INVISIBLE_REFERENCE!>QueryPagingSource<!>
|
import pagind.QueryPagingSource
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
QueryPagingSource<Int>(10)
|
QueryPagingSource<Int>(10)
|
||||||
|
|||||||
Reference in New Issue
Block a user