Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableCollection.fir.kt
T
Denis.Zharkov f70ae2df3a FIR: Refine inference constraints when type variable in flexible position
That issue might be fixed via changing
TypeVariableMarker.shouldBeFlexible at ConeConstraintSystemUtilContext
but this and some other tricks have been added because of incorrect
handling of constraints where type variable has a flexible bound

^KT-51168 Fixed
2022-05-19 16:53:59 +00:00

33 lines
589 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_VARIABLE
// JAVAC_EXPECTED_FILE
import java.util.*;
// FILE: A.java
@kotlin.jvm.PurelyImplements("kotlin.collections.MutableCollection")
class A<T> extends AbstractCollection<T> {
@Override
public Iterator<T> iterator() {
return null;
}
@Override
public int size() {
return 0;
}
}
// FILE: b.kt
fun bar(): String? = null
fun foo() {
var x = A<String>()
x.add(null)
x.add(bar())
x.add("")
val b1: Collection<String?> = x
val b2: MutableCollection<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
}