Use separate logic for filtering and skipping in collectAndFilterRealOverrides [KT-43487] (#3921)
This commit is contained in:
Generated
+5
@@ -31384,6 +31384,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
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
|
return this.overriddenSymbols
|
||||||
.map { it.owner }
|
.map { it.owner }
|
||||||
.collectAndFilterRealOverrides {
|
.collectAndFilterRealOverrides(
|
||||||
require(it is IrSimpleFunction) { "Expected IrSimpleFunction: ${it.render()}" }
|
{
|
||||||
toSkip(it) || filter(it)
|
require(it is IrSimpleFunction) { "Expected IrSimpleFunction: ${it.render()}" }
|
||||||
}
|
toSkip(it)
|
||||||
|
},
|
||||||
|
filter
|
||||||
|
)
|
||||||
.map { it as IrSimpleFunction }
|
.map { it as IrSimpleFunction }
|
||||||
.toSet()
|
.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 visited = mutableSetOf<IrOverridableMember>()
|
||||||
val realOverrides = mutableSetOf<IrOverridableMember>()
|
val realOverrides = mutableSetOf<IrOverridableMember>()
|
||||||
@@ -60,7 +66,7 @@ fun Collection<IrOverridableMember>.collectAndFilterRealOverrides(toSkip: (IrOve
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun collectRealOverrides(member: IrOverridableMember) {
|
fun collectRealOverrides(member: IrOverridableMember) {
|
||||||
if (!visited.add(member)) return
|
if (!visited.add(member) || filter(member)) return
|
||||||
|
|
||||||
if (member.isReal && !toSkip(member)) {
|
if (member.isReal && !toSkip(member)) {
|
||||||
realOverrides += 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()
|
||||||
+5
@@ -33155,6 +33155,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -30789,6 +30789,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -31384,6 +31384,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/traits/abstractClassInheritsFromInterface.kt");
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5
@@ -25410,6 +25410,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
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 {
|
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);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5
@@ -25410,6 +25410,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -25425,6 +25425,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5
@@ -13828,6 +13828,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
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 {
|
public void testAllFilesPresentInTraits() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/traits"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user