K1: implement warning for upper bound violated in type alias constructors
Partially implements KT-47473
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ val test5 = NA<Int>()
|
||||
val test6 = NA<<!UPPER_BOUND_VIOLATED!>Any<!>>()
|
||||
val test7 = NL<Int>()
|
||||
val test8 = MMMM<<!UPPER_BOUND_VIOLATED!>Int<!>>()
|
||||
val test9dwd = NL<Any>()
|
||||
val test9dwd = NL<<!UPPER_BOUND_VIOLATED_WARNING!>Any<!>>()
|
||||
|
||||
fun test9(x: TC<Number, Collection<Number>>) {}
|
||||
fun test10(x: TC<Number, Collection<Int>>) {}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ fun main1(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A<Int?><!>) {}
|
||||
fun main2(x: A2<Int?>) {}
|
||||
fun main3(x: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!>) {}
|
||||
fun main3() {
|
||||
val x = <!UPPER_BOUND_VIOLATED!>A3<Int?>()<!> // TODO: support reporting errors on typealias constructor calls
|
||||
val x = <!UPPER_BOUND_VIOLATED!>A3<Int?>()<!>
|
||||
val x2 = <!UPPER_BOUND_VIOLATED!>A<Int?>()<!>
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!> = <!UPPER_BOUND_VIOLATED!>A3<Int?>()<!>
|
||||
}
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ 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 main3() {
|
||||
val x = A3<Int?>() // TODO: support reporting errors on typealias constructor calls
|
||||
val x = A3<<!UPPER_BOUND_VIOLATED_WARNING!>Int?<!>>()
|
||||
val x2 = A<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!> = A3<Int?>()
|
||||
val y: <!UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION!>A3<Int?><!> = A3<<!UPPER_BOUND_VIOLATED_WARNING!>Int?<!>>()
|
||||
}
|
||||
|
||||
-4
@@ -4,7 +4,3 @@ typealias AliasOfNumList<A3> = NumList<A3>
|
||||
|
||||
val falseUpperBoundViolation = AliasOfNumList<Int>() // Shouldn't be error
|
||||
val missedUpperBoundViolation = <!UPPER_BOUND_VIOLATED!>NumList<Any>()<!> // Should be error
|
||||
|
||||
class Base<T : List<CharSequence>>
|
||||
typealias Alias<T> = Base<List<T>>
|
||||
val a = <!UPPER_BOUND_VIOLATED!>Alias<Any>()<!> // Also should be error
|
||||
|
||||
+2
-6
@@ -2,9 +2,5 @@ class NumColl<T : Collection<Number>>
|
||||
typealias NumList<T2> = NumColl<List<T2>>
|
||||
typealias AliasOfNumList<A3> = NumList<A3>
|
||||
|
||||
val falseUpperBoundViolation = AliasOfNumList<<!UPPER_BOUND_VIOLATED!>Int<!>>() // Shouldn't be error
|
||||
val missedUpperBoundViolation = NumList<Any>() // Should be error
|
||||
|
||||
class Base<T : List<CharSequence>>
|
||||
typealias Alias<T> = Base<List<T>>
|
||||
val a = Alias<Any>() // Also should be error
|
||||
val falseUpperBoundViolation = AliasOfNumList<<!UPPER_BOUND_VIOLATED("Collection<Number>; Int")!>Int<!>>() // Shouldn't be error
|
||||
val missedUpperBoundViolation = NumList<<!UPPER_BOUND_VIOLATED_WARNING("Collection<Number>; List<Any>")!>Any<!>>() // Should be error
|
||||
|
||||
+1
-9
@@ -1,22 +1,14 @@
|
||||
package
|
||||
|
||||
public val a: Alias<kotlin.Any> /* = Base<kotlin.collections.List<kotlin.Any>> */
|
||||
public val falseUpperBoundViolation: AliasOfNumList<kotlin.Int> /* = NumColl<kotlin.collections.List<kotlin.Int>> */
|
||||
public val missedUpperBoundViolation: NumList<kotlin.Any> /* = NumColl<kotlin.collections.List<kotlin.Any>> */
|
||||
|
||||
public final class Base</*0*/ T : kotlin.collections.List<kotlin.CharSequence>> {
|
||||
public constructor Base</*0*/ T : kotlin.collections.List<kotlin.CharSequence>>()
|
||||
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 final class NumColl</*0*/ T : kotlin.collections.Collection<kotlin.Number>> {
|
||||
public constructor NumColl</*0*/ T : kotlin.collections.Collection<kotlin.Number>>()
|
||||
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 Alias</*0*/ T> = Base<kotlin.collections.List<T>>
|
||||
public typealias AliasOfNumList</*0*/ A3> = NumList<A3>
|
||||
public typealias NumList</*0*/ T2> = NumColl<kotlin.collections.List<T2>>
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
/upperBoundViolated2.kt:4:15: warning: type argument is not within its bounds: 'List<Any>' should be subtype of 'List<CharSequence>'. This warning will become an error in K2
|
||||
val a = Alias<Any>() // Also should be error
|
||||
^
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||
class Base<T : List<CharSequence>>
|
||||
typealias Alias<T> = Base<List<T>>
|
||||
val a = <!UPPER_BOUND_VIOLATED!>Alias<Any>()<!> // Also should be error
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// !RENDER_DIAGNOSTICS_FULL_TEXT
|
||||
class Base<T : List<CharSequence>>
|
||||
typealias Alias<T> = Base<List<T>>
|
||||
val a = Alias<<!UPPER_BOUND_VIOLATED_WARNING("List<CharSequence>; List<Any>")!>Any<!>>() // Also should be error
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public val a: Alias<kotlin.Any> /* = Base<kotlin.collections.List<kotlin.Any>> */
|
||||
|
||||
public final class Base</*0*/ T : kotlin.collections.List<kotlin.CharSequence>> {
|
||||
public constructor Base</*0*/ T : kotlin.collections.List<kotlin.CharSequence>>()
|
||||
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 Alias</*0*/ T> = Base<kotlin.collections.List<T>>
|
||||
Reference in New Issue
Block a user