allow namespace-qualified references; generate nested namespaces
This commit is contained in:
@@ -615,7 +615,7 @@ public class ExpressionCodegen extends JetVisitor {
|
||||
myStack.push(iValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (!(descriptor instanceof NamespaceDescriptor)) {
|
||||
throw new UnsupportedOperationException("don't know how to generate reference " + descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +38,8 @@ public class NamespaceCodegen {
|
||||
}
|
||||
|
||||
public void generate(JetNamespace namespace) {
|
||||
BindingContext bindingContext1 = AnalyzingUtils.analyzeNamespace(namespace, JetControlFlowDataTraceFactory.EMPTY);
|
||||
AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingContext1);
|
||||
BindingContext bindingContext = bindingContext1;
|
||||
BindingContext bindingContext = AnalyzingUtils.analyzeNamespace(namespace, JetControlFlowDataTraceFactory.EMPTY);
|
||||
AnalyzingUtils.applyHandler(ErrorHandler.THROW_EXCEPTION, bindingContext);
|
||||
|
||||
final JetStandardLibrary standardLibrary = JetStandardLibrary.getJetStandardLibrary(project);
|
||||
final FunctionCodegen functionCodegen = new FunctionCodegen(namespace, v, standardLibrary, bindingContext);
|
||||
@@ -65,6 +64,10 @@ public class NamespaceCodegen {
|
||||
else if (declaration instanceof JetClassOrObject) {
|
||||
classCodegen.generate((JetClassOrObject) declaration);
|
||||
}
|
||||
else if (declaration instanceof JetNamespace) {
|
||||
JetNamespace childNamespace = (JetNamespace) declaration;
|
||||
codegens.forNamespace(childNamespace).generate(childNamespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Foo {
|
||||
fun bar() = 610
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return if (Foo.bar() == 610) "OK" else "fail"
|
||||
}
|
||||
@@ -400,4 +400,8 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
final StringBuilder sb = new StringBuilder("x");
|
||||
assertEquals('x', ((Character) main.invoke(null, sb)).charValue());
|
||||
}
|
||||
|
||||
public void testNamespaceQualifiedMethod() throws Exception {
|
||||
blackBoxFile("namespaceQualifiedMethod.jet");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user