/** * Test whether one type is a subtype of another. * * @param sub * @param sup * @return True if sub is a subtype of sup. */ public synchronized boolean isSubType(PType sub, PType sup) { return isSubType(sub, sup, false); }
public synchronized PType narrowest(PType t1, PType t2) { return isSubType(t1, t2) ? t1 : t2; } }
public boolean alwaysMatches(PPattern pattern, PType type) { return af.getTypeComparator().isSubType(getPossibleType(pattern), type) && alwaysMatches(pattern); } }
public PType checkConstraint(PType constraint, PType actual, ILexLocation location) { if (constraint != null) { if (!af.getTypeComparator().isSubType(actual, constraint, true)) { TypeChecker.report(3327, "Value is not of the right type", location); TypeChecker.detail2("Actual", actual, "Expected", constraint); } } return actual; }
public IProofObligationList caseAInstanceVariableDefinition( AInstanceVariableDefinition node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); PExp expression = node.getExpression(); PType type = node.getType(); PType expType = node.getExpType(); obligations.addAll(expression.apply(rootVisitor, question)); if (!assistantFactory.getTypeComparator().isSubType(question.checkType(expression, expType), type)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(expression, type, expType, question, assistantFactory); if (sto != null) { obligations.add(sto); } } return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
if (!question.ctxt.assistantFactory.getTypeComparator().isSubType(objval.getType(), pattern.getType()))
@Override public IProofObligationList caseAAssignmentDefinition( AAssignmentDefinition node, IPOContextStack question) throws AnalysisException { try { IProofObligationList obligations = new ProofObligationList(); PExp expression = node.getExpression(); PType type = node.getType(); PType expType = node.getExpType(); obligations.addAll(expression.apply(rootVisitor, question)); if (!assistantFactory.getTypeComparator().isSubType(question.checkType(expression, expType), type)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(expression, type, expType, question, assistantFactory); if (sto != null) { obligations.add(sto); } } return obligations; } catch (Exception e) { throw new POException(node, e.getMessage()); } }
PExp aExp = args.poll(); if (!aF.getTypeComparator().isSubType(question.checkType(aExp, aType), f.getType()))
@Override // RWL See [1] pg. 56 public IProofObligationList caseAMuExp(AMuExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = node.getRecord().apply(rootVisitor, question); Queue<ARecordModifier> modifiers = node.getModifiers(); ARecordInvariantType recordType = node.getRecordType(); LinkedList<PType> mTypes = node.getModTypes(); int i = 0; for (ARecordModifier mod : modifiers) { obligations.addAll(mod.getValue().apply(mainVisitor, question)); AFieldField f = findField(recordType, mod.getTag()); PType mType = mTypes.get(i++); if (f != null) { if (!aF.getTypeComparator().isSubType(mType, f.getType())) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(mod.getValue(), f.getType(), mType, question, aF); if (sto != null) { obligations.add(sto); } } } } return obligations; }
AClassType exptype = typeAssistant.getClassType(question.ptype, null); if (exptype == null || !af.getTypeComparator().isSubType(pattype, exptype))
@Override public IProofObligationList caseANarrowExp(ANarrowExp node, IPOContextStack question) throws AnalysisException { IProofObligationList obligations = new ProofObligationList(); PType expected = node.getTypedef() == null ? node.getBasicType() : aF.createPDefinitionAssistant().getType(node.getTypedef()); question.noteType(node.getTest(), expected); if (!aF.getTypeComparator().isSubType(node.getTest().getType(), expected)) { TypeCompatibilityObligation sto = TypeCompatibilityObligation.newInstance(node.getTest(), expected, node.getTest().getType(), question, aF); if (sto != null) { obligations.add(sto); } } obligations.addAll(node.getTest().apply(rootVisitor, question)); return obligations; }
obligations.addAll(node.getExp().apply(rootVisitor, question)); if (!aF.getTypeComparator().isSubType(question.checkType(node.getExp(), node.getExpType()), node.getTargetType()))
else if (ctxt.assistantFactory.getTypeComparator().isSubType(type, restrictedType))
|| !assistantFactory.getTypeComparator().isSubType(node.getActualResult(), ((AFunctionType) node.getType()).getResult()))
&& !assistantFactory.getTypeComparator().isSubType(node.getActualResult(), ((AOperationType) node.getType()).getResult()))
&& !assistantFactory.getTypeComparator().isSubType(node.getActualResult(), ((AOperationType) node.getType()).getResult()))