FIR: set super type reference properly
This commit is contained in:
+9
-5
@@ -376,11 +376,15 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
|||||||
qualifiedAccessExpression.resultType = FirResolvedTypeRefImpl(session, null, type, emptyList())
|
qualifiedAccessExpression.resultType = FirResolvedTypeRefImpl(session, null, type, emptyList())
|
||||||
}
|
}
|
||||||
is FirSuperReference -> {
|
is FirSuperReference -> {
|
||||||
qualifiedAccessExpression.resultType =
|
if (callee.superTypeRef is FirResolvedTypeRef) {
|
||||||
callee.superTypeRef as? FirResolvedTypeRef
|
qualifiedAccessExpression.resultType = callee.superTypeRef
|
||||||
?: implicitReceiverStack.filterIsInstance<ImplicitDispatchReceiverValue>().lastOrNull()
|
} else {
|
||||||
?.boundSymbol?.fir?.superTypeRefs?.firstOrNull()
|
val superTypeRef = implicitReceiverStack.filterIsInstance<ImplicitDispatchReceiverValue>().lastOrNull()
|
||||||
?: FirErrorTypeRefImpl(session, qualifiedAccessExpression.psi, "No super type")
|
?.boundSymbol?.fir?.superTypeRefs?.firstOrNull()
|
||||||
|
?: FirErrorTypeRefImpl(session, qualifiedAccessExpression.psi, "No super type")
|
||||||
|
qualifiedAccessExpression.resultType = superTypeRef
|
||||||
|
callee.replaceSuperTypeRef(superTypeRef)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
is FirResolvedCallableReference -> {
|
is FirResolvedCallableReference -> {
|
||||||
if (qualifiedAccessExpression.typeRef !is FirResolvedTypeRef) {
|
if (qualifiedAccessExpression.typeRef !is FirResolvedTypeRef) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
|||||||
interface FirSuperReference : FirReference {
|
interface FirSuperReference : FirReference {
|
||||||
val superTypeRef: FirTypeRef
|
val superTypeRef: FirTypeRef
|
||||||
|
|
||||||
|
fun replaceSuperTypeRef(newSuperTypeRef: FirTypeRef)
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||||
visitor.visitSuperReference(this, data)
|
visitor.visitSuperReference(this, data)
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ class FirExplicitSuperReference(
|
|||||||
psi: PsiElement?,
|
psi: PsiElement?,
|
||||||
override var superTypeRef: FirTypeRef
|
override var superTypeRef: FirTypeRef
|
||||||
) : FirAbstractElement(session, psi), FirSuperReference {
|
) : FirAbstractElement(session, psi), FirSuperReference {
|
||||||
|
override fun replaceSuperTypeRef(newSuperTypeRef: FirTypeRef) {
|
||||||
|
superTypeRef = newSuperTypeRef
|
||||||
|
}
|
||||||
|
|
||||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||||
superTypeRef = superTypeRef.transformSingle(transformer, data)
|
superTypeRef = superTypeRef.transformSingle(transformer, data)
|
||||||
return this
|
return this
|
||||||
|
|||||||
+3
-3
@@ -24,7 +24,7 @@ FILE fqName:<root> fileName:/superCalls.kt
|
|||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.Base'
|
RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in <root>.Base'
|
||||||
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null
|
||||||
$this: ERROR_CALL 'Unresolved reference: super<<implicit>>' type=kotlin.Any
|
$this: ERROR_CALL 'Unresolved reference: super<R|kotlin/Any|>' type=kotlin.Any
|
||||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
|
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
|
||||||
overridden:
|
overridden:
|
||||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
|
||||||
@@ -44,7 +44,7 @@ FILE fqName:<root> fileName:/superCalls.kt
|
|||||||
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
CALL 'public open fun foo (): kotlin.Unit declared in <root>.Base' type=kotlin.Unit origin=null
|
CALL 'public open fun foo (): kotlin.Unit declared in <root>.Base' type=kotlin.Unit origin=null
|
||||||
$this: ERROR_CALL 'Unresolved reference: super<<implicit>>' type=<root>.Base
|
$this: ERROR_CALL 'Unresolved reference: super<R|Base|>' type=<root>.Base
|
||||||
PROPERTY name:bar visibility:public modality:FINAL [val]
|
PROPERTY name:bar visibility:public modality:FINAL [val]
|
||||||
FUN name:<get-bar> visibility:public modality:FINAL <> ($this:<root>.Derived) returnType:kotlin.String
|
FUN name:<get-bar> visibility:public modality:FINAL <> ($this:<root>.Derived) returnType:kotlin.String
|
||||||
correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [val]
|
correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [val]
|
||||||
@@ -52,7 +52,7 @@ FILE fqName:<root> fileName:/superCalls.kt
|
|||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public final fun <get-bar> (): kotlin.String declared in <root>.Derived'
|
RETURN type=kotlin.Nothing from='public final fun <get-bar> (): kotlin.String declared in <root>.Derived'
|
||||||
CALL 'public open fun <get-bar> (): kotlin.String declared in <root>.Base' type=kotlin.String origin=null
|
CALL 'public open fun <get-bar> (): kotlin.String declared in <root>.Base' type=kotlin.String origin=null
|
||||||
$this: ERROR_CALL 'Unresolved reference: super<<implicit>>' type=<root>.Base
|
$this: ERROR_CALL 'Unresolved reference: super<R|Base|>' type=<root>.Base
|
||||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:<root>.Base) returnType:kotlin.Int
|
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:<root>.Base) returnType:kotlin.Int
|
||||||
overridden:
|
overridden:
|
||||||
public open fun hashCode (): kotlin.Int declared in <root>.Base
|
public open fun hashCode (): kotlin.Int declared in <root>.Base
|
||||||
|
|||||||
Reference in New Issue
Block a user