Add reporting of the warnings based on Java annotations for expanded type aliases
Before that, such warnings weren't reported as the corresponding errors were reported during type inference (only original types took part there)
This commit is contained in:
+3
-3
@@ -13,6 +13,6 @@ class TColl<T, C : Collection<T>>
|
||||
typealias TC<T, C> = TColl<T, C>
|
||||
typealias TC2<T, C> = TC<T, C>
|
||||
|
||||
val y1 = TColl<Any, <!UPPER_BOUND_VIOLATED{NI}, UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val y2 = TC<Any, <!UPPER_BOUND_VIOLATED{NI}, UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val y3 = TC2<Any, <!UPPER_BOUND_VIOLATED{NI}, UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val y1 = TColl<Any, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val y2 = TC<Any, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val y3 = TC2<Any, <!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
|
||||
+12
-2
@@ -1,8 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: MapLike.java
|
||||
import java.util.Map;
|
||||
|
||||
public class MapLike<@org.jetbrains.annotations.NotNull K> {
|
||||
MapLike(K x) { }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class Cons<T : Number>(val head: T, val tail: Cons<T>?)
|
||||
typealias C<T> = Cons<T>
|
||||
typealias C2<T> = MapLike<T>
|
||||
|
||||
val test1 = C(1, C(2, null))
|
||||
val test2 = C(1, C("", null))
|
||||
val test23 = C2(if (true) 1 else null)
|
||||
val test234 = C2(C2(if (true) 1 else null))
|
||||
|
||||
+13
-3
@@ -1,8 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: MapLike.java
|
||||
import java.util.Map;
|
||||
|
||||
public class MapLike<@org.jetbrains.annotations.NotNull K> {
|
||||
MapLike(K x) { }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
class Cons<T : Number>(val head: T, val tail: Cons<T>?)
|
||||
typealias C<T> = Cons<T>
|
||||
typealias C2<T> = MapLike<T>
|
||||
|
||||
val test1 = C(1, C(2, null))
|
||||
val test2 = C(1, <!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!><!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>C<!>(<!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>""<!>, null)<!>)
|
||||
val test2 = C(1, <!TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>C(<!TYPE_MISMATCH, TYPE_MISMATCH!>""<!>, null)<!>)
|
||||
val test23 = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>C2(if (true) 1 else null)<!>
|
||||
val test234 = C2(<!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>C2(if (true) 1 else null)<!>)
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package
|
||||
|
||||
public val test1: C<kotlin.Int> /* = Cons<kotlin.Int> */
|
||||
public val test2: Cons<out kotlin.Any?>
|
||||
|
||||
public final class Cons</*0*/ T : kotlin.Number> {
|
||||
public constructor Cons</*0*/ T : kotlin.Number>(/*0*/ head: T, /*1*/ tail: Cons<T>?)
|
||||
public final val head: T
|
||||
public final val tail: Cons<T>?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias C</*0*/ T> = Cons<T>
|
||||
+12
-1
@@ -1,7 +1,9 @@
|
||||
package
|
||||
|
||||
public val test1: C<kotlin.Int> /* = Cons<kotlin.Int> */
|
||||
public val test2: C<kotlin.Int> /* = Cons<kotlin.Int> */
|
||||
public val test2: Cons<out kotlin.Any?>
|
||||
public val test23: C2<kotlin.Int?> /* = MapLike<kotlin.Int?> */
|
||||
public val test234: C2<(C2<kotlin.Int?> /* = MapLike<kotlin.Int?> */..C2<kotlin.Int?>? /* = MapLike<kotlin.Int?>? */)> /* = MapLike<(C2<kotlin.Int?> /* = MapLike<kotlin.Int?> */..C2<kotlin.Int?>? /* = MapLike<kotlin.Int?>? */)> */
|
||||
|
||||
public final class Cons</*0*/ T : kotlin.Number> {
|
||||
public constructor Cons</*0*/ T : kotlin.Number>(/*0*/ head: T, /*1*/ tail: Cons<T>?)
|
||||
@@ -11,4 +13,13 @@ public final class Cons</*0*/ T : kotlin.Number> {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any!> {
|
||||
public/*package*/ constructor MapLike</*0*/ @org.jetbrains.annotations.NotNull K : kotlin.Any!>(/*0*/ x: K!)
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
public typealias C</*0*/ T> = Cons<T>
|
||||
public typealias C2</*0*/ T> = MapLike<T>
|
||||
|
||||
|
||||
+8
-8
@@ -14,11 +14,11 @@ import java.util.Collection;
|
||||
public class ListLike<K extends Collection<@org.jetbrains.annotations.NotNull Object>> {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test0(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>, Int>) {}
|
||||
fun <K> test11(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K<!>, K>) {}
|
||||
fun <K> test12(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K?<!>, K>) {}
|
||||
fun test0(map : MapLike<Int?, Int>) {}
|
||||
fun <K> test11(map : MapLike<K, K>) {}
|
||||
fun <K> test12(map : MapLike<K?, K>) {}
|
||||
fun <K : Any> test13(map : MapLike<K, K>) {}
|
||||
fun <K : Any> test14(map : MapLike<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>K?<!>, K>) {}
|
||||
fun <K : Any> test14(map : MapLike<K?, K>) {}
|
||||
|
||||
class Foo<K>
|
||||
|
||||
@@ -26,11 +26,11 @@ typealias A<A> = MapLike<A, Int>
|
||||
typealias A2<B> = Foo<MapLike<B, Int>>
|
||||
typealias A3<C> = ListLike<List<C>>
|
||||
|
||||
fun main1(x: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
|
||||
fun main2(x: A2<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
|
||||
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!>) {}
|
||||
fun main1(x: A<Int?>) {}
|
||||
fun main2(x: A2<Int?>) {}
|
||||
fun main3(x: A3<Int?>) {}
|
||||
fun main3() {
|
||||
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
|
||||
val x2 = A<Int?>() // TODO: support reporting errors on typealias constructor calls
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!> = A3<Int?>()
|
||||
val y: A3<Int?> = A3<Int?>()
|
||||
}
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ fun main1(x: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
|
||||
fun main2(x: A2<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Int?<!>>) {}
|
||||
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!>) {}
|
||||
fun main3() {
|
||||
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
|
||||
val x2 = A<Int?>() // TODO: support reporting errors on typealias constructor calls
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!> = A3<Int?>()
|
||||
val x = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?>()<!> // TODO: support reporting errors on typealias constructor calls
|
||||
val x2 = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A<Int?>()<!> // TODO: support reporting errors on typealias constructor calls
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?><!> = <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION_BASED_ON_JAVA_ANNOTATIONS!>A3<Int?>()<!>
|
||||
}
|
||||
|
||||
+8
-8
@@ -15,11 +15,11 @@ import java.util.Collection;
|
||||
public class ListLike<K extends Collection<@org.jetbrains.annotations.NotNull Object>> {}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test0(map : MapLike<<!UPPER_BOUND_VIOLATED!>Int?<!>, Int>) {}
|
||||
fun <K> test11(map : MapLike<<!UPPER_BOUND_VIOLATED!>K<!>, K>) {}
|
||||
fun <K> test12(map : MapLike<<!UPPER_BOUND_VIOLATED!>K?<!>, K>) {}
|
||||
fun test0(map : MapLike<Int?, Int>) {}
|
||||
fun <K> test11(map : MapLike<K, K>) {}
|
||||
fun <K> test12(map : MapLike<K?, K>) {}
|
||||
fun <K : Any> test13(map : MapLike<K, K>) {}
|
||||
fun <K : Any> test14(map : MapLike<<!UPPER_BOUND_VIOLATED!>K?<!>, K>) {}
|
||||
fun <K : Any> test14(map : MapLike<K?, K>) {}
|
||||
|
||||
class Foo<K>
|
||||
|
||||
@@ -27,11 +27,11 @@ typealias A<A> = MapLike<A, Int>
|
||||
typealias A2<B> = Foo<MapLike<B, Int>>
|
||||
typealias A3<C> = ListLike<List<C>>
|
||||
|
||||
fun main1(x: A<<!UPPER_BOUND_VIOLATED!>Int?<!>>) {}
|
||||
fun main2(x: A2<<!UPPER_BOUND_VIOLATED!>Int?<!>>) {}
|
||||
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!>) {}
|
||||
fun main1(x: A<Int?>) {}
|
||||
fun main2(x: A2<Int?>) {}
|
||||
fun main3(x: A3<Int?>) {}
|
||||
fun main3() {
|
||||
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
|
||||
val x2 = A<Int?>()
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!> = A3<Int?>()
|
||||
val y: A3<Int?> = A3<Int?>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user