KT-2752: JsName renames native declarations

This commit is contained in:
Alexey Andreev
2016-05-31 15:23:11 +03:00
parent 7a7a6914a6
commit 638952e96e
3 changed files with 52 additions and 0 deletions
@@ -100,6 +100,9 @@ public final class AnnotationsUtils {
continue;
}
String name = getNameForAnnotatedObject(descriptor, annotation);
if (name == null) {
name = getJsName(descriptor);
}
return name != null ? name : descriptor.getName().asString();
}
}
+36
View File
@@ -0,0 +1,36 @@
package foo
@JsName("bar") @native fun foo(): Int = noImpl
@JsName("baz") @native val prop: Int get() = noImpl
@JsName("B") @native class A {
@JsName("g") fun f(): Int = noImpl
@JsName("q") val p: Int get() = noImpl
companion object {
@JsName("g") fun f(): Int = noImpl
@JsName("q") val p: Int get() = noImpl
}
}
@JsName("P") @native object O {
fun f(): Int = noImpl
}
fun box(): String {
assertEquals(23, foo())
assertEquals(123, prop)
assertEquals(42, A().f())
assertEquals(32, A().p)
assertEquals(142, A.f())
assertEquals(132, A.p)
assertEquals(222, O.f())
return "OK"
}
+13
View File
@@ -0,0 +1,13 @@
var bar = function() { return 23; };
var baz = 123;
function B() {
this.q = 32;
}
B.prototype.g = function() { return 42; };
B.q = 132;
B.g = function() { return 142; };
var P = {
f: function() { return 222; }
};