Check platform<->impl compatibility for class members
When matching platform and impl classifiers, ensure that each declaration from the platform class scope is present in the impl class scope. Note that the presence of the 'impl' modifier is not checked yet
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
platform class Foo {
|
||||
constructor(s: String)
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
impl class Foo {
|
||||
impl constructor(s: Array<String>)
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/common.kt:1:16: error: no definition is found for platform declaration 'Foo'
|
||||
The following declaration is incompatible because some members are not implemented.
|
||||
No implementations are found for members listed below:
|
||||
|
||||
public constructor Foo(s: String)
|
||||
|
||||
The following declaration is incompatible because parameter types are different:
|
||||
public constructor Foo(s: Array<String>)
|
||||
|
||||
platform class Foo {
|
||||
^
|
||||
compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl class Foo {
|
||||
^
|
||||
compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/jvm.kt:2:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl constructor(s: Array<String>)
|
||||
^
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
platform class Foo {
|
||||
fun function(b: ByteArray): Int
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
impl class Foo {
|
||||
impl fun function(b: ByteArray): Long = b.size.toLong()
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/classScopes/functionIncorrectSignature/common.kt:1:16: error: no definition is found for platform declaration 'Foo'
|
||||
The following declaration is incompatible because some members are not implemented.
|
||||
No implementations are found for members listed below:
|
||||
|
||||
public final platform fun function(b: ByteArray): Int
|
||||
|
||||
The following declaration is incompatible because return type is different:
|
||||
public final impl fun function(b: ByteArray): Long
|
||||
|
||||
platform class Foo {
|
||||
^
|
||||
compiler/testData/multiplatform/classScopes/functionIncorrectSignature/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl class Foo {
|
||||
^
|
||||
compiler/testData/multiplatform/classScopes/functionIncorrectSignature/jvm.kt:2:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun function(b: ByteArray): Long = b.size.toLong()
|
||||
^
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
platform class Foo {
|
||||
constructor(s: String)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
impl class Foo
|
||||
@@ -0,0 +1,22 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/classScopes/missingConstructor/common.kt:1:16: error: no definition is found for platform declaration 'Foo'
|
||||
The following declaration is incompatible because some members are not implemented.
|
||||
No implementations are found for members listed below:
|
||||
|
||||
public constructor Foo(s: String)
|
||||
|
||||
The following declaration is incompatible because number of value parameters is different:
|
||||
public constructor Foo()
|
||||
|
||||
platform class Foo {
|
||||
^
|
||||
compiler/testData/multiplatform/classScopes/missingConstructor/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl class Foo
|
||||
^
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
platform class Foo {
|
||||
fun function(s: String)
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
impl class Foo
|
||||
@@ -0,0 +1,19 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/classScopes/missingFunction/common.kt:1:16: error: no definition is found for platform declaration 'Foo'
|
||||
The following declaration is incompatible because some members are not implemented.
|
||||
No implementations are found for members listed below:
|
||||
|
||||
public final platform fun function(s: String): Unit
|
||||
|
||||
platform class Foo {
|
||||
^
|
||||
compiler/testData/multiplatform/classScopes/missingFunction/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl class Foo
|
||||
^
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
platform class Foo(param: String) {
|
||||
var property: Int
|
||||
|
||||
fun <T> function(p: List<T>): T
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
impl class Foo impl constructor(param: String) {
|
||||
impl var property: Int = param.length
|
||||
|
||||
impl fun <T> function(p: List<T>): T = p.first()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
platform class Foo
|
||||
@@ -0,0 +1,10 @@
|
||||
impl class Foo impl constructor() {
|
||||
impl constructor(s: String) : this()
|
||||
|
||||
impl fun nonPlatformFun() {}
|
||||
|
||||
impl val nonPlatformVal = ""
|
||||
|
||||
private fun nonImplFun() {}
|
||||
private val nonImplVal = ""
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/incorrectImplInClass/jvm.kt:2:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl constructor(s: String) : this()
|
||||
^
|
||||
compiler/testData/multiplatform/incorrectImplInClass/jvm.kt:4:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun nonPlatformFun() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incorrectImplInClass/jvm.kt:6:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl val nonPlatformVal = ""
|
||||
^
|
||||
|
||||
Reference in New Issue
Block a user