Пример #1
0
 @Override
 public Verification verifySelf() {
   Verification result = Valid.create();
   try {
     Expression var = variableExpression();
     if (var == null) {
       result =
           result.and(
               new BasicProblem(this, "The assignment has no variable at the left-hand side"));
     }
     Expression value = getValue();
     if (value == null) {
       result =
           result.and(
               new BasicProblem(
                   this, "The assignment has no valid expression at the right-hand side"));
     }
     Type varType = var.getType();
     Type exprType = value.getType();
     if (!exprType.subtypeOf(varType)) {
       result = result.and(new InvalidType(this, varType, exprType));
     }
   } catch (LookupException e) {
     result =
         result.and(
             new BasicProblem(
                 this,
                 "The type of the expression is not assignable to the type of the variable."));
   }
   return result;
 }
Пример #2
0
 public InvalidType(Element element, Type varType, Type exprType) {
   super(
       element,
       "The type of the left-hand side ("
           + exprType.getFullyQualifiedName()
           + ") is not assignable to a variable of type "
           + varType.getFullyQualifiedName());
 }