Report error when type parameter has a type parameter bound and any other bound
To prevent issues with erasure on JVM: it's unclear what such type parameter should be erased to
This commit is contained in:
@@ -16,12 +16,6 @@ interface IncorrectH<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : G<D<A>><!>> whe
|
||||
|
||||
interface CorrectH<T> where T : G<D<A>>, T : <!REPEATED_BOUND!>G<D<B>><!>
|
||||
|
||||
interface I<T : G<D<T>>> {
|
||||
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS, INCONSISTENT_TYPE_PARAMETER_BOUNDS!>S : T?<!>> incorrectFoo() where S : G<D<S>>
|
||||
|
||||
fun <<!INCONSISTENT_TYPE_PARAMETER_BOUNDS!>S<!>> correctFoo() where S : T?, S : G<D<S>>
|
||||
}
|
||||
|
||||
interface incorrectJ<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T: G<D<T>><!>> where T : <!REPEATED_BOUND!>G<D<T?>><!>
|
||||
|
||||
interface correctJ<T> where T : G<D<T>>, T : <!REPEATED_BOUND!>G<D<T?>><!>
|
||||
|
||||
@@ -38,14 +38,6 @@ public interface G</*0*/ T> {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface I</*0*/ T : G<D<T>>> {
|
||||
public abstract fun </*0*/ S : T?> correctFoo(): kotlin.Unit where S : G<D<S>>
|
||||
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 abstract fun </*0*/ S : T?> incorrectFoo(): kotlin.Unit where S : G<D<S>>
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface IncorrectF</*0*/ T : D<A>> where T : D<B> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
interface I1
|
||||
interface I2
|
||||
open class C
|
||||
|
||||
interface A1<K, V> where V : K, V : <!REPEATED_BOUND!>K<!>
|
||||
interface A2<K, V, <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>W<!>> where W : K, W : V
|
||||
interface A3<K, <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>V<!>> where V : I1, V : K, V : I2
|
||||
interface A4<<!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>K<!>, V> where K : I1, K : I2, K : C, K : V, V : I2, V : I1
|
||||
|
||||
fun <K, V> f1() where V : K, V : <!REPEATED_BOUND!>K<!> {}
|
||||
fun <K, V, <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>W<!>> f2() where W : K, W : V {}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K, /*1*/ V : K> f1(): kotlin.Unit where V : K
|
||||
public fun </*0*/ K, /*1*/ V, /*2*/ W : K> f2(): kotlin.Unit where W : V
|
||||
|
||||
public interface A1</*0*/ K, /*1*/ V : K> where V : 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 interface A2</*0*/ K, /*1*/ V, /*2*/ W : K> where W : V {
|
||||
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 interface A3</*0*/ K, /*1*/ V : I1> where V : K, V : I2 {
|
||||
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 interface A4</*0*/ K : I1, /*1*/ V : I2> where K : I2, K : C, K : V, V : I1 {
|
||||
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 open class C {
|
||||
public constructor C()
|
||||
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 interface I1 {
|
||||
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 interface I2 {
|
||||
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
|
||||
}
|
||||
+1
-1
@@ -34,7 +34,7 @@ fun test4() {
|
||||
|
||||
//--------------
|
||||
|
||||
fun <T: A, R> emptyStrangeMap2(t: T): Map<T, R> where R: T, R: A = throw Exception("$t")
|
||||
fun <T: A, R> emptyStrangeMap2(t: T): Map<T, R> where R: T = throw Exception("$t")
|
||||
|
||||
fun test5(a: A) {
|
||||
emptyStrangeMap2(a)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ package a {
|
||||
public fun </*0*/ T : a.A> emptyListOfA(): kotlin.List<T>
|
||||
public fun </*0*/ T : a.A, /*1*/ R : T> emptyStrangeMap(): kotlin.Map<T, R>
|
||||
public fun </*0*/ T, /*1*/ R : T> emptyStrangeMap1(/*0*/ t: T): kotlin.Map<T, R>
|
||||
public fun </*0*/ T : a.A, /*1*/ R : T> emptyStrangeMap2(/*0*/ t: T): kotlin.Map<T, R> where R : a.A
|
||||
public fun </*0*/ T : a.A, /*1*/ R : T> emptyStrangeMap2(/*0*/ t: T): kotlin.Map<T, R>
|
||||
public fun </*0*/ T : a.A, /*1*/ R : T> emptyStrangeMap3(/*0*/ r: R): kotlin.Map<T, R>
|
||||
public fun </*0*/ T, /*1*/ R : T> emptyStrangeMap4(/*0*/ l: kotlin.MutableList<T>): kotlin.Map<T, R>
|
||||
public fun </*0*/ U, /*1*/ V : U> foo(): U
|
||||
|
||||
-5
@@ -3,11 +3,6 @@ fun <NN: Any, NNN: NN> nonMisleadingNullable(
|
||||
<!UNUSED_PARAMETER!>nnn<!>: NNN?
|
||||
) {}
|
||||
|
||||
fun <NN: Any, TWO_BOUNDS> twoBounds(
|
||||
<!UNUSED_PARAMETER!>tb<!>: TWO_BOUNDS?
|
||||
|
||||
) where TWO_BOUNDS: Any, TWO_BOUNDS : NN {}
|
||||
|
||||
fun <T, N: T, INDIRECT: N> misleadingNullableSimple(
|
||||
<!UNUSED_PARAMETER!>t<!>: T?,
|
||||
<!UNUSED_PARAMETER!>t2<!>: T?,
|
||||
|
||||
-1
@@ -3,4 +3,3 @@ package
|
||||
public fun </*0*/ T> interactionWithRedundant(/*0*/ t: T?): kotlin.Unit
|
||||
public fun </*0*/ T, /*1*/ N : T, /*2*/ INDIRECT : N> misleadingNullableSimple(/*0*/ t: T?, /*1*/ t2: T?, /*2*/ n: N?, /*3*/ ind: INDIRECT?): kotlin.Unit
|
||||
public fun </*0*/ NN : kotlin.Any, /*1*/ NNN : NN> nonMisleadingNullable(/*0*/ nn: NN?, /*1*/ nnn: NNN?): kotlin.Unit
|
||||
public fun </*0*/ NN : kotlin.Any, /*1*/ TWO_BOUNDS : kotlin.Any> twoBounds(/*0*/ tb: TWO_BOUNDS?): kotlin.Unit where TWO_BOUNDS : NN
|
||||
|
||||
Reference in New Issue
Block a user