Fail calls constraints of which contain uninferred type parameter
^KT-44055 Fixed It's possible only if there is a callable reference among subcalls which go though the old type inference (and the error for uninferred type parameter wasn't reported)
This commit is contained in:
+7
-3
@@ -141,8 +141,12 @@ class VariableFixationFinder(
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Context.variableHasProperArgumentConstraints(variable: TypeConstructorMarker): Boolean =
|
private fun Context.variableHasProperArgumentConstraints(variable: TypeConstructorMarker): Boolean {
|
||||||
notFixedTypeVariables[variable]?.constraints?.any { isProperArgumentConstraint(it) } ?: false
|
val constraints = notFixedTypeVariables[variable]?.constraints ?: return false
|
||||||
|
// temporary hack to fail calls which contain callable references resolved though OI with uninferred type parameters
|
||||||
|
val areThereConstraintsWithUninferredTypeParameter = constraints.any { c -> c.type.contains { it.isUninferredParameter() } }
|
||||||
|
return constraints.any { isProperArgumentConstraint(it) } && !areThereConstraintsWithUninferredTypeParameter
|
||||||
|
}
|
||||||
|
|
||||||
private fun Context.isProperArgumentConstraint(c: Constraint) =
|
private fun Context.isProperArgumentConstraint(c: Constraint) =
|
||||||
isProperType(c.type)
|
isProperType(c.type)
|
||||||
@@ -167,7 +171,7 @@ inline fun TypeSystemInferenceExtensionContext.isProperTypeForFixation(
|
|||||||
type: KotlinTypeMarker,
|
type: KotlinTypeMarker,
|
||||||
isProper: (KotlinTypeMarker) -> Boolean
|
isProper: (KotlinTypeMarker) -> Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (!isProper(type) || type.contains { it.isUninferredParameter() }) return false
|
if (!isProper(type)) return false
|
||||||
if (type.isCapturedType()) {
|
if (type.isCapturedType()) {
|
||||||
val projection = (type as? SimpleTypeMarker)?.asCapturedType()?.typeConstructorProjection() ?: return true
|
val projection = (type as? SimpleTypeMarker)?.asCapturedType()?.typeConstructorProjection() ?: return true
|
||||||
if (projection.isStarProjection()) return true
|
if (projection.isStarProjection()) return true
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
import kotlin.experimental.ExperimentalTypeInference
|
import kotlin.experimental.ExperimentalTypeInference
|
||||||
|
|
||||||
|
|||||||
-29
@@ -32,12 +32,6 @@ fun poll16(flag: Boolean): Any? {
|
|||||||
return inv()
|
return inv()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
//fun poll17(flag: Boolean): Any? {
|
|
||||||
// val inv = if (flag) { foo7() } else { ::Foo7 }
|
|
||||||
// return inv
|
|
||||||
//}
|
|
||||||
|
|
||||||
fun poll21(flag: Boolean): Any? {
|
fun poll21(flag: Boolean): Any? {
|
||||||
val inv = when (flag) { true -> ::bar2 else -> ::foo2 }
|
val inv = when (flag) { true -> ::bar2 else -> ::foo2 }
|
||||||
return inv()
|
return inv()
|
||||||
@@ -48,12 +42,6 @@ fun poll25(flag: Boolean): Any? {
|
|||||||
return inv
|
return inv
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
//fun poll26(flag: Boolean): Any? {
|
|
||||||
// val inv = when (flag) { true -> ::Foo7 false -> foo7() else -> ::Foo7 }
|
|
||||||
// return inv
|
|
||||||
//}
|
|
||||||
|
|
||||||
fun poll31(flag: Boolean): Any? {
|
fun poll31(flag: Boolean): Any? {
|
||||||
val inv = when (flag) { true -> ::bar2 false -> ::foo2 }
|
val inv = when (flag) { true -> ::bar2 false -> ::foo2 }
|
||||||
return inv()
|
return inv()
|
||||||
@@ -64,12 +52,6 @@ fun poll35(flag: Boolean): Any? {
|
|||||||
return inv
|
return inv
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
//fun poll36(flag: Boolean): Any? {
|
|
||||||
// val inv = when (flag) { true -> ::Foo7 false -> foo7() }
|
|
||||||
// return inv
|
|
||||||
//}
|
|
||||||
|
|
||||||
fun poll41(): Any? {
|
fun poll41(): Any? {
|
||||||
val inv = try { ::bar2 } finally { ::foo2 }
|
val inv = try { ::bar2 } finally { ::foo2 }
|
||||||
return inv()
|
return inv()
|
||||||
@@ -90,12 +72,6 @@ fun poll55(): Any? {
|
|||||||
return inv()
|
return inv()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
//fun poll56(): Any? {
|
|
||||||
// val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() }
|
|
||||||
// return inv
|
|
||||||
//}
|
|
||||||
|
|
||||||
fun poll61(): Any? {
|
fun poll61(): Any? {
|
||||||
val inv = ::bar2
|
val inv = ::bar2
|
||||||
return inv
|
return inv
|
||||||
@@ -121,7 +97,6 @@ fun poll81(): Any? {
|
|||||||
return inv
|
return inv
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun poll85(): Any? {
|
fun poll85(): Any? {
|
||||||
val inv = ::Foo6 in setOf(::Foo6)
|
val inv = ::Foo6 in setOf(::Foo6)
|
||||||
return inv
|
return inv
|
||||||
@@ -131,18 +106,14 @@ fun box(): String {
|
|||||||
poll1(true)
|
poll1(true)
|
||||||
poll11(true)
|
poll11(true)
|
||||||
poll16(true)
|
poll16(true)
|
||||||
// poll17(true)
|
|
||||||
poll21(true)
|
poll21(true)
|
||||||
poll25(true)
|
poll25(true)
|
||||||
// poll26(true)
|
|
||||||
poll31(true)
|
poll31(true)
|
||||||
poll35(true)
|
poll35(true)
|
||||||
// poll36(true)
|
|
||||||
poll41()
|
poll41()
|
||||||
poll45()
|
poll45()
|
||||||
poll51()
|
poll51()
|
||||||
poll55()
|
poll55()
|
||||||
// poll56()
|
|
||||||
poll61()
|
poll61()
|
||||||
poll65()
|
poll65()
|
||||||
poll71()
|
poll71()
|
||||||
|
|||||||
compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.kt
Vendored
+6
-6
@@ -136,8 +136,8 @@ fun poll16(flag: Boolean): Flow<String> {
|
|||||||
|
|
||||||
fun poll17(flag: Boolean): Flow<String> {
|
fun poll17(flag: Boolean): Flow<String> {
|
||||||
return flow {
|
return flow {
|
||||||
val inv = if (flag) { <!IMPLICIT_CAST_TO_ANY!>foo7()<!> } else { <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> }
|
val inv = if (flag) { foo7() } else { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||||
inv
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ fun poll25(flag: Boolean): Flow<String> {
|
|||||||
|
|
||||||
fun poll26(flag: Boolean): Flow<String> {
|
fun poll26(flag: Boolean): Flow<String> {
|
||||||
return flow {
|
return flow {
|
||||||
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> }
|
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> <!IMPLICIT_CAST_TO_ANY, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||||
inv
|
inv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,7 +234,7 @@ fun poll35(flag: Boolean): Flow<String> {
|
|||||||
|
|
||||||
fun poll36(flag: Boolean): Flow<String> {
|
fun poll36(flag: Boolean): Flow<String> {
|
||||||
return flow {
|
return flow {
|
||||||
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> }
|
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> }
|
||||||
inv
|
inv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,8 +332,8 @@ fun poll55(): Flow<String> {
|
|||||||
|
|
||||||
fun poll56(): Flow<String> {
|
fun poll56(): Flow<String> {
|
||||||
return flow {
|
return flow {
|
||||||
val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() }
|
val inv = try { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> } catch (e: Exception) { foo7() } finally { foo7() }
|
||||||
inv
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -85,8 +85,8 @@ fun poll16(flag: Boolean): Flow<String> {
|
|||||||
|
|
||||||
fun poll17(flag: Boolean): Flow<String> {
|
fun poll17(flag: Boolean): Flow<String> {
|
||||||
return flow {
|
return flow {
|
||||||
val inv = if (flag) { <!IMPLICIT_CAST_TO_ANY!>foo7()<!> } else { <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> }
|
val inv = if (flag) { foo7() } else { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||||
inv
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ fun poll55(): Flow<String> {
|
|||||||
|
|
||||||
fun poll56(): Flow<String> {
|
fun poll56(): Flow<String> {
|
||||||
return flow {
|
return flow {
|
||||||
val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() }
|
val inv = try { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> } catch (e: Exception) { foo7() } finally { foo7() }
|
||||||
inv
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -9,8 +9,8 @@ class Foo7<T>
|
|||||||
fun foo7() = null as Foo7<Int>
|
fun foo7() = null as Foo7<Int>
|
||||||
|
|
||||||
fun poll17(flag: Boolean): Any? {
|
fun poll17(flag: Boolean): Any? {
|
||||||
val inv = if (flag) { <!IMPLICIT_CAST_TO_ANY!>foo7()<!> } else { <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> }
|
val inv = if (flag) { foo7() } else { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||||
return inv
|
return <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun poll26(flag: Boolean): Any? {
|
fun poll26(flag: Boolean): Any? {
|
||||||
@@ -24,6 +24,6 @@ fun poll36(flag: Boolean): Any? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun poll56(): Any? {
|
fun poll56(): Any? {
|
||||||
val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() }
|
val inv = try { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> } catch (e: Exception) { foo7() } finally { foo7() }
|
||||||
return inv
|
return <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -3,10 +3,10 @@
|
|||||||
class Foo
|
class Foo
|
||||||
|
|
||||||
fun main1() = when {
|
fun main1() = when {
|
||||||
else -> <!TYPE_MISMATCH!>Foo::plus<!>
|
else -> <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_MISMATCH!>Foo::plus<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main2() = if (true) Foo::<!UNRESOLVED_REFERENCE!>minus<!> else Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
fun main2() = if (true) <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo::<!UNRESOLVED_REFERENCE!>minus<!><!> else <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>Foo::<!UNRESOLVED_REFERENCE!>times<!><!>
|
||||||
|
|
||||||
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -54,8 +54,8 @@ fun poll16(flag: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun poll17(flag: Boolean) {
|
fun poll17(flag: Boolean) {
|
||||||
val inv = if (flag) { <!IMPLICIT_CAST_TO_ANY!>foo7()<!> } else { <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> }
|
val inv = if (flag) { foo7() } else { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||||
inv
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun poll2(flag: Boolean) {
|
fun poll2(flag: Boolean) {
|
||||||
@@ -89,7 +89,7 @@ fun poll25(flag: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun poll26(flag: Boolean) {
|
fun poll26(flag: Boolean) {
|
||||||
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> }
|
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> <!IMPLICIT_CAST_TO_ANY, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> }
|
||||||
inv
|
inv
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ fun poll35(flag: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun poll36(flag: Boolean) {
|
fun poll36(flag: Boolean) {
|
||||||
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> }
|
val inv = when (flag) { true -> <!IMPLICIT_CAST_TO_ANY, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> false -> <!IMPLICIT_CAST_TO_ANY!>foo7()<!> }
|
||||||
inv
|
inv
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +194,8 @@ fun poll55() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun poll56() {
|
fun poll56() {
|
||||||
val inv = try { ::Foo7 } catch (e: Exception) { foo7() } finally { foo7() }
|
val inv = try { <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>::Foo7<!> } catch (e: Exception) { foo7() } finally { foo7() }
|
||||||
inv
|
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>inv<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
fun poll6() {
|
fun poll6() {
|
||||||
|
|||||||
Reference in New Issue
Block a user