@Override public PType caseATypeMultipleBind(ATypeMultipleBind mb) throws AnalysisException { return af.createPPatternListAssistant().getPossibleType(mb.getPlist(), mb.getLocation()); }
@Override public PType caseASeqMultipleBind(ASeqMultipleBind mb) throws AnalysisException { return af.createPPatternListAssistant().getPossibleType(mb.getPlist(), mb.getLocation()); }
@Override public PType caseASetMultipleBind(ASetMultipleBind mb) throws AnalysisException { return af.createPPatternListAssistant().getPossibleType(mb.getPlist(), mb.getLocation()); }
@Override public PType caseASetPattern(ASetPattern pattern) throws AnalysisException { return AstFactory.newASetSetType(pattern.getLocation(), af.createPPatternListAssistant().getPossibleType(pattern.getPlist(), pattern.getLocation())); }
@Override public PType caseASeqPattern(ASeqPattern pattern) throws AnalysisException { return AstFactory.newASeqSeqType(pattern.getLocation(), af.createPPatternListAssistant().getPossibleType(pattern.getPlist(), pattern.getLocation())); }
@Override public PType caseATypeMultipleBind(ATypeMultipleBind node, TypeCheckInfo question) throws AnalysisException { question.assistantFactory.createPPatternListAssistant().typeResolve(node.getPlist(), THIS, question); PType type = question.assistantFactory.createPTypeAssistant().typeResolve(node.getType(), null, THIS, question); PType ptype = question.assistantFactory.createPPatternListAssistant().getPossibleType(node.getPlist(), node.getLocation()); if (!question.assistantFactory.getTypeComparator().compatible(ptype, type)) { TypeCheckerErrors.report(3265, "At least one bind cannot match this type", type.getLocation(), type); TypeCheckerErrors.detail2("Binds", ptype, "Type", type); } node.setType(type); return type; }
@Override public Boolean caseASetPattern(ASetPattern pattern) throws AnalysisException { if (af.createPTypeAssistant().isUnion(af.createPPatternListAssistant().getPossibleType(pattern.getPlist(), pattern.getLocation()))) { return true; // Set types are various, so we must permute } // Check that lengths of the members are the same int length = 0; for (PPattern p: pattern.getPlist()) { if (length == 0) { length = p.apply(af.getLengthFinder()); } else { if (p.apply(af.getLengthFinder()) != length) { return true; // Patterns are different sizes, so permute them } } } return isConstrained(pattern.getPlist()); }