FIR: fix substitution of type arguments in SAM type aliases
^KT-54730 Fixed
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
fun interface KRunnable {
|
||||
fun invoke()
|
||||
}
|
||||
|
||||
fun interface KConsumer<T> {
|
||||
fun accept(value: T)
|
||||
}
|
||||
|
||||
typealias KRunnableAlias = KRunnable
|
||||
|
||||
typealias StringConsumer = KConsumer<String>
|
||||
|
||||
fun foo(f: KRunnable) = f
|
||||
|
||||
fun <T> bar(f: KConsumer<T>) = f
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
foo(KRunnable {
|
||||
bar(KConsumer<String> {
|
||||
result += it
|
||||
}).accept("O")
|
||||
}).invoke()
|
||||
foo(KRunnableAlias {
|
||||
bar(StringConsumer {
|
||||
result += it
|
||||
}).accept("K")
|
||||
}).invoke()
|
||||
return result
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
// FILE: test.kt
|
||||
typealias RunnableT = java.lang.Runnable
|
||||
typealias ComparatorT<T> = java.util.Comparator<T>
|
||||
typealias ComparatorStrT = ComparatorT<String>
|
||||
|
||||
val test1 = RunnableT { }
|
||||
val test2 = ComparatorT<String> { s1, s2 -> s1.compareTo(s2) }
|
||||
val test3 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>ComparatorStrT<!> { <!CANNOT_INFER_PARAMETER_TYPE!>s1<!>, <!CANNOT_INFER_PARAMETER_TYPE!>s2<!> -> s1.compareTo(s2) }
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: test.kt
|
||||
typealias RunnableT = java.lang.Runnable
|
||||
typealias ComparatorT<T> = java.util.Comparator<T>
|
||||
|
||||
Vendored
-27
@@ -1,27 +0,0 @@
|
||||
// FILE: JHost.java
|
||||
public class JHost {
|
||||
public static interface Runnable {
|
||||
void run();
|
||||
}
|
||||
|
||||
public static interface Consumer<T> {
|
||||
void consume(T x);
|
||||
}
|
||||
|
||||
public static interface Consumer2<T1, T2> {
|
||||
void run(T1 x1, T2 x2);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
typealias R = JHost.Runnable
|
||||
typealias C<T> = JHost.Consumer<T>
|
||||
typealias CStr = JHost.Consumer<String>
|
||||
typealias CStrList = JHost.Consumer<List<String>>
|
||||
typealias C2<T> = JHost.Consumer2<T, T>
|
||||
|
||||
val test1 = R { }
|
||||
val test2 = C<String> { s -> println(s.length) }
|
||||
val test3 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>CStr<!> { <!CANNOT_INFER_PARAMETER_TYPE!>s<!> -> <!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(s.<!UNRESOLVED_REFERENCE!>length<!>) }
|
||||
val test4 = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>CStrList<!> { <!CANNOT_INFER_PARAMETER_TYPE!>ss<!> -> for (s in <!ITERATOR_AMBIGUITY!>ss<!>) { <!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(s.<!UNRESOLVED_REFERENCE!>length<!>) } }
|
||||
val test5 = <!INAPPLICABLE_CANDIDATE!>C2<!><<!CANNOT_INFER_PARAMETER_TYPE!>Int<!>> { <!CANNOT_INFER_PARAMETER_TYPE!>a<!>, <!CANNOT_INFER_PARAMETER_TYPE!>b<!> -> val x: Int = a <!OVERLOAD_RESOLUTION_AMBIGUITY!>+<!> b; println(x)}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: JHost.java
|
||||
public class JHost {
|
||||
public static interface Runnable {
|
||||
|
||||
+8
-8
@@ -112,15 +112,15 @@ FILE fqName:<root> fileName:/funInterfaceConstructorReference.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test2a (): kotlin.Function1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> declared in <root>'
|
||||
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
|
||||
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSupplier visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.String>) returnType:<root>.KSupplier<kotlin.String>
|
||||
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KSS visibility:local modality:FINAL <> (function:kotlin.Function0<kotlin.String>) returnType:<root>.KSupplier<kotlin.String>
|
||||
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function0<kotlin.String>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun KSupplier (function: kotlin.Function0<kotlin.String>): <root>.KSupplier<kotlin.String> declared in <root>.test2a'
|
||||
RETURN type=kotlin.Nothing from='local final fun KSS (function: kotlin.Function0<kotlin.String>): <root>.KSupplier<kotlin.String> declared in <root>.test2a'
|
||||
TYPE_OP type=<root>.KSupplier<kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.KSupplier<kotlin.String>
|
||||
CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function0<kotlin.String> origin=EXCLEXCL
|
||||
<T0>: kotlin.Function0<kotlin.String>
|
||||
arg0: GET_VAR 'function: kotlin.Function0<kotlin.String> declared in <root>.test2a.KSupplier' type=kotlin.Function0<kotlin.String> origin=null
|
||||
FUNCTION_REFERENCE 'local final fun KSupplier (function: kotlin.Function0<kotlin.String>): <root>.KSupplier<kotlin.String> declared in <root>.test2a' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
|
||||
arg0: GET_VAR 'function: kotlin.Function0<kotlin.String> declared in <root>.test2a.KSS' type=kotlin.Function0<kotlin.String> origin=null
|
||||
FUNCTION_REFERENCE 'local final fun KSS (function: kotlin.Function0<kotlin.String>): <root>.KSupplier<kotlin.String> declared in <root>.test2a' type=kotlin.reflect.KFunction1<kotlin.Function0<kotlin.String>, <root>.KSupplier<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
|
||||
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> declared in <root>'
|
||||
@@ -138,15 +138,15 @@ FILE fqName:<root> fileName:/funInterfaceConstructorReference.kt
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test3a (): kotlin.Function1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> declared in <root>'
|
||||
BLOCK type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE
|
||||
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KConsumer visibility:local modality:FINAL <> (function:kotlin.Function1<kotlin.String, kotlin.Unit>) returnType:<root>.KConsumer<kotlin.String>
|
||||
FUN ADAPTER_FOR_FUN_INTERFACE_CONSTRUCTOR name:KCS visibility:local modality:FINAL <> (function:kotlin.Function1<kotlin.String, kotlin.Unit>) returnType:<root>.KConsumer<kotlin.String>
|
||||
VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:function index:0 type:kotlin.Function1<kotlin.String, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun KConsumer (function: kotlin.Function1<kotlin.String, kotlin.Unit>): <root>.KConsumer<kotlin.String> declared in <root>.test3a'
|
||||
RETURN type=kotlin.Nothing from='local final fun KCS (function: kotlin.Function1<kotlin.String, kotlin.Unit>): <root>.KConsumer<kotlin.String> declared in <root>.test3a'
|
||||
TYPE_OP type=<root>.KConsumer<kotlin.String> origin=SAM_CONVERSION typeOperand=<root>.KConsumer<kotlin.String>
|
||||
CALL 'public final fun CHECK_NOT_NULL <T0> (arg0: T0 of kotlin.internal.ir.CHECK_NOT_NULL?): {T0 of kotlin.internal.ir.CHECK_NOT_NULL & Any} declared in kotlin.internal.ir' type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=EXCLEXCL
|
||||
<T0>: kotlin.Function1<kotlin.String, kotlin.Unit>
|
||||
arg0: GET_VAR 'function: kotlin.Function1<kotlin.String, kotlin.Unit> declared in <root>.test3a.KConsumer' type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=null
|
||||
FUNCTION_REFERENCE 'local final fun KConsumer (function: kotlin.Function1<kotlin.String, kotlin.Unit>): <root>.KConsumer<kotlin.String> declared in <root>.test3a' type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
|
||||
arg0: GET_VAR 'function: kotlin.Function1<kotlin.String, kotlin.Unit> declared in <root>.test3a.KCS' type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=null
|
||||
FUNCTION_REFERENCE 'local final fun KCS (function: kotlin.Function1<kotlin.String, kotlin.Unit>): <root>.KConsumer<kotlin.String> declared in <root>.test3a' type=kotlin.reflect.KFunction1<kotlin.Function1<kotlin.String, kotlin.Unit>, <root>.KConsumer<kotlin.String>> origin=FUN_INTERFACE_CONSTRUCTOR_REFERENCE reflectionTarget=<same>
|
||||
FUN name:test3b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction<<root>.KConsumer<kotlin.String>>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test3b (): kotlin.reflect.KFunction<<root>.KConsumer<kotlin.String>> declared in <root>'
|
||||
|
||||
+4
-5
@@ -58,11 +58,11 @@ fun test2(): Function1<Function0<String>, KSupplier<String>> {
|
||||
|
||||
fun test2a(): Function1<Function0<String>, KSupplier<String>> {
|
||||
return { // BLOCK
|
||||
local fun KSupplier(function: Function0<String>): KSupplier<String> {
|
||||
local fun KSS(function: Function0<String>): KSupplier<String> {
|
||||
return CHECK_NOT_NULL<Function0<String>>(arg0 = function) /*-> KSupplier<String> */
|
||||
}
|
||||
|
||||
::KSupplier
|
||||
::KSS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ fun test3(): Function1<Function1<String, Unit>, KConsumer<String>> {
|
||||
|
||||
fun test3a(): Function1<Function1<String, Unit>, KConsumer<String>> {
|
||||
return { // BLOCK
|
||||
local fun KConsumer(function: Function1<String, Unit>): KConsumer<String> {
|
||||
local fun KCS(function: Function1<String, Unit>): KConsumer<String> {
|
||||
return CHECK_NOT_NULL<Function1<String, Unit>>(arg0 = function) /*-> KConsumer<String> */
|
||||
}
|
||||
|
||||
::KConsumer
|
||||
::KCS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,4 +95,3 @@ fun test3b(): KFunction<KConsumer<String>> {
|
||||
::KConsumer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user