NI: Prefer nullable lower bound to flexible one when substitution of type variable is performed and remember flexibility of type parameters based on flexibility of its upper bounds
^KT-32435 Fixed
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
// FILE: Function.java
|
||||
|
||||
public interface Function<Param, Result> {
|
||||
Result fun(Param param);
|
||||
}
|
||||
|
||||
// FILE: AdapterProcessor.java
|
||||
|
||||
public class AdapterProcessor<T, S> {
|
||||
public AdapterProcessor(Function<? super T, ? extends S> conversion) {}
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface PsiMethod {
|
||||
val containingClass: PsiClass?
|
||||
}
|
||||
|
||||
interface PsiClass
|
||||
|
||||
fun test() {
|
||||
// TODO: don't forget to implement preservation flexibility of java type parameters in FIR (this is the reason of error here)
|
||||
val processor = <!INAPPLICABLE_CANDIDATE!>AdapterProcessor<!><PsiMethod, PsiClass>(
|
||||
Function { method: PsiMethod? -> method?.containingClass }
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
// FILE: Function.java
|
||||
|
||||
public interface Function<Param, Result> {
|
||||
Result fun(Param param);
|
||||
}
|
||||
|
||||
// FILE: AdapterProcessor.java
|
||||
|
||||
public class AdapterProcessor<T, S> {
|
||||
public AdapterProcessor(Function<? super T, ? extends S> conversion) {}
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface PsiMethod {
|
||||
val containingClass: PsiClass?
|
||||
}
|
||||
|
||||
interface PsiClass
|
||||
|
||||
fun test() {
|
||||
// TODO: don't forget to implement preservation flexibility of java type parameters in FIR (this is the reason of error here)
|
||||
val processor = AdapterProcessor<PsiMethod, PsiClass>(
|
||||
Function { method: PsiMethod? -> method?.containingClass }
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class AdapterProcessor</*0*/ T : kotlin.Any!, /*1*/ S : kotlin.Any!> {
|
||||
public constructor AdapterProcessor</*0*/ T : kotlin.Any!, /*1*/ S : kotlin.Any!>(/*0*/ conversion: Function<in T!, out 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Function</*0*/ Param : kotlin.Any!, /*1*/ Result : kotlin.Any!> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun `fun`(/*0*/ param: Param!): Result!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface PsiClass {
|
||||
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 PsiMethod {
|
||||
public abstract val containingClass: PsiClass?
|
||||
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
@@ -14,5 +14,5 @@ public class Matcher<T> {
|
||||
|
||||
// FILE: main.kt
|
||||
fun test(x: List<String>) {
|
||||
Assert.assertThat(x, Matcher.hasItem("abc"))
|
||||
Assert.<!INAPPLICABLE_CANDIDATE!>assertThat<!>(x, Matcher.hasItem("abc"))
|
||||
}
|
||||
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNCHECKED_CAST -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
||||
// !LANGUAGE: +NewInference
|
||||
// SKIP_TXT
|
||||
|
||||
// FILE: Foo.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Foo<T> {
|
||||
T x;
|
||||
|
||||
public Foo(T x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public static Number bar() { return null; }
|
||||
|
||||
public static <K> K simpleId(K k) {
|
||||
return k;
|
||||
}
|
||||
|
||||
public T produceT() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public T produceNotNullT() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void consumeT(T x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun <T> bar(n: Number?, d: T, e: T) {
|
||||
val a: Number = Foo.simpleId(n)
|
||||
val b: Number? = Foo.simpleId(n)
|
||||
val c = Foo.simpleId(n)
|
||||
|
||||
val x4 = Foo(if (true) 10 else null)
|
||||
val x5: Number = x4.produceT()
|
||||
val x6: Number? = x4.produceT()
|
||||
val x7 = x4.produceT()
|
||||
val x8 = x4.produceNotNullT()
|
||||
|
||||
x4.consumeT(x7)
|
||||
|
||||
val x9: T = Foo.simpleId(d)
|
||||
val x10: T? = Foo.simpleId(d)
|
||||
|
||||
if (e != null) {
|
||||
var x11 = e
|
||||
x11 = Foo.simpleId(d) // assign to definitely not-null T, the lack an error is consistent with old inference
|
||||
}
|
||||
|
||||
var x11 = Foo<T>(null as T).x
|
||||
x11 = Foo.simpleId(d) // assign to flexible T
|
||||
|
||||
var x12 = Foo.bar()
|
||||
x12 = Foo.simpleId(n) // assign to flexible Number
|
||||
|
||||
var x13 = e
|
||||
x13 = Foo.simpleId(d)
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNCHECKED_CAST -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
||||
// !LANGUAGE: +NewInference
|
||||
// SKIP_TXT
|
||||
|
||||
// FILE: Foo.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Foo<T> {
|
||||
T x;
|
||||
|
||||
public Foo(T x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public static Number bar() { return null; }
|
||||
|
||||
public static <K> K simpleId(K k) {
|
||||
return k;
|
||||
}
|
||||
|
||||
public T produceT() {
|
||||
return x;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public T produceNotNullT() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void consumeT(T x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun <T> bar(n: Number?, d: T, e: T) {
|
||||
val a: Number = <!TYPE_MISMATCH!>Foo.simpleId(n)<!>
|
||||
val b: Number? = Foo.simpleId(n)
|
||||
val c = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Number?")!>Foo.simpleId(n)<!>
|
||||
|
||||
val x4 = Foo(if (true) 10 else null)
|
||||
val x5: Number = <!TYPE_MISMATCH!>x4.produceT()<!>
|
||||
val x6: Number? = x4.produceT()
|
||||
val x7 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x4.produceT()<!>
|
||||
val x8 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>x4.produceNotNullT()<!>
|
||||
|
||||
x4.consumeT(x7)
|
||||
|
||||
val x9: T = Foo.simpleId(d)
|
||||
val x10: T? = Foo.simpleId(d)
|
||||
|
||||
if (e != null) {
|
||||
var x11 = e
|
||||
x11 = Foo.simpleId(d) // assign to definitely not-null T, the lack an error is consistent with old inference
|
||||
}
|
||||
|
||||
var x11 = Foo<T>(null as T).x
|
||||
x11 = Foo.simpleId(d) // assign to flexible T
|
||||
|
||||
var x12 = Foo.bar()
|
||||
x12 = Foo.simpleId(n) // assign to flexible Number
|
||||
|
||||
var x13 = e
|
||||
x13 = Foo.simpleId(d)
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
// It's relevant only for Java constructor calls
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
public class J<T extends Integer> {}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class Foo(val attributes: Map<String, String>)
|
||||
|
||||
class A<R>
|
||||
|
||||
class Bar<T, K: Any> {
|
||||
val foos1 = ArrayList<Foo>()
|
||||
val foos2 = ArrayList<Foo?>()
|
||||
val foos3 = ArrayList<A<Foo>>()
|
||||
val foos4 = ArrayList<A<Foo>?>()
|
||||
val foos5 = ArrayList<A<Foo?>?>()
|
||||
val foos6 = ArrayList<A<Foo?>>()
|
||||
val foos7 = ArrayList<T>()
|
||||
val foos8 = ArrayList<T?>()
|
||||
val foos9 = ArrayList<K>()
|
||||
val foos10 = ArrayList<K?>()
|
||||
val foos11 = ArrayList<A<K?>>()
|
||||
val foos12 = ArrayList<A<K>>()
|
||||
val foos13 = ArrayList<A<T>>()
|
||||
val foos14 = ArrayList<A<T>?>()
|
||||
val foos15 = ArrayList<A<T?>>()
|
||||
|
||||
val foos16 = J<Foo>()
|
||||
val foos17 = J<Foo?>()
|
||||
val foos18 = J<T>()
|
||||
val foos19 = J<T?>()
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
// It's relevant only for Java constructor calls
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
public class J<T extends Integer> {}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class Foo(val attributes: Map<String, String>)
|
||||
|
||||
class A<R>
|
||||
|
||||
class Bar<T, K: Any> {
|
||||
val foos1 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<Foo>")!>ArrayList<Foo>()<!>
|
||||
val foos2 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<Foo?>")!>ArrayList<Foo?>()<!>
|
||||
val foos3 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<Foo>>")!>ArrayList<A<Foo>>()<!>
|
||||
val foos4 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<Foo>?>")!>ArrayList<A<Foo>?>()<!>
|
||||
val foos5 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<Foo?>?>")!>ArrayList<A<Foo?>?>()<!>
|
||||
val foos6 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<Foo?>>")!>ArrayList<A<Foo?>>()<!>
|
||||
val foos7 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<T>")!>ArrayList<T>()<!>
|
||||
val foos8 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<T?>")!>ArrayList<T?>()<!>
|
||||
val foos9 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<K>")!>ArrayList<K>()<!>
|
||||
val foos10 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<K?>")!>ArrayList<K?>()<!>
|
||||
val foos11 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<K?>>")!>ArrayList<A<K?>>()<!>
|
||||
val foos12 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<K>>")!>ArrayList<A<K>>()<!>
|
||||
val foos13 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<T>>")!>ArrayList<A<T>>()<!>
|
||||
val foos14 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<T>?>")!>ArrayList<A<T>?>()<!>
|
||||
val foos15 = <!DEBUG_INFO_EXPRESSION_TYPE("java.util.ArrayList<A<T?>>")!>ArrayList<A<T?>>()<!>
|
||||
|
||||
val foos16 = <!DEBUG_INFO_EXPRESSION_TYPE("J<Foo>")!>J<<!UPPER_BOUND_VIOLATED!>Foo<!>>()<!>
|
||||
val foos17 = <!DEBUG_INFO_EXPRESSION_TYPE("J<Foo?>")!>J<<!UPPER_BOUND_VIOLATED!>Foo?<!>>()<!>
|
||||
val foos18 = <!DEBUG_INFO_EXPRESSION_TYPE("J<T>")!>J<<!UPPER_BOUND_VIOLATED!>T<!>>()<!>
|
||||
val foos19 = <!DEBUG_INFO_EXPRESSION_TYPE("J<T?>")!>J<<!UPPER_BOUND_VIOLATED!>T?<!>>()<!>
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package
|
||||
|
||||
public final class A</*0*/ R> {
|
||||
public constructor A</*0*/ R>()
|
||||
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 Bar</*0*/ T, /*1*/ K : kotlin.Any> {
|
||||
public constructor Bar</*0*/ T, /*1*/ K : kotlin.Any>()
|
||||
public final val foos1: java.util.ArrayList<Foo>
|
||||
public final val foos10: java.util.ArrayList<K?>
|
||||
public final val foos11: java.util.ArrayList<A<K?>>
|
||||
public final val foos12: java.util.ArrayList<A<K>>
|
||||
public final val foos13: java.util.ArrayList<A<T>>
|
||||
public final val foos14: java.util.ArrayList<A<T>?>
|
||||
public final val foos15: java.util.ArrayList<A<T?>>
|
||||
public final val foos16: J<Foo>
|
||||
public final val foos17: J<Foo?>
|
||||
public final val foos18: J<T>
|
||||
public final val foos19: J<T?>
|
||||
public final val foos2: java.util.ArrayList<Foo?>
|
||||
public final val foos3: java.util.ArrayList<A<Foo>>
|
||||
public final val foos4: java.util.ArrayList<A<Foo>?>
|
||||
public final val foos5: java.util.ArrayList<A<Foo?>?>
|
||||
public final val foos6: java.util.ArrayList<A<Foo?>>
|
||||
public final val foos7: java.util.ArrayList<T>
|
||||
public final val foos8: java.util.ArrayList<T?>
|
||||
public final val foos9: java.util.ArrayList<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 final class Foo {
|
||||
public constructor Foo(/*0*/ attributes: kotlin.collections.Map<kotlin.String, kotlin.String>)
|
||||
public final val attributes: kotlin.collections.Map<kotlin.String, kotlin.String>
|
||||
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 J</*0*/ T : kotlin.Int!> {
|
||||
public constructor J</*0*/ T : kotlin.Int!>()
|
||||
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
|
||||
}
|
||||
@@ -5,6 +5,6 @@ interface Foo
|
||||
|
||||
fun test() {
|
||||
var nullable: Foo? = null
|
||||
val foo: Collection<Foo> = java.util.Collections.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>singleton(nullable)<!>
|
||||
val foo: Collection<Foo> = <!NI;TYPE_MISMATCH!>java.util.Collections.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>singleton(nullable)<!><!>
|
||||
val foo1: Collection<Foo> = java.util.Collections.singleton(nullable!!)
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
// FILE: samConversionToGeneric.kt
|
||||
|
||||
fun test1() = J<String> { x -> x }
|
||||
|
||||
fun test2() = J { x: String -> x }
|
||||
|
||||
fun test3() = H.bar { x: String -> x }
|
||||
|
||||
fun test4(a: Any) {
|
||||
a as J<String>
|
||||
H.bar(a)
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
a as (String) -> String
|
||||
H.bar(a)
|
||||
}
|
||||
|
||||
fun <T> test6(a: (T) -> T) {
|
||||
H.bar(a)
|
||||
}
|
||||
|
||||
fun <T> test7(a: Any) {
|
||||
a as (T) -> T
|
||||
H.bar(a)
|
||||
}
|
||||
|
||||
fun test8(efn: String.() -> String) = J(efn)
|
||||
|
||||
fun test9(efn: String.() -> String) {
|
||||
H.bar(efn)
|
||||
}
|
||||
|
||||
fun test10(fn: (Int) -> String) {
|
||||
H.bar2x(fn)
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public interface J<T> {
|
||||
T foo(T x);
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
public interface J2<T1, T2> {
|
||||
T1 foo(T2 x);
|
||||
}
|
||||
|
||||
// FILE: J2X.java
|
||||
public interface J2X<T3> extends J2<String, T3> {
|
||||
}
|
||||
|
||||
// FILE: H.java
|
||||
public class H {
|
||||
public static <X> void bar(J<X> j) {}
|
||||
public static <Y> void bar2x(J2X<Y> j2x) {}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
// FILE: samConversionToGeneric.kt
|
||||
|
||||
fun test1() = J<String> { x -> x }
|
||||
|
||||
fun test2() = J { x: String -> x }
|
||||
|
||||
fun test3() = H.bar { x: String -> x }
|
||||
|
||||
fun test4(a: Any) {
|
||||
a <!UNCHECKED_CAST!>as J<String><!>
|
||||
H.bar(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
a <!UNCHECKED_CAST!>as (String) -> String<!>
|
||||
H.bar(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
|
||||
fun <T> test6(a: (T) -> T) {
|
||||
H.bar(a)
|
||||
}
|
||||
|
||||
fun <T> test7(a: Any) {
|
||||
a <!UNCHECKED_CAST!>as (T) -> T<!>
|
||||
H.bar(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
|
||||
fun test8(efn: String.() -> String) = J(efn)
|
||||
|
||||
fun test9(efn: String.() -> String) {
|
||||
H.bar(efn)
|
||||
}
|
||||
|
||||
fun test10(fn: (Int) -> String) {
|
||||
H.bar2x(fn)
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public interface J<T> {
|
||||
T foo(T x);
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
public interface J2<T1, T2> {
|
||||
T1 foo(T2 x);
|
||||
}
|
||||
|
||||
// FILE: J2X.java
|
||||
public interface J2X<T3> extends J2<String, T3> {
|
||||
}
|
||||
|
||||
// FILE: H.java
|
||||
public class H {
|
||||
public static <X> void bar(J<X> j) {}
|
||||
public static <Y> void bar2x(J2X<Y> j2x) {}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package
|
||||
|
||||
public fun test1(): J<kotlin.String>
|
||||
public fun test10(/*0*/ fn: (kotlin.Int) -> kotlin.String): kotlin.Unit
|
||||
public fun test2(): J<kotlin.String!>
|
||||
public fun test3(): kotlin.Unit
|
||||
public fun test4(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun test5(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun </*0*/ T> test6(/*0*/ a: (T) -> T): kotlin.Unit
|
||||
public fun </*0*/ T> test7(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun test8(/*0*/ efn: kotlin.String.() -> kotlin.String): J<kotlin.String!>
|
||||
public fun test9(/*0*/ efn: kotlin.String.() -> kotlin.String): kotlin.Unit
|
||||
|
||||
public open class H {
|
||||
public constructor H()
|
||||
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
|
||||
|
||||
// Static members
|
||||
public open fun </*0*/ X : kotlin.Any!> bar(/*0*/ j: J<X!>!): kotlin.Unit
|
||||
public open fun </*0*/ Y : kotlin.Any!> bar2x(/*0*/ j2x: J2X<Y!>!): kotlin.Unit
|
||||
}
|
||||
|
||||
public interface J</*0*/ T : kotlin.Any!> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(/*0*/ x: T!): T!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface J2</*0*/ T1 : kotlin.Any!, /*1*/ T2 : kotlin.Any!> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract fun foo(/*0*/ x: T2!): T1!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface J2X</*0*/ T3 : kotlin.Any!> : J2<kotlin.String!, T3!> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract override /*1*/ /*fake_override*/ fun foo(/*0*/ x: T3!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
// NB new inference doesn't really work with old JVM back-end.
|
||||
|
||||
// WITH_JDK
|
||||
// FILE: samConversionsWithSmartCasts.kt
|
||||
|
||||
fun test1(a: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J.runStatic(a)
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(a: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J().run1(a)
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(a: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J().run2(a, a)
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a: () -> Unit, b: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J().run2(a, b)
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
if (a is Runnable) {
|
||||
J().run1(a)
|
||||
}
|
||||
}
|
||||
|
||||
fun test5x(a: Any) {
|
||||
if (a is Runnable) {
|
||||
a as () -> Unit
|
||||
J().run1(a)
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(a: Any) {
|
||||
a as () -> Unit
|
||||
J().run1(a)
|
||||
}
|
||||
|
||||
fun test7(a: (Int) -> Int) {
|
||||
a as () -> Unit
|
||||
J().<!INAPPLICABLE_CANDIDATE!>run1<!>(a)
|
||||
}
|
||||
|
||||
fun test8(a: () -> Unit) {
|
||||
J().<!INAPPLICABLE_CANDIDATE!>run1<!>(J.id(a))
|
||||
}
|
||||
|
||||
fun test9() {
|
||||
J().run1(::test9)
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void runStatic(Runnable r) {}
|
||||
|
||||
public void run1(Runnable r) {}
|
||||
|
||||
public void run2(Runnable r1, Runnable r2) {}
|
||||
|
||||
public static <T> T id(T x) { return x; }
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
// NB new inference doesn't really work with old JVM back-end.
|
||||
|
||||
// WITH_JDK
|
||||
// FILE: samConversionsWithSmartCasts.kt
|
||||
|
||||
fun test1(a: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J.runStatic(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(a: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J().run1(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(a: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J().run2(<!DEBUG_INFO_SMARTCAST!>a<!>, <!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a: () -> Unit, b: () -> Unit) {
|
||||
if (a is Runnable) {
|
||||
J().run2(a, b)
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
if (a is Runnable) {
|
||||
J().run1(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
}
|
||||
|
||||
fun test5x(a: Any) {
|
||||
if (a is Runnable) {
|
||||
a <!UNCHECKED_CAST!>as () -> Unit<!>
|
||||
J().run1(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(a: Any) {
|
||||
a <!UNCHECKED_CAST!>as () -> Unit<!>
|
||||
J().run1(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
|
||||
fun test7(a: (Int) -> Int) {
|
||||
a <!UNCHECKED_CAST!>as () -> Unit<!>
|
||||
J().run1(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
}
|
||||
|
||||
fun test8(a: () -> Unit) {
|
||||
J().run1(J.id(a))
|
||||
}
|
||||
|
||||
fun test9() {
|
||||
J().run1(::test9)
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void runStatic(Runnable r) {}
|
||||
|
||||
public void run1(Runnable r) {}
|
||||
|
||||
public void run2(Runnable r1, Runnable r2) {}
|
||||
|
||||
public static <T> T id(T x) { return x; }
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public fun test1(/*0*/ a: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test2(/*0*/ a: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test3(/*0*/ a: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test4(/*0*/ a: () -> kotlin.Unit, /*1*/ b: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test5(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun test5x(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun test6(/*0*/ a: kotlin.Any): kotlin.Unit
|
||||
public fun test7(/*0*/ a: (kotlin.Int) -> kotlin.Int): kotlin.Unit
|
||||
public fun test8(/*0*/ a: () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test9(): kotlin.Unit
|
||||
|
||||
public open class J {
|
||||
public constructor J()
|
||||
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 fun run1(/*0*/ r: java.lang.Runnable!): kotlin.Unit
|
||||
public open fun run2(/*0*/ r1: java.lang.Runnable!, /*1*/ r2: java.lang.Runnable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public open fun </*0*/ T : kotlin.Any!> id(/*0*/ x: T!): T!
|
||||
public open fun runStatic(/*0*/ r: java.lang.Runnable!): kotlin.Unit
|
||||
}
|
||||
Reference in New Issue
Block a user