diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 68537dcbc62..e0d40dee354 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -8,11 +8,10 @@
-
+
-
-
-
+
+
@@ -96,7 +95,7 @@
-
+
@@ -109,7 +108,7 @@
-
+
@@ -122,46 +121,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -237,7 +197,7 @@
-
+
@@ -245,66 +205,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -312,19 +223,46 @@
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -337,8 +275,13 @@
-
-
+
+
+
+
+
+
+
@@ -405,7 +348,7 @@
-
+
@@ -450,9 +393,6 @@
@@ -720,10 +663,6 @@
-
-
-
-
@@ -782,58 +721,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -966,8 +853,8 @@
-
+
@@ -977,72 +864,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1118,6 +939,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1238,12 +1121,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
localhost
@@ -1316,8 +1199,8 @@
-
-
+
+
@@ -1361,7 +1244,7 @@
-
+
@@ -1374,7 +1257,6 @@
-
@@ -1399,6 +1281,7 @@
+
@@ -1408,9 +1291,16 @@
-
+
-
+
+
+
+
+
+
+
+
@@ -1422,39 +1312,23 @@
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
@@ -1466,62 +1340,53 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java b/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
index d2c2f40fae9..bb9c429841d 100644
--- a/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
+++ b/translator/src/org/jetbrains/k2js/translate/utils/BindingUtils.java
@@ -191,11 +191,22 @@ public final class BindingUtils {
return null;
}
+ //TODO: duplication
public static boolean isOwnedByNamespace(@NotNull DeclarationDescriptor descriptor) {
+ if (descriptor instanceof ConstructorDescriptor) {
+ DeclarationDescriptor classDescriptor = descriptor.getContainingDeclaration();
+ assert classDescriptor != null;
+ return isOwnedByNamespace(classDescriptor);
+ }
return (descriptor.getContainingDeclaration() instanceof NamespaceDescriptor);
}
public static boolean isOwnedByClass(@NotNull DeclarationDescriptor descriptor) {
+ if (descriptor instanceof ConstructorDescriptor) {
+ DeclarationDescriptor classDescriptor = descriptor.getContainingDeclaration();
+ assert classDescriptor != null;
+ return isOwnedByClass(classDescriptor);
+ }
return (descriptor.getContainingDeclaration() instanceof ClassDescriptor);
}
diff --git a/translator/test/org/jetbrains/k2js/test/JavascriptTest.java b/translator/test/org/jetbrains/k2js/test/JavascriptTest.java
index a873a2f0ef2..67fee47b272 100644
--- a/translator/test/org/jetbrains/k2js/test/JavascriptTest.java
+++ b/translator/test/org/jetbrains/k2js/test/JavascriptTest.java
@@ -1,9 +1,5 @@
package org.jetbrains.k2js.test;
-import org.junit.Test;
-
-import java.util.Arrays;
-
/**
* @author Talanov Pavel
*/
@@ -16,9 +12,4 @@ public final class JavascriptTest extends TranslationTest {
return MAIN;
}
- @Test
- public void enclosingThis() throws Exception {
- runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("enclosingThis.js")),
- new RhinoFunctionResultChecker("Anonymous", "box", "OK"));
- }
}
diff --git a/translator/testFiles/javascript/cases/enclosingThis.js b/translator/testFiles/javascript/cases/enclosingThis.js
deleted file mode 100644
index 6a365266601..00000000000
--- a/translator/testFiles/javascript/cases/enclosingThis.js
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- classes = function () {
- var Point = Class.create({initialize:function (x, y) {
- this.$x = x;
- this.$y = y;
- }, get_x:function () {
- return this.$x;
- }, get_y:function () {
- return this.$y;
- }, mul:function () {
- return (that = this, function (scalar) {
- return new Point(that.get_x() * scalar, that.get_y() * scalar);
- })
- ;
- }
- });
- return {Point:Point};
- }
- ();
- Anonymous = Namespace.create({initialize:function () {
- Anonymous.$m = (new Anonymous.Point(2, 3)).mul();
- }, get_m:function () {
- return Anonymous.$m;
- }, box:function () {
- var answer = Anonymous.get_m()(5);
- return answer.get_x() === 10 && answer.get_y() === 15 ? 'OK' : 'FAIL';
- }
- }, classes);
- Anonymous.initialize();
-}