Fix false positive "Cannot capture" error reporting
There is no need to report an error in case of non-top-level capture conversion, just don't add relevant capture type in the system instead If system can be solved successfully without captured type, then it's just fine (see KT-13950) In case of contradiction TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR is reported #KT-13950 Fixed
This commit is contained in:
+3
-3
@@ -3,7 +3,7 @@
|
||||
fun <T> foo(array: Array<Array<T>>): Array<Array<T>> = array
|
||||
|
||||
fun test(array: Array<Array<out Int>>) {
|
||||
<!TYPE_INFERENCE_CANNOT_CAPTURE_TYPES!>foo<!>(array)
|
||||
<!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>foo<!>(array)
|
||||
|
||||
val f: Array<out Array<out Int>> = <!TYPE_INFERENCE_CANNOT_CAPTURE_TYPES!>foo<!>(array)
|
||||
}
|
||||
val f: Array<out Array<out Int>> = <!TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>foo<!>(<!TYPE_MISMATCH!>array<!>)
|
||||
}
|
||||
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
class A<T>
|
||||
class B<T>
|
||||
|
||||
fun <E> foo(b: B<in A<E>>) {}
|
||||
fun <E> baz(b: B<out A<E>>) {}
|
||||
|
||||
// See KT-13950
|
||||
fun bar(b: B<in A<out Number>>, bOut: B<out A<out Number>>, bOut2: B<out A<Number>>) {
|
||||
foo(b)
|
||||
foo<Number>(b)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>baz<!>(bOut)
|
||||
baz<Number>(<!TYPE_MISMATCH!>bOut<!>)
|
||||
|
||||
baz(bOut2)
|
||||
baz<Number>(bOut2)
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ b: B<in A<out kotlin.Number>>, /*1*/ bOut: B<out A<out kotlin.Number>>, /*2*/ bOut2: B<out A<kotlin.Number>>): kotlin.Unit
|
||||
public fun </*0*/ E> baz(/*0*/ b: B<out A<E>>): kotlin.Unit
|
||||
public fun </*0*/ E> foo(/*0*/ b: B<in A<E>>): kotlin.Unit
|
||||
|
||||
public final class A</*0*/ T> {
|
||||
public constructor A</*0*/ T>()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B</*0*/ T> {
|
||||
public constructor B</*0*/ T>()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user