KT-2752: JsName renames native declarations
This commit is contained in:
@@ -100,6 +100,9 @@ public final class AnnotationsUtils {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String name = getNameForAnnotatedObject(descriptor, annotation);
|
String name = getNameForAnnotatedObject(descriptor, annotation);
|
||||||
|
if (name == null) {
|
||||||
|
name = getJsName(descriptor);
|
||||||
|
}
|
||||||
return name != null ? name : descriptor.getName().asString();
|
return name != null ? name : descriptor.getName().asString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"
|
||||||
|
}
|
||||||
@@ -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; }
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user