FIR: add resolve for delegated super-type

This commit fixes FIR modularized resolve test on whole Kotlin project
(without it we had empty super-type set with delegated super-types)
This commit is contained in:
Mikhail Glukhikh
2019-08-22 18:28:30 +03:00
parent a9bc3c19d6
commit 27ccff12c1
7 changed files with 146 additions and 9 deletions
@@ -117,7 +117,10 @@ class FirTypeResolverImpl(private val session: FirSession) : FirTypeResolver {
is FirImplicitBuiltinTypeRef -> {
resolveToSymbol(typeRef, scope, position)!!.constructType(emptyList(), isNullable = false)
}
is FirDynamicTypeRef, is FirDelegatedTypeRef -> {
is FirDelegatedTypeRef -> {
resolveType(typeRef.typeRef, scope, position)
}
is FirDynamicTypeRef -> {
ConeKotlinErrorType("Not supported: ${typeRef::class.simpleName}")
}
else -> error("!")
@@ -0,0 +1,9 @@
interface A {
fun foo()
}
class B : A {
override fun foo() {}
}
class C(val b: B) : A by b
@@ -0,0 +1,23 @@
FILE: delegatedSuperType.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public final class B : R|A| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
public final override fun foo(): R|kotlin/Unit| {
}
}
public final class C : R|A| {
public constructor(b: R|B|): R|C| {
super<R|kotlin/Any|>()
}
public final val b: R|B| = R|<local>/b|
public get(): R|B|
}
@@ -44,6 +44,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
runTest("compiler/fir/resolve/testData/resolve/copy.kt");
}
@TestMetadata("delegatedSuperType.kt")
public void testDelegatedSuperType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/delegatedSuperType.kt");
}
@TestMetadata("derivedClass.kt")
public void testDerivedClass() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/derivedClass.kt");
@@ -157,15 +157,71 @@ FILE fqName:<root> fileName:/delegatedImplementation.kt
VALUE_PARAMETER name:value index:0 type:kotlin.Int
BLOCK_BODY
CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.otherImpl.<no name provided>' type=<root>.otherImpl.<no name provided> origin=null
CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[]
CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[<root>.IBase]
$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:FINAL visibility:public superTypes:[]'
CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[]
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[<root>.IBase]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
VALUE_PARAMETER name:x index:0 type:kotlin.Int
VALUE_PARAMETER name:s index:1 type:kotlin.String
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.IBase) returnType:kotlin.Int
overridden:
public abstract fun bar (): kotlin.Int declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:<root>.IBase, $receiver:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun qux (): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean 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
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
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.IBase; <root>.IOther]
$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 kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[<root>.IBase; <root>.IOther]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IBase, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
VALUE_PARAMETER name:x index:0 type:kotlin.Int
VALUE_PARAMETER name:s index:1 type:kotlin.String
FUN FAKE_OVERRIDE name:bar visibility:public modality:ABSTRACT <> ($this:<root>.IBase) returnType:kotlin.Int
overridden:
public abstract fun bar (): kotlin.Int declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:<root>.IBase, $receiver:kotlin.String) returnType:kotlin.Unit
overridden:
public abstract fun qux (): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean 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
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
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -43,12 +43,29 @@ FILE fqName:<root> fileName:/delegatedImplementationWithExplicitOverride.kt
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[]
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.IFooBar]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[<root>.IFooBar]'
FUN name:bar visibility:public modality:FINAL <> ($this:<root>.C) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.C
BLOCK_BODY
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFooBar) returnType:kotlin.Unit
overridden:
public abstract fun foo (): kotlin.Unit declared in <root>.IFooBar
$this: VALUE_PARAMETER name:<this> type:<root>.IFooBar
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean 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
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
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
@@ -27,11 +27,35 @@ FILE fqName:<root> fileName:/delegatedMembers.kt
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[]
CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[<root>.IBase<TT of <root>.Test>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test
TYPE_PARAMETER name:TT index:0 variance: superTypes:[]
CONSTRUCTOR visibility:public <> (impl:<root>.IBase<TT of <uninitialized parent>>) returnType:<root>.Test<TT of <uninitialized parent>> [primary]
VALUE_PARAMETER name:impl index:0 type:<root>.IBase<TT of <uninitialized parent>>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[<root>.IBase<TT of <root>.Test>]'
FUN FAKE_OVERRIDE name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IBase, x:kotlin.Int) returnType:kotlin.Unit
overridden:
public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
VALUE_PARAMETER name:x index:0 type:kotlin.Int
FUN FAKE_OVERRIDE name:qux visibility:public modality:ABSTRACT <> ($this:<root>.IBase, t:TT of <root>.Test, x:X of <root>.IBase.qux) returnType:kotlin.Unit
overridden:
public abstract fun qux <X> (t: T of <root>.IBase, x: X of <root>.IBase.qux): kotlin.Unit declared in <root>.IBase
$this: VALUE_PARAMETER name:<this> type:<root>.IBase
VALUE_PARAMETER name:t index:0 type:TT of <root>.Test
VALUE_PARAMETER name:x index:1 type:X of <root>.IBase.qux
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean 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
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
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any