JVM_IR: handle type parameters in constructors for @JvmOverloads stubs
This commit is contained in:
+2
-1
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
|
|||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.types.defaultType
|
import org.jetbrains.kotlin.ir.types.defaultType
|
||||||
|
import org.jetbrains.kotlin.ir.util.allTypeParameters
|
||||||
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
||||||
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
import org.jetbrains.kotlin.ir.util.hasAnnotation
|
||||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_OVERLOADS_FQ_NAME
|
import org.jetbrains.kotlin.resolve.jvm.annotations.JVM_OVERLOADS_FQ_NAME
|
||||||
@@ -60,7 +61,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
|
|||||||
IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol, target.descriptor)
|
IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol, target.descriptor)
|
||||||
else
|
else
|
||||||
IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol)
|
IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol)
|
||||||
for (arg in wrapperIrFunction.typeParameters) {
|
for (arg in wrapperIrFunction.allTypeParameters) {
|
||||||
call.putTypeArgument(arg.index, arg.defaultType)
|
call.putTypeArgument(arg.index, arg.defaultType)
|
||||||
}
|
}
|
||||||
call.dispatchReceiver = wrapperIrFunction.dispatchReceiverParameter?.let { dispatchReceiver ->
|
call.dispatchReceiver = wrapperIrFunction.dispatchReceiverParameter?.let { dispatchReceiver ->
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
class C<K> @JvmOverloads constructor(val s: String = "OK")
|
||||||
|
|
||||||
|
fun box() = C<Unit>().s
|
||||||
+5
@@ -15152,6 +15152,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/jvmOverloads/companionObject.kt");
|
runTest("compiler/testData/codegen/box/jvmOverloads/companionObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constructorWithTypeParams.kt")
|
||||||
|
public void testConstructorWithTypeParams() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmOverloads/constructorWithTypeParams.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("defaultsNotAtEnd.kt")
|
@TestMetadata("defaultsNotAtEnd.kt")
|
||||||
public void testDefaultsNotAtEnd() throws Exception {
|
public void testDefaultsNotAtEnd() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
|
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
|
||||||
|
|||||||
+5
@@ -15152,6 +15152,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/jvmOverloads/companionObject.kt");
|
runTest("compiler/testData/codegen/box/jvmOverloads/companionObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constructorWithTypeParams.kt")
|
||||||
|
public void testConstructorWithTypeParams() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmOverloads/constructorWithTypeParams.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("defaultsNotAtEnd.kt")
|
@TestMetadata("defaultsNotAtEnd.kt")
|
||||||
public void testDefaultsNotAtEnd() throws Exception {
|
public void testDefaultsNotAtEnd() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
|
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
|
||||||
|
|||||||
+5
@@ -14037,6 +14037,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/jvmOverloads/companionObject.kt");
|
runTest("compiler/testData/codegen/box/jvmOverloads/companionObject.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("constructorWithTypeParams.kt")
|
||||||
|
public void testConstructorWithTypeParams() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/jvmOverloads/constructorWithTypeParams.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("defaultsNotAtEnd.kt")
|
@TestMetadata("defaultsNotAtEnd.kt")
|
||||||
public void testDefaultsNotAtEnd() throws Exception {
|
public void testDefaultsNotAtEnd() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
|
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
|
||||||
|
|||||||
@@ -181,20 +181,5 @@ public class IrJsTextTestCaseGenerated extends AbstractIrJsTextTestCase {
|
|||||||
public void testAllFilesPresentInScripting() throws Exception {
|
public void testAllFilesPresentInScripting() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/scripting"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/scripting"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("arrayAssignment.kts")
|
|
||||||
public void testArrayAssignment() throws Exception {
|
|
||||||
runTest("compiler/testData/ir/irJsText/scripting/arrayAssignment.kts");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("fun.kts")
|
|
||||||
public void testFun() throws Exception {
|
|
||||||
runTest("compiler/testData/ir/irJsText/scripting/fun.kts");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("safeCalls.kts")
|
|
||||||
public void testSafeCalls() throws Exception {
|
|
||||||
runTest("compiler/testData/ir/irJsText/scripting/safeCalls.kts");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user