Add a set of new tests for KT-27075 (create expected class) + some fixes
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
@@ -0,0 +1,24 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
/**
|
||||
* Dokka comment: class to be created as expect
|
||||
*/
|
||||
expect class My {
|
||||
fun foo(param: String): Int
|
||||
fun String.bar(y: Double): Boolean
|
||||
/**
|
||||
* Dokka comment: Just does nothing
|
||||
*/
|
||||
fun baz()
|
||||
|
||||
/**
|
||||
* Dokka comment: Just does nothing
|
||||
*
|
||||
* @flag this parameter is just ignored
|
||||
*/
|
||||
constructor(flag: Boolean)
|
||||
|
||||
val isGood: Boolean
|
||||
var status: Int
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
/**
|
||||
* Dokka comment: class to be created as expect
|
||||
*/
|
||||
actual class <caret>My {
|
||||
// Helpful function
|
||||
actual fun foo(param: String): Int = 42
|
||||
|
||||
/* Very helpful extension */
|
||||
actual fun String.bar(y: Double): Boolean = true
|
||||
|
||||
/**
|
||||
* Dokka comment: Just does nothing
|
||||
*/
|
||||
actual fun baz() {}
|
||||
|
||||
/**
|
||||
* Dokka comment: Just does nothing
|
||||
*
|
||||
* @flag this parameter is just ignored
|
||||
*/
|
||||
actual constructor(flag: Boolean) {}
|
||||
|
||||
// Some immutable property
|
||||
actual val isGood: Boolean
|
||||
get() = true
|
||||
|
||||
/* Interesting mutable property */
|
||||
actual var status: Int
|
||||
get() = 0
|
||||
set(value) {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
/**
|
||||
* Dokka comment: class to be created as expect
|
||||
*/
|
||||
actual class <caret>My {
|
||||
// Helpful function
|
||||
actual fun foo(param: String): Int = 42
|
||||
|
||||
/* Very helpful extension */
|
||||
actual fun String.bar(y: Double): Boolean = true
|
||||
|
||||
/**
|
||||
* Dokka comment: Just does nothing
|
||||
*/
|
||||
actual fun baz() {}
|
||||
|
||||
/**
|
||||
* Dokka comment: Just does nothing
|
||||
*
|
||||
* @flag this parameter is just ignored
|
||||
*/
|
||||
actual constructor(flag: Boolean) {}
|
||||
|
||||
// Some immutable property
|
||||
actual val isGood: Boolean
|
||||
get() = true
|
||||
|
||||
/* Interesting mutable property */
|
||||
actual var status: Int
|
||||
get() = 0
|
||||
set(value) {}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Create expected property in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual class My(actual val <caret>s: String)
|
||||
actual class My(actual val s: String)
|
||||
@@ -0,0 +1,5 @@
|
||||
expect class My {
|
||||
fun foo(): Int
|
||||
val some: Double
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import kotlin.Double as MyDouble
|
||||
|
||||
typealias MyInt = Int
|
||||
|
||||
actual class <caret>My {
|
||||
actual fun foo(): MyInt = 42
|
||||
|
||||
actual val some: MyDouble = 4.0
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import kotlin.Double as MyDouble
|
||||
|
||||
typealias MyInt = Int
|
||||
|
||||
actual class <caret>My {
|
||||
actual fun foo(): MyInt = 42
|
||||
|
||||
actual val some: MyDouble = 4.0
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
expect class My(x: Int, y: Int) {
|
||||
val x: Int
|
||||
val y: Int
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual data class <caret>My actual constructor(actual val x: Int, actual val y: Int)
|
||||
@@ -0,0 +1,4 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual data class My actual constructor(actual val x: Int, actual val y: Int)
|
||||
@@ -5,6 +5,4 @@ expect enum class My {
|
||||
SECOND,
|
||||
LAST;
|
||||
|
||||
val num: Int
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
@@ -0,0 +1,8 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
expect enum class My {
|
||||
;
|
||||
|
||||
fun getHello(): String
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Create expected enum class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual enum class <caret>My {
|
||||
;
|
||||
|
||||
actual fun getHello() = "Hello"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Create expected enum class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual enum class My {
|
||||
;
|
||||
|
||||
actual fun getHello() = "Hello"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
expect fun <T> createList(): java.util.ArrayList<T>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Create expected function in common module proj_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
actual fun <T> <caret>createList(): ArrayList<T> = ArrayList()
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Create expected function in common module proj_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
actual fun <T> createList(): ArrayList<T> = ArrayList()
|
||||
@@ -7,7 +7,10 @@ expect class My {
|
||||
|
||||
class OtherNested(d: Double) {
|
||||
val dd: Double
|
||||
var d: Double
|
||||
}
|
||||
|
||||
val s: String
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
@@ -0,0 +1,21 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
expect sealed class My private constructor(x: Double) {
|
||||
abstract val num: Int
|
||||
open fun isGood(): Boolean
|
||||
|
||||
object First : My {
|
||||
override val num: Int
|
||||
}
|
||||
class Some(num: Int) : My {
|
||||
override val num: Int
|
||||
}
|
||||
object Best : My {
|
||||
override val num: Int
|
||||
override fun isGood(): Boolean
|
||||
|
||||
}
|
||||
|
||||
val x: Double
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual sealed class <caret>My actual constructor(actual val x: Double) {
|
||||
|
||||
actual abstract val num: Int
|
||||
|
||||
actual open fun isGood() = false
|
||||
|
||||
actual object First : My(1.0) {
|
||||
actual override val num = 0
|
||||
}
|
||||
|
||||
actual class Some actual constructor(actual override val num: Int) : My(num.toDouble())
|
||||
|
||||
actual object Best : My(999.0) {
|
||||
actual override val num = 42
|
||||
|
||||
actual override fun isGood() = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
actual sealed class My actual constructor(actual val x: Double) {
|
||||
|
||||
actual abstract val num: Int
|
||||
|
||||
actual open fun isGood() = false
|
||||
|
||||
actual object First : My(1.0) {
|
||||
actual override val num = 0
|
||||
}
|
||||
|
||||
actual class Some actual constructor(actual override val num: Int) : My(num.toDouble())
|
||||
|
||||
actual object Best : My(999.0) {
|
||||
actual override val num = 42
|
||||
|
||||
actual override fun isGood() = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// Not to be implemented
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Create expected class in common module testModule_Common" "false"
|
||||
// DISABLE-ERRORS
|
||||
// ACTION: Remove 'actual' modifier
|
||||
|
||||
class Some(val x: Int, val y: Int) {
|
||||
fun processIt(z: Int) = x + y - z
|
||||
}
|
||||
|
||||
actual typealias <caret>My = Some
|
||||
@@ -0,0 +1,4 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
|
||||
annotation class CommonAnnotation
|
||||
@@ -0,0 +1,10 @@
|
||||
// My: to be implemented
|
||||
// DISABLE-ERRORS
|
||||
|
||||
annotation class CommonAnnotation
|
||||
expect class My {
|
||||
tailrec fun foo(arg: Int): Int
|
||||
var some: Boolean
|
||||
fun initialize()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
annotation class PlatformAnnotation
|
||||
|
||||
actual class <caret>My {
|
||||
@PlatformAnnotation
|
||||
actual tailrec fun foo(arg: Int): Int {
|
||||
if (arg <= 1) return 1
|
||||
return foo(arg - 1)
|
||||
}
|
||||
|
||||
// Here we will have an error (lateinit is not supported on both sides)
|
||||
actual lateinit var some: Boolean
|
||||
|
||||
@CommonAnnotation
|
||||
actual fun initialize() {
|
||||
some = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// "Create expected class in common module testModule_Common" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
annotation class PlatformAnnotation
|
||||
|
||||
actual class <caret>My {
|
||||
@PlatformAnnotation
|
||||
actual tailrec fun foo(arg: Int): Int {
|
||||
if (arg <= 1) return 1
|
||||
return foo(arg - 1)
|
||||
}
|
||||
|
||||
// Here we will have an error (lateinit is not supported on both sides)
|
||||
actual lateinit var some: Boolean
|
||||
|
||||
@CommonAnnotation
|
||||
actual fun initialize() {
|
||||
some = true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user