Relax rules about inferring to Nothing for special calls
#KT-37388 Fixed #KT-38427 Fixed #KT-39953 Fixed #KT-38899 Fixed
This commit is contained in:
@@ -6,8 +6,8 @@ fun main() {
|
||||
val x1: String.() -> String = if (true) {{ this }} else {{ this }}
|
||||
val x2: String.() -> String = if (true) {{ -> this }} else {{ -> this }}
|
||||
val x3: () -> String = if (true) {{ -> "this" }} else {{ -> "this" }}
|
||||
val x4: String.() -> String = if (true) {{ str: String -> "this" }} else {{ str: String -> "this" }}
|
||||
val x41: String.(String) -> String = if (true) {{ str: String, str2: String -> "this" }} else {{ str: String, str2: String -> "this" }}
|
||||
val x4: String.() -> String = if (true) <!TYPE_MISMATCH!>{{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str: String<!> -> "this" }}<!> else <!TYPE_MISMATCH!>{{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str: String<!> -> "this" }}<!>
|
||||
val x41: String.(String) -> String = if (true) <!TYPE_MISMATCH!>{{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str: String, str2: String<!> -> "this" }}<!> else <!TYPE_MISMATCH!>{{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str: String, str2: String<!> -> "this" }}<!>
|
||||
val x42: String.(String) -> String = if (true) <!TYPE_MISMATCH!>{{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str, <!CANNOT_INFER_PARAMETER_TYPE!>str2<!><!> -> "this" }}<!> else <!TYPE_MISMATCH!>{{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str, <!CANNOT_INFER_PARAMETER_TYPE!>str2<!><!> -> "this" }}<!>
|
||||
val x5: String.() -> String = if (true) <!TYPE_MISMATCH!>{{ <!CANNOT_INFER_PARAMETER_TYPE, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str<!> -> "this" }}<!> else <!TYPE_MISMATCH!>{{ <!CANNOT_INFER_PARAMETER_TYPE, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str<!> -> "this" }}<!>
|
||||
val x6: String.() -> String = if (true) <!TYPE_MISMATCH!>{{ <!CANNOT_INFER_PARAMETER_TYPE, EXPECTED_PARAMETERS_NUMBER_MISMATCH!>str<!> -> "this" }}<!> else {{ "this" }}
|
||||
|
||||
Vendored
+1
-1
@@ -25,5 +25,5 @@ fun test(s: SelectorFor<State>): Double {
|
||||
val e = s { return p1 }
|
||||
e checkType { _<AbstractSelector<State, Nothing>>() }
|
||||
|
||||
<!UNREACHABLE_CODE!>return<!> null!!
|
||||
<!OI;UNREACHABLE_CODE!>return<!> null!!
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
fun <A, B> Either<A, B>.recover(f: (A) -> B): Either<A, B> = when (this) {
|
||||
is Either.Left -> f(<!DEBUG_INFO_SMARTCAST!>this<!>.a).right()
|
||||
is Either.Right -> <!NI;DEBUG_INFO_SMARTCAST!>this<!>
|
||||
is Either.Right -> this
|
||||
}
|
||||
|
||||
fun <A> A.right(): Either<Nothing, A> = Either.Right(this)
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Foo<T> {
|
||||
private fun append(map: MutableMap<String, T>, field: String, appendedValue: T?) {
|
||||
if (appendedValue != null) {
|
||||
var currentValue: T? = map[field]
|
||||
currentValue = if (currentValue == null) {
|
||||
appendedValue
|
||||
} else {
|
||||
or(currentValue, appendedValue)
|
||||
}
|
||||
map[field] = currentValue
|
||||
}
|
||||
}
|
||||
|
||||
fun or(left: T, right: T): T = left
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
|
||||
class Foo<T> {
|
||||
private fun append(map: MutableMap<String, T>, field: String, appendedValue: T?) {
|
||||
if (appendedValue != null) {
|
||||
var currentValue: T? = map[field]
|
||||
currentValue = if (currentValue == null) {
|
||||
appendedValue
|
||||
} else {
|
||||
or(<!DEBUG_INFO_SMARTCAST!>currentValue<!>, <!DEBUG_INFO_SMARTCAST!>appendedValue<!>)
|
||||
}
|
||||
map[field] = <!DEBUG_INFO_SMARTCAST!>currentValue<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun or(left: T, right: T): T = left
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
public final class Foo</*0*/ T> {
|
||||
public constructor Foo</*0*/ T>()
|
||||
private final fun append(/*0*/ map: kotlin.collections.MutableMap<kotlin.String, T>, /*1*/ field: kotlin.String, /*2*/ appendedValue: T?): 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 final fun or(/*0*/ left: T, /*1*/ right: T): T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+2
-2
@@ -27,8 +27,8 @@ inline fun <reified T : In<T>> testIn(): T {
|
||||
|
||||
// Unexpected behaviour
|
||||
inline fun <reified T : Out<T>> testOut(): T {
|
||||
<!UNREACHABLE_CODE!>return<!> try {
|
||||
<!IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION, REIFIED_TYPE_FORBIDDEN_SUBSTITUTION!>outBound<!>()
|
||||
return try {
|
||||
outBound()
|
||||
} catch (ex: Exception) {
|
||||
throw Exception()
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun foo() {
|
||||
val s: String? = if (true) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing?")!>materialize()<!> else null
|
||||
}
|
||||
|
||||
fun <K> materialize(): K = TODO()
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
fun foo() {
|
||||
val s: String? = if (true) <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String?")!>materialize()<!> else null
|
||||
}
|
||||
|
||||
fun <K> materialize(): K = TODO()
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
public fun </*0*/ K> materialize(): K
|
||||
Reference in New Issue
Block a user