Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
experimental impl of #4285
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Jan 28, 2015
1 parent 9fe125e commit 5b6f069
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;

import com.redhat.ceylon.compiler.typechecker.model.ProducedType;
import com.redhat.ceylon.compiler.typechecker.tree.Node;
import com.redhat.ceylon.compiler.typechecker.tree.Tree;
import com.redhat.ceylon.compiler.typechecker.tree.Visitor;
Expand Down Expand Up @@ -336,7 +337,7 @@ public void visit(Tree.Return that) {
exit();
exitLoopScope();
}

@Override
public void visit(Tree.Throw that) {
super.visit(that);
Expand Down Expand Up @@ -580,17 +581,22 @@ public void visit(Tree.ExpressionStatement that) {
super.visit(that);
Tree.Expression expr = that.getExpression();
if (expr!=null) {
Tree.Term t = expr.getTerm();
if (t==null) {
Tree.Term term = expr.getTerm();
if (term==null) {
expr.addError("malformed expression statement");
}
else if (!(term instanceof Tree.InvocationExpression
|| term instanceof Tree.PostfixOperatorExpression
|| term instanceof Tree.PrefixOperatorExpression
|| term instanceof Tree.AssignmentOp)) {
expr.addError("not a legal statement (not an invocation, assignment, or increment/decrement)",
3000);
}
else {
if (!(t instanceof Tree.InvocationExpression
|| t instanceof Tree.PostfixOperatorExpression
|| t instanceof Tree.PrefixOperatorExpression
|| t instanceof Tree.AssignmentOp)) {
expr.addError("not a legal statement (not an invocation, assignment, or increment/decrement)",
3000);
ProducedType type = term.getTypeModel();
if (type!=null && type.isNothing()) {
exit();
exitLoopScope();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.redhat.ceylon.compiler.typechecker.model.Method;
import com.redhat.ceylon.compiler.typechecker.model.MethodOrValue;
import com.redhat.ceylon.compiler.typechecker.model.Parameter;
import com.redhat.ceylon.compiler.typechecker.model.ProducedType;
import com.redhat.ceylon.compiler.typechecker.model.Setter;
import com.redhat.ceylon.compiler.typechecker.model.TypedDeclaration;
import com.redhat.ceylon.compiler.typechecker.model.Value;
Expand Down Expand Up @@ -991,6 +992,21 @@ public void visit(Tree.Return that) {
}
exit();
}

@Override
public void visit(Tree.ExpressionStatement that) {
super.visit(that);
Tree.Expression expr = that.getExpression();
if (expr!=null) {
Tree.Term term = expr.getTerm();
if (term!=null) {
ProducedType type = term.getTypeModel();
if (type!=null && type.isNothing()) {
exit();
}
}
}
}

private boolean isSharedDeclarationUninitialized() {
return (declaration.isShared() ||
Expand Down

0 comments on commit 5b6f069

Please sign in to comment.