Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/platformName.kt
T
dnpetrov 50ea67ba13 KT-5524 Support [platformName] annotation for class members
@platformName is now supported for final non-overriding class member functions
(including property accessors).
Front-end provides diagnostics for inapplicable annotation cases.
Code generation updated:
- ignore kotlin.platform.platformName annotation for Java class methods;
- bridges generation generates proper JVM declarations in case of methods renamed with @platformName.
@platformName-related tests added.

#KT-5524 Fixed
2015-06-04 17:54:08 +03:00

92 lines
1.8 KiB
Kotlin
Vendored

// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
import kotlin.platform.*
@platformName("a")
fun foo() {}
@platformName("b")
fun Any.foo() {}
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("c")<!>
val px = 1
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("d")<!>
val Any.px : Int
get() = 1
val valx: Int
@platformName("e")
get() = 1
var varx: Int
@platformName("f")
get() = 1
@platformName("g")
set(v) {}
var vardef: Int = 1
@platformName("h")
get
@platformName("i")
set
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("C")<!>
class C <!INAPPLICABLE_PLATFORM_NAME!>platformName("primary")<!> constructor() {
<!INAPPLICABLE_PLATFORM_NAME!>platformName("ctr")<!> constructor(x: Int): this() {}
@platformName("a")
fun foo() {}
@platformName("b")
fun Any.foo() {}
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("c")<!>
val px = 1
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("d")<!>
val Any.px : Int
get() = 1
val valx: Int
@platformName("e")
get() = 1
var varx: Int
@platformName("f")
get() = 1
@platformName("g")
set(v) {}
}
fun foo1() {
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("a")<!>
fun foo() {}
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("a")<!>
val x = 1
}
abstract class AB {
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("AB_absFun1")<!>
abstract fun absFun1()
abstract fun absFun2()
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("AB_openFun")<!>
open fun openFun() {}
}
class D: AB() {
override fun absFun1() {}
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("D_absFun2")<!>
override fun absFun2() {}
<!INAPPLICABLE_PLATFORM_NAME!>@platformName("D_openFun")<!>
final override fun openFun() {}
@platformName("D_finalFun")
fun finalFun() {}
}