JS: replace all usages of @native annotation with external modifier, in tests, stdlib, etc

This commit is contained in:
Alexey Andreev
2016-11-25 12:36:47 +03:00
parent e0cb56b3c3
commit 68412ae94f
173 changed files with 486 additions and 651 deletions
@@ -222,7 +222,7 @@ class NameSuggestion {
descriptor
}
// If declaration is marked with either @native, @library or @JsName, return its stable name as is.
// If declaration is marked with either external, @native, @library or @JsName, return its stable name as is.
val nativeName = getNameForAnnotatedObject(overriddenDescriptor)
if (nativeName != null) return NameAndStability(nativeName, true)
@@ -50,9 +50,7 @@ private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy {
put(ErrorsJs.JS_NAME_PROHIBITED_FOR_NAMED_NATIVE, "@JsName is prohibited for @native declaration with explicit name")
put(ErrorsJs.JS_MODULE_PROHIBITED_ON_VAR, "@JsModule and @JsNonModule annotations prohibited for 'var' declarations. " +
"Use 'val' instead.")
put(ErrorsJs.JS_MODULE_PROHIBITED_ON_NON_NATIVE, "@JsModule and @JsNonModule annotations prohibited for non-@native declarations.")
put(ErrorsJs.JS_MODULE_PROHIBITED_ON_NON_TOPLEVEL, "@JsModule and @JsNonModule annotations are only allowed to appear " +
"on packages and top-level declarations")
put(ErrorsJs.JS_MODULE_PROHIBITED_ON_NON_NATIVE, "@JsModule and @JsNonModule annotations prohibited for non-external declarations.")
put(ErrorsJs.NESTED_JS_MODULE_PROHIBITED, "@JsModule and @JsNonModule can't appear on here since the file is already " +
"marked by either @JsModule or @JsNonModule")
put(ErrorsJs.CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM, "Can't access declaration marked with @JsModule annotation " +
@@ -54,7 +54,6 @@ public interface ErrorsJs {
DiagnosticFactory0<PsiElement> JS_NAME_PROHIBITED_FOR_NAMED_NATIVE = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtElement> JS_MODULE_PROHIBITED_ON_VAR = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory0<KtElement> JS_MODULE_PROHIBITED_ON_NON_NATIVE = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory0<KtElement> JS_MODULE_PROHIBITED_ON_NON_TOPLEVEL = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory0<KtElement> NESTED_JS_MODULE_PROHIBITED = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE_OR_DEFAULT);
DiagnosticFactory0<PsiElement> CALL_TO_JS_MODULE_WITHOUT_MODULE_SYSTEM = DiagnosticFactory0.create(ERROR, DEFAULT);
DiagnosticFactory0<PsiElement> CALL_TO_JS_NON_MODULE_WITH_MODULE_SYSTEM = DiagnosticFactory0.create(ERROR, DEFAULT);
@@ -42,10 +42,6 @@ object JsModuleChecker : SimpleDeclarationChecker {
diagnosticHolder.report(ErrorsJs.JS_MODULE_PROHIBITED_ON_NON_NATIVE.on(declaration))
}
if (!DescriptorUtils.isTopLevelDeclaration(descriptor)) {
diagnosticHolder.report(ErrorsJs.JS_MODULE_PROHIBITED_ON_NON_TOPLEVEL.on(declaration))
}
val isFileModuleOrNonModule = AnnotationsUtils.getFileModuleName(bindingContext, descriptor) != null ||
AnnotationsUtils.isFromNonModuleFile(bindingContext, descriptor)
if (isFileModuleOrNonModule) {
+1 -2
View File
@@ -16,6 +16,5 @@
package kotlin.js.internal
@native
@JsName("Error")
public open class JsError(message: String?)
public external open class JsError(message: String?)
+3 -3
View File
@@ -20,8 +20,8 @@ import kotlin.annotation.AnnotationTarget.*
@Retention(AnnotationRetention.BINARY)
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
@native internal annotation class JsName(val name: String)
internal external annotation class JsName(val name: String)
@native internal annotation class native
internal external annotation class native
@native internal fun js(code: String): dynamic
internal external fun js(code: String): dynamic
+10 -17
View File
@@ -18,37 +18,30 @@ package kotlin.js
import kotlin.annotation.AnnotationTarget.*
@native
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, VALUE_PARAMETER, PROPERTY_GETTER, PROPERTY_SETTER)
@Deprecated("Use `external` modifier instead")
public annotation class native(@Deprecated public val name: String = "")
public external annotation class native(@Deprecated public val name: String = "")
@native
@Target(FUNCTION)
@Deprecated
public annotation class nativeGetter
@Deprecated("Use inline extension function with body using dynamic")
public external annotation class nativeGetter
@native
@Target(FUNCTION)
@Deprecated
public annotation class nativeSetter
@Deprecated("Use inline extension function with body using dynamic")
public external annotation class nativeSetter
@native
@Target(FUNCTION)
@Deprecated
public annotation class nativeInvoke
@Deprecated("Use inline extension function with body using dynamic")
public external annotation class nativeInvoke
@native
@Target(CLASS, FUNCTION, PROPERTY)
internal annotation class library(public val name: String = "")
internal external annotation class library(public val name: String = "")
@native
@Target(PROPERTY)
public annotation class enumerable()
public external annotation class enumerable()
@native
@Target(CLASS)
internal annotation class marker
internal external annotation class marker
@Retention(AnnotationRetention.BINARY)
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
+2 -2
View File
@@ -19,9 +19,9 @@ package kotlin.text
// actually \s is enough to match all whitespace, but \xA0 added because of different regexp behavior of Rhino used in Selenium tests
public fun Char.isWhitespace(): Boolean = toString().matches("[\\s\\xA0]")
@native public fun Char.toLowerCase(): Char = noImpl
public external fun Char.toLowerCase(): Char = noImpl
@native public fun Char.toUpperCase(): Char = noImpl
public external fun Char.toUpperCase(): Char = noImpl
/**
* Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit).
+4 -4
View File
@@ -19,7 +19,7 @@ package kotlin
// Note:
// Right now we don't want to have neither 'volatile' nor 'synchronized' at runtime,
// so they annotated as 'native' to avoid warnings/errors from some minifiers.
// so they annotated as `external` to avoid warnings/errors from some minifiers.
// They was reserved word in ECMAScript 2, but is not since ECMAScript 5.
// Additional note:
@@ -29,10 +29,10 @@ package kotlin
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FIELD)
@Retention(AnnotationRetention.SOURCE)
public annotation class Volatile
public external annotation class Volatile
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@Retention(AnnotationRetention.SOURCE)
public annotation class Synchronized
public external annotation class Synchronized
public inline fun <R> synchronized(lock: Any, crossinline block: () -> R): R = block()
public external inline fun <R> synchronized(lock: Any, crossinline block: () -> R): R = block()
+6 -11
View File
@@ -1,16 +1,13 @@
package kotlin.js
@native
public val noImpl: Nothing
public external val noImpl: Nothing
get() = throw Exception()
@native
public fun eval(expr: String): dynamic = noImpl
public external fun eval(expr: String): dynamic = noImpl
@native
public val undefined: Nothing? = noImpl
public external val undefined: Nothing? = noImpl
@native operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = noImpl
external operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = noImpl
@library
public fun println() {}
@@ -22,8 +19,7 @@ public fun println(s: Any?) {}
public fun print(s: Any?) {}
//TODO: consistent parseInt
@native
public fun parseInt(s: String, radix: Int = 10): Int = noImpl
public external fun parseInt(s: String, radix: Int = 10): Int = noImpl
@library
public fun safeParseInt(s: String): Int? = noImpl
@@ -31,8 +27,7 @@ public fun safeParseInt(s: String): Int? = noImpl
@library
public fun safeParseDouble(s: String): Double? = noImpl
@native
public fun js(code: String): dynamic = noImpl
public external fun js(code: String): dynamic = noImpl
/**
* Function corresponding to JavaScript's `typeof` operator
+1 -2
View File
@@ -1,6 +1,5 @@
package kotlin.js
@native
public class Date() {
public external class Date() {
public fun getTime(): Int = noImpl
}
+7 -8
View File
@@ -1,13 +1,12 @@
package kotlin.js
// https://developer.mozilla.org/en/DOM/console
@native public interface Console {
@native public fun dir(o: Any): Unit = noImpl
@native public fun error(vararg o: Any?): Unit = noImpl
@native public fun info(vararg o: Any?): Unit = noImpl
@native public fun log(vararg o: Any?): Unit = noImpl
@native public fun warn(vararg o: Any?): Unit = noImpl
external public interface Console {
public fun dir(o: Any): Unit = noImpl
public fun error(vararg o: Any?): Unit = noImpl
public fun info(vararg o: Any?): Unit = noImpl
public fun log(vararg o: Any?): Unit = noImpl
public fun warn(vararg o: Any?): Unit = noImpl
}
@native
public val console: Console = noImpl
public external val console: Console = noImpl
+1 -2
View File
@@ -21,8 +21,7 @@ package java.util
// typealias Date = kotlin.js.Date
@Deprecated("Use kotlin.js.Date instead", ReplaceWith("kotlin.js.Date"))
@native
public class Date() {
public external class Date() {
public fun getTime(): Int = noImpl
}
+3 -5
View File
@@ -1,6 +1,6 @@
package kotlin.js
@native public class Json() {
public external class Json() {
operator fun get(propertyName: String): Any? = noImpl
operator fun set(propertyName: String, value: Any?): Unit = noImpl
}
@@ -16,8 +16,7 @@ public fun json(vararg pairs: Pair<String, Any?>): Json {
@library("jsonAddProperties")
public fun Json.add(other: Json): Json = noImpl
@native
public interface JsonClass {
public external interface JsonClass {
public fun stringify(o: Any): String
public fun stringify(o: Any, replacer: (key: String, value: Any?) -> Any?): String
public fun stringify(o: Any, replacer: (key: String, value: Any?) -> Any?, space: Int): String
@@ -30,5 +29,4 @@ public interface JsonClass {
public fun <T> parse(text: String, reviver: ((key: String, value: Any?) -> Any?)): T
}
@native
public val JSON: JsonClass = noImpl
public external val JSON: JsonClass = noImpl
+2 -4
View File
@@ -1,8 +1,7 @@
package kotlin.js
//TODO: declare using number
@native
public class MathClass() {
public external class MathClass() {
public val PI: Double = noImpl
public fun random(): Double = noImpl
public fun abs(value: Double): Double = noImpl
@@ -26,5 +25,4 @@ public class MathClass() {
public fun ceil(value: Number): Int = noImpl
}
@native
public val Math: MathClass = MathClass()
public external val Math: MathClass = MathClass()
+2 -2
View File
@@ -17,7 +17,7 @@
package kotlin.text.js
@native public class RegExp(pattern: String, flags: String? = null) {
public external class RegExp(pattern: String, flags: String? = null) {
public fun test(str: String): Boolean = noImpl
@@ -40,7 +40,7 @@ public fun RegExp.reset() {
}
// TODO: Inherit from array or introduce asArray() extension
@native public interface RegExpMatch {
public external interface RegExpMatch {
public val index: Int
public val input: String
public val length: Int
+17 -18
View File
@@ -2,21 +2,21 @@ package kotlin.text
import kotlin.text.js.RegExp
@native public fun String.toUpperCase(): String = noImpl
public external fun String.toUpperCase(): String = noImpl
@native public fun String.toLowerCase(): String = noImpl
public external fun String.toLowerCase(): String = noImpl
@native("indexOf")
internal fun String.nativeIndexOf(str: String, fromIndex: Int): Int = noImpl
@JsName("indexOf")
internal external fun String.nativeIndexOf(str: String, fromIndex: Int): Int = noImpl
@native("lastIndexOf")
internal fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = noImpl
@JsName("lastIndexOf")
internal external fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = noImpl
@native("startsWith")
internal fun String.nativeStartsWith(s: String, position: Int): Boolean = noImpl
@JsName("startsWith")
internal external fun String.nativeStartsWith(s: String, position: Int): Boolean = noImpl
@native("endsWith")
internal fun String.nativeEndsWith(s: String): Boolean = noImpl
@JsName("endsWith")
internal external fun String.nativeEndsWith(s: String): Boolean = noImpl
@Deprecated("Use split(Regex) instead.", ReplaceWith("split(regex.toRegex()).toTypedArray()"))
@library("splitString")
@@ -26,19 +26,18 @@ public fun String.splitWithRegex(regex: String): Array<String> = noImpl
@library("splitString")
public fun String.splitWithRegex(regex: String, limit: Int): Array<String> = noImpl
@native public fun String.substring(startIndex: Int): String = noImpl
public external fun String.substring(startIndex: Int): String = noImpl
@native public fun String.substring(startIndex: Int, endIndex: Int): String = noImpl
public external fun String.substring(startIndex: Int, endIndex: Int): String = noImpl
@native public fun String.concat(str: String): String = noImpl
public external fun String.concat(str: String): String = noImpl
@native public fun String.match(regex: String): Array<String> = noImpl
public external fun String.match(regex: String): Array<String> = noImpl
//native public fun String.trim() : String = noImpl
//TODO: String.replace to implement effective trimLeading and trimTrailing
@native("length")
public val CharSequence.size: Int get() = noImpl
public inline val CharSequence.size: Int get() = asDynamic().length
@native("replace")
internal fun String.nativeReplace(pattern: RegExp, replacement: String): String = noImpl
@JsName("replace")
internal external fun String.nativeReplace(pattern: RegExp, replacement: String): String = noImpl
+15 -18
View File
@@ -2,8 +2,7 @@ package jquery
import org.w3c.dom.Element
@native
public class JQuery() {
public external class JQuery() {
public fun addClass(className: String): JQuery = noImpl;
public fun addClass(f: Element.(Int, String) -> String): JQuery = noImpl;
@@ -43,8 +42,7 @@ public class JQuery() {
public fun `val`(): String? = noImpl
}
@native
open public class MouseEvent() {
open public external class MouseEvent() {
public val pageX: Double = 0.0;
public val pageY: Double = 0.0;
public fun preventDefault() {
@@ -52,20 +50,19 @@ open public class MouseEvent() {
public fun isDefaultPrevented(): Boolean = true;
}
@native
public class MouseClickEvent() : MouseEvent() {
public external class MouseClickEvent() : MouseEvent() {
public val which: Int = 0;
}
@native("$")
public fun jq(selector: String): JQuery = JQuery();
@native("$")
public fun jq(selector: String, context: Element): JQuery = JQuery();
@native("$")
public fun jq(callback: () -> Unit): JQuery = JQuery();
@native("$")
public fun jq(obj: JQuery): JQuery = JQuery();
@native("$")
public fun jq(el: Element): JQuery = JQuery();
@native("$")
public fun jq(): JQuery = JQuery();
@JsName("$")
public external fun jq(selector: String): JQuery = JQuery();
@JsName("$")
public external fun jq(selector: String, context: Element): JQuery = JQuery();
@JsName("$")
public external fun jq(callback: () -> Unit): JQuery = JQuery();
@JsName("$")
public external fun jq(obj: JQuery): JQuery = JQuery();
@JsName("$")
public external fun jq(el: Element): JQuery = JQuery();
@JsName("$")
public external fun jq(): JQuery = JQuery();
+19 -20
View File
@@ -4,23 +4,22 @@ package jquery.ui
//jquery UI
import jquery.JQuery
@native
public fun JQuery.buttonset() : JQuery = noImpl;
@native
public fun JQuery.dialog() : JQuery = noImpl;
@native
public fun JQuery.dialog(params : Json) : JQuery = noImpl
@native
public fun JQuery.dialog(mode : String, param : String) : Any? = noImpl
@native
public fun JQuery.dialog(mode : String) : JQuery = noImpl
@native
public fun JQuery.dialog(mode : String, param : String, value : Any?) : JQuery = noImpl
@native
public fun JQuery.button() : JQuery = noImpl;
@native
public fun JQuery.accordion() : JQuery = noImpl
@native
public fun JQuery.draggable(params : Json) : JQuery = noImpl
@native
public fun JQuery.selectable() : JQuery = noImpl
public external fun JQuery.buttonset() : JQuery = noImpl;
public external fun JQuery.dialog() : JQuery = noImpl;
public external fun JQuery.dialog(params : Json) : JQuery = noImpl
public external fun JQuery.dialog(mode : String, param : String) : Any? = noImpl
public external fun JQuery.dialog(mode : String) : JQuery = noImpl
public external fun JQuery.dialog(mode : String, param : String, value : Any?) : JQuery = noImpl
public external fun JQuery.button() : JQuery = noImpl;
public external fun JQuery.accordion() : JQuery = noImpl
public external fun JQuery.draggable(params : Json) : JQuery = noImpl
public external fun JQuery.selectable() : JQuery = noImpl
+1 -2
View File
@@ -1,4 +1,3 @@
package org.junit
@native
public annotation class Test(val name: String = "")
public external annotation class Test(val name: String = "")
+1 -2
View File
@@ -4,6 +4,5 @@ package QUnit
* The [QUnit](http://qunitjs.com/) API
*/
@native
public fun ok(actual: Boolean, message: String?): Unit = noImpl
public external fun ok(actual: Boolean, message: String?): Unit = noImpl
+2 -4
View File
@@ -20,14 +20,12 @@ import getKClass
import kotlin.reflect.KClass
import kotlin.reflect.js.internal.KClassImpl
@native
interface JsClass<T : Any> {
external interface JsClass<T : Any> {
val name: String
}
@native
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("T::class.js"))
fun <T : Any> jsClass(): JsClass<T> = noImpl
external fun <T : Any> jsClass(): JsClass<T> = noImpl
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"))
val <T : Any> T.jsClass: JsClass<T>
+4 -8
View File
@@ -2,15 +2,11 @@ package kotlin.browser
import org.w3c.dom.*
@native
public val window: Window = noImpl
public external val window: Window = noImpl
@native
public val document: Document = noImpl
public external val document: Document = noImpl
@native
public val localStorage: Storage = noImpl
public external val localStorage: Storage = noImpl
@native
public val sessionStorage: Storage = noImpl
public external val sessionStorage: Storage = noImpl
+1 -1
View File
@@ -7,7 +7,7 @@ import org.w3c.dom.Node
public fun createDocument(): Document = Document()
@Deprecated("use member property outerHTML of Element class instead")
@native public val Node.outerHTML: String get() = noImpl
public external val Node.outerHTML: String get() = noImpl
/** Converts the node to an XML String */
@Deprecated("use outerHTML directly")
@@ -2,15 +2,14 @@ package foo
// HACKS
@native
const val PATH_TO_F_CREATOR = "B\$far\$lambda"
@native
const val PATH_TO_G_CREATOR = "B\$gar\$lambda"
external const val PATH_TO_F_CREATOR = "B\$far\$lambda"
external const val PATH_TO_G_CREATOR = "B\$gar\$lambda"
@native("$PATH_TO_F_CREATOR")
val F_CREATOR: Any = noImpl
@native("$PATH_TO_G_CREATOR")
val G_CREATOR: Any = noImpl
@JsName("$PATH_TO_F_CREATOR")
external val F_CREATOR: Any = noImpl
@JsName("$PATH_TO_G_CREATOR")
external val G_CREATOR: Any = noImpl
// Test
@@ -46,10 +45,8 @@ fun box(): String {
// Helpers
@native
fun String.replace(regexp: RegExp, replacement: String): String = noImpl
external fun String.replace(regexp: RegExp, replacement: String): String = noImpl
fun String.replaceAll(regexp: String, replacement: String): String = replace(RegExp(regexp, "g"), replacement)
@native
class RegExp(regexp: String, flags: String)
external class RegExp(regexp: String, flags: String)
@@ -6,7 +6,7 @@ class A(val x: Int) {
constructor(a: Int, b: Int) : this(a + b)
}
@native class B(x: Int) {
external class B(x: Int) {
constructor(a: Int, b: Int) : this(0) {}
val x: Int
@@ -5,7 +5,7 @@ package lib
fun foo() = 23
@native fun bar(): Int = noImpl
external fun bar(): Int = noImpl
inline fun baz() = 99
@@ -7,9 +7,9 @@ val foo = 23
val boo: Int
get() = 42
@native val bar: Int = noImpl
external val bar: Int = noImpl
@native val far: Int
external val far: Int
get() = noImpl
// TODO: annotations like this are not serialized properly. Uncomment after KT-14529 gets fixed
@@ -20,7 +20,8 @@ val fuzz: Int
inline fun fetchFoo() = foo
@JsName("fee") val tee = 2525
@JsName("fee")
val tee = 2525
// FILE: lib.js
+3 -6
View File
@@ -1,13 +1,10 @@
package foo
@native
var bar: dynamic = noImpl
external var bar: dynamic = noImpl
@native
var arr: dynamic = noImpl
external var arr: dynamic = noImpl
@native
var baz: dynamic = noImpl
external var baz: dynamic = noImpl
object t {
override fun toString() = "object t {}"
+1 -2
View File
@@ -3,8 +3,7 @@ package foo
class A
@native
class B
external class B
fun box(): String {
val a: dynamic = A()
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
enum class JsEnum {
external enum class JsEnum {
Foo,
Bar,
Baz
@@ -1,14 +1,11 @@
package foo
@native
fun String.replace(regexp: RegExp, replacement: String): String = noImpl
external fun String.replace(regexp: RegExp, replacement: String): String = noImpl
fun String.replaceAll(regexp: String, replacement: String): String = replace(RegExp(regexp, "g"), replacement)
@native
fun String.search(regexp: RegExp): Int = noImpl
external fun String.search(regexp: RegExp): Int = noImpl
@native
class RegExp(regexp: String, flags: String = "") {
external class RegExp(regexp: String, flags: String = "") {
fun exec(s: String): Array<String>? = noImpl
}
+21 -21
View File
@@ -5,35 +5,35 @@ private var log = ""
public fun public_baz(i: Int) {
log = "public_baz"
}
@native public fun public_baz(a: String) {
external public fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
internal @native fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun getCurrentPackage(): dynamic = js("_").foo
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
public class PublicClass {
public fun public_baz(i: Int) {
}
@native public fun public_baz(a: String) {
public external fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
@native internal fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) }
@@ -43,17 +43,17 @@ public class PublicClass {
internal class InternalClass {
public fun public_baz(i: Int) {
}
@native public fun public_baz(a: String) {
public external fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
@native internal fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) }
@@ -63,17 +63,17 @@ internal class InternalClass {
private class PrivateClass {
public fun public_baz(i: Int) {
}
@native public fun public_baz(a: String) {
public external fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
@native internal fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) }
@@ -83,17 +83,17 @@ private class PrivateClass {
open public class OpenPublicClass {
public fun public_baz(i: Int) {
}
@native public fun public_baz(a: String) {
public external fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
@native internal fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) }
@@ -103,17 +103,17 @@ open public class OpenPublicClass {
internal open class OpenInternalClass {
public fun public_baz(i: Int) {
}
@native public fun public_baz(a: String) {
public external fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
@native internal fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) }
@@ -123,17 +123,17 @@ internal open class OpenInternalClass {
open private class OpenPrivateClass {
public fun public_baz(i: Int) {
}
@native public fun public_baz(a: String) {
public external fun public_baz(a: String) {
}
internal fun internal_baz(i: Int) {
}
@native internal fun internal_baz(a: String) {
internal external fun internal_baz(a: String) {
}
private fun private_baz(i: Int) {
}
@native private fun private_baz(a: String) {
private external fun private_baz(a: String) {
}
val call_private_baz = { private_baz(0) }
@@ -6,9 +6,6 @@ fun bar(): Any? {
return null
}
@native
val Exception.message: String get() = noImpl
fun box(): String {
val a: String? = null
try {
@@ -2,7 +2,7 @@ package foo
data class A(val bar: Int)
@native class B
external class B
fun makeB(): B = js("new Object();")
@@ -1,7 +1,6 @@
package foo
@native
interface A {
external interface A {
val bar: Int get() = noImpl
fun foo(): String = noImpl
}
@@ -2,8 +2,7 @@
package foo
@native
class A {
external class A {
open class B {
fun foo(): String
}
@@ -2,13 +2,11 @@
package foo
@native
open class A {
external open class A {
fun foo(): String
}
@native
open class B : A() {
external open class B : A() {
fun bar(): String
}
@@ -1,7 +1,6 @@
package foo
@native
fun String.charCodeAt(i: Int): Int = noImpl
external fun String.charCodeAt(i: Int): Int = noImpl
// Because String in JS doesn't have hashCode method
fun String.myHashCode(): Int {
@@ -28,9 +28,9 @@ package foo
// CHECK_NOT_CALLED: moveTo
@native fun Array<Int>.push(element: Int): Unit = noImpl
external fun Array<Int>.push(element: Int): Unit = noImpl
@native fun Array<Int>.splice(index: Int, howMany: Int): Unit = noImpl
external fun Array<Int>.splice(index: Int, howMany: Int): Unit = noImpl
data class PairArray<T, R>(val fst: Array<T>, val snd: Array<R>)
+1 -1
View File
@@ -1 +1 @@
@native public fun parseInt(s: String, radix: Int = 10): Int = noImpl
external public fun parseInt(s: String, radix: Int = 10): Int = noImpl
+1 -1
View File
@@ -136,7 +136,7 @@ inline fun <T, R> T.performWithFail2(job: (T)-> R, failJob: (e: RuntimeException
}
}
@native object Number {
external object Number {
fun parseInt(str: String): Int = noImpl
}
+1 -1
View File
@@ -1,6 +1,6 @@
package foo
@native interface HasName {
external interface HasName {
val name: String
}
+1 -1
View File
@@ -1,6 +1,6 @@
package foo
@native interface Summizer {
external interface Summizer {
fun sum(a: Int, b: Int): Int
}
+1 -1
View File
@@ -1,6 +1,6 @@
package foo
@native interface Summizer {
external interface Summizer {
fun sum(a: Int, b: Int): Int
}
+2 -2
View File
@@ -2,8 +2,8 @@
package foo
@JsModule("lib")
@native class A(@native val x: Int = noImpl) {
@native fun foo(y: Int): Int = noImpl
external class A(val x: Int = noImpl) {
fun foo(y: Int): Int = noImpl
}
fun box(): String {
+1 -1
View File
@@ -2,7 +2,7 @@
package foo
@JsModule("lib")
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
fun box(): String {
assertEquals(65, foo(42))
@@ -2,7 +2,7 @@ package foo
@JsModule("lib")
@JsNonModule
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
fun box(): String {
assertEquals(65, foo(42))
@@ -3,7 +3,7 @@ package foo
@JsModule("lib-foo")
@JsNonModule
@native fun foo(x: Int): Int = noImpl
external fun foo(x: Int): Int = noImpl
fun box(): String {
assertEquals(65, foo(42))
@@ -4,12 +4,12 @@ package foo
@JsModule("libfoo")
@JsNonModule
@native fun foo(x: Int): Int = noImpl
external fun foo(x: Int): Int = noImpl
@JsModule("libbar")
@JsNonModule
@JsName("baz")
@native fun bar(x: Int): Int = noImpl
external fun bar(x: Int): Int = noImpl
fun box(): String {
assertEquals(65, foo(42))
+3 -3
View File
@@ -2,10 +2,10 @@
package foo
@JsModule("lib")
@native object A {
@native val x: Int = noImpl
external object A {
val x: Int = noImpl
@native fun foo(y: Int): Int = noImpl
fun foo(y: Int): Int = noImpl
}
fun box(): String {
+8 -8
View File
@@ -2,21 +2,21 @@
@file:JsModule("lib")
package foo
@native class A(@native val x: Int = noImpl) {
@native fun foo(y: Int): Int = noImpl
external class A(@native val x: Int = noImpl) {
fun foo(y: Int): Int = noImpl
}
@native object B {
@native val x: Int = noImpl
external object B {
val x: Int = noImpl
@native fun foo(y: Int): Int = noImpl
fun foo(y: Int): Int = noImpl
}
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
@native val bar: Int = noImpl
external val bar: Int = noImpl
@native var mbar: Int = noImpl
external var mbar: Int = noImpl
fun box(): String {
val a = A(23)
@@ -3,26 +3,26 @@
@file:JsModule("lib")
package foo
@native class A(@native val x: Int = noImpl) {
@native fun foo(y: Int): Int = noImpl
external class A(@native val x: Int = noImpl) {
fun foo(y: Int): Int = noImpl
}
@native object B {
@native val x: Int = noImpl
external object B {
val x: Int = noImpl
@native fun foo(y: Int): Int = noImpl
fun foo(y: Int): Int = noImpl
}
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
@native val bar: Int = noImpl
external val bar: Int = noImpl
@native var mbar: Int = noImpl
external var mbar: Int = noImpl
// FILE: lib2.kt
package foo
@native object C {
external object C {
fun f(): Int = noImpl
}
@@ -2,21 +2,21 @@
@file:JsNonModule
package foo
@native class A(@native val x: Int = noImpl) {
@native fun foo(y: Int): Int = noImpl
external class A(val x: Int = noImpl) {
fun foo(y: Int): Int = noImpl
}
@native object B {
@native val x: Int = noImpl
external object B {
val x: Int = noImpl
@native fun foo(y: Int): Int = noImpl
fun foo(y: Int): Int = noImpl
}
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
@native val bar: Int = noImpl
external val bar: Int = noImpl
@native var mbar: Int = noImpl
external var mbar: Int = noImpl
fun box(): String {
val a = A(23)
@@ -4,21 +4,21 @@
@file:JsNonModule
package foo
@native class A(@native val x: Int = noImpl) {
@native fun foo(y: Int): Int = noImpl
external class A(val x: Int = noImpl) {
fun foo(y: Int): Int = noImpl
}
@native object B {
@native val x: Int = noImpl
external object B {
val x: Int = noImpl
@native fun foo(y: Int): Int = noImpl
fun foo(y: Int): Int = noImpl
}
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
@native val bar: Int = noImpl
external val bar: Int = noImpl
@native var mbar: Int = noImpl
external var mbar: Int = noImpl
fun box(): String {
val a = A(23)
+1 -1
View File
@@ -2,7 +2,7 @@
package foo
@JsModule("lib")
@native val foo: Int = noImpl
external val foo: Int = noImpl
fun box(): String {
assertEquals(23, foo)
@@ -2,9 +2,8 @@
package foo
@native
@JsName("A")
open class B(val foo: String)
external open class B(val foo: String)
class C(s: String) : B(s)
@@ -3,9 +3,8 @@
package foo
@native
@JsName("A")
open class B(val foo: String)
external open class B(val foo: String)
// MODULE: main(module1)
// FILE: main.kt
+16 -8
View File
@@ -1,22 +1,30 @@
package foo
@JsName("bar") @native fun foo(): Int = noImpl
@JsName("bar")
external fun foo(): Int = noImpl
@JsName("baz") @native val prop: Int get() = noImpl
@JsName("baz")
external val prop: Int get() = noImpl
@JsName("B") @native class A {
@JsName("g") fun f(): Int = noImpl
@JsName("B")
external class A {
@JsName("g")
fun f(): Int = noImpl
@JsName("q") val p: Int get() = noImpl
@JsName("q")
val p: Int get() = noImpl
companion object {
@JsName("g") fun f(): Int = noImpl
@JsName("g")
fun f(): Int = noImpl
@JsName("q") val p: Int get() = noImpl
@JsName("q")
val p: Int get() = noImpl
}
}
@JsName("P") @native object O {
@JsName("P")
external object O {
fun f(): Int = noImpl
}
@@ -1,6 +1,6 @@
package foo
@native class A {
external class A {
val xx: Int
@JsName("getX") get
@@ -9,7 +9,7 @@ package foo
@JsName("setY") set
}
@native var zz: Int
external var zz: Int
@JsName("getZ") get
@JsName("setZ") set
@@ -4,21 +4,21 @@
@file:JsModule("native-lib")
package foo
@native class A(@native val x: Int = noImpl) {
@native fun foo(y: Int): Int = noImpl
external class A(val x: Int = noImpl) {
fun foo(y: Int): Int = noImpl
}
@native object B {
@native val x: Int = noImpl
external object B {
val x: Int = noImpl
@native fun foo(y: Int): Int = noImpl
fun foo(y: Int): Int = noImpl
}
@native fun foo(y: Int): Int = noImpl
external fun foo(y: Int): Int = noImpl
@native val bar: Int = noImpl
external val bar: Int = noImpl
@native var mbar: Int = noImpl
external var mbar: Int = noImpl
// MODULE: main(lib)
// FILE: main.kt
@@ -2,7 +2,7 @@
// FILE: lib.kt
package lib
@native fun bar()
external fun bar()
val bar = 32
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
class A(b: Int) {
external class A(b: Int) {
fun g(): Int = noImpl
fun m(): Int = noImpl
}
+2 -4
View File
@@ -1,9 +1,7 @@
package foo
@native
class A(val c: Int) {
@native
companion object {
external class A(val c: Int) {
external companion object {
val g: Int = noImpl
val c: String = noImpl
}
@@ -1,13 +1,12 @@
package foo
@native
internal open class A(val a: Int) {
internal external open class A(val a: Int) {
fun g(): Int = noImpl
fun m(): Int = noImpl
public open fun foo(i: Int): String = noImpl
public fun boo(i: Int): String = noImpl
@native("bar")
@JsName("bar")
open fun baz(i: Int): String = noImpl
}
@@ -1,11 +1,10 @@
package foo
@native
interface NativeTrait {
external interface NativeTrait {
val foo: String
fun bar(a: Int): Any
@native("boo")
@JsName("boo")
fun baz(): String
}
@@ -12,9 +12,9 @@ open class B {
open fun bar(n: Int) = 142
}
@native fun createA(): A
external fun createA(): A
@native fun createB(): B
external fun createB(): B
fun box(): String {
val a = createA()
+2 -4
View File
@@ -1,13 +1,11 @@
package foo
@native
class Wow() {
external class Wow() {
val x: Int = noImpl
val y: Int = noImpl
}
@native
fun Wow.sum(): Int = noImpl
external fun Wow.sum(): Int = noImpl
fun Wow.dblSum(): Int {
return 2 * sum()
+4 -8
View File
@@ -1,22 +1,18 @@
package foo
@native
interface Chrome {
external interface Chrome {
val extension: Extension
}
@native
interface Extension {
external interface Extension {
val lastError: LastError?
}
@native
interface LastError {
external interface LastError {
val message: String
}
@native
val chrome: Chrome = noImpl
external val chrome: Chrome = noImpl
fun box(): String {
val lastError = chrome.extension.lastError?.message
+3 -4
View File
@@ -1,10 +1,9 @@
package foo
@native
val classes: Map<String, Any> = noImpl
@native
val classesMutable: HashMap<String, String> = noImpl
external val classes: Map<String, Any> = noImpl
external val classesMutable: HashMap<String, String> = noImpl
fun box(): String {
classesMutable.set("why", "?")
@@ -1,7 +1,6 @@
package foo
@native
open class A(val value: String) {
external open class A(val value: String) {
}
class B : A("B") {
@@ -9,9 +8,9 @@ class B : A("B") {
var prop: String = "B prop"
}
@native fun A.bar(): String = noImpl
external fun A.bar(): String = noImpl
@native var A.prop: String
external var A.prop: String
get() = noImpl
set(value) = noImpl
@@ -1,7 +1,7 @@
package foo
@native("Object")
class JsObject {
@JsName("Object")
external class JsObject {
@nativeGetter
operator fun get(a: String): Any? = noImpl
@@ -30,8 +30,7 @@ fun JsObject.put(a: String, v: Any?): Unit = noImpl
object t{}
@native
fun getTestObject(): JsObject = noImpl
external fun getTestObject(): JsObject = noImpl
fun test(obj: JsObject, key: String, oldValue: Any?, newValue: Any) {
assertEquals(oldValue, obj[key])
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
class Function(vararg argsAndCode: String) {
external class Function(vararg argsAndCode: String) {
@nativeInvoke
operator fun invoke(a: Any?): Any? = noImpl
+8 -10
View File
@@ -85,14 +85,13 @@ fun box(): String {
return "OK";
}
@native
object Object {
external object Object {
object Object {
val a: String = noImpl
var b: String = noImpl
fun test(): Int = noImpl
@native("AnotherClass")
@JsName("AnotherClass")
class Class(val a: String) {
var b: String = noImpl
fun test(): Int = noImpl
@@ -133,8 +132,8 @@ object Object {
fun test(): Int = noImpl
}
@native("SomeClass")
class Class {
@JsName("SomeClass")
external class Class {
object Object {
val a: String = noImpl
var b: String = noImpl
@@ -170,16 +169,15 @@ class Class {
}
companion object {
@native("aaa")
@JsName("aaa")
val a: Trait = noImpl
var b: String = noImpl
fun test(): Int = noImpl
}
}
@native
interface Trait {
@native("SomeObject")
external interface Trait {
@JsName("SomeObject")
object Object {
val a: String = noImpl
var b: String = noImpl
@@ -197,7 +195,7 @@ interface Trait {
}
}
@native("SomeTrait")
@JsName("SomeTrait")
interface Trait {
val a: String
var b: String
@@ -1,14 +1,13 @@
package foo
@native
internal class A(val v: String)
internal external class A(val v: String)
internal class B {
fun bar(a: A, extLambda: A.(Int, String) -> String): String = a.extLambda(7, "_rr_")
}
@native
internal fun nativeBox(b: B): String = noImpl
internal external fun nativeBox(b: B): String = noImpl
fun box(): String {
val r = nativeBox(B())
@@ -1,10 +1,8 @@
package foo
@native
class A(val v: String)
external class A(val v: String)
@native
fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
external fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
fun box(): String {
val a = A("test")
@@ -1,14 +1,13 @@
package foo
@native
class A(val v: String) {
external class A(val v: String) {
fun m(i:Int, s:String): String = noImpl
}
@native
fun A.nativeExt(i:Int, s:String): String = noImpl
@native("nativeExt2AnotherName")
fun A.nativeExt2(i:Int, s:String): String = noImpl
external fun A.nativeExt(i:Int, s:String): String = noImpl
@JsName("nativeExt2AnotherName")
external fun A.nativeExt2(i:Int, s:String): String = noImpl
fun bar(a: A, extLambda: A.(Int, String) -> String): String = a.(extLambda)(4, "boo")
@@ -8,8 +8,7 @@ class B(v: String): A(v) {
override fun m(i:Int, s:String): String = "B.m ${this.v} $i $s"
}
@native
fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
external fun bar(a: A, extLambda: A.(Int, String) -> String): String = noImpl
fun A.topLevelExt(i:Int, s:String): String = "A::topLevelExt ${this.v} $i $s"
@@ -1,7 +1,6 @@
package foo
@native
fun nativeFun(i:Int, s:String): String = noImpl
external fun nativeFun(i:Int, s:String): String = noImpl
fun bar(funRef: (Int, String) -> String): String = funRef(4, "boo")
@@ -1,7 +1,6 @@
package foo
@native
fun run(i:Int, s:String, funRef: (Int, String) -> String): String = noImpl
external fun run(i:Int, s:String, funRef: (Int, String) -> String): String = noImpl
fun funTopLevel(i:Int, s:String): String = "funTopLevel $i $s"
+1 -2
View File
@@ -22,8 +22,7 @@ val EXPECTED_NEWLINE_FOR_EACH = """Hello
"""
@native
var buffer: String = noImpl
external var buffer: String = noImpl
fun test(expected: String, initCode: String, getResult: () -> String) {
buffer = ""
@@ -1,7 +1,6 @@
package foo
@native
class A {
external class A {
constructor()
constructor(s: String)
constructor(i: Int)
+1 -2
View File
@@ -1,6 +1,5 @@
package foo
@native
fun returnFalse(): Boolean = noImpl
external fun returnFalse(): Boolean = noImpl
fun box() = if (!returnFalse()) "OK" else "fail"
+1 -2
View File
@@ -1,7 +1,6 @@
package foo
@native
val c: Any? = noImpl
external val c: Any? = noImpl
fun box(): String {
if (c != null) return "fail1"
+13 -22
View File
@@ -1,13 +1,12 @@
package foo
@native
fun paramCount(vararg a: Int): Int = noImpl
external fun paramCount(vararg a: Int): Int = noImpl
@native("paramCount")
fun anotherParamCount(vararg a: Int): Int = noImpl
@JsName("paramCount")
external fun anotherParamCount(vararg a: Int): Int = noImpl
@native("paramCount")
fun <T> genericParamCount(vararg a: T): Int = noImpl
@JsName("paramCount")
external fun <T> genericParamCount(vararg a: T): Int = noImpl
// test spread operator
fun count(vararg a: Int) = paramCount(*a)
@@ -15,14 +14,11 @@ fun count(vararg a: Int) = paramCount(*a)
// test spread operator
fun anotherCount(vararg a: Int) = anotherParamCount(*a)
@native
fun test3(bar: Bar, dummy: Int, vararg args: Int): Boolean = noImpl
external fun test3(bar: Bar, dummy: Int, vararg args: Int): Boolean = noImpl
@native
fun Bar.test2(order: Int, dummy: Int, vararg args: Int): Boolean = noImpl
external fun Bar.test2(order: Int, dummy: Int, vararg args: Int): Boolean = noImpl
@native
class Bar(val size: Int, order: Int = 0) {
external class Bar(val size: Int, order: Int = 0) {
fun test(order: Int, dummy: Int, vararg args: Int): Boolean = noImpl
companion object {
fun startNewTest(): Boolean = noImpl
@@ -30,8 +26,7 @@ class Bar(val size: Int, order: Int = 0) {
}
}
@native
object obj {
external object obj {
fun test(size: Int, vararg args: Int): Boolean = noImpl
}
@@ -43,8 +38,7 @@ fun spreadInMethodCallWithReceiver(size: Int, vararg args: Int) = Bar(size).test
fun spreadInPackageMethodCall(size: Int, vararg args: Int) = test3(Bar(size), 1, *args)
@native
fun testNativeVarargWithFunLit(vararg args: Int, f: (a: IntArray) -> Boolean): Boolean = noImpl
external fun testNativeVarargWithFunLit(vararg args: Int, f: (a: IntArray) -> Boolean): Boolean = noImpl
fun testSpreadOperatorWithSafeCall(a: Bar?, expected: Boolean?, vararg args: Int): Boolean {
return a?.test(0, 1, *args) == expected
@@ -59,14 +53,11 @@ fun testCallOrder(vararg args: Int) =
Bar(args.size, 0).test(1, 1, *args) && Bar(args.size, 2).test(3, 1, *args) &&
!Bar.hasOrderProblem
@native
fun sumOfParameters(x: Int, y: Int, vararg a: Int): Int = noImpl
external fun sumOfParameters(x: Int, y: Int, vararg a: Int): Int = noImpl
@native
fun sumFunValuesOnParameters(x: Int, y: Int, vararg a: Int, f: (Int) -> Int): Int = noImpl
external fun sumFunValuesOnParameters(x: Int, y: Int, vararg a: Int, f: (Int) -> Int): Int = noImpl
@native
fun <T> idArrayVarArg(vararg a: Array<T>): Array<T> = noImpl
external fun <T> idArrayVarArg(vararg a: Array<T>): Array<T> = noImpl
fun box(): String {
if (paramCount() != 0)
+1 -1
View File
@@ -1,6 +1,6 @@
package foo
@native class A(x: Int) {
external class A(x: Int) {
var x: Int
get() = noImpl
set(value) = noImpl
+2 -4
View File
@@ -1,11 +1,9 @@
// FILE: enumerable.kt
package foo
@native
fun <T> _enumerate(o: T): T = noImpl
external fun <T> _enumerate(o: T): T = noImpl
@native
fun <T> _findFirst(o: Any): T = noImpl
external fun <T> _findFirst(o: Any): T = noImpl
class Test() {
val a: Int = 100
@@ -3,8 +3,8 @@ package foo
val PACKAGE = "kotlin.modules.JS_TESTS.foo"
class A
@native val Any.__proto__: String get() = noImpl
@native val A.__proto__: String get() = noImpl
external val Any.__proto__: String get() = noImpl
external val A.__proto__: String get() = noImpl
fun box(): String {
val a = A()
@@ -9,7 +9,7 @@ public interface B : A {
}
}
@native class Function(vararg args: String)
external class Function(vararg args: String)
val hasProp = Function("obj, prop", "return obj[prop] !== undefined") as ((Any, String) -> Boolean)
+4 -6
View File
@@ -1,7 +1,5 @@
package kotlin.test
import kotlin.test.*
fun init() {
asserter = JsTestsAsserter()
}
@@ -10,8 +8,8 @@ public class JsTestsAsserter() : Asserter {
public override fun fail(message: String?): Nothing = failWithMessage(message)
}
@native("JsTests.assert")
public fun assert(value: Boolean, message: String?): Unit = noImpl
@JsName("JsTests.assert")
public external fun assert(value: Boolean, message: String?): Unit = noImpl
@native("JsTests.fail")
private fun failWithMessage(message: String?): Nothing = noImpl
@JsName("JsTests.fail")
private external fun failWithMessage(message: String?): Nothing = noImpl