[JS IR] Fix findInterfaceImplementation

isOrOverridesSynthesized uses descriptors which does not work with
wrapped descriptors
This commit is contained in:
Svyatoslav Kuzmich
2020-05-29 17:08:25 +03:00
parent 19219c37b6
commit e9e850ad8f
9 changed files with 70 additions and 12 deletions
@@ -27581,6 +27581,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");
@@ -234,8 +234,6 @@ val IrBody.statements: List<IrStatement>
val IrClass.defaultType: IrSimpleType
get() = this.thisReceiver!!.type as IrSimpleType
val IrSimpleFunction.isSynthesized: Boolean get() = descriptor.kind == CallableMemberDescriptor.Kind.SYNTHESIZED
fun IrClass.isSubclassOf(ancestor: IrClass): Boolean {
val alreadyVisited = mutableSetOf<IrClass>()
@@ -252,19 +250,9 @@ fun IrClass.isSubclassOf(ancestor: IrClass): Boolean {
return this.hasAncestorInSuperTypes()
}
fun IrSimpleFunction.isOrOverridesSynthesized(): Boolean {
if (isSynthesized) return true
if (isFakeOverride) return overriddenSymbols.all { it.owner.isOrOverridesSynthesized() }
return false
}
fun IrSimpleFunction.findInterfaceImplementation(): IrSimpleFunction? {
if (isReal) return null
if (isOrOverridesSynthesized()) return null
return resolveFakeOverride()?.run { if (parentAsClass.isInterface) this else null }
}
+35
View File
@@ -0,0 +1,35 @@
// MODULE: lib
// FILE: lib.kt
package lib
interface Stoppable {
fun isStopped(): Boolean
}
interface EventRo : Stoppable
interface Event : Stoppable {
override fun isStopped(): Boolean {
return true
}
}
abstract class EventBase : Event
interface MouseEventRo : EventRo
open class MouseEvent : EventBase(), MouseEventRo
// MODULE: main(lib)
// FILE: main.kt
package main
fun box(): String {
if (lib.MouseEvent().isStopped()) {
return "OK"
}
return "Fail"
}
@@ -29167,6 +29167,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");
@@ -26801,6 +26801,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");
@@ -27581,6 +27581,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");
@@ -22642,6 +22642,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");
@@ -22697,6 +22697,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");
@@ -22712,6 +22712,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/regressions/kt3903.kt");
}
@TestMetadata("kt39088.kt")
public void testKt39088() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt39088.kt");
}
@TestMetadata("kt4142.kt")
public void testKt4142() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt4142.kt");