[MPP] Performance optimization in expect/actual checker

Previously, the checker executed for every declaration i.e. every
declaration was considered as expect declaration. Because of that in
some cases this checker could eat 6% of compilation time.
After this commit only declarations marked with expect or actual
are checked. To achieve that, logic, that do reporting about missing
actual modifier was moved to the Actual part.

Please note, that in cases where there is no expect/actual modifier at
all other errors (like redeclaration and missing body on "actual"
declaration) would be reported.

Useful nodes:
- In this checker reportOn is always the same as
descriptor.sourceElement.ktElement. This is because the only case when
it isn't true is PropertyAccessors and they are filtered
- Annotation constructor descriptor isActual == true all the time
- previously for weak incompatible members ACTUAL_MISSING
was not reported
- the logic here is super complicated and crazy, but I don't think that
there is sense to refactor it in the old FE
This commit is contained in:
Stanislav Erokhin
2021-07-30 14:27:49 +02:00
committed by teamcityserver
parent e9a2997f7e
commit 748a2d2e7c
6 changed files with 60 additions and 29 deletions
@@ -16,7 +16,7 @@ expect open class <!AMBIGUOUS_ACTUALS{JVM}, PACKAGE_OR_CLASSIFIER_REDECLARATION{
// FILE: jvm.kt
<!ACTUAL_WITHOUT_EXPECT!>interface<!> Foo1
interface <!ACTUAL_MISSING!>Foo1<!>
actual <!ACTUAL_WITHOUT_EXPECT!>interface<!> Foo2
actual <!ACTUAL_WITHOUT_EXPECT!>var<!> s: String = "value"
@@ -25,4 +25,4 @@ fun <!ACTUAL_MISSING!>foo2<!>(): Int = 0
actual class <!ACTUAL_WITHOUT_EXPECT, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo3<!>
class <!ACTUAL_WITHOUT_EXPECT, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo3<!>
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION!>Foo3<!>
@@ -4,6 +4,7 @@
expect class Foo {
fun bar(): String
fun bas(f: Int)
}
// MODULE: m2-jvm()()(m1-common)
@@ -11,4 +12,5 @@ expect class Foo {
actual class Foo {
fun bar(): String = "bar"
}
fun bas(g: Int) {}
}
@@ -4,6 +4,7 @@
expect class Foo {
fun bar(): String
fun bas(f: Int)
}
// MODULE: m2-jvm()()(m1-common)
@@ -11,4 +12,5 @@ expect class Foo {
actual class Foo {
fun <!ACTUAL_MISSING!>bar<!>(): String = "bar"
fun <!ACTUAL_MISSING!>bas<!><!ACTUAL_WITHOUT_EXPECT!>(g: Int)<!> {}
}
@@ -3,6 +3,7 @@ package
public final expect class Foo {
public final expect fun bar(): kotlin.String
public final expect fun bas(/*0*/ f: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
@@ -14,6 +15,7 @@ package
public final actual class Foo {
public constructor Foo()
public final fun bar(): kotlin.String
public final fun bas(/*0*/ g: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String