Fix exception on resolving collection literal inside lambda

#KT-31907 Fixed
 #EA-90906 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2020-12-08 04:02:36 +03:00
parent c5015c9294
commit 2ad4824eb0
7 changed files with 37 additions and 2 deletions
@@ -19071,6 +19071,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt");
}
@TestMetadata("resolveCollectionLiteralInsideLambda.kt")
public void testResolveCollectionLiteralInsideLambda() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt");
}
@TestMetadata("resolveSubclassOfList.kt")
public void testResolveSubclassOfList() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt");
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.BindingContext.COLLECTION_LITERAL_CALL
import org.jetbrains.kotlin.resolve.calls.CallResolver
import org.jetbrains.kotlin.resolve.calls.util.CallMaker
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
@@ -94,7 +94,7 @@ class CollectionLiteralResolver(
}
private fun getArrayFunctionCallName(expectedType: KotlinType): Name {
if (NO_EXPECTED_TYPE === expectedType ||
if (TypeUtils.noExpectedType(expectedType) ||
!(KotlinBuiltIns.isPrimitiveArray(expectedType) || KotlinBuiltIns.isUnsignedArrayType(expectedType))
) {
return ArrayFqNames.ARRAY_OF_FUNCTION
@@ -0,0 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(l: () -> Unit) {}
fun bar(l: () -> String) {}
val a = foo { [] }
val b = bar { [] }
@@ -0,0 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(l: () -> Unit) {}
fun bar(l: () -> String) {}
val a = foo { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, UNSUPPORTED!>[]<!> }
val b = bar { <!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH, UNSUPPORTED!>[]<!> }
@@ -0,0 +1,6 @@
package
public val a: kotlin.Unit
public val b: kotlin.Unit
public fun bar(/*0*/ l: () -> kotlin.String): kotlin.Unit
public fun foo(/*0*/ l: () -> kotlin.Unit): kotlin.Unit
@@ -19083,6 +19083,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt");
}
@TestMetadata("resolveCollectionLiteralInsideLambda.kt")
public void testResolveCollectionLiteralInsideLambda() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt");
}
@TestMetadata("resolveSubclassOfList.kt")
public void testResolveSubclassOfList() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt");
@@ -19073,6 +19073,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt");
}
@TestMetadata("resolveCollectionLiteralInsideLambda.kt")
public void testResolveCollectionLiteralInsideLambda() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt");
}
@TestMetadata("resolveSubclassOfList.kt")
public void testResolveSubclassOfList() throws Exception {
runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt");