Add compatibility resolve when variable has "bad" intersection type
#KT-39468 Fixed
This commit is contained in:
+37
@@ -0,0 +1,37 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
abstract class Foo<T>
|
||||
|
||||
abstract class Bar<T> : Foo<T>(), Comparable<Bar<T>>
|
||||
|
||||
object Scope {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, other: Foo<T>) {}
|
||||
|
||||
object Nested {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
<!DEBUG_INFO_CALL("fqName: Scope.Nested.greater; typeCall: function")!>greater(b, b)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object OnlyOne {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
<!DEBUG_INFO_CALL("fqName: OnlyOne.greater; typeCall: function")!>greater(b, b)<!>
|
||||
}
|
||||
}
|
||||
|
||||
object GoodOldCandidate {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||
|
||||
object Nested {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, other: Foo<T>) {}
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
<!DEBUG_INFO_CALL("fqName: GoodOldCandidate.Nested.greater; typeCall: function")!>greater(b, b)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
abstract class Foo<T>
|
||||
|
||||
abstract class Bar<T> : Foo<T>(), Comparable<Bar<T>>
|
||||
|
||||
object Scope {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, other: Foo<T>) {}
|
||||
|
||||
object Nested {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
<!DEBUG_INFO_CALL("fqName: Scope.greater; typeCall: function")!><!COMPATIBILITY_WARNING!>greater<!>(b, b)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object OnlyOne {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
<!DEBUG_INFO_CALL("fqName: OnlyOne.greater; typeCall: function")!>greater(b, b)<!>
|
||||
}
|
||||
}
|
||||
|
||||
object GoodOldCandidate {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T) {}
|
||||
|
||||
object Nested {
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, other: Foo<T>) {}
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
<!DEBUG_INFO_CALL("fqName: GoodOldCandidate.Nested.greater; typeCall: function")!>greater(b, b)<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package
|
||||
|
||||
public abstract class Bar</*0*/ T> : Foo<T>, kotlin.Comparable<Bar<T>> {
|
||||
public constructor Bar</*0*/ T>()
|
||||
public abstract override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Bar<T>): kotlin.Int
|
||||
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 toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class Foo</*0*/ T> {
|
||||
public constructor Foo</*0*/ 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 object GoodOldCandidate {
|
||||
private constructor GoodOldCandidate()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ t: T): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public object Nested {
|
||||
private constructor Nested()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ other: Foo<T>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(/*0*/ b: Bar<kotlin.Long>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public object OnlyOne {
|
||||
private constructor OnlyOne()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ t: T): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(/*0*/ b: Bar<kotlin.Long>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object Scope {
|
||||
private constructor Scope()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ other: Foo<T>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public object Nested {
|
||||
private constructor Nested()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ t: T): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun test(/*0*/ b: Bar<kotlin.Long>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
abstract class Foo<T>
|
||||
|
||||
abstract class Bar<T> : Foo<T>(), Comparable<Bar<T>>
|
||||
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T): Int = 0
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, other: Foo<T>): String = ""
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
val result = <!AMBIGUITY!>greater<!>(b, b)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Ambiguity: greater, [/greater, /greater]")!>result<!>
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
abstract class Foo<T>
|
||||
|
||||
abstract class Bar<T> : Foo<T>(), Comparable<Bar<T>>
|
||||
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, t: T): Int = 0
|
||||
fun <T : Comparable<T>, S : T> greater(x: Bar<in S>, other: Foo<T>): String = ""
|
||||
|
||||
fun test(b: Bar<Long>) {
|
||||
val result = greater(b, b)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ other: Foo<T>): kotlin.String
|
||||
public fun </*0*/ T : kotlin.Comparable<T>, /*1*/ S : T> greater(/*0*/ x: Bar<in S>, /*1*/ t: T): kotlin.Int
|
||||
public fun test(/*0*/ b: Bar<kotlin.Long>): kotlin.Unit
|
||||
|
||||
public abstract class Bar</*0*/ T> : Foo<T>, kotlin.Comparable<Bar<T>> {
|
||||
public constructor Bar</*0*/ T>()
|
||||
public abstract override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Bar<T>): kotlin.Int
|
||||
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 toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class Foo</*0*/ T> {
|
||||
public constructor Foo</*0*/ 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
|
||||
}
|
||||
Reference in New Issue
Block a user