mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-18 08:31:38 +00:00
See doNotCaptureSupertype test for clarification: When resolving b.collect(toList()) we're building a common system with two variables T and R. The problem was that when introducing the constraint C<T, Inv<T>> <: C<in String, R> we then were seeing the constraint T <= in String, and add the constaint T=Captured(in String) That lead to R=Inv<T>=Inv<Captured(in String)>, and after approximation R=Inv<in String>, that is not the desirable result (Inv<String> suits here) But the root problem was that we add captured constaint when projection was from supertype, that seems to be wrong, and for example Java doesn't do that in the similar situation. #KT-11259 Fixed
12 lines
315 B
Kotlin
Vendored
12 lines
315 B
Kotlin
Vendored
// !CHECK_TYPE
|
|
// SKIP_TXT
|
|
import java.util.stream.Collectors
|
|
import java.util.stream.Stream
|
|
|
|
fun test(a: Stream<String>) {
|
|
a.collect(Collectors.toList()) checkType { _<MutableList<String>>() }
|
|
// actually the inferred type is platform
|
|
a.collect(Collectors.toList()) checkType { _<List<String?>>() }
|
|
}
|
|
|