PSI2IR KT-44013 WA: function interface constructor call accepted by FE

This commit is contained in:
Dmitry Petrov
2021-04-27 11:49:57 +03:00
committed by TeamCityServer
parent 704b5a0e13
commit 660208740e
6 changed files with 161 additions and 1 deletions
@@ -238,6 +238,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/classes/kt43217.kt");
}
@Test
@TestMetadata("kt44013.kt")
public void testKt44013() throws Exception {
runTest("compiler/testData/ir/irText/classes/kt44013.kt");
}
@Test
@TestMetadata("kt45853.kt")
public void testKt45853() throws Exception {
@@ -239,7 +239,8 @@ class BodyGenerator(
(ktClassOrObject as? KtClassOrObject)?.getSuperTypeList()?.let { ktSuperTypeList ->
for (ktSuperTypeListEntry in ktSuperTypeList.entries) {
if (ktSuperTypeListEntry is KtSuperTypeCallEntry) {
val superConstructorCall = statementGenerator.pregenerateCall(getResolvedCall(ktSuperTypeListEntry)!!)
val resolvedCall = getResolvedCall(ktSuperTypeListEntry) ?: continue
val superConstructorCall = statementGenerator.pregenerateCall(resolvedCall)
val irSuperConstructorCall = CallGenerator(statementGenerator).generateDelegatingConstructorCall(
ktSuperTypeListEntry.startOffsetSkippingComments, ktSuperTypeListEntry.endOffset, superConstructorCall
)
+69
View File
@@ -0,0 +1,69 @@
FILE fqName:<root> fileName:/kt44013.kt
CLASS CLASS name:Test1 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test1
CONSTRUCTOR visibility:public <> () returnType:<root>.Test1 [primary]
BLOCK_BODY
ERROR_CALL 'Cannot find delegated constructor call' type=kotlin.Function0<kotlin.Int>
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>]'
FUN FAKE_OVERRIDE name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<R of kotlin.Function0>) returnType:kotlin.Int [fake_override,operator]
overridden:
public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Function0<R of kotlin.Function0>
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Base
CONSTRUCTOR visibility:public <> () returnType:<root>.Base [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Test2 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>; <root>.Base]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test2
CONSTRUCTOR visibility:public <> () returnType:<root>.Test2 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>; <root>.Base]'
FUN FAKE_OVERRIDE name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<R of kotlin.Function0>) returnType:kotlin.Int [fake_override,operator]
overridden:
public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Function0<R of kotlin.Function0>
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Function0
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Function0
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Function0
public open fun toString (): kotlin.String [fake_override] declared in <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
+9
View File
@@ -0,0 +1,9 @@
// SKIP_KT_DUMP
// IGNORE_FIR_DIAGNOSTICS
// See KT-44013: FE accepts incorrect code in 1.5
abstract class Test1 : () -> Int()
abstract class Base
abstract class Test2 : () -> Int(), Base()
+69
View File
@@ -0,0 +1,69 @@
FILE fqName:<root> fileName:/kt44013.kt
CLASS CLASS name:Test1 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test1
CONSTRUCTOR visibility:public <> () returnType:<root>.Test1 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>]'
FUN FAKE_OVERRIDE name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<kotlin.Int>) returnType:kotlin.Int [fake_override,operator]
overridden:
public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Function0<kotlin.Int>
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Base
CONSTRUCTOR visibility:public <> () returnType:<root>.Base [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Test2 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>; <root>.Base]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test2
CONSTRUCTOR visibility:public <> () returnType:<root>.Test2 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Base'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:ABSTRACT visibility:public superTypes:[kotlin.Function0<kotlin.Int>; <root>.Base]'
FUN FAKE_OVERRIDE name:invoke visibility:public modality:ABSTRACT <> ($this:kotlin.Function0<kotlin.Int>) returnType:kotlin.Int [fake_override,operator]
overridden:
public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0
$this: VALUE_PARAMETER name:<this> type:kotlin.Function0<kotlin.Int>
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Function0
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Function0
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String [fake_override] declared in kotlin.Function0
public open fun toString (): kotlin.String [fake_override] declared in <root>.Base
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -238,6 +238,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
runTest("compiler/testData/ir/irText/classes/kt43217.kt");
}
@Test
@TestMetadata("kt44013.kt")
public void testKt44013() throws Exception {
runTest("compiler/testData/ir/irText/classes/kt44013.kt");
}
@Test
@TestMetadata("kt45853.kt")
public void testKt45853() throws Exception {