public boolean alwaysMatches(List<PPattern> pl) { for (PPattern p : pl) { if (!af.createPPatternAssistant().alwaysMatches(p)) { return false; // NB. AND } } return true; }
@Override public Boolean caseAConcatenationPattern(AConcatenationPattern node) throws AnalysisException { return af.createPPatternAssistant().alwaysMatches(node.getLeft()) && af.createPPatternAssistant().alwaysMatches(node.getRight()); }
@Override public Boolean caseAUnionPattern(AUnionPattern node) throws AnalysisException { return af.createPPatternAssistant().alwaysMatches(node.getLeft()) && af.createPPatternAssistant().alwaysMatches(node.getRight()); }
public boolean alwaysMatches(PPattern pattern, PType type) { return af.getTypeComparator().isSubType(getPossibleType(pattern), type) && alwaysMatches(pattern); } }
@Override public PType caseACasesStm(ACasesStm node, TypeCheckInfo question) throws AnalysisException { PType expType = node.getExp().apply(THIS, question); PTypeSet rtypes = new PTypeSet(question.assistantFactory); boolean always = false; for (ACaseAlternativeStm c : node.getCases()) { c.setCtype(expType); rtypes.add(c.apply(THIS, question)); always = always || question.assistantFactory.createPPatternAssistant().alwaysMatches(c.getPattern(), expType); } if (node.getOthers() != null) { rtypes.add(node.getOthers().apply(THIS, question)); } else if (!always) { rtypes.add(AstFactory.newAVoidType(node.getLocation())); } node.setType(rtypes.getType(node.getLocation())); return node.getType(); }