9ec0210c04
When a type annotated with @PurelyImplements (explicitly or implicitly) inherited some methods from a java supertype and the purely implemented Kotlin supertype, it was inconsistent which of the signatures the intersection override would have (with or without flexible types). This commit adds support for the enhancement of intersection overrides. If one of the overridden methods has non-flexible types, the enhanced method will have non-flexible types. This fixes some false negative nullability type mismatches. #KT-59921 Fixed
49 lines
1.3 KiB
Kotlin
Vendored
49 lines
1.3 KiB
Kotlin
Vendored
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
|
// FULL_JDK
|
|
|
|
import java.util.*
|
|
|
|
fun bar(): String? = null
|
|
|
|
fun fooHashSet() {
|
|
var x = HashSet<String>()
|
|
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
|
x.add(<!ARGUMENT_TYPE_MISMATCH!>bar()<!>)
|
|
x.add("")
|
|
|
|
val b1: MutableSet<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
|
val b2: MutableSet<String> = x
|
|
val b3: Set<String?> = x
|
|
|
|
val b4: Collection<String?> = x
|
|
val b6: MutableCollection<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
|
}
|
|
|
|
fun fooTreeSet() {
|
|
var x = TreeSet<String>()
|
|
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
|
x.add(<!ARGUMENT_TYPE_MISMATCH!>bar()<!>)
|
|
x.add("")
|
|
|
|
val b1: MutableSet<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
|
val b2: MutableSet<String> = x
|
|
val b3: Set<String?> = x
|
|
|
|
val b4: Collection<String?> = x
|
|
val b6: MutableCollection<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
|
}
|
|
|
|
fun fooLinkedHashSet() {
|
|
var x = LinkedHashSet<String>()
|
|
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
|
|
x.add(<!ARGUMENT_TYPE_MISMATCH!>bar()<!>)
|
|
x.add("")
|
|
|
|
val b1: MutableSet<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
|
val b2: MutableSet<String> = x
|
|
val b3: Set<String?> = x
|
|
|
|
val b4: Collection<String?> = x
|
|
val b6: MutableCollection<String?> = <!INITIALIZER_TYPE_MISMATCH!>x<!>
|
|
}
|