Add "expectedBy" to module descriptor and use it in checker

Now ExpectActualDeclarationChecker in IDE context
uses common module descriptors for relevant checks.
Compiler still uses own module instead (see comment in checker)
So #KT-21771 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-12-12 17:22:35 +03:00
parent 78136fbb07
commit 3f500a1655
16 changed files with 93 additions and 11 deletions
@@ -10,6 +10,6 @@ expect class Their {
}
actual class Their {
actual class <error descr="[ACTUAL_WITHOUT_EXPECT] Actual class 'Their' has no corresponding expected declaration">Their</error> {
}
@@ -0,0 +1 @@
expect class My
@@ -0,0 +1 @@
class <error descr="[ACTUAL_MISSING] Declaration must be marked with 'actual'">My</error>
@@ -0,0 +1 @@
expect class My
@@ -0,0 +1 @@
expect fun foo(my: Any)
@@ -0,0 +1,3 @@
class My
actual fun foo(my: Any) {}
@@ -0,0 +1 @@
expect class My
@@ -0,0 +1 @@
expect fun foo(my: My)
@@ -0,0 +1,3 @@
class <error descr="[ACTUAL_MISSING] Declaration must be marked with 'actual'">My</error>
actual fun foo(my: My) {}
@@ -33,6 +33,20 @@ class MultiPlatformHighlightingTest : AbstractMultiModuleHighlightingTest() {
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
}
fun testDepends() {
val commonModule = module("common", TestJdkKind.MOCK_JDK)
commonModule.createFacet(TargetPlatformKind.Common)
commonModule.enableMultiPlatform()
val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
val jvmModule = module("jvm", TestJdkKind.MOCK_JDK)
jvmModule.createFacet(jvmPlatform)
jvmModule.enableMultiPlatform()
jvmModule.addDependency(commonModule)
checkHighlightingInAllFiles()
}
fun testHeaderClass() {
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
}
@@ -106,4 +120,40 @@ class MultiPlatformHighlightingTest : AbstractMultiModuleHighlightingTest() {
checkHighlightingInAllFiles()
}
fun testTriangle() {
val commonModule = module("common_base", TestJdkKind.MOCK_JDK)
commonModule.createFacet(TargetPlatformKind.Common, false)
val derivedModule = module("common_derived", TestJdkKind.MOCK_JDK)
derivedModule.createFacet(TargetPlatformKind.Common)
derivedModule.enableMultiPlatform()
val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
val jvmModule = module("jvm_derived", TestJdkKind.MOCK_JDK)
jvmModule.createFacet(jvmPlatform, implementedModuleName = "common_derived")
jvmModule.enableMultiPlatform()
jvmModule.addDependency(commonModule)
jvmModule.addDependency(derivedModule)
checkHighlightingInAllFiles()
}
fun testTriangleWithDependency() {
val commonModule = module("common_base", TestJdkKind.MOCK_JDK)
commonModule.createFacet(TargetPlatformKind.Common, false)
val derivedModule = module("common_derived", TestJdkKind.MOCK_JDK)
derivedModule.createFacet(TargetPlatformKind.Common)
derivedModule.enableMultiPlatform()
derivedModule.addDependency(commonModule)
val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
val jvmModule = module("jvm_derived", TestJdkKind.MOCK_JDK)
jvmModule.createFacet(jvmPlatform, implementedModuleName = "common_derived")
jvmModule.enableMultiPlatform()
jvmModule.addDependency(commonModule)
jvmModule.addDependency(derivedModule)
checkHighlightingInAllFiles()
}
}