Skip to content

Commit

Permalink
another go at #637
Browse files Browse the repository at this point in the history
  • Loading branch information
chochos committed Oct 6, 2015
1 parent 50c19a5 commit a1c79c1
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/main/java/com/redhat/ceylon/compiler/js/JsCompiler.java
Expand Up @@ -174,17 +174,7 @@ public void visit(Tree.ImportMemberOrType that) {
if (that.getImportModel() == null) {
return;
}
Declaration importedDeclaration = nativeImplToJavascript(importModel.getDeclaration());
if (importedDeclaration == null) {
return;
}

Unit importedDeclarationUnit = importedDeclaration.getUnit();
if (importedDeclarationUnit != null && nonCeylonUnit(importedDeclarationUnit)) {
if (!providedByAJavaNativeModuleImport(that.getUnit(), importedDeclarationUnit)) {
that.addUnsupportedError("cannot import Java declarations in Javascript", Backend.JavaScript);
}
}
javaUnit(that, importModel.getDeclaration(), "cannot import Java declarations in Javascript");
super.visit(that);
}
@Override
Expand Down Expand Up @@ -234,21 +224,36 @@ private Declaration nativeImplToJavascript(Declaration declaration) {
return declaration;
}

@Override
public void visit(Tree.MemberOrTypeExpression that) {
if (hasErrors(that)) return;
Declaration declaration = nativeImplToJavascript(that.getDeclaration());
private boolean javaUnit(Node that, Declaration d, String msg) {
Declaration declaration = nativeImplToJavascript(d);
Unit declarationUnit = null;
if (declaration != null) {
declarationUnit = declaration.getUnit();
}

if (declarationUnit != null && nonCeylonUnit(declarationUnit)) {
if (!providedByAJavaNativeModuleImport(that.getUnit(), declarationUnit)) {
that.addUnsupportedError("cannot call Java declarations in Javascript", Backend.JavaScript);
return;
return true;
}
}
return false;
}

@Override
public void visit(Tree.MemberOrTypeExpression that) {
if (hasErrors(that)) return;
if (javaUnit(that, that.getDeclaration(), "cannot call Java declarations in Javascript")) {
return;
}
super.visit(that);
}

@Override
public void visit(Tree.BaseType that) {
if (hasErrors(that)) return;
if (javaUnit(that, that.getDeclarationModel(), "cannot call Java declarations in Javascript")) {
return;
}
super.visit(that);
}

Expand Down

0 comments on commit a1c79c1

Please sign in to comment.