Exemplo n.º 1
0
 @Override
 public VerificationResult verifySelf() {
   VerificationResult result =
       checkNull(signature(), "The variable declaration has no signature", Valid.create());
   Expression initialization = initialization();
   if (initialization != null) {
     Type initType = null;
     try {
       initType = initialization.getType();
     } catch (LookupException e) {
       result =
           result.and(
               new BasicProblem(
                   this, "Cannot calculate the type of the initialization expression"));
     }
     Type variableType = null;
     try {
       variableType = variable().getType();
     } catch (LookupException e) {
       result =
           result.and(
               new BasicProblem(this, "Cannot calculate the type of the declared variable."));
     }
     if (initType != null && variableType != null) {
       try {
         if (!initType.subTypeOf(variableType)) {
           result =
               result.and(
                   new BasicProblem(
                       this,
                       "The type of the initializer ("
                           + initType.getFullyQualifiedName()
                           + ") is not a subtype of the type of the declared variable ("
                           + variableType.getFullyQualifiedName()
                           + ")."));
           initialization.getType().subTypeOf(variable().getType());
         }
       } catch (LookupException e) {
         result =
             result.and(
                 new BasicProblem(
                     this,
                     "Cannot determine the relation between the type of the initializer and the type of the declared variable."));
       }
     }
   }
   return result;
 }
Exemplo n.º 2
0
 @Override
 public VerificationResult verifySelf() {
   return Valid.create();
 }