[Expect/Actual] Adjust IdeaModuleStructureOracle to old IDE Resolve
The main issue is that we have CombinedModuleInfo in old IDE Resolve, which essentially merges platfor-modules together with its dependsOn-parents. It conceals real module structure, which is fine for practically all clients except for ExpectedActualDeclarationChecker. In particular, it is nearly impossible to check expect/actual via ModuleDescriptors, because you'll always get one and the same 'merged'-module descriptor. So, this commit rewrites IdeaModuleStructureOracle in the following way: - use ModuleInfos instead of ModuleDescriptor, as they allow more fine-grained way to work with modules - use 'unwrapModuleSourceInfo' in seemingly random places in order to get real, non-merged moduleInfos - carefully convert them back to ModuleDescriptors, because EADC work with descriptors This is still not an ideal solution. In particular, last step is flawed: conversion back to ModuleDescriptors will always return merged moduleDescriptor for platform-modules. There's no easy way to fix that except for removing CombinedModuleInfo altogether, so we leave it as known issue. Also, there are some weird changes in testdata (again, because sometimes we see several modules merged together), but they are mostly confusing rather than plain incorrect.
This commit is contained in:
+3
-3
@@ -1,6 +1,6 @@
|
||||
package sample
|
||||
|
||||
actual class A {
|
||||
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!> {
|
||||
actual fun foo(): Int = 45
|
||||
fun fromBottom(): Int = 0
|
||||
}
|
||||
@@ -11,6 +11,6 @@ fun main() {
|
||||
// Any behaviour is acceptable, as the code is erroneous.
|
||||
// At the time of writing this test, we resolve to nearest A, i.e.
|
||||
// 'fromBottom' is resolved, and 'fromLeft' is not.
|
||||
A().<!UNRESOLVED_REFERENCE("fromLeft")!>fromLeft<!>()
|
||||
A().fromBottom()
|
||||
A().fromLeft()
|
||||
A().<!UNRESOLVED_REFERENCE("fromBottom")!>fromBottom<!>()
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
package sample
|
||||
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom for JVM, left")!>A<!> {
|
||||
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "bottom for JVM, left")!>foo<!>(): Int
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, bottom.kt"), AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, bottom.kt")!>A<!> {
|
||||
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, bottom.kt"), AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, bottom.kt")!>foo<!>(): Int
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
package sample
|
||||
|
||||
expect class A {
|
||||
fun foo(): Int
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, right.kt"), AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, right.kt")!>A<!> {
|
||||
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, right.kt"), AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, right.kt")!>foo<!>(): Int
|
||||
}
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package foo
|
||||
|
||||
actual class A
|
||||
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package foo
|
||||
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom for JVM, middle")!>A<!>
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "middle.kt, bottom.kt")!>A<!>
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package foo
|
||||
|
||||
class <!ACTUAL_MISSING!>ActualInMiddleCompatibleInBottom<!>
|
||||
actual class CompatibleInMiddleActualInBottom
|
||||
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION("ActualInMiddleCompatibleInBottom")!>ActualInMiddleCompatibleInBottom<!>
|
||||
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("CompatibleInMiddleActualInBottom")!>CompatibleInMiddleActualInBottom<!>
|
||||
|
||||
class <!ACTUAL_MISSING!>CompatibleInMiddleAndBottom<!>
|
||||
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION("CompatibleInMiddleAndBottom")!>CompatibleInMiddleAndBottom<!>
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package foo
|
||||
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'ActualInMiddleCompatibleInBottom'", "bottom for JVM, middle")!>ActualInMiddleCompatibleInBottom<!>
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleActualInBottom'", "bottom for JVM, middle")!>CompatibleInMiddleActualInBottom<!>
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'ActualInMiddleCompatibleInBottom'", "middle.kt, bottom.kt")!>ActualInMiddleCompatibleInBottom<!>
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleActualInBottom'", "bottom.kt, middle.kt")!>CompatibleInMiddleActualInBottom<!>
|
||||
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleAndBottom'", "bottom for JVM, middle")!>CompatibleInMiddleAndBottom<!>
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleAndBottom'", "middle.kt, bottom.kt")!>CompatibleInMiddleAndBottom<!>
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package foo
|
||||
|
||||
<!ACTUAL_WITHOUT_EXPECT("Class 'A'", " The following declaration is incompatible because visibility is different: public final expect class A ")!>private<!> class A
|
||||
<!ACTUAL_WITHOUT_EXPECT("Class 'A'", " The following declaration is incompatible because visibility is different: public final expect class A ")!>private<!> class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package foo
|
||||
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "middle, bottom for JVM")!>A<!>
|
||||
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "middle.kt, bottom.kt")!>A<!>
|
||||
+1
-1
@@ -1 +1 @@
|
||||
actual class <!AMBIGUOUS_EXPECTS("Actual class 'A'", "right, left")!>A<!>
|
||||
actual class <!AMBIGUOUS_EXPECTS("Actual class 'A'", "left.kt, right.kt"), PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
// Note that here we have no ambiguity, becuase we don't consider
|
||||
// declarations without 'expect' as potential weakly-compatible 'expect'-counterpart
|
||||
actual class A
|
||||
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
|
||||
Reference in New Issue
Block a user