Set primary constructor and its properties actual in "create actual"

So #KT-20044 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-10-03 13:12:47 +03:00
parent d85c2dbe1f
commit fe786ad7f3
8 changed files with 25 additions and 2 deletions
@@ -235,6 +235,15 @@ private fun KtPsiFactory.generateClassOrObject(
} }
actualClass.addDeclaration(actualDeclaration) actualClass.addDeclaration(actualDeclaration)
} }
actualClass.primaryConstructor?.let {
it.addModifier(KtTokens.ACTUAL_KEYWORD)
for (parameter in it.valueParameters) {
if (parameter.hasValOrVar()) {
parameter.addModifier(KtTokens.ACTUAL_KEYWORD)
}
}
}
} }
return actualClass.apply { return actualClass.apply {
@@ -1,2 +1,2 @@
// Ann: to be implemented // Ann: to be implemented
actual annotation class Ann(val x: Int, val y: String) actual annotation class Ann actual constructor(actual val x: Int, actual val y: String)
@@ -0,0 +1,3 @@
// "Create actual class for platform JVM" "true"
expect class <caret>WithPrimaryConstructor(x: Int, s: String)
@@ -0,0 +1,3 @@
// "Create actual class for platform JVM" "true"
expect class WithPrimaryConstructor(x: Int, s: String)
@@ -0,0 +1 @@
// WithPrimaryConstructor: to be implemented
@@ -0,0 +1,2 @@
// WithPrimaryConstructor: to be implemented
actual class WithPrimaryConstructor actual constructor(x: Int, s: String)
@@ -1,6 +1,6 @@
// Sealed: to be implemented // Sealed: to be implemented
actual sealed class Sealed { actual sealed class Sealed {
actual object Obj : Sealed actual object Obj : Sealed
actual class Klass(x: Int) : Sealed actual class Klass actual constructor(x: Int) : Sealed
} }
@@ -129,6 +129,11 @@ class QuickFixMultiModuleTest : AbstractQuickFixMultiModuleTest() {
doMultiPlatformTest() doMultiPlatformTest()
} }
@Test
fun testPrimaryConstructor() {
doMultiPlatformTest()
}
@Test @Test
fun testProperty() { fun testProperty() {
doMultiPlatformTest() doMultiPlatformTest()