Add simple tests for using nested namespace.
This commit is contained in:
@@ -40,5 +40,9 @@ public class MultiNamespaceTest extends MultipleFilesTranslationTest {
|
|||||||
checkFooBoxIsTrue("namespaceVariableVisibleFromOtherNamespace");
|
checkFooBoxIsTrue("namespaceVariableVisibleFromOtherNamespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testNestedNamespaceFunctionCalledFromOtherNamespace() throws Exception {
|
||||||
|
checkFooBoxIsTrue("nestedNamespaceFunctionCalledFromOtherNamespace");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,4 +34,7 @@ public final class NamespaceTest extends SingleFileTranslationTest {
|
|||||||
runFunctionOutputTest("deeplyNestedNamespace.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
|
runFunctionOutputTest("deeplyNestedNamespace.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDeeplyNestedNamespaceFunctionCalled() throws Exception {
|
||||||
|
runFunctionOutputTest("deeplyNestedNamespaceFunctionCalled.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-5
@@ -42,8 +42,8 @@ public final class QualifiedExpressionTranslator {
|
|||||||
|
|
||||||
JsExpression receiver = translateReceiver(expression, context);
|
JsExpression receiver = translateReceiver(expression, context);
|
||||||
PropertyAccessTranslator result =
|
PropertyAccessTranslator result =
|
||||||
PropertyAccessTranslator.newInstance(getNotNullSimpleNameSelector(expression), receiver,
|
PropertyAccessTranslator.newInstance(getNotNullSimpleNameSelector(expression), receiver,
|
||||||
CallType.getCallTypeForQualifiedExpression(expression), context);
|
CallType.getCallTypeForQualifiedExpression(expression), context);
|
||||||
result.setCallType(CallType.getCallTypeForQualifiedExpression(expression));
|
result.setCallType(CallType.getCallTypeForQualifiedExpression(expression));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -65,12 +65,15 @@ public final class QualifiedExpressionTranslator {
|
|||||||
if (PropertyAccessTranslator.canBePropertyGetterCall(selector, context)) {
|
if (PropertyAccessTranslator.canBePropertyGetterCall(selector, context)) {
|
||||||
assert selector instanceof JetSimpleNameExpression : "Selectors for properties must be simple names.";
|
assert selector instanceof JetSimpleNameExpression : "Selectors for properties must be simple names.";
|
||||||
return PropertyAccessTranslator.translateAsPropertyGetterCall
|
return PropertyAccessTranslator.translateAsPropertyGetterCall
|
||||||
((JetSimpleNameExpression) selector, receiver, callType, context);
|
((JetSimpleNameExpression)selector, receiver, callType, context);
|
||||||
}
|
}
|
||||||
if (selector instanceof JetCallExpression) {
|
if (selector instanceof JetCallExpression) {
|
||||||
return CallExpressionTranslator.translate((JetCallExpression) selector, receiver, callType, context);
|
return CallExpressionTranslator.translate((JetCallExpression)selector, receiver, callType, context);
|
||||||
}
|
}
|
||||||
throw new AssertionError("Unexpected qualified expression");
|
if (selector instanceof JetSimpleNameExpression) {
|
||||||
|
return ReferenceTranslator.translateSimpleName((JetSimpleNameExpression)selector, context);
|
||||||
|
}
|
||||||
|
throw new AssertionError("Unexpected qualified expression: " + selector.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: if has duplications
|
//TODO: if has duplications
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package a.foo
|
||||||
|
|
||||||
|
fun box() = b.bar.f()
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
package b.bar
|
||||||
|
fun f() = true
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package foo1.foo2.foo3.foo5.foo6.foo7.foo8
|
||||||
|
|
||||||
|
fun box() = f()
|
||||||
|
fun f() = true
|
||||||
Reference in New Issue
Block a user