[FE] Properly report diagnostics about type arguments of implicit invoke
#KT-40396 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
329066a4f3
commit
44948aa9a2
+5
@@ -10447,6 +10447,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt39220.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt39220.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt40396.kt")
|
||||||
|
public void testKt40396() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/kt40396.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
||||||
|
|||||||
+1
-1
@@ -436,8 +436,8 @@ class DiagnosticReporterByTrackingStrategy(
|
|||||||
|
|
||||||
if (isSpecialFunction(error.resolvedAtom))
|
if (isSpecialFunction(error.resolvedAtom))
|
||||||
return
|
return
|
||||||
|
|
||||||
val expression = when (val atom = error.resolvedAtom.atom) {
|
val expression = when (val atom = error.resolvedAtom.atom) {
|
||||||
|
is PSIKotlinCallForInvoke -> (atom.psiCall as? CallTransformer.CallForImplicitInvoke)?.outerCall?.calleeExpression
|
||||||
is PSIKotlinCall -> atom.psiCall.calleeExpression
|
is PSIKotlinCall -> atom.psiCall.calleeExpression
|
||||||
is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression()
|
is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression()
|
||||||
else -> call.calleeExpression
|
else -> call.calleeExpression
|
||||||
|
|||||||
+2
-9
@@ -24,10 +24,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
|||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.psi.Call
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
|
|
||||||
import org.jetbrains.kotlin.psi.KtDestructuringDeclarationEntry
|
|
||||||
import org.jetbrains.kotlin.psi.KtOperationReferenceExpression
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
||||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isConventionCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
@@ -52,11 +49,7 @@ class OperatorCallChecker : CallChecker {
|
|||||||
val containingDeclarationName = functionDescriptor.containingDeclaration.fqNameUnsafe.asString()
|
val containingDeclarationName = functionDescriptor.containingDeclaration.fqNameUnsafe.asString()
|
||||||
context.trace.report(Errors.PROPERTY_AS_OPERATOR.on(reportOn, functionDescriptor, containingDeclarationName))
|
context.trace.report(Errors.PROPERTY_AS_OPERATOR.on(reportOn, functionDescriptor, containingDeclarationName))
|
||||||
} else if (isWrongCallWithExplicitTypeArguments(resolvedCall, outerCall)) {
|
} else if (isWrongCallWithExplicitTypeArguments(resolvedCall, outerCall)) {
|
||||||
throw AssertionError(
|
context.trace.report(Errors.TYPE_ARGUMENTS_NOT_ALLOWED.on(reportOn as KtElement, "on implicit invoke call"))
|
||||||
"Illegal resolved call to variable with invoke for $outerCall. " +
|
|
||||||
"Variable: ${resolvedCall.variableCall.resultingDescriptor}" +
|
|
||||||
"Invoke: ${resolvedCall.functionCall.resultingDescriptor}"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// ISSUE: KT-40396
|
||||||
|
|
||||||
|
val <C> C.foo get() = Foo<C>()
|
||||||
|
|
||||||
|
class Foo<K> {
|
||||||
|
operator fun <T> invoke(body: () -> Unit) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar {
|
||||||
|
val bar = foo {}
|
||||||
|
val baz = foo<Int> {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
// ISSUE: KT-40396
|
||||||
|
|
||||||
|
val <C> C.foo get() = Foo<C>()
|
||||||
|
|
||||||
|
class Foo<K> {
|
||||||
|
operator fun <T> invoke(body: () -> Unit) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar {
|
||||||
|
val bar = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> {}
|
||||||
|
val baz = <!TYPE_ARGUMENTS_NOT_ALLOWED!>foo<!><Int> {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val </*0*/ C> C.foo: Foo<C>
|
||||||
|
|
||||||
|
public final class Bar {
|
||||||
|
public constructor Bar()
|
||||||
|
public final val bar: kotlin.Unit
|
||||||
|
public final val baz: kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Foo</*0*/ K> {
|
||||||
|
public constructor Foo</*0*/ K>()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final operator fun </*0*/ T> invoke(/*0*/ body: () -> kotlin.Unit): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
+5
@@ -10454,6 +10454,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt39220.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt39220.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt40396.kt")
|
||||||
|
public void testKt40396() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/kt40396.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10449,6 +10449,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/kt39220.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt39220.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt40396.kt")
|
||||||
|
public void testKt40396() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/kt40396.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt6175.kt")
|
@TestMetadata("kt6175.kt")
|
||||||
public void testKt6175() throws Exception {
|
public void testKt6175() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user