FIR checker: report non-typed LHS of callable references
This commit is contained in:
committed by
Mikhail Glukhikh
parent
329be4f906
commit
33c5b49632
+4
@@ -82,6 +82,10 @@ class ConeTypeParameterSupertype(val symbol: FirTypeParameterSymbol) : ConeDiagn
|
||||
override val reason: String get() = "Type parameter ${symbol.fir.name} cannot be a supertype"
|
||||
}
|
||||
|
||||
class ConeTypeParameterInQualifiedAccess(val symbol: FirTypeParameterSymbol) : ConeDiagnostic() {
|
||||
override val reason: String get() = "Type parameter ${symbol.fir.name} in qualified access"
|
||||
}
|
||||
|
||||
private fun describeSymbol(symbol: AbstractFirBasedSymbol<*>): String {
|
||||
return when (symbol) {
|
||||
is FirClassLikeSymbol<*> -> symbol.classId.asString()
|
||||
|
||||
+8
-4
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.FirDataFlowAnalyzer
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeTypeParameterInQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.resolve.inference.*
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirArrayOfCallTransformer
|
||||
@@ -89,11 +90,14 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
// e.g. `T::toString` where T is a generic type.
|
||||
// in these cases we should report an error on
|
||||
// the calleeReference.source which is not a fake source.
|
||||
// uncommenting `?.fakeElement...` here removes reports
|
||||
// of OTHER_ERROR from tests.
|
||||
buildErrorTypeRef {
|
||||
source = calleeReference.source //?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)
|
||||
diagnostic = ConeSimpleDiagnostic("Callee reference to candidate without return type: ${declaration.render()}")
|
||||
source = calleeReference.source?.fakeElement(FirFakeSourceElementKind.ImplicitTypeRef)
|
||||
diagnostic =
|
||||
when (declaration) {
|
||||
is FirTypeParameter -> ConeTypeParameterInQualifiedAccess(declaration.symbol)
|
||||
is FirResolvedReifiedParameterReference -> ConeTypeParameterInQualifiedAccess(declaration.symbol)
|
||||
else -> ConeSimpleDiagnostic("Callee reference to candidate without return type: ${declaration.render()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user