Пример #1
0
  protected Node typeCheckNullTarget(
      TypeChecker tc, List<Type> paramTypes, List<Type> explicitTypeArgs) throws SemanticException {
    JL5TypeSystem ts = (JL5TypeSystem) tc.typeSystem();
    JL5NodeFactory nf = (JL5NodeFactory) tc.nodeFactory();
    JL5Context c = (JL5Context) tc.context();

    // the target is null, and thus implicit
    // let's find the target, using the context, and
    // set the target appropriately, and then type check
    // the result
    JL5MethodInstance mi = c.findJL5Method(this.name(), paramTypes, explicitTypeArgs);

    Receiver r;
    if (mi.flags().isStatic()) {
      r = nf.CanonicalTypeNode(position(), mi.container()).type(mi.container());
    } else {
      // The method is non-static, so we must prepend with "this", but we
      // need to determine if the "this" should be qualified. Get the
      // enclosing class which brought the method into scope. This is
      // different from mi.container(). mi.container() returns a super
      // type
      // of the class we want.
      ClassType scope = c.findMethodScope(name);

      if (!ts.equals(scope, c.currentClass())) {
        r = nf.This(position(), nf.CanonicalTypeNode(position(), scope)).type(scope);
      } else {
        r = nf.This(position()).type(scope);
      }
    }

    // we call typeCheck on the reciever too.
    r = (Receiver) r.del().typeCheck(tc);
    return this.targetImplicit(true).target(r).del().typeCheck(tc);
  }