[NI] Don't report uninferred type parameter error on special functions
Type parameters can't be specified explicitly for special constructions. Reporting this error does not help fixing the cause of it and needlessly reveals implementation details. ^KT-36342 Fixed
This commit is contained in:
Generated
+10
@@ -11310,6 +11310,16 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt35943.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt35943.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36342.kt")
|
||||||
|
public void testKt36342() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt36342.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36342_2.kt")
|
||||||
|
public void testKt36342_2() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt4420.kt")
|
@TestMetadata("kt4420.kt")
|
||||||
public void testKt4420() throws Exception {
|
public void testKt4420() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||||
|
|||||||
+12
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluat
|
|||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
|
|
||||||
@@ -391,6 +392,9 @@ class DiagnosticReporterByTrackingStrategy(
|
|||||||
}
|
}
|
||||||
) return
|
) return
|
||||||
|
|
||||||
|
if (isSpecialFunction(error.resolvedAtom))
|
||||||
|
return
|
||||||
|
|
||||||
val expression = when (val atom = error.resolvedAtom.atom) {
|
val expression = when (val atom = error.resolvedAtom.atom) {
|
||||||
is PSIKotlinCall -> atom.psiCall.calleeExpression
|
is PSIKotlinCall -> atom.psiCall.calleeExpression
|
||||||
is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression()
|
is PSIKotlinCallArgument -> atom.valueArgument.getArgumentExpression()
|
||||||
@@ -407,6 +411,14 @@ class DiagnosticReporterByTrackingStrategy(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun isSpecialFunction(atom: ResolvedAtom): Boolean {
|
||||||
|
if (atom !is ResolvedCallAtom) return false
|
||||||
|
|
||||||
|
return ControlStructureTypingUtils.ResolveConstruct.values().any { specialFunction ->
|
||||||
|
specialFunction.specialFunctionName == atom.candidateDescriptor.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun reportConstantTypeMismatch(constraintError: NewConstraintError, expression: KtExpression): Boolean {
|
private fun reportConstantTypeMismatch(constraintError: NewConstraintError, expression: KtExpression): Boolean {
|
||||||
if (expression is KtConstantExpression) {
|
if (expression is KtConstantExpression) {
|
||||||
val module = context.scope.ownerDescriptor.module
|
val module = context.scope.ownerDescriptor.module
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
// !WITH_NEW_INFERENCE
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
fun test1() {
|
fun test1() {
|
||||||
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>if (<!UNRESOLVED_REFERENCE!>rr<!>) {
|
if (<!UNRESOLVED_REFERENCE!>rr<!>) {
|
||||||
if (<!UNRESOLVED_REFERENCE!>l<!>) {
|
if (<!UNRESOLVED_REFERENCE!>l<!>) {
|
||||||
<!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>q<!>()
|
<!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>q<!>()
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ fun test1() {
|
|||||||
else {
|
else {
|
||||||
<!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>u<!>()
|
<!UNRESOLVED_REFERENCE!>a<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>u<!>()
|
||||||
}
|
}
|
||||||
}<!>
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(l: List<<!UNRESOLVED_REFERENCE!>AA<!>>) {
|
fun test2(l: List<<!UNRESOLVED_REFERENCE!>AA<!>>) {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
|
fun <K> id(arg: K): K = arg
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)!!
|
||||||
|
<!UNRESOLVED_REFERENCE!>unresolved<!>!!!!
|
||||||
|
try {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
else
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
|
||||||
|
when {
|
||||||
|
true -> <!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>) ?: <!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
import java.lang.Exception
|
||||||
|
|
||||||
|
fun <K> id(arg: K): K = arg
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>unresolved<!>!!<!NI;UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
|
||||||
|
try {
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (true)
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
else
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
|
||||||
|
when {
|
||||||
|
true -> id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
}
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>) ?: id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
fun <K> id(arg: K): K = arg
|
||||||
|
fun <M> materialize(): M = TODO()
|
||||||
|
|
||||||
|
fun test(b: Boolean) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(if (b) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>id<!>(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
} else {
|
||||||
|
id(
|
||||||
|
materialize()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
fun <K> id(arg: K): K = arg
|
||||||
|
fun <M> materialize(): M = TODO()
|
||||||
|
|
||||||
|
fun test(b: Boolean) {
|
||||||
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>id<!>(if (b) {
|
||||||
|
id(<!UNRESOLVED_REFERENCE!>unresolved<!>)
|
||||||
|
} else {
|
||||||
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>id<!>(
|
||||||
|
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>materialize<!>()
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun </*0*/ K> id(/*0*/ arg: K): K
|
||||||
|
public fun </*0*/ M> materialize(): M
|
||||||
|
public fun test(/*0*/ b: kotlin.Boolean): kotlin.Unit
|
||||||
@@ -12,7 +12,7 @@ fun <T> emptyList() : List<T>? = ArrayList<T>()
|
|||||||
fun foo() {
|
fun foo() {
|
||||||
// type arguments shouldn't be required
|
// type arguments shouldn't be required
|
||||||
val <!UNUSED_VARIABLE!>l<!> : List<Int> = emptyList()!!
|
val <!UNUSED_VARIABLE!>l<!> : List<Int> = emptyList()!!
|
||||||
val <!UNUSED_VARIABLE!>l1<!> = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>!!<!>
|
val <!UNUSED_VARIABLE!>l1<!> = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()!!
|
||||||
|
|
||||||
checkSubtype<List<Int>>(emptyList()!!)
|
checkSubtype<List<Int>>(emptyList()!!)
|
||||||
checkSubtype<List<Int>?>(emptyList())
|
checkSubtype<List<Int>?>(emptyList())
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fun testElvis(x: Any?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testExclExcl() {
|
fun testExclExcl() {
|
||||||
val y = :: <!UNRESOLVED_REFERENCE!>unresolved<!><!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
val y = :: <!UNRESOLVED_REFERENCE!>unresolved<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testTry() {
|
fun testTry() {
|
||||||
|
|||||||
@@ -11317,6 +11317,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt35943.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt35943.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36342.kt")
|
||||||
|
public void testKt36342() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt36342.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36342_2.kt")
|
||||||
|
public void testKt36342_2() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt4420.kt")
|
@TestMetadata("kt4420.kt")
|
||||||
public void testKt4420() throws Exception {
|
public void testKt4420() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||||
|
|||||||
Generated
+10
@@ -11312,6 +11312,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt35943.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt35943.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36342.kt")
|
||||||
|
public void testKt36342() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt36342.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt36342_2.kt")
|
||||||
|
public void testKt36342_2() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt36342_2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt4420.kt")
|
@TestMetadata("kt4420.kt")
|
||||||
public void testKt4420() throws Exception {
|
public void testKt4420() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user