From d1acb09addc47e47b3123c915fc2aac6f4aa030d Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Wed, 27 Oct 2021 11:24:04 +0300 Subject: [PATCH] Report unsupported on using underscored type argument if the corresponding feature is disabled --- .../jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt | 6 +++++- .../tests/inference/underscoredTypeArgument.fir.kt | 2 +- .../diagnostics/tests/inference/underscoredTypeArgument.kt | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt index 2a38759d15d..2f2eab86c23 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/PSICallResolver.kt @@ -691,7 +691,7 @@ class PSICallResolver( val typeReference = projection.typeReference ?: return@map TypeArgumentPlaceholder - if (typeReference.isPlaceholder && arePartiallySpecifiedTypeArgumentsEnabled) { + if (typeReference.isPlaceholder) { val resolvedAnnotations = typeResolver.resolveTypeAnnotations(context.trace, context.scope, typeReference) .apply(ForceResolveUtil::forceResolveAllContents) @@ -700,6 +700,10 @@ class PSICallResolver( context.trace.report(Errors.UNSUPPORTED.on(annotationElement, "annotations on an underscored type argument")) } + if (!arePartiallySpecifiedTypeArgumentsEnabled) { + context.trace.report(Errors.UNSUPPORTED.on(typeReference, "underscored type argument")) + } + return@map TypeArgumentPlaceholder } diff --git a/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.fir.kt b/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.fir.kt index cf7e90aab08..83466923b98 100644 --- a/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.fir.kt @@ -1,4 +1,4 @@ -// FIR_IDENTICAL +// !LANGUAGE: -PartiallySpecifiedTypeArguments // !DIAGNOSTICS: -UNCHECKED_CAST // WITH_RUNTIME diff --git a/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.kt b/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.kt index 0d9879e1d42..bbe9b79b2f7 100644 --- a/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.kt +++ b/compiler/testData/diagnostics/tests/inference/underscoredTypeArgument.kt @@ -1,9 +1,10 @@ +// !LANGUAGE: -PartiallySpecifiedTypeArguments // !DIAGNOSTICS: -UNCHECKED_CAST // WITH_RUNTIME fun foo(x: (K) -> T): Pair = (1 as K) to (1f as T) fun box(): String { - val x = foo_> { it.toFloat() } // Pair + val x = foo_> { it.toFloat() } // Pair return "OK" }