Use CompositeResolve in HierarchicalExpectActual tests

This commit is contained in:
Dmitry Savvinov
2019-06-14 16:16:16 +03:00
parent aaf76a0e46
commit 1fe8e4ba15
13 changed files with 40 additions and 19 deletions
@@ -1,6 +1,6 @@
package sample
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!> {
actual class 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().fromLeft()
A().<!UNRESOLVED_REFERENCE("fromBottom")!>fromBottom<!>()
A().<!UNRESOLVED_REFERENCE("fromLeft")!>fromLeft<!>()
A().fromBottom()
}
@@ -1,5 +1,5 @@
package sample
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
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, left.kt")!>A<!> {
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "bottom.kt, left.kt")!>foo<!>(): Int
}
@@ -1,5 +1,5 @@
package sample
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
expect class A {
fun foo(): Int
}
@@ -1,3 +1,3 @@
package foo
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
actual class A
@@ -1,3 +1,3 @@
package foo
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "middle.kt, bottom.kt")!>A<!>
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, middle.kt")!>A<!>
@@ -1,6 +1,6 @@
package foo
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION("ActualInMiddleCompatibleInBottom")!>ActualInMiddleCompatibleInBottom<!>
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("CompatibleInMiddleActualInBottom")!>CompatibleInMiddleActualInBottom<!>
class <!ACTUAL_MISSING!>ActualInMiddleCompatibleInBottom<!>
actual class CompatibleInMiddleActualInBottom
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION("CompatibleInMiddleAndBottom")!>CompatibleInMiddleAndBottom<!>
class <!ACTUAL_MISSING!>CompatibleInMiddleAndBottom<!>
@@ -1,6 +1,6 @@
package foo
expect class <!AMBIGUOUS_ACTUALS("Class 'ActualInMiddleCompatibleInBottom'", "middle.kt, bottom.kt")!>ActualInMiddleCompatibleInBottom<!>
expect class <!AMBIGUOUS_ACTUALS("Class 'ActualInMiddleCompatibleInBottom'", "bottom.kt, middle.kt")!>ActualInMiddleCompatibleInBottom<!>
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleActualInBottom'", "bottom.kt, middle.kt")!>CompatibleInMiddleActualInBottom<!>
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleAndBottom'", "middle.kt, bottom.kt")!>CompatibleInMiddleAndBottom<!>
expect class <!AMBIGUOUS_ACTUALS("Class 'CompatibleInMiddleAndBottom'", "bottom.kt, middle.kt")!>CompatibleInMiddleAndBottom<!>
@@ -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 <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
<!ACTUAL_WITHOUT_EXPECT("Class 'A'", " The following declaration is incompatible because visibility is different: public final expect class A ")!>private<!> class A
@@ -1,3 +1,3 @@
package foo
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "middle.kt, bottom.kt")!>A<!>
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, middle.kt")!>A<!>
@@ -1 +1 @@
actual class <!AMBIGUOUS_EXPECTS("Actual class 'A'", "left.kt, right.kt"), PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
actual class <!AMBIGUOUS_EXPECTS("Actual class 'A'", "left.kt, right.kt")!>A<!>
@@ -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 <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!>
actual class A
@@ -1 +1 @@
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, right.kt")!>A<!>
expect class A
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.checkers.BaseDiagnosticsTest
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromTextFile
import org.jetbrains.kotlin.idea.project.KotlinMultiplatformAnalysisModeComponent
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
@@ -103,8 +104,28 @@ abstract class AbstractMultiModuleIdeResolveTest : AbstractMultiModuleTest() {
abstract class AbstractHierarchicalExpectActualTest : AbstractMultiModuleIdeResolveTest() {
override fun getTestDataPath(): String = "${PluginTestCaseBase.getTestDataPathBase()}/hierarchicalExpectActual"
override fun setUp() {
super.setUp()
KotlinMultiplatformAnalysisModeComponent.setMode(project, KotlinMultiplatformAnalysisModeComponent.Mode.COMPOSITE)
}
override fun tearDown() {
KotlinMultiplatformAnalysisModeComponent.setMode(project, KotlinMultiplatformAnalysisModeComponent.Mode.SEPARATE)
super.tearDown()
}
}
abstract class AbstractMultiplatformAnalysisTest : AbstractMultiModuleIdeResolveTest() {
override fun getTestDataPath(): String = "${PluginTestCaseBase.getTestDataPathBase()}/multiplatform"
override fun setUp() {
super.setUp()
KotlinMultiplatformAnalysisModeComponent.setMode(project, KotlinMultiplatformAnalysisModeComponent.Mode.COMPOSITE)
}
override fun tearDown() {
KotlinMultiplatformAnalysisModeComponent.setMode(project, KotlinMultiplatformAnalysisModeComponent.Mode.SEPARATE)
super.tearDown()
}
}