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 package sample
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!> { actual class A {
actual fun foo(): Int = 45 actual fun foo(): Int = 45
fun fromBottom(): Int = 0 fun fromBottom(): Int = 0
} }
@@ -11,6 +11,6 @@ fun main() {
// Any behaviour is acceptable, as the code is erroneous. // Any behaviour is acceptable, as the code is erroneous.
// At the time of writing this test, we resolve to nearest A, i.e. // At the time of writing this test, we resolve to nearest A, i.e.
// 'fromBottom' is resolved, and 'fromLeft' is not. // 'fromBottom' is resolved, and 'fromLeft' is not.
A().fromLeft() A().<!UNRESOLVED_REFERENCE("fromLeft")!>fromLeft<!>()
A().<!UNRESOLVED_REFERENCE("fromBottom")!>fromBottom<!>() A().fromBottom()
} }
@@ -1,5 +1,5 @@
package sample package sample
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, bottom.kt"), AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, bottom.kt")!>A<!> { expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "bottom.kt, left.kt")!>A<!> {
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, bottom.kt"), AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, bottom.kt")!>foo<!>(): Int fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "bottom.kt, left.kt")!>foo<!>(): Int
} }
@@ -1,5 +1,5 @@
package sample package sample
expect class <!AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, right.kt"), AMBIGUOUS_ACTUALS("Class 'A'", "left.kt, right.kt")!>A<!> { expect class A {
fun <!AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, right.kt"), AMBIGUOUS_ACTUALS("Function 'foo'", "left.kt, right.kt")!>foo<!>(): Int fun foo(): Int
} }
@@ -1,3 +1,3 @@
package foo package foo
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("A")!>A<!> actual class A
@@ -1,3 +1,3 @@
package foo 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 package foo
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION("ActualInMiddleCompatibleInBottom")!>ActualInMiddleCompatibleInBottom<!> class <!ACTUAL_MISSING!>ActualInMiddleCompatibleInBottom<!>
actual class <!PACKAGE_OR_CLASSIFIER_REDECLARATION("CompatibleInMiddleActualInBottom")!>CompatibleInMiddleActualInBottom<!> actual class CompatibleInMiddleActualInBottom
class <!ACTUAL_MISSING, PACKAGE_OR_CLASSIFIER_REDECLARATION("CompatibleInMiddleAndBottom")!>CompatibleInMiddleAndBottom<!> class <!ACTUAL_MISSING!>CompatibleInMiddleAndBottom<!>
@@ -1,6 +1,6 @@
package foo 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 '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 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 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 // Note that here we have no ambiguity, becuase we don't consider
// declarations without 'expect' as potential weakly-compatible 'expect'-counterpart // 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.checkers.utils.CheckerTestUtil
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromTextFile 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.resolve.frontendService
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
@@ -103,8 +104,28 @@ abstract class AbstractMultiModuleIdeResolveTest : AbstractMultiModuleTest() {
abstract class AbstractHierarchicalExpectActualTest : AbstractMultiModuleIdeResolveTest() { abstract class AbstractHierarchicalExpectActualTest : AbstractMultiModuleIdeResolveTest() {
override fun getTestDataPath(): String = "${PluginTestCaseBase.getTestDataPathBase()}/hierarchicalExpectActual" 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() { abstract class AbstractMultiplatformAnalysisTest : AbstractMultiModuleIdeResolveTest() {
override fun getTestDataPath(): String = "${PluginTestCaseBase.getTestDataPathBase()}/multiplatform" 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()
}
} }