Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/sets.kt
T
Pavel Kirpichenkov 8c52bb4212 Add frontend checks for missing dependency supertypes
Call checker and declaration checker are used in order to preserve backward compatibility.
Attempt to use classifier usage checker was not good enouth,
since not all errors found with it would actually be reported before.
For example types and constructor calls don't cause supertypes to resolve,
so missing supertypes would not lead to errors in case they are the only use of class name.

Updated tests failing due to missing Java dependencies in superclasses.
2019-11-18 12:06:41 +03:00

50 lines
1.2 KiB
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_VARIABLE
// !WITH_NEW_INFERENCE
// FULL_JDK
import java.util.*
fun bar(): String? = null
fun fooHashSet() {
var x = HashSet<String>()
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.add(<!TYPE_MISMATCH!>bar()<!>)
x.add("")
val b1: MutableSet<String?> = <!TYPE_MISMATCH!>x<!>
val b2: MutableSet<String> = x
val b3: Set<String?> = x
val b4: Collection<String?> = x
val b6: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
}
fun fooTreeSet() {
var x = TreeSet<String>()
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.add(<!TYPE_MISMATCH!>bar()<!>)
x.add("")
val b1: MutableSet<String?> = <!TYPE_MISMATCH!>x<!>
val b2: MutableSet<String> = x
val b3: Set<String?> = x
val b4: Collection<String?> = x
val b6: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
}
fun fooLinkedHashSet() {
var x = LinkedHashSet<String>()
x.add(<!NULL_FOR_NONNULL_TYPE!>null<!>)
x.add(<!TYPE_MISMATCH!>bar()<!>)
x.add("")
val b1: MutableSet<String?> = <!TYPE_MISMATCH!>x<!>
val b2: MutableSet<String> = x
val b3: Set<String?> = x
val b4: Collection<String?> = x
val b6: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
}