JS: fix explicit cross-module SAM constructor calls
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument
|
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument
|
||||||
// IGNORE_BACKEND: JS_IR
|
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// SKIP_DCE_DRIVEN
|
||||||
|
|
||||||
fun interface MyRunnable {
|
fun interface MyRunnable {
|
||||||
fun run()
|
fun run()
|
||||||
|
|||||||
+17
-1
@@ -12,6 +12,8 @@ fun rn(i: I) = i.f()
|
|||||||
|
|
||||||
inline fun rnInline(i: I) = i.f()
|
inline fun rnInline(i: I) = i.f()
|
||||||
|
|
||||||
|
inline fun rnInlineCtor(s: String) = I { s + ".m1" }
|
||||||
|
|
||||||
// MODULE: m2(m1)
|
// MODULE: m2(m1)
|
||||||
// FILE: m2.kt
|
// FILE: m2.kt
|
||||||
|
|
||||||
@@ -19,12 +21,26 @@ fun rn2(f: () -> String) = rn(f)
|
|||||||
|
|
||||||
inline fun rn2Inline(noinline f: () -> String) = rnInline(f)
|
inline fun rn2Inline(noinline f: () -> String) = rnInline(f)
|
||||||
|
|
||||||
|
inline fun rnInlineCtorProxy(s: String) = rnInlineCtor(s + ".m2").f()
|
||||||
|
|
||||||
|
fun interface II {
|
||||||
|
fun f(): String
|
||||||
|
}
|
||||||
|
|
||||||
// MODULE: main(m2)
|
// MODULE: main(m2)
|
||||||
// FILE: main.kt
|
// FILE: main.kt
|
||||||
|
|
||||||
|
fun id(i: II) = i
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
|
|
||||||
if (rn2Inline { "inline" } != "inline") return "fail"
|
if (id { "1" }.f() != "1") return "fail 1"
|
||||||
|
|
||||||
|
if (II { "2" }.f() != "2") return "fail 2"
|
||||||
|
|
||||||
|
if (rnInlineCtorProxy("3") != "3.m2.m1") return "fail 3"
|
||||||
|
|
||||||
|
if (rn2Inline { "inline" } != "inline") return "fail 4"
|
||||||
|
|
||||||
return rn2 { "OK" }
|
return rn2 { "OK" }
|
||||||
}
|
}
|
||||||
+4
-2
@@ -197,12 +197,14 @@ object ConstructorCallCase : FunctionCallCase() {
|
|||||||
private inline fun FunctionCallInfo.doTranslate(
|
private inline fun FunctionCallInfo.doTranslate(
|
||||||
getArguments: CallArgumentTranslator.ArgumentsInfo.() -> List<JsExpression>
|
getArguments: CallArgumentTranslator.ArgumentsInfo.() -> List<JsExpression>
|
||||||
): JsExpression {
|
): JsExpression {
|
||||||
val functionRef = ReferenceTranslator.translateAsValueReference(callableDescriptor, context)
|
|
||||||
|
|
||||||
if (callableDescriptor is SamConstructorDescriptor) {
|
(callableDescriptor as? SamConstructorDescriptor)?.baseDescriptorForSynthetic?.let { funInterface ->
|
||||||
|
val functionRef = ReferenceTranslator.translateAsTypeReference(funInterface, context)
|
||||||
return JsNew(functionRef, argumentsInfo.getArguments())
|
return JsNew(functionRef, argumentsInfo.getArguments())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val functionRef = ReferenceTranslator.translateAsValueReference(callableDescriptor, context)
|
||||||
|
|
||||||
val invocationArguments = mutableListOf<JsExpression>()
|
val invocationArguments = mutableListOf<JsExpression>()
|
||||||
|
|
||||||
val constructorDescriptor = callableDescriptor as ClassConstructorDescriptor
|
val constructorDescriptor = callableDescriptor as ClassConstructorDescriptor
|
||||||
|
|||||||
Reference in New Issue
Block a user