FIR: handle labeled super reference properly

This commit is contained in:
Jinseong Jeon
2020-04-30 23:37:37 -07:00
committed by Mikhail Glukhikh
parent 260683c20e
commit 7b01cf7b04
32 changed files with 141 additions and 299 deletions
@@ -1,6 +1,6 @@
FILE: superNotAvailable.kt FILE: superNotAvailable.kt
public final fun R|kotlin/String|.f(): R|kotlin/Unit| { public final fun R|kotlin/String|.f(): R|kotlin/Unit| {
super<<ERROR TYPE REF: No super type>>.<Unresolved name: compareTo>#(String()) super<<ERROR TYPE REF: No super type>>@f#.<Unresolved name: compareTo>#(String())
super<<ERROR TYPE REF: No super type>>.<Unresolved name: compareTo>#(String()) super<<ERROR TYPE REF: No super type>>.<Unresolved name: compareTo>#(String())
} }
public final fun foo(): R|kotlin/Unit| { public final fun foo(): R|kotlin/Unit| {
@@ -20,13 +20,14 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
object FirNotASupertypeChecker : FirQualifiedAccessChecker() { object FirNotASupertypeChecker : FirQualifiedAccessChecker() {
override fun check(functionCall: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) { override fun check(functionCall: FirQualifiedAccessExpression, context: CheckerContext, reporter: DiagnosticReporter) {
val surrounding = context.findClosestClass() ?: return val superReference = functionCall.calleeReference.safeAs<FirSuperReference>()
val targetClass = functionCall.calleeReference.safeAs<FirSuperReference>() val targetClass = superReference
?.superTypeRef ?.superTypeRef
?.toRegularClass(context.session) ?.toRegularClass(context.session)
?: return ?: return
val surrounding = context.findClosestClass(superReference.labelName) ?: return
if (!targetClass.isSupertypeOf(surrounding)) { if (!targetClass.isSupertypeOf(surrounding)) {
reporter.report(functionCall.source) reporter.report(functionCall.source)
} }
@@ -37,13 +38,14 @@ object FirNotASupertypeChecker : FirQualifiedAccessChecker() {
* item like FirRegularClass or FirAnonymousObject * item like FirRegularClass or FirAnonymousObject
* or null if no such item could be found. * or null if no such item could be found.
*/ */
private fun CheckerContext.findClosestClass(): FirClass<*>? { private fun CheckerContext.findClosestClass(label: String?): FirClass<*>? {
for (it in containingDeclarations.reversed()) { for (it in containingDeclarations.reversed()) {
if ( if (it is FirRegularClass || it is FirAnonymousObject) {
it is FirRegularClass || val firClass = it as FirClass<*>
it is FirAnonymousObject val className = firClass.symbol.classId.shortClassName
) { if (label == null || (!className.isSpecial && className.identifier == label)) {
return it as FirClass<*> return firClass
}
} }
} }
@@ -96,6 +96,20 @@ class Fir2IrConversionScope {
return irClass.thisReceiver return irClass.thisReceiver
} }
fun dispatchReceiverParameter(label: String): IrValueParameter? {
for (function in functionStack.asReversed()) {
if (!function.name.isSpecial && function.name.identifier == label) {
function.dispatchReceiverParameter?.let { return it }
}
}
for (irClass in classStack.asReversed()) {
if (!irClass.name.isSpecial && irClass.name.identifier == label) {
return irClass.thisReceiver
}
}
return null
}
fun lastDispatchReceiverParameter(): IrValueParameter? { fun lastDispatchReceiverParameter(): IrValueParameter? {
// Use the dispatch receiver of the containing/enclosing functions (from the last to the first) // Use the dispatch receiver of the containing/enclosing functions (from the last to the first)
for (function in functionStack.asReversed()) { for (function in functionStack.asReversed()) {
@@ -166,8 +166,12 @@ internal class CallAndReferenceGenerator(
) )
return typeRef.convertWithOffsets { startOffset, endOffset -> return typeRef.convertWithOffsets { startOffset, endOffset ->
if (qualifiedAccess.calleeReference is FirSuperReference) { if (qualifiedAccess.calleeReference is FirSuperReference) {
val superReference = qualifiedAccess.calleeReference as FirSuperReference
if (typeRef !is FirComposedSuperTypeRef) { if (typeRef !is FirComposedSuperTypeRef) {
val dispatchReceiver = conversionScope.lastDispatchReceiverParameter() val label = superReference.labelName
val dispatchReceiver =
if (label != null) conversionScope.dispatchReceiverParameter(label)
else conversionScope.lastDispatchReceiverParameter()
if (dispatchReceiver != null) { if (dispatchReceiver != null) {
return@convertWithOffsets IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol) return@convertWithOffsets IrGetValueImpl(startOffset, endOffset, dispatchReceiver.type, dispatchReceiver.symbol)
} }
@@ -1143,6 +1143,7 @@ class ExpressionsConverter(
* @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitSuperExpression * @see org.jetbrains.kotlin.fir.builder.RawFirBuilder.Visitor.visitSuperExpression
*/ */
private fun convertSuperExpression(superExpression: LighterASTNode): FirQualifiedAccessExpression { private fun convertSuperExpression(superExpression: LighterASTNode): FirQualifiedAccessExpression {
val label: String? = superExpression.getLabelName()
var superTypeRef: FirTypeRef = implicitType var superTypeRef: FirTypeRef = implicitType
superExpression.forEachChildren { superExpression.forEachChildren {
when (it.tokenType) { when (it.tokenType) {
@@ -1153,6 +1154,7 @@ class ExpressionsConverter(
return buildQualifiedAccessExpression { return buildQualifiedAccessExpression {
source = superExpression.toFirSourceElement() source = superExpression.toFirSourceElement()
calleeReference = buildExplicitSuperReference { calleeReference = buildExplicitSuperReference {
labelName = label
this.superTypeRef = superTypeRef this.superTypeRef = superTypeRef
} }
} }
@@ -1723,6 +1723,7 @@ class RawFirBuilder(
this.source = source this.source = source
calleeReference = buildExplicitSuperReference { calleeReference = buildExplicitSuperReference {
this.source this.source
labelName = expression.getLabelName()
superTypeRef = superType.toFirOrImplicitType() superTypeRef = superType.toFirOrImplicitType()
} }
} }
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.references.FirSuperReference import org.jetbrains.kotlin.fir.references.FirSuperReference
import org.jetbrains.kotlin.fir.references.FirThisReference import org.jetbrains.kotlin.fir.references.FirThisReference
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue
import org.jetbrains.kotlin.fir.resolve.calls.isSuperReferenceExpression import org.jetbrains.kotlin.fir.resolve.calls.isSuperReferenceExpression
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
@@ -353,7 +354,12 @@ fun <T : FirResolvable> BodyResolveComponents.typeFromCallee(access: T): FirReso
} }
} }
is FirSuperReference -> { is FirSuperReference -> {
newCallee.superTypeRef as? FirResolvedTypeRef ?: buildErrorTypeRef { val labelName = newCallee.labelName
val implicitReceiver = implicitReceiverStack[labelName] as? ImplicitDispatchReceiverValue
val resolvedTypeRef =
if (implicitReceiver != null) implicitReceiver.boundSymbol.phasedFir.superTypeRefs.singleOrNull() as? FirResolvedTypeRef
else newCallee.superTypeRef as? FirResolvedTypeRef
resolvedTypeRef ?: buildErrorTypeRef {
source = newCallee.source source = newCallee.source
diagnostic = ConeUnresolvedNameError(Name.identifier("super")) diagnostic = ConeUnresolvedNameError(Name.identifier("super"))
} }
@@ -375,7 +381,6 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol<
} }
} }
is FirClassifierSymbol<*> -> { is FirClassifierSymbol<*> -> {
val fir = (symbol as? AbstractFirBasedSymbol<*>)?.phasedFir
// TODO: unhack // TODO: unhack
buildResolvedTypeRef { buildResolvedTypeRef {
source = null source = null
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue
import org.jetbrains.kotlin.fir.resolve.calls.candidate import org.jetbrains.kotlin.fir.resolve.calls.candidate
import org.jetbrains.kotlin.fir.resolve.diagnostics.* import org.jetbrains.kotlin.fir.resolve.diagnostics.*
import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer
@@ -89,7 +90,11 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
qualifiedAccessExpression.resultType = callee.superTypeRef qualifiedAccessExpression.resultType = callee.superTypeRef
} }
else -> { else -> {
val superTypeRefs = implicitReceiverStack.lastDispatchReceiver()?.boundSymbol?.phasedFir?.superTypeRefs val labelName = callee.labelName
val implicitReceiver =
if (labelName != null) implicitReceiverStack[labelName] as? ImplicitDispatchReceiverValue
else implicitReceiverStack.lastDispatchReceiver()
val superTypeRefs = implicitReceiver?.boundSymbol?.phasedFir?.superTypeRefs
val resultType = when { val resultType = when {
superTypeRefs?.isNotEmpty() != true -> { superTypeRefs?.isNotEmpty() != true -> {
buildErrorTypeRef { buildErrorTypeRef {
@@ -27,7 +27,7 @@ internal class FirDelegatedConstructorCallImpl(
override var constructedTypeRef: FirTypeRef, override var constructedTypeRef: FirTypeRef,
override val isThis: Boolean, override val isThis: Boolean,
) : FirDelegatedConstructorCall() { ) : FirDelegatedConstructorCall() {
override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef) override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, null, constructedTypeRef)
override val isSuper: Boolean get() = !isThis override val isSuper: Boolean get() = !isThis
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.fir.visitors.*
abstract class FirSuperReference : FirReference() { abstract class FirSuperReference : FirReference() {
abstract override val source: FirSourceElement? abstract override val source: FirSourceElement?
abstract val labelName: String?
abstract val superTypeRef: FirTypeRef abstract val superTypeRef: FirTypeRef
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitSuperReference(this, data) override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitSuperReference(this, data)
@@ -21,11 +21,13 @@ import org.jetbrains.kotlin.fir.visitors.*
@FirBuilderDsl @FirBuilderDsl
class FirExplicitSuperReferenceBuilder { class FirExplicitSuperReferenceBuilder {
var source: FirSourceElement? = null var source: FirSourceElement? = null
var labelName: String? = null
lateinit var superTypeRef: FirTypeRef lateinit var superTypeRef: FirTypeRef
fun build(): FirSuperReference { fun build(): FirSuperReference {
return FirExplicitSuperReference( return FirExplicitSuperReference(
source, source,
labelName,
superTypeRef, superTypeRef,
) )
} }
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.visitors.*
internal class FirExplicitSuperReference( internal class FirExplicitSuperReference(
override val source: FirSourceElement?, override val source: FirSourceElement?,
override val labelName: String?,
override var superTypeRef: FirTypeRef, override var superTypeRef: FirTypeRef,
) : FirSuperReference() { ) : FirSuperReference() {
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) { override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
@@ -962,6 +962,9 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
print("super<") print("super<")
superReference.superTypeRef.accept(this) superReference.superTypeRef.accept(this)
print(">") print(">")
superReference.labelName?.let {
print("@$it#")
}
} }
override fun visitQualifiedAccess(qualifiedAccess: FirQualifiedAccess) { override fun visitQualifiedAccess(qualifiedAccess: FirQualifiedAccess) {
@@ -105,7 +105,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(delegatedConstructorCall) { impl(delegatedConstructorCall) {
default( default(
"calleeReference", "calleeReference",
"if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef)" "if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, null, constructedTypeRef)"
) )
default("isSuper") { default("isSuper") {
value = "!isThis" value = "!isThis"
@@ -521,6 +521,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
} }
superReference.configure { superReference.configure {
+stringField("labelName", nullable = true)
+field("superTypeRef", typeRef, withReplace = true) +field("superTypeRef", typeRef, withReplace = true)
} }
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A { open class A {
open val foo: String = "OK" open val foo: String = "OK"
} }
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface BK { interface BK {
fun x() : Int = 50 fun x() : Int = 50
} }
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A { open class A {
open fun foo2(): String = "OK" open fun foo2(): String = "OK"
} }
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A { open class A {
open val foo: String = "OK" open val foo: String = "OK"
} }
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface ATrait { interface ATrait {
open fun foo2(): String = "OK" open fun foo2(): String = "OK"
} }
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface A { interface A {
open val foo: String open val foo: String
get() = "OK" get() = "OK"
@@ -7,16 +7,16 @@ interface Trait {
class Outer : Trait { class Outer : Trait {
class Nested { class Nested {
val t = this@Outer.bar() val t = this@Outer.bar()
val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val s = super@Outer.bar()
inner class NestedInner { inner class NestedInner {
val t = this@Outer.bar() val t = this@Outer.bar()
val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val s = super@Outer.bar()
} }
} }
inner class Inner { inner class Inner {
val t = this@Outer.bar() val t = this@Outer.bar()
val s = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val s = super@Outer.bar()
} }
} }
@@ -13,10 +13,10 @@ class Outer : Trait {
inner class Inner { inner class Inner {
val t = this@Local val t = this@Local
val s = super@Local.<!UNRESOLVED_REFERENCE!>bar<!>() val s = super@Local.bar()
val tt = this@Outer val tt = this@Outer
val ss = super@Outer.<!UNRESOLVED_REFERENCE!>bar<!>() val ss = super@Outer.bar()
} }
} }
} }
+10 -10
View File
@@ -24,7 +24,7 @@ interface KotlinInterface : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
} }
} }
} }
@@ -35,7 +35,7 @@ interface KotlinInterface : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
} }
} }
return "" return ""
@@ -53,7 +53,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
} }
} }
} }
@@ -64,7 +64,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
} }
} }
return "" return ""
@@ -79,7 +79,7 @@ open class KotlinClass : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClass.test()
} }
} }
} }
@@ -91,7 +91,7 @@ open class KotlinClass : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClass.test()
} }
} }
return "" return ""
@@ -106,7 +106,7 @@ class KotlinClassIndirectInheritance : KotlinClass() {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance.test()
} }
} }
} }
@@ -118,7 +118,7 @@ class KotlinClassIndirectInheritance : KotlinClass() {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance.test()
} }
} }
return "" return ""
@@ -133,7 +133,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance2.test()
} }
} }
} }
@@ -145,7 +145,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance2.test()
} }
} }
return "" return ""
@@ -26,7 +26,7 @@ interface KotlinInterface : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
} }
} }
} }
@@ -37,7 +37,7 @@ interface KotlinInterface : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
} }
} }
return "" return ""
@@ -55,7 +55,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
} }
} }
} }
@@ -66,7 +66,7 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
} }
} }
return "" return ""
@@ -81,7 +81,7 @@ open class KotlinClass : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClass.test()
} }
} }
} }
@@ -93,7 +93,7 @@ open class KotlinClass : JavaInterface {
object { object {
fun run () { fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClass.test()
} }
} }
return "" return ""
@@ -108,7 +108,7 @@ class KotlinClassIndirectInheritance : KotlinClass() {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance.test()
} }
} }
} }
@@ -120,7 +120,7 @@ class KotlinClassIndirectInheritance : KotlinClass() {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance.test()
} }
} }
return "" return ""
@@ -135,7 +135,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance2.test()
} }
} }
} }
@@ -147,7 +147,7 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance2.test()
} }
} }
return "" return ""
@@ -7,6 +7,6 @@ class A {
constructor(x: Any?) constructor(x: Any?)
constructor() : this(object { constructor() : this(object {
fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + this@A.<!UNRESOLVED_REFERENCE!>foo<!>() + fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + this@A.<!UNRESOLVED_REFERENCE!>foo<!>() +
<!INAPPLICABLE_CANDIDATE!>foobar<!>() + super@A.hashCode() <!INAPPLICABLE_CANDIDATE!>foobar<!>() + super@A.<!UNRESOLVED_REFERENCE!>hashCode<!>()
}) })
} }
@@ -31,7 +31,7 @@ class A<E>() : C(), T {
fun test() { fun test() {
super<T>.foo(); super<T>.foo();
<!NOT_A_SUPERTYPE!>super<C><!>.bar() <!NOT_A_SUPERTYPE!>super<C><!>.bar()
<!NOT_A_SUPERTYPE!>super<C>@A<!>.bar() super<C>@A.bar()
super<T>@A.foo() super<T>@A.foo()
super<T>@B.foo() super<T>@B.foo()
<!NOT_A_SUPERTYPE!>super<C>@B<!>.<!UNRESOLVED_REFERENCE!>foo<!>() <!NOT_A_SUPERTYPE!>super<C>@B<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -1,33 +0,0 @@
open class A {
open fun foo() {}
}
interface B {
fun bar() {}
}
interface Q {
fun qux() {}
}
class C : A(), B {
override fun foo() {
super@C.foo()
}
override fun bar() {
super@C.bar()
}
inner class D : A(), Q {
override fun foo() {
super@C.foo()
super@D.foo()
}
override fun qux() {
super@C.qux()
super@D.qux()
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
open class A { open class A {
open fun foo() {} open fun foo() {}
} }
@@ -33,11 +33,11 @@ interface KotlinInterface : KInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterface.property
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterface.testNonDefault()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterface.propertyNonDefault
} }
} }
} }
@@ -53,11 +53,11 @@ interface KotlinInterface : KInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterface.property
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterface.testNonDefault()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterface.propertyNonDefault
} }
} }
return "" return ""
@@ -72,11 +72,11 @@ interface KotlinInterface : KInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterface.property
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterface.testNonDefault()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterface.propertyNonDefault
} }
} }
} }
@@ -91,11 +91,11 @@ interface KotlinInterface : KInterface {
object { object {
fun run () { fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterface.test()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterface.property
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterface.testNonDefault()
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterface.propertyNonDefault
} }
} }
return "" return ""
@@ -115,11 +115,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterfaceIndirectInheritance.property
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterfaceIndirectInheritance.testNonDefault()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterfaceIndirectInheritance.propertyNonDefault
} }
} }
} }
@@ -135,11 +135,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterfaceIndirectInheritance.property
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterfaceIndirectInheritance.testNonDefault()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterfaceIndirectInheritance.propertyNonDefault
} }
} }
return "" return ""
@@ -154,11 +154,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterfaceIndirectInheritance.property
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterfaceIndirectInheritance.testNonDefault()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterfaceIndirectInheritance.propertyNonDefault
} }
} }
} }
@@ -173,11 +173,11 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface {
object { object {
fun run () { fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinInterfaceIndirectInheritance.test()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinInterfaceIndirectInheritance.property
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinInterfaceIndirectInheritance.testNonDefault()
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinInterfaceIndirectInheritance.propertyNonDefault
} }
} }
return "" return ""
@@ -194,11 +194,11 @@ open class KotlinClass : KInterface {
object { object {
fun run () { fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClass.test()
super@KotlinClass.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinClass.property
super@KotlinClass.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinClass.testNonDefault()
super@KotlinClass.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinClass.propertyNonDefault
} }
} }
} }
@@ -213,11 +213,11 @@ open class KotlinClass : KInterface {
object { object {
fun run () { fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClass.test()
super@KotlinClass.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinClass.property
super@KotlinClass.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinClass.testNonDefault()
super@KotlinClass.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinClass.propertyNonDefault
} }
} }
@@ -235,11 +235,11 @@ class KotlinClassIndirectInheritance : KotlinClass() {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance.test()
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinClassIndirectInheritance.property
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinClassIndirectInheritance.testNonDefault()
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinClassIndirectInheritance.propertyNonDefault
} }
} }
@@ -255,11 +255,11 @@ class KotlinClassIndirectInheritance : KotlinClass() {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance.test()
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinClassIndirectInheritance.property
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinClassIndirectInheritance.testNonDefault()
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinClassIndirectInheritance.propertyNonDefault
} }
} }
return "" return ""
@@ -276,11 +276,11 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance2.test()
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinClassIndirectInheritance2.property
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinClassIndirectInheritance2.testNonDefault()
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinClassIndirectInheritance2.propertyNonDefault
} }
} }
} }
@@ -295,11 +295,11 @@ class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
object { object {
fun run () { fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>() super@KotlinClassIndirectInheritance2.test()
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>property<!> super@KotlinClassIndirectInheritance2.property
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>testNonDefault<!>() super@KotlinClassIndirectInheritance2.testNonDefault()
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>propertyNonDefault<!> super@KotlinClassIndirectInheritance2.propertyNonDefault
} }
} }
return "" return ""
@@ -1,162 +0,0 @@
// !JVM_DEFAULT_MODE: enable
// !JVM_TARGET: 1.8
// FILE: JavaInterface.java
public interface JavaInterface {
default String test() {
return "OK";
}
default String testOverride() {
return "OK";
}
}
// FILE: 1.kt
interface KotlinInterface : JavaInterface {
@JvmDefault
fun fooo() {
super.test()
object {
fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
}
@JvmDefault
val propertyy: String
get() {
super.test()
object {
fun run () {
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
return ""
}
@JvmDefault
override fun testOverride(): String {
return "OK";
}
}
interface KotlinInterfaceIndirectInheritance : KotlinInterface {
@JvmDefault
fun foooo() {
super.test()
object {
fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
}
@JvmDefault
val propertyyy: String
get() {
super.test()
object {
fun run () {
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
return ""
}
}
open class KotlinClass : JavaInterface {
fun foo() {
super.test()
super.testOverride()
object {
fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
}
val property: String
get() {
super.test()
super.testOverride()
object {
fun run () {
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
return ""
}
}
class KotlinClassIndirectInheritance : KotlinClass() {
fun foo2() {
super.test()
super.testOverride()
object {
fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
}
val property2: String
get() {
super.test()
super.testOverride()
object {
fun run () {
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
return ""
}
}
class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
fun foo() {
super.test()
super.testOverride()
object {
fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
}
val property: String
get() {
super.test()
super.testOverride()
object {
fun run () {
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>()
}
}
return ""
}
}
fun test() {
KotlinClass().foo()
KotlinClass().property
KotlinClassIndirectInheritance2().foo()
KotlinClassIndirectInheritance2().property
KotlinClass().test()
KotlinClass().property
KotlinClass().testOverride()
KotlinClassIndirectInheritance().testOverride()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !JVM_DEFAULT_MODE: enable // !JVM_DEFAULT_MODE: enable
// !JVM_TARGET: 1.8 // !JVM_TARGET: 1.8
// FILE: JavaInterface.java // FILE: JavaInterface.java