KT-5214 Annotation to provide platform name to avoid signature conflict

#KT-5214 Fixed
This commit is contained in:
Andrey Breslav
2014-06-10 14:10:49 +04:00
parent 43cac31722
commit 705a081919
21 changed files with 329 additions and 12 deletions
@@ -0,0 +1,11 @@
import kotlin.platform.*
[platformName("bar")]
fun foo() = "foo"
fun box(): String {
val f = (::foo)()
if (f != "foo") return "Fail: $f"
return "OK"
}
@@ -0,0 +1,16 @@
import kotlin.platform.*
fun <T> List<T>.foo() = "foo"
[platformName("fooInt")]
fun List<Int>.foo() = "fooInt"
fun box(): String {
val strings = listOf("", "").foo()
if (strings != "foo") return "Fail: $strings"
val ints = listOf(1, 2).foo()
if (ints != "fooInt") return "Fail: $ints"
return "OK"
}
@@ -0,0 +1,11 @@
import kotlin.platform.*
[platformName("bar")]
fun foo() = "foo"
fun box(): String {
val f = foo()
if (f != "foo") return "Fail: $f"
return "OK"
}
@@ -0,0 +1,14 @@
import kotlin.platform.*
var v: Int = 1
[platformName("vget")]
get
[platformName("vset")]
set
fun box(): String {
v += 1
if (v != 2) return "Fail: $v"
return "OK"
}
@@ -0,0 +1,7 @@
package test;
public class PlatformName {
public static void main(String[] args) {
TestPackage.bar();
}
}
@@ -0,0 +1,6 @@
package test
import kotlin.platform.*
[platformName("bar")]
fun foo() {}
@@ -0,0 +1,8 @@
package test;
public class PlatformName {
public static void main(String[] args) {
int x = TestPackage.vget();
TestPackage.vset(0);
}
}
@@ -0,0 +1,9 @@
package test
import kotlin.platform.*
var v: Int = 1
[platformName("vget")]
get
[platformName("vset")]
set
@@ -0,0 +1,12 @@
package lib
import kotlin.platform.*
[platformName("bar")]
fun foo() = "foo"
var v: Int = 1
[platformName("vget")]
get
[platformName("vset")]
set
@@ -0,0 +1,8 @@
import lib.*
fun main(args: Array<String>) {
foo()
v = 1
println(v)
}
@@ -0,0 +1,66 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
import kotlin.platform.*
[platformName("a")]
fun foo() {}
[platformName("b")]
fun Any.foo() {}
[<!INAPPLICABLE_ANNOTATION!>platformName("c")<!>]
val px = 1
[<!INAPPLICABLE_ANNOTATION!>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("f")]
get
[platformName("g")]
set
[<!INAPPLICABLE_ANNOTATION!>platformName("C")<!>]
class C {
[<!INAPPLICABLE_ANNOTATION!>platformName("a")<!>]
fun foo() {}
[<!INAPPLICABLE_ANNOTATION!>platformName("b")<!>]
fun Any.foo() {}
[<!INAPPLICABLE_ANNOTATION!>platformName("c")<!>]
val px = 1
[<!INAPPLICABLE_ANNOTATION!>platformName("d")<!>]
val Any.px : Int
get() = 1
val valx: Int
[<!INAPPLICABLE_ANNOTATION!>platformName("e")<!>]
get() = 1
var varx: Int
[<!INAPPLICABLE_ANNOTATION!>platformName("f")<!>]
get() = 1
[<!INAPPLICABLE_ANNOTATION!>platformName("g")<!>]
set(v) {}
}
fun foo1() {
[<!INAPPLICABLE_ANNOTATION!>platformName("a")<!>]
fun foo() {}
[<!INAPPLICABLE_ANNOTATION!>platformName("a")<!>]
val x = 1
}