Use separate logic for filtering and skipping in collectAndFilterRealOverrides [KT-43487] (#3921)

This commit is contained in:
LepilkinaElena
2020-11-20 19:10:41 +03:00
committed by GitHub
parent 362775b6b6
commit dd9c0c5c6e
10 changed files with 67 additions and 6 deletions
@@ -31384,6 +31384,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@@ -38,15 +38,21 @@ fun IrSimpleFunction.collectRealOverrides(
return this.overriddenSymbols
.map { it.owner }
.collectAndFilterRealOverrides {
require(it is IrSimpleFunction) { "Expected IrSimpleFunction: ${it.render()}" }
toSkip(it) || filter(it)
}
.collectAndFilterRealOverrides(
{
require(it is IrSimpleFunction) { "Expected IrSimpleFunction: ${it.render()}" }
toSkip(it)
},
filter
)
.map { it as IrSimpleFunction }
.toSet()
}
fun Collection<IrOverridableMember>.collectAndFilterRealOverrides(toSkip: (IrOverridableMember) -> Boolean = { false }): Set<IrOverridableMember> {
fun Collection<IrOverridableMember>.collectAndFilterRealOverrides(
toSkip: (IrOverridableMember) -> Boolean = { false },
filter: (IrOverridableMember) -> Boolean = { false }
): Set<IrOverridableMember> {
val visited = mutableSetOf<IrOverridableMember>()
val realOverrides = mutableSetOf<IrOverridableMember>()
@@ -60,7 +66,7 @@ fun Collection<IrOverridableMember>.collectAndFilterRealOverrides(toSkip: (IrOve
}
fun collectRealOverrides(member: IrOverridableMember) {
if (!visited.add(member)) return
if (!visited.add(member) || filter(member)) return
if (member.isReal && !toSkip(member)) {
realOverrides += member
@@ -0,0 +1,15 @@
interface A {
fun foo(): String = "Fail"
}
abstract class B : A {
abstract override fun foo(): String
}
abstract class C : B()
class D : C() {
override fun foo(): String = "OK"
}
fun box() = D().foo()
@@ -33155,6 +33155,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@@ -30789,6 +30789,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@@ -31384,6 +31384,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@@ -25410,6 +25410,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@@ -25410,6 +25410,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@@ -25425,6 +25425,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@@ -13828,6 +13828,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
}
@TestMetadata("abstractClassWithFakeOverride.kt")
public void testAbstractClassWithFakeOverride() throws Exception {
runTest("compiler/testData/codegen/box/traits/abstractClassWithFakeOverride.kt");
}
public void testAllFilesPresentInTraits() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}