KT-37604 Use proper type when generating constructor call
This commit is contained in:
+3
-1
@@ -189,7 +189,9 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
|
|||||||
result = codegen.generateNewArray(fakeExpression, referencedFunction.getReturnType(), fakeResolvedCall);
|
result = codegen.generateNewArray(fakeExpression, referencedFunction.getReturnType(), fakeResolvedCall);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = codegen.generateConstructorCall(fakeResolvedCall, returnType);
|
//noinspection ConstantConditions
|
||||||
|
Type constructedType = codegen.typeMapper.mapTypeAsDeclaration(referencedFunction.getReturnType());
|
||||||
|
result = codegen.generateConstructorCall(fakeResolvedCall, constructedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Generated
+5
@@ -1973,6 +1973,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37604.kt")
|
||||||
|
public void testKt37604() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
|
||||||
|
fun useUnit(fn: () -> Unit) {
|
||||||
|
fn.invoke()
|
||||||
|
}
|
||||||
|
|
||||||
|
var cInit = false
|
||||||
|
|
||||||
|
class C {
|
||||||
|
init {
|
||||||
|
cInit = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var cWithDefaultInit = false
|
||||||
|
|
||||||
|
class CWithDefault(x: Int = 1) {
|
||||||
|
init {
|
||||||
|
cWithDefaultInit = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var cWithVarargInit = false
|
||||||
|
|
||||||
|
class CWithVararg(vararg x: Int) {
|
||||||
|
init {
|
||||||
|
cWithVarargInit = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
useUnit(::C)
|
||||||
|
if (!cInit) throw AssertionError("cInit")
|
||||||
|
|
||||||
|
useUnit(::CWithDefault)
|
||||||
|
if (!cWithDefaultInit) throw AssertionError("cWithDefaultInit")
|
||||||
|
|
||||||
|
useUnit(::CWithVararg)
|
||||||
|
if (!cWithVarargInit) throw AssertionError("cWithVarargInit")
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -1993,6 +1993,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37604.kt")
|
||||||
|
public void testKt37604() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
+5
@@ -1993,6 +1993,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37604.kt")
|
||||||
|
public void testKt37604() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
+5
@@ -1973,6 +1973,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
runTest("compiler/testData/codegen/box/callableReference/classesAreSynthetic.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37604.kt")
|
||||||
|
public void testKt37604() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
Generated
+5
@@ -1423,6 +1423,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37604.kt")
|
||||||
|
public void testKt37604() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
+5
@@ -1423,6 +1423,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt37604.kt")
|
||||||
|
public void testKt37604() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nested.kt")
|
@TestMetadata("nested.kt")
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user