Check platform<->impl declaration compatibility
For each platform declaration, there must be at least one impl declaration in the module with the compatible signature; similarly, for each impl declaration, there must be at least one platform declaration with the compatible signature. Note that currently the presence of the 'impl' modifier is not checked yet. Also, the sad fact is that if you have platform and impl declarations which are not compatible, you get two errors: on the platform delcaration and on the impl declaration. This needs to be addressed as well
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
platform infix fun Int.plus(s: CharSequence): Int
|
||||
platform fun Int.minus(s: String): Int
|
||||
|
||||
platform operator fun Double.times(x: CharArray)
|
||||
platform fun Double.divide(x: ByteArray)
|
||||
|
||||
platform external fun f1()
|
||||
platform fun g1()
|
||||
|
||||
platform inline fun f2()
|
||||
platform fun g2()
|
||||
|
||||
platform tailrec fun f3()
|
||||
platform fun g3()
|
||||
@@ -0,0 +1,14 @@
|
||||
impl fun Int.plus(s: CharSequence): Int = 0
|
||||
impl infix fun Int.minus(s: String): Int = 1
|
||||
|
||||
impl fun Double.times(x: CharArray) {}
|
||||
impl operator fun Double.divide(x: ByteArray) {}
|
||||
|
||||
impl fun f1() {}
|
||||
impl external fun g1()
|
||||
|
||||
impl fun f2() {}
|
||||
impl inline fun g2() {}
|
||||
|
||||
impl fun f3() {}
|
||||
impl tailrec fun g3() {}
|
||||
@@ -0,0 +1,101 @@
|
||||
-- Common --
|
||||
Exit code: OK
|
||||
Output:
|
||||
|
||||
-- JVM --
|
||||
Exit code: COMPILATION_ERROR
|
||||
Output:
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:1:1: error: no definition is found for platform declaration 'plus'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public impl fun Int.plus(s: CharSequence): Int
|
||||
|
||||
platform infix fun Int.plus(s: CharSequence): Int
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:2:1: error: no definition is found for platform declaration 'minus'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public infix impl fun Int.minus(s: String): Int
|
||||
|
||||
platform fun Int.minus(s: String): Int
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:4:1: error: no definition is found for platform declaration 'times'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public impl fun Double.times(x: CharArray): Unit
|
||||
|
||||
platform operator fun Double.times(x: CharArray)
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:5:1: error: no definition is found for platform declaration 'divide'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public operator impl fun Double.divide(x: ByteArray): Unit
|
||||
|
||||
platform fun Double.divide(x: ByteArray)
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:7:1: error: no definition is found for platform declaration 'f1'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public impl fun f1(): Unit
|
||||
|
||||
platform external fun f1()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:8:1: error: no definition is found for platform declaration 'g1'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public external impl fun g1(): Unit
|
||||
|
||||
platform fun g1()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:10:1: error: no definition is found for platform declaration 'f2'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public impl fun f2(): Unit
|
||||
|
||||
platform inline fun f2()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:11:1: error: no definition is found for platform declaration 'g2'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public inline impl fun g2(): Unit
|
||||
|
||||
platform fun g2()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:13:1: error: no definition is found for platform declaration 'f3'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public impl fun f3(): Unit
|
||||
|
||||
platform tailrec fun f3()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/common.kt:14:1: error: no definition is found for platform declaration 'g3'
|
||||
The following declaration is incompatible because modifiers are different (external, infix, inline, operator, suspend, tailrec):
|
||||
public tailrec impl fun g3(): Unit
|
||||
|
||||
platform fun g3()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun Int.plus(s: CharSequence): Int = 0
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:2:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl infix fun Int.minus(s: String): Int = 1
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:4:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun Double.times(x: CharArray) {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:5:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl operator fun Double.divide(x: ByteArray) {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:5:6: error: 'operator' modifier is inapplicable on this function: illegal function name
|
||||
impl operator fun Double.divide(x: ByteArray) {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:7:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun f1() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:8:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl external fun g1()
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:10:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun f2() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:11:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl inline fun g2() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:13:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl fun f3() {}
|
||||
^
|
||||
compiler/testData/multiplatform/incompatibleFunctions/jvm.kt:14:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
|
||||
impl tailrec fun g3() {}
|
||||
^
|
||||
|
||||
Reference in New Issue
Block a user