diff --git a/prism/src/parser/ast/ASTElement.java b/prism/src/parser/ast/ASTElement.java index becbc733..4f59bc7b 100644 --- a/prism/src/parser/ast/ASTElement.java +++ b/prism/src/parser/ast/ASTElement.java @@ -111,7 +111,7 @@ public abstract class ASTElement /** * Get the type for this element. It should have already been computed * by calling typeCheck(). If not, it will be computed first but, in - * the case of error, you will get "unknown" type, not the error. + * the case of error, you will get "unknown" (null) type, not the error. */ public Type getType() { @@ -128,11 +128,12 @@ public abstract class ASTElement } /** - * Get the type for this element, as a string. + * Get the type for this element but, unlike getType(), don't call typeCheck() + * if it has not been computed yet - just return null instead. */ - public String getTypeString() + public Type getTypeIfDefined() { - return type.getTypeString(); + return type; } public boolean hasPosition() diff --git a/prism/src/parser/visitor/ExpandFormulas.java b/prism/src/parser/visitor/ExpandFormulas.java index 3ecff782..d7a6caa0 100644 --- a/prism/src/parser/visitor/ExpandFormulas.java +++ b/prism/src/parser/visitor/ExpandFormulas.java @@ -67,7 +67,7 @@ public class ExpandFormulas extends ASTTraverseModify expr = Expression.Parenth(expr); // This is probably being done before type-checking so // don't really need to preserve type, but do so just in case - t = expr.getType(); + t = expr.getTypeIfDefined(); expr = Expression.Parenth(expr); expr.setType(t); // Return replacement expression