[JS IR] Remove redundant guard assertion for extension funs with default params
Introduce corresponding test See https://youtrack.jetbrains.com/issue/KT-41076
This commit is contained in:
Generated
+5
@@ -3840,6 +3840,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
+4
-3
@@ -37,11 +37,12 @@ class JsDefaultArgumentStubGenerator(override val context: JsIrBackendContext) :
|
||||
): IrExpression {
|
||||
val paramCount = oldIrFunction.valueParameters.size
|
||||
val invokeFunctionN = resolveInvoke(paramCount)
|
||||
// NOTE: currently we do not have a syntax to perform super extension call
|
||||
// but in case we have such functionality in the future the logic bellow should be fixed
|
||||
|
||||
return irCall(invokeFunctionN, IrStatementOrigin.INVOKE).apply {
|
||||
dispatchReceiver = irImplicitCast(irGet(handlerDeclaration), invokeFunctionN.dispatchReceiverParameter!!.type)
|
||||
assert(newIrFunction.extensionReceiverParameter == null)
|
||||
// NOTE: currently we do not have a syntax to perform super extension call
|
||||
// that's why we've used to just fail with an exception in case we have extension function in for JS IR compilation
|
||||
// TODO: that was overkill, however, we still need to revisit this issue later on
|
||||
params.forEachIndexed { i, variable -> putValueArgument(i, irGet(variable)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: IGNORED_IN_JS
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
|
||||
open class MyLogic {
|
||||
protected open val postfix = "ZZZ"
|
||||
open fun String.foo(prefix: String = "XXX"): String = transform(prefix + this + postfix)
|
||||
protected fun transform(a: String) = "$a:$a"
|
||||
fun result(): String {
|
||||
return "YYY".foo()
|
||||
}
|
||||
}
|
||||
open class MyLogicWithDifferentPostfix : MyLogic() {
|
||||
override val postfix = "WWW"
|
||||
}
|
||||
|
||||
class MyLogicSpecified : MyLogic() {
|
||||
override fun String.foo(prefix: String): String = "$prefix::$this::$postfix"
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result1 = MyLogic().result()
|
||||
if (result1 != "XXXYYYZZZ:XXXYYYZZZ") {
|
||||
return "fail1: ${result1}"
|
||||
}
|
||||
|
||||
val result2 = MyLogicWithDifferentPostfix().result()
|
||||
if (result2 != "XXXYYYWWW:XXXYYYWWW") {
|
||||
return "fail2: ${result2}"
|
||||
}
|
||||
|
||||
val result3 = MyLogicSpecified().result()
|
||||
if (result3 != "XXX::YYY::ZZZ") {
|
||||
return "fail3: ${result3}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -3860,6 +3860,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
+5
@@ -3865,6 +3865,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
+5
@@ -3840,6 +3840,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -3015,6 +3015,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
Generated
+5
@@ -3015,6 +3015,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
Generated
+5
@@ -3015,6 +3015,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/classes/exceptionConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunWithDefaultParam.kt")
|
||||
public void testExtensionFunWithDefaultParam() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionFunWithDefaultParam.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionOnNamedClassObject.kt")
|
||||
public void testExtensionOnNamedClassObject() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/extensionOnNamedClassObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user