diff --git a/build.xml b/build.xml
index d78957ae3be..948ace257f9 100644
--- a/build.xml
+++ b/build.xml
@@ -376,6 +376,14 @@
+
+
@@ -401,6 +410,7 @@
+
diff --git a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/jsScopes.kt b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/jsScopes.kt
index f037125dd8e..a7833920e81 100644
--- a/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/jsScopes.kt
+++ b/js/js.dart-ast/src/com/google/dart/compiler/backend/js/ast/jsScopes.kt
@@ -96,15 +96,15 @@ open class JsFunctionScope(parent: JsScope, description: String) : JsScope(paren
// disallowed as variable names in strict mode
"eval", "arguments",
- // non-reserved words that act like reserved words
+ // global identifiers usually declared in a typical JS interpreter
"NaN", "Infinity", "undefined",
-
- // the special Kotlin object
- "Kotlin",
-
"Error", "Object", "Math", "String", "Number", "Boolean", "Date", "Array", "RegExp", "JSON",
- "require", "define", "module", "window", "self"
+ // global identifiers usually declared in know environments (node.js, browser, require.js, WebWorkers, etc)
+ "require", "define", "module", "window", "self",
+
+ // the special Kotlin object
+ "Kotlin"
)
}
}
diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectUtils.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectUtils.kt
index a58e9b1fcf3..909bf0af646 100644
--- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectUtils.kt
+++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectUtils.kt
@@ -18,10 +18,8 @@ package org.jetbrains.kotlin.js.inline.util
import com.google.dart.compiler.backend.js.ast.*
import com.google.dart.compiler.backend.js.ast.metadata.staticRef
-
import org.jetbrains.kotlin.js.inline.util.collectors.InstanceCollector
-import org.jetbrains.kotlin.js.inline.util.collectors.PropertyCollector
-import org.jetbrains.kotlin.js.translate.expression.*
+import org.jetbrains.kotlin.js.translate.expression.InlineMetadata
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import java.util.*
@@ -128,12 +126,6 @@ fun JsFunction.collectFreeVariables() = collectUsedNames(body) - collectDefinedN
fun JsFunction.collectLocalVariables() = collectDefinedNames(body) + parameters.map { it.name }
-fun collectJsProperties(scope: JsNode): IdentityHashMap {
- val collector = PropertyCollector()
- collector.accept(scope)
- return collector.properties
-}
-
fun collectNamedFunctions(scope: JsNode) = collectNamedFunctionsAndMetadata(scope).mapValues { it.value.first }
fun collectNamedFunctionsOrMetadata(scope: JsNode) = collectNamedFunctionsAndMetadata(scope).mapValues { it.value.second }
diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectors/PropertyCollector.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectors/PropertyCollector.kt
deleted file mode 100644
index 5049cfbf90c..00000000000
--- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/util/collectors/PropertyCollector.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2010-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jetbrains.kotlin.js.inline.util.collectors
-
-import com.google.dart.compiler.backend.js.ast.*
-import org.jetbrains.kotlin.js.translate.expression.InlineMetadata
-import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
-
-import java.util.IdentityHashMap
-
-class PropertyCollector : RecursiveJsVisitor() {
- val properties: IdentityHashMap = IdentityHashMap()
-
- override fun visitPropertyInitializer(x: JsPropertyInitializer) {
- super.visitPropertyInitializer(x)
-
- val label = x.labelExpr as? JsNameRef
- val name = label?.name
- if (name == null) return
-
- val value = x.valueExpr
- properties[name] = value
- }
-}
diff --git a/js/js.libraries/src/builtins/annotations.kt b/js/js.libraries/src/builtins/hacks.kt
similarity index 100%
rename from js/js.libraries/src/builtins/annotations.kt
rename to js/js.libraries/src/builtins/hacks.kt
diff --git a/js/js.libraries/src/builtins/kotlin.kt b/js/js.libraries/src/builtins/kotlin.kt
index c99ce26d86a..2c784361f70 100644
--- a/js/js.libraries/src/builtins/kotlin.kt
+++ b/js/js.libraries/src/builtins/kotlin.kt
@@ -33,6 +33,6 @@ class Enum> : Comparable> {
override fun hashCode(): Int = js("Kotlin.identityHashCode(this)")
override fun toString() = name
-}
-interface Annotation
\ No newline at end of file
+ companion object
+}
\ No newline at end of file
diff --git a/js/js.libraries/src/builtins/primitiveCompanionObjects.kt b/js/js.libraries/src/builtins/primitiveCompanionObjects.kt
index e15933124df..7781bb62eb1 100644
--- a/js/js.libraries/src/builtins/primitiveCompanionObjects.kt
+++ b/js/js.libraries/src/builtins/primitiveCompanionObjects.kt
@@ -16,51 +16,98 @@
package kotlin.js.internal
-@JsName("DoubleCompanionObject") private object DoubleCompanionObject {
- @JsName("MIN_VALUE") val MIN_VALUE: Double = js("Number.MIN_VALUE")
- @JsName("MAX_VALUE") val MAX_VALUE: Double = js("Number.MAX_VALUE")
- @JsName("POSITIVE_INFINITY") val POSITIVE_INFINITY: Double = js("Number.POSITIVE_INFINITY")
- @JsName("NEGATIVE_INFINITY") val NEGATIVE_INFINITY: Double = js("Number.NEGATIVE_INFINITY")
- @JsName("NaN") val NaN: Double = js("Number.NaN")
+@JsName("DoubleCompanionObject")
+private object DoubleCompanionObject {
+ @JsName("MIN_VALUE")
+ val MIN_VALUE: Double = js("Number.MIN_VALUE")
+
+ @JsName("MAX_VALUE")
+ val MAX_VALUE: Double = js("Number.MAX_VALUE")
+
+ @JsName("POSITIVE_INFINITY")
+ val POSITIVE_INFINITY: Double = js("Number.POSITIVE_INFINITY")
+
+ @JsName("NEGATIVE_INFINITY")
+ val NEGATIVE_INFINITY: Double = js("Number.NEGATIVE_INFINITY")
+
+ @JsName("NaN")
+ val NaN: Double = js("Number.NaN")
}
-@JsName("FloatCompanionObject") private object FloatCompanionObject {
- @JsName("MIN_VALUE") val MIN_VALUE: Float = js("Number.MIN_VALUE")
- @JsName("MAX_VALUE") val MAX_VALUE: Float = js("Number.MAX_VALUE")
- @JsName("POSITIVE_INFINITY") val POSITIVE_INFINITY: Float = js("Number.POSITIVE_INFINITY")
- @JsName("NEGATIVE_INFINITY") val NEGATIVE_INFINITY: Float = js("Number.NEGATIVE_INFINITY")
- @JsName("NaN") val NaN: Float = js("Number.NaN")
+@JsName("FloatCompanionObject")
+private object FloatCompanionObject {
+ @JsName("MIN_VALUE")
+ val MIN_VALUE: Float = js("Number.MIN_VALUE")
+
+ @JsName("MAX_VALUE")
+ val MAX_VALUE: Float = js("Number.MAX_VALUE")
+
+ @JsName("POSITIVE_INFINITY")
+ val POSITIVE_INFINITY: Float = js("Number.POSITIVE_INFINITY")
+
+ @JsName("NEGATIVE_INFINITY")
+ val NEGATIVE_INFINITY: Float = js("Number.NEGATIVE_INFINITY")
+
+ @JsName("NaN")
+ val NaN: Float = js("Number.NaN")
}
-@JsName("IntCompanionObject") private object IntCompanionObject {
- @JsName("MIN_VALUE") val MIN_VALUE: Int = -2147483647 - 1
- @JsName("MAX_VALUE") val MAX_VALUE: Int = 2147483647
+@JsName("IntCompanionObject")
+private object IntCompanionObject {
+ @JsName("MIN_VALUE")
+ val MIN_VALUE: Int = -2147483647 - 1
+
+ @JsName("MAX_VALUE")
+ val MAX_VALUE: Int = 2147483647
}
-@JsName("LongCompanionObject") private object LongCompanionObject {
- @JsName("MIN_VALUE") val MIN_VALUE: Long = js("Kotlin.Long.MIN_VALUE")
- @JsName("MAX_VALUE") val MAX_VALUE: Long = js("Kotlin.Long.MAX_VALUE")
+@JsName("LongCompanionObject")
+private object LongCompanionObject {
+ @JsName("MIN_VALUE")
+ val MIN_VALUE: Long = js("Kotlin.Long.MIN_VALUE")
+
+ @JsName("MAX_VALUE")
+ val MAX_VALUE: Long = js("Kotlin.Long.MAX_VALUE")
}
-@JsName("ShortCompanionObject") private object ShortCompanionObject {
- @JsName("MIN_VALUE") val MIN_VALUE: Short = -32768
- @JsName("MAX_VALUE") val MAX_VALUE: Short = 32767
+@JsName("ShortCompanionObject")
+private object ShortCompanionObject {
+ @JsName("MIN_VALUE")
+ val MIN_VALUE: Short = -32768
+
+ @JsName("MAX_VALUE")
+ val MAX_VALUE: Short = 32767
}
-@JsName("ByteCompanionObject") private object ByteCompanionObject {
- @JsName("MIN_VALUE") val MIN_VALUE: Byte = -128
- @JsName("MAX_VALUE") val MAX_VALUE: Byte = 127
+@JsName("ByteCompanionObject")
+private object ByteCompanionObject {
+ @JsName("MIN_VALUE")
+ val MIN_VALUE: Byte = -128
+
+ @JsName("MAX_VALUE")
+ val MAX_VALUE: Byte = 127
}
-@JsName("CharCompanionObject") private object CharCompanionObject {
- @JsName("MIN_HIGH_SURROGATE") public const val MIN_HIGH_SURROGATE: Char = '\uD800'
- @JsName("MAX_HIGH_SURROGATE") public const val MAX_HIGH_SURROGATE: Char = '\uDBFF'
- @JsName("MIN_LOW_SURROGATE") public const val MIN_LOW_SURROGATE: Char = '\uDC00'
- @JsName("MAX_LOW_SURROGATE") public const val MAX_LOW_SURROGATE: Char = '\uDFFF'
- @JsName("MIN_SURROGATE") public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
- @JsName("MAX_SURROGATE") public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
+@JsName("CharCompanionObject")
+private object CharCompanionObject {
+ @JsName("MIN_HIGH_SURROGATE")
+ public const val MIN_HIGH_SURROGATE: Char = '\uD800'
+
+ @JsName("MAX_HIGH_SURROGATE")
+ public const val MAX_HIGH_SURROGATE: Char = '\uDBFF'
+
+ @JsName("MIN_LOW_SURROGATE")
+ public const val MIN_LOW_SURROGATE: Char = '\uDC00'
+
+ @JsName("MAX_LOW_SURROGATE")
+ public const val MAX_LOW_SURROGATE: Char = '\uDFFF'
+
+ @JsName("MIN_SURROGATE")
+ public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
+
+ @JsName("MAX_SURROGATE")
+ public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
}
private object StringCompanionObject {}
-private object EnumCompanionObject {}
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java
index 4ccb699168e..52d0a9dc7ab 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/StaticContext.java
@@ -142,7 +142,7 @@ public final class StaticContext {
private final DeclarationExporter exporter = new DeclarationExporter(this);
@NotNull
- private final Set classes = new HashSet();
+ private final Set classes = new LinkedHashSet();
//TODO: too many parameters in constructor
private StaticContext(
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java
index 2ede2d38cb3..d421fca47cc 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/context/TranslationContext.java
@@ -576,12 +576,12 @@ public class TranslationContext {
}
@NotNull
- public JsFunction createTopLevelFunction(@NotNull DeclarationDescriptor descriptor) {
- return createTopLevelFunction(descriptor.toString());
+ public JsFunction createRootScopedFunction(@NotNull DeclarationDescriptor descriptor) {
+ return createRootScopedFunction(descriptor.toString());
}
@NotNull
- public JsFunction createTopLevelFunction(@NotNull String description) {
+ public JsFunction createRootScopedFunction(@NotNull String description) {
return new JsFunction(staticContext.getRootFunction().getScope(), new JsBlock(), description);
}
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt
index b942aa77026..69178ed1cea 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/ClassTranslator.kt
@@ -74,7 +74,7 @@ class ClassTranslator private constructor(
val scope = context().getScopeForDescriptor(descriptor)
val context = context().newDeclaration(descriptor)
- val constructorFunction = context.createTopLevelFunction(descriptor)
+ val constructorFunction = context.createRootScopedFunction(descriptor)
constructorFunction.name = context.getInnerNameForDescriptor(descriptor)
context.addDeclarationStatement(constructorFunction.makeStmt())
val enumInitFunction = if (descriptor.kind == ClassKind.ENUM_CLASS) createEnumInitFunction() else null
@@ -141,9 +141,9 @@ class ClassTranslator private constructor(
}
private fun createEnumInitFunction(): JsFunction {
- val function = context().createTopLevelFunction(descriptor)
+ val function = context().createRootScopedFunction(descriptor)
function.name = context().createGlobalName(StaticContext.getSuggestedName(descriptor) + "_initFields")
- val emptyFunction = context().createTopLevelFunction(descriptor)
+ val emptyFunction = context().createRootScopedFunction(descriptor)
function.body.statements += JsAstUtils.assignment(JsAstUtils.pureFqn(function.name, null), emptyFunction).makeStmt()
context().addDeclarationStatement(function.makeStmt())
return function
@@ -419,7 +419,7 @@ class ClassTranslator private constructor(
private fun addObjectMethods() {
context().addDeclarationStatement(JsAstUtils.newVar(cachedInstanceName, JsLiteral.NULL))
- val instanceFun = context().createTopLevelFunction("Instance function: " + descriptor)
+ val instanceFun = context().createRootScopedFunction("Instance function: " + descriptor)
instanceFun.name = context().getNameForObjectInstance(descriptor)
if (enumInitializerName == null) {
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.kt
index c3e87ef1f49..ddc3bc02e0e 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.kt
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/DeclarationBodyVisitor.kt
@@ -69,7 +69,7 @@ class DeclarationBodyVisitor(
context.addDeclarationStatement(JsAstUtils.newVar(enumInstanceName, null))
enumInitializer.body.statements += JsAstUtils.assignment(pureFqn(enumInstanceName, null), jsEnumEntryCreation).makeStmt()
- val enumInstanceFunction = context.createTopLevelFunction(descriptor)
+ val enumInstanceFunction = context.createRootScopedFunction(descriptor)
enumInstanceFunction.name = context.getNameForObjectInstance(descriptor)
context.addDeclarationStatement(enumInstanceFunction.makeStmt())
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/JsDataClassGenerator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/JsDataClassGenerator.java
index fe57bec011e..cc1cf7f5dce 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/JsDataClassGenerator.java
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/declaration/JsDataClassGenerator.java
@@ -189,7 +189,7 @@ class JsDataClassGenerator extends DataClassMethodGenerator {
}
private JsFunction generateJsMethod(@NotNull FunctionDescriptor functionDescriptor) {
- JsFunction functionObject = context.createTopLevelFunction(functionDescriptor);
+ JsFunction functionObject = context.createRootScopedFunction(functionDescriptor);
ClassDescriptor containingClass = (ClassDescriptor) functionDescriptor.getContainingDeclaration();
UtilsKt.addFunctionToPrototype(context, containingClass, functionDescriptor, functionObject);
return functionObject;
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java
index c33910995ca..cef9f941463 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/general/Translation.java
@@ -253,7 +253,7 @@ public final class Translation {
) {
StaticContext staticContext = StaticContext.generateStaticContext(bindingTrace, config, moduleDescriptor);
JsProgram program = staticContext.getProgram();
- program.getRootScope().declareName("_");
+ JsName rootPackageName = program.getRootScope().declareName(Namer.getRootPackageName());
JsFunction rootFunction = staticContext.getRootFunction();
JsBlock rootBlock = rootFunction.getBody();
@@ -270,8 +270,6 @@ public final class Translation {
}
mayBeGenerateTests(files, config, rootBlock, context);
-
- JsName rootPackageName = program.getRootScope().declareName(Namer.getRootPackageName());
rootFunction.getParameters().add(new JsParameter((rootPackageName)));
// Invoke function passing modules as arguments
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt
index 1201edc0e5c..d6e79a97e32 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/intrinsic/objects/objectsIntrinsics.kt
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.js.translate.intrinsic.objects
import com.google.dart.compiler.backend.js.ast.JsExpression
import com.google.dart.compiler.backend.js.ast.JsName
import org.jetbrains.kotlin.builtins.CompanionObjectMapping
+import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.js.translate.context.Namer
import org.jetbrains.kotlin.js.translate.context.StaticContext
@@ -26,6 +27,7 @@ import org.jetbrains.kotlin.js.translate.context.TranslationContext
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
+import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
class DefaultClassObjectIntrinsic(val staticContext: StaticContext, val fqName: FqName): ObjectIntrinsic {
private val innerName: JsName by lazy {
@@ -42,7 +44,11 @@ class ObjectIntrinsics(private val staticContext: StaticContext) {
fun getIntrinsic(classDescriptor: ClassDescriptor) = cache.getOrPut(classDescriptor) { createIntrinsic(classDescriptor) }
private fun createIntrinsic(classDescriptor: ClassDescriptor): ObjectIntrinsic {
- if (!CompanionObjectMapping.isMappedIntrinsicCompanionObject(classDescriptor)) return NO_OBJECT_INTRINSIC
+ if (classDescriptor.fqNameUnsafe == KotlinBuiltIns.FQ_NAMES._enum ||
+ !CompanionObjectMapping.isMappedIntrinsicCompanionObject(classDescriptor)
+ ) {
+ return NO_OBJECT_INTRINSIC
+ }
val containingDeclaration = classDescriptor.containingDeclaration
val name = Name.identifier(containingDeclaration.name.asString() + "CompanionObject")
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt
index 62f3c51c4e7..f821be970f6 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/CallableReferenceTranslator.kt
@@ -109,7 +109,7 @@ object CallableReferenceTranslator {
ReferenceTranslator.translateAsValueReference(descriptor, context)
}
- val function = context.createTopLevelFunction(getter)
+ val function = context.createRootScopedFunction(getter)
function.body.statements += JsReturn(expression)
return function
@@ -121,7 +121,7 @@ object CallableReferenceTranslator {
return context.getInnerReference(setter)
}
- val function = context.createTopLevelFunction(setter)
+ val function = context.createRootScopedFunction(setter)
val valueParam = function.scope.declareFreshName("value")
function.parameters += JsParameter(valueParam)
diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ReferenceTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ReferenceTranslator.java
index 432e1e18464..6d86a7ae5f9 100644
--- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ReferenceTranslator.java
+++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/reference/ReferenceTranslator.java
@@ -68,10 +68,7 @@ public final class ReferenceTranslator {
}
if (DescriptorUtils.isObject(descriptor) || DescriptorUtils.isEnumEntry(descriptor)) {
- if (AnnotationsUtils.isNativeObject(descriptor)) {
- return context.getQualifiedReference(descriptor);
- }
- else if (!context.isFromCurrentModule(descriptor)) {
+ if (!context.isFromCurrentModule(descriptor)) {
return getLazyReferenceToObject((ClassDescriptor) descriptor, context);
}
else {
diff --git a/js/js.translator/testData/box/closure/closureThisByUsingMethodFromParentClass.kt b/js/js.translator/testData/box/closure/closureThisByUsingMethodFromParentClass.kt
index 4f741cde24a..9d70f90dceb 100644
--- a/js/js.translator/testData/box/closure/closureThisByUsingMethodFromParentClass.kt
+++ b/js/js.translator/testData/box/closure/closureThisByUsingMethodFromParentClass.kt
@@ -2,8 +2,6 @@ package foo
// HACKS
-@native
-const val ROOT = "Kotlin.modules.JS_TESTS"
@native
const val PATH_TO_F_CREATOR = "B\$far\$lambda"
@native
diff --git a/js/js.translator/testData/box/native/nativePropertyWithCustomName.kt b/js/js.translator/testData/box/native/nativePropertyWithCustomName.kt
index 4eca4bd50e9..2a1bb9eeb1d 100644
--- a/js/js.translator/testData/box/native/nativePropertyWithCustomName.kt
+++ b/js/js.translator/testData/box/native/nativePropertyWithCustomName.kt
@@ -1,12 +1,13 @@
package foo
-internal val PACKAGE = "kotlin.modules.JS_TESTS.foo"
+// TODO: this feature is deprecated, remove this test when either @native annotation or its parameter get eliminated.
-internal @native @JsName("\"O\"") val foo: String = noImpl
-internal @native @JsName("boo") val bar: String = noImpl
+internal @native("\"O\"") val foo: String = noImpl
+internal @native("boo") val bar: String = noImpl
internal class A
-internal fun proto(o: Any?): String = js("o.__proto__")
+internal @native("__proto__") val Any.proto: String get() = noImpl
+internal @native("__proto__") val A.proto: String get() = noImpl
internal fun actual(foo: String, @native("boo") bar: String) = foo + bar
internal fun expected(foo: String, boo: String) = foo + boo
@@ -23,9 +24,9 @@ fun box(): String {
val a = A()
val any: Any = a
- val protoA = js("A.prototype")
- if (proto(a) != proto(any) || proto(a) != protoA)
- return "a.proto != any.proto /*${proto(a) != proto(any)}*/ || a.proto != A.prototype /*${proto(a) != protoA}*/"
+ val protoA = A::class.js.asDynamic().prototype
+ if (a.proto != any.proto || a.proto != protoA)
+ return "a.proto != any.proto /*${a.proto != any.proto}*/ || a.proto != A.prototype /*${a.proto != protoA}*/"
return OK
}
diff --git a/js/js.translator/testData/kotlin_lib_ecma5.js b/js/js.translator/testData/kotlin_lib_ecma5.js
index 9d6630b8326..1421e02c58d 100644
--- a/js/js.translator/testData/kotlin_lib_ecma5.js
+++ b/js/js.translator/testData/kotlin_lib_ecma5.js
@@ -363,7 +363,8 @@
propertyDescriptor.set.call(thisObject, value);
}
else if ("value" in propertyDescriptor) {
- propertyDescriptor.value = value;
+ throw new Error("Assertion failed: Kotlin compiler should not generate simple JavaScript properties for overridable " +
+ "Kotlin properties.");
}
}
else {
diff --git a/jslib_files.xml b/jslib_files.xml
index 761cd607b8c..67c961c091c 100644
--- a/jslib_files.xml
+++ b/jslib_files.xml
@@ -3,6 +3,7 @@
+