Add PurelyImplements annotation
It's parameter is FQ-name of class (currently only from builtins) that added as supertype to annotated Java class. Parameters of annotated class used as non-flexible arguments of added supertype, that helps to propagate more precise types when using in Kotlin. Some standard JDK collections loaded as they annotated with PurelyImplements. See tests for clarification. Before: ArrayList<Int>.add(x: Int!) // possible to add null After: ArrayList<Int>.add(x: Int) // impossible to add null #KT-7628 Fixed #KT-7835 Fixed
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
import java.util.*
|
||||
|
||||
fun bar(): String? = null
|
||||
|
||||
fun foo() {
|
||||
var x = ArrayList<String>()
|
||||
x.<!NONE_APPLICABLE!>add<!>(null)
|
||||
x.<!NONE_APPLICABLE!>add<!>(bar())
|
||||
x.add("")
|
||||
|
||||
x[0] = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
x[0] = <!TYPE_MISMATCH!>bar()<!>
|
||||
x[0] = ""
|
||||
|
||||
val b1: MutableList<String?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableList<String> = x
|
||||
val b3: List<String?> = x
|
||||
|
||||
val b4: Collection<String?> = x
|
||||
val b6: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun foo(): kotlin.Unit
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
import java.util.*
|
||||
|
||||
fun bar(): String? = null
|
||||
|
||||
fun foo() {
|
||||
var x = ArrayList<String?>()
|
||||
x.add(null)
|
||||
x.add(bar())
|
||||
x.add("")
|
||||
|
||||
x[0] = null
|
||||
x[0] = bar()
|
||||
x[0] = ""
|
||||
|
||||
val b1: MutableList<String?> = x
|
||||
val b2: MutableList<String> = <!TYPE_MISMATCH!>x<!>
|
||||
val b3: List<String?> = x
|
||||
|
||||
val b4: Collection<String?> = x
|
||||
val b6: MutableCollection<String?> = x
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun foo(): kotlin.Unit
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import java.util.*
|
||||
|
||||
// FILE: A.java
|
||||
@kotlin.jvm.PurelyImplements("kotlin.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_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.add(<!TYPE_MISMATCH!>bar()<!>)
|
||||
x.add("")
|
||||
|
||||
val b1: Collection<String?> = x
|
||||
val b2: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun foo(): kotlin.Unit
|
||||
|
||||
kotlin.jvm.PurelyImplements(value = "kotlin.MutableCollection") public/*package*/ open class A</*0*/ T> : java.util.AbstractCollection<T!>, kotlin.MutableCollection<T> {
|
||||
public/*package*/ constructor A</*0*/ T>()
|
||||
public open override /*2*/ /*fake_override*/ fun add(/*0*/ e: T): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection<T>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun clear(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean
|
||||
java.lang.Override() public open override /*2*/ fun iterator(): kotlin.MutableIterator<T>
|
||||
public open override /*2*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
java.lang.Override() public open override /*2*/ fun size(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>!
|
||||
public open override /*1*/ /*fake_override*/ fun </*0*/ T> toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>!
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import java.util.*
|
||||
|
||||
// FILE: A.java
|
||||
@kotlin.jvm.PurelyImplements("kotlin.MutableList")
|
||||
class A<T> extends AbstractList<T> {
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
fun bar(): String? = null
|
||||
|
||||
fun foo() {
|
||||
var x = A<String>()
|
||||
x.<!NONE_APPLICABLE!>add<!>(null)
|
||||
x.<!NONE_APPLICABLE!>add<!>(bar())
|
||||
x.add("")
|
||||
|
||||
x[0] = <!NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
x[0] = <!TYPE_MISMATCH!>bar()<!>
|
||||
x[0] = ""
|
||||
|
||||
val b1: MutableList<String?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableList<String> = x
|
||||
val b3: List<String?> = x
|
||||
|
||||
val b4: Collection<String?> = x
|
||||
val b6: MutableCollection<String?> = <!TYPE_MISMATCH!>x<!>
|
||||
}
|
||||
compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/customClassMutableList.txt
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
package
|
||||
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun foo(): kotlin.Unit
|
||||
|
||||
kotlin.jvm.PurelyImplements(value = "kotlin.MutableList") public/*package*/ open class A</*0*/ T> : java.util.AbstractList<T!>, kotlin.MutableList<T> {
|
||||
public/*package*/ constructor A</*0*/ T>()
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun add(/*0*/ e: T): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: T): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection<T>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection<T>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun clear(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
java.lang.Override() public open override /*2*/ fun get(/*0*/ index: kotlin.Int): T
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator<T>
|
||||
public open override /*2*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator<T>
|
||||
public open override /*2*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator<T>
|
||||
invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String!
|
||||
invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): T
|
||||
public open override /*2*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: T): T
|
||||
java.lang.Override() public open override /*2*/ fun size(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList<T>
|
||||
public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>!
|
||||
public open override /*1*/ /*fake_override*/ fun </*0*/ T> toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>!
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
import java.util.*
|
||||
import java.util.concurrent.*
|
||||
|
||||
fun bar(): String? = null
|
||||
val nullableInt: Int? = null
|
||||
|
||||
fun hashMapTest() {
|
||||
var x: HashMap<String, Int> = HashMap<String, Int>()
|
||||
x.put(<!NULL_FOR_NONNULL_TYPE!>null<!>, <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put("", <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put(<!TYPE_MISMATCH!>bar()<!>, 1)
|
||||
x.put("", 1)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[null]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[bar()]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[""]<!> = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String, Int> = x
|
||||
val b3: Map<String?, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b4: Map<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b5: Map<String, Int?> = x
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b8: Int? = x.get("")
|
||||
}
|
||||
|
||||
fun treeMapTest() {
|
||||
var x: TreeMap<String, Int> = TreeMap<String, Int>()
|
||||
x.put(<!NULL_FOR_NONNULL_TYPE!>null<!>, <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put("", <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put(<!TYPE_MISMATCH!>bar()<!>, 1)
|
||||
x.put("", 1)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[null]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[bar()]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[""]<!> = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String, Int> = x
|
||||
val b3: Map<String?, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b4: Map<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b5: Map<String, Int?> = x
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b8: Int? = x.get("")
|
||||
}
|
||||
|
||||
fun concurrentHashMapTest() {
|
||||
var x: ConcurrentHashMap<String, Int> = ConcurrentHashMap<String, Int>()
|
||||
x.put(<!NULL_FOR_NONNULL_TYPE!>null<!>, <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put("", <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put(<!TYPE_MISMATCH!>bar()<!>, 1)
|
||||
x.put("", 1)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[null]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[bar()]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[""]<!> = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String, Int> = x
|
||||
val b3: Map<String?, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b4: Map<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b5: Map<String, Int?> = x
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b8: Int? = x.get("")
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package
|
||||
|
||||
internal val nullableInt: kotlin.Int? = null
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun concurrentHashMapTest(): kotlin.Unit
|
||||
internal fun hashMapTest(): kotlin.Unit
|
||||
internal fun treeMapTest(): kotlin.Unit
|
||||
Vendored
+54
@@ -0,0 +1,54 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
import java.util.*
|
||||
|
||||
fun bar(): String? = null
|
||||
val nullableInt: Int? = null
|
||||
|
||||
fun hashMapTest() {
|
||||
var x: HashMap<String?, Int> = HashMap<String?, Int>()
|
||||
x.put(null, <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put("", <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put(bar(), 1)
|
||||
x.put("", 1)
|
||||
|
||||
x[null] = 1
|
||||
x[bar()] = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[""]<!> = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String?, Int> = x
|
||||
val b3: Map<String?, Int> = x
|
||||
val b4: Map<String?, Int?> = x
|
||||
val b5: Map<String, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x[null]<!>
|
||||
val b8: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b9: Int? = x.get("")
|
||||
}
|
||||
|
||||
fun treeMapTest() {
|
||||
var x: TreeMap<String?, Int> = TreeMap<String?, Int>()
|
||||
x.put(null, <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put("", <!NULL_FOR_NONNULL_TYPE!>null<!>)
|
||||
x.put(bar(), 1)
|
||||
x.put("", 1)
|
||||
|
||||
x[null] = 1
|
||||
x[bar()] = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[""]<!> = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String?, Int> = x
|
||||
val b3: Map<String?, Int> = x
|
||||
val b4: Map<String?, Int?> = x
|
||||
val b5: Map<String, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b8: Int? = x.get("")
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
internal val nullableInt: kotlin.Int? = null
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun hashMapTest(): kotlin.Unit
|
||||
internal fun treeMapTest(): kotlin.Unit
|
||||
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
import java.util.*
|
||||
|
||||
fun bar(): String? = null
|
||||
val nullableInt: Int? = null
|
||||
|
||||
fun hashMapTest() {
|
||||
var x: HashMap<String, Int?> = HashMap<String, Int?>()
|
||||
x.put(<!NULL_FOR_NONNULL_TYPE!>null<!>, null)
|
||||
x.put("", null)
|
||||
x.put(<!TYPE_MISMATCH!>bar()<!>, 1)
|
||||
x.put("", 1)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[null]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[bar()]<!> = 1
|
||||
x[""] = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String, Int?> = x
|
||||
val b3: Map<String, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b4: Map<String, Int?> = x
|
||||
val b5: Map<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b8: Int? = x.get("")
|
||||
}
|
||||
|
||||
fun treeMapTest() {
|
||||
var x: TreeMap<String, Int?> = TreeMap<String, Int?>()
|
||||
x.put(<!NULL_FOR_NONNULL_TYPE!>null<!>, null)
|
||||
x.put("", null)
|
||||
x.put(<!TYPE_MISMATCH!>bar()<!>, 1)
|
||||
x.put("", 1)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[null]<!> = 1
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>x[bar()]<!> = 1
|
||||
x[""] = nullableInt
|
||||
x[""] = 1
|
||||
|
||||
val b1: MutableMap<String, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b2: MutableMap<String, Int?> = x
|
||||
val b3: Map<String, Int> = <!TYPE_MISMATCH!>x<!>
|
||||
val b4: Map<String, Int?> = x
|
||||
val b5: Map<String?, Int?> = <!TYPE_MISMATCH!>x<!>
|
||||
|
||||
val b6: Int = <!TYPE_MISMATCH!>x[""]<!>
|
||||
val b7: Int = <!TYPE_MISMATCH!>x.get("")<!>
|
||||
|
||||
val b8: Int? = x.get("")
|
||||
}
|
||||
compiler/testData/diagnostics/testsWithStdLib/purelyImplementedCollection/mapsWithNullableValues.txt
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
internal val nullableInt: kotlin.Int? = null
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun hashMapTest(): kotlin.Unit
|
||||
internal fun treeMapTest(): kotlin.Unit
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
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<!>
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun fooHashSet(): kotlin.Unit
|
||||
internal fun fooLinkedHashSet(): kotlin.Unit
|
||||
internal fun fooTreeSet(): kotlin.Unit
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import java.util.*
|
||||
|
||||
// FILE: A.java
|
||||
@kotlin.jvm.PurelyImplements("kotlin.MutableList")
|
||||
class A<T, V> extends AbstractList<T> {
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
fun bar(): String? = null
|
||||
|
||||
fun foo() {
|
||||
var x = A<String, String>()
|
||||
x.add(null)
|
||||
x.add(bar())
|
||||
x.add("")
|
||||
|
||||
x[0] = null
|
||||
x[0] = bar()
|
||||
x[0] = ""
|
||||
|
||||
val b1: MutableList<String?> = x
|
||||
val b2: MutableList<String> = x
|
||||
val b3: List<String?> = x
|
||||
|
||||
val b4: Collection<String?> = x
|
||||
val b6: MutableCollection<String?> = x
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package
|
||||
|
||||
internal fun bar(): kotlin.String?
|
||||
internal fun foo(): kotlin.Unit
|
||||
|
||||
kotlin.jvm.PurelyImplements(value = "kotlin.MutableList") public/*package*/ open class A</*0*/ T, /*1*/ V> : java.util.AbstractList<T!> {
|
||||
public/*package*/ constructor A</*0*/ T, /*1*/ V>()
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ var modCount: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun add(/*0*/ e: T!): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun add(/*0*/ index: kotlin.Int, /*1*/ element: T!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ c: kotlin.Collection<T!>): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun addAll(/*0*/ index: kotlin.Int, /*1*/ c: kotlin.Collection<T!>): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun clear(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun contains(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun containsAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
java.lang.Override() public open override /*1*/ fun get(/*0*/ index: kotlin.Int): T!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun indexOf(/*0*/ o: kotlin.Any?): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun isEmpty(): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun iterator(): kotlin.MutableIterator<T!>
|
||||
public open override /*1*/ /*fake_override*/ fun lastIndexOf(/*0*/ o: kotlin.Any?): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun listIterator(): kotlin.MutableListIterator<T!>
|
||||
public open override /*1*/ /*fake_override*/ fun listIterator(/*0*/ index: kotlin.Int): kotlin.MutableListIterator<T!>
|
||||
invisible_fake open override /*1*/ /*fake_override*/ fun outOfBoundsMsg(/*0*/ p0: kotlin.Int): kotlin.String!
|
||||
invisible_fake open override /*1*/ /*fake_override*/ fun rangeCheckForAdd(/*0*/ p0: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ o: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun remove(/*0*/ index: kotlin.Int): T!
|
||||
public open override /*1*/ /*fake_override*/ fun removeAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
protected/*protected and package*/ open override /*1*/ /*fake_override*/ fun removeRange(/*0*/ p0: kotlin.Int, /*1*/ p1: kotlin.Int): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun retainAll(/*0*/ c: kotlin.Collection<kotlin.Any?>): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun set(/*0*/ index: kotlin.Int, /*1*/ element: T!): T!
|
||||
java.lang.Override() public open override /*1*/ fun size(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun subList(/*0*/ fromIndex: kotlin.Int, /*1*/ toIndex: kotlin.Int): kotlin.MutableList<T!>
|
||||
public open override /*1*/ /*fake_override*/ fun toArray(): kotlin.Array<(out) kotlin.Any!>!
|
||||
public open override /*1*/ /*fake_override*/ fun </*0*/ T> toArray(/*0*/ p0: kotlin.Array<(out) T!>!): kotlin.Array<(out) T!>!
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user