JVM_IR: handle type parameters in constructors for @JvmOverloads stubs

This commit is contained in:
Georgy Bronnikov
2019-10-11 15:04:17 +03:00
parent 7ceb2c79b8
commit f3cae210f8
6 changed files with 23 additions and 16 deletions
@@ -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.IrSimpleFunctionSymbolImpl
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.hasAnnotation
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)
else
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.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
@@ -15152,6 +15152,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
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")
public void testDefaultsNotAtEnd() throws Exception {
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
@@ -15152,6 +15152,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
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")
public void testDefaultsNotAtEnd() throws Exception {
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
@@ -14037,6 +14037,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
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")
public void testDefaultsNotAtEnd() throws Exception {
runTest("compiler/testData/codegen/box/jvmOverloads/defaultsNotAtEnd.kt");
@@ -181,20 +181,5 @@ public class IrJsTextTestCaseGenerated extends AbstractIrJsTextTestCase {
public void testAllFilesPresentInScripting() throws Exception {
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");
}
}
}