FIR IDE: fix reference resolve with invalid number of type args
This commit is contained in:
+1
-1
@@ -76,7 +76,7 @@ private fun ConeDiagnostic.toFirDiagnostic(
|
||||
is ConeOuterClassArgumentsRequired ->
|
||||
FirErrors.OUTER_CLASS_ARGUMENTS_REQUIRED.createOn(qualifiedAccessSource ?: source, this.symbol)
|
||||
is ConeNoTypeArgumentsOnRhsError ->
|
||||
FirErrors.NO_TYPE_ARGUMENTS_ON_RHS.createOn(qualifiedAccessSource ?: source, this.desiredCount, this.type)
|
||||
FirErrors.NO_TYPE_ARGUMENTS_ON_RHS.createOn(qualifiedAccessSource ?: source, this.desiredCount, this.symbol)
|
||||
is ConeSimpleDiagnostic -> when {
|
||||
source.kind is FirFakeSourceElementKind && source.kind != FirFakeSourceElementKind.ReferenceInAtomicQualifiedAccess -> null
|
||||
else -> this.getFactory(source).createOn(qualifiedAccessSource ?: source)
|
||||
|
||||
+10
-7
@@ -108,20 +108,23 @@ class ConeIllegalAnnotationError(val name: Name) : ConeDiagnostic() {
|
||||
override val reason: String get() = "Not a legal annotation: $name"
|
||||
}
|
||||
|
||||
abstract class ConeUnmatchedTypeArgumentsError(val desiredCount: Int, val type: FirClassLikeSymbol<*>) : ConeDiagnostic()
|
||||
interface ConeUnmatchedTypeArgumentsError {
|
||||
val desiredCount: Int
|
||||
val symbol: FirClassLikeSymbol<*>
|
||||
}
|
||||
|
||||
class ConeWrongNumberOfTypeArgumentsError(
|
||||
val desiredCount: Int,
|
||||
val symbol: FirRegularClassSymbol,
|
||||
override val desiredCount: Int,
|
||||
override val symbol: FirRegularClassSymbol,
|
||||
source: FirSourceElement
|
||||
) : ConeDiagnosticWithSource(source) {
|
||||
) : ConeDiagnosticWithSource(source), ConeUnmatchedTypeArgumentsError {
|
||||
override val reason: String get() = "Wrong number of type arguments"
|
||||
}
|
||||
|
||||
class ConeNoTypeArgumentsOnRhsError(
|
||||
desiredCount: Int,
|
||||
type: FirClassLikeSymbol<*>
|
||||
) : ConeUnmatchedTypeArgumentsError(desiredCount, type) {
|
||||
override val desiredCount: Int,
|
||||
override val symbol: FirClassLikeSymbol<*>
|
||||
) : ConeDiagnostic(), ConeUnmatchedTypeArgumentsError {
|
||||
override val reason: String get() = "No type arguments on RHS"
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ internal object FirReferenceResolveHelper {
|
||||
|
||||
val symbol = resolvedSymbol ?: run {
|
||||
val diagnostic = (this as? FirErrorTypeRef)?.diagnostic
|
||||
(diagnostic as? ConeUnmatchedTypeArgumentsError)?.type
|
||||
(diagnostic as? ConeUnmatchedTypeArgumentsError)?.symbol
|
||||
}
|
||||
|
||||
return symbol?.fir?.buildSymbol(symbolBuilder)
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package foo
|
||||
class CC<T>
|
||||
class DD<T, T2>
|
||||
|
||||
val v1 = D<caret>D<C<caret>C>
|
||||
val v1 = D<caret>D<CC>
|
||||
|
||||
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package foo
|
||||
|
||||
class CC<T>
|
||||
class DD<T, T2>
|
||||
|
||||
val v1 = DD<C<caret>C>
|
||||
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in foo) class CC<T>
|
||||
+6
@@ -576,6 +576,12 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest
|
||||
runTest("idea/idea-frontend-fir/testData/referenceResolve/WrongNumberOfTypeArguments3.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("WrongNumberOfTypeArguments4.kt")
|
||||
public void testWrongNumberOfTypeArguments4() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/referenceResolve/WrongNumberOfTypeArguments4.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("WrongNumberOfTypeArgumentsInSupertype.kt")
|
||||
public void testWrongNumberOfTypeArgumentsInSupertype() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user