src/com/google/javascript/jscomp/TypeCheck.java
/** Check that @abstract methods are not called */
Check that @abstract methods are not called
Check that @abstract methods are not called
private void checkAbstractMethodCall(NodeTraversal t, Node call) {
    if (NodeUtil.isFunctionObjectCall(call) || NodeUtil.isFunctionObjectApply(call)) {
      Node method = call.getFirstFirstChild();
      if (method.isGetProp()
          && (method.getFirstChild().isThis()
              || method.getFirstChild().matchesQualifiedName(Es6RewriteArrowFunction.THIS_VAR))) {
        return;
      }
      FunctionType methodType = method.getJSType().toMaybeFunctionType();
      if (methodType != null && methodType.isAbstract() && !methodType.isConstructor()) {
        report(t, call, ABSTRACT_SUPER_METHOD_NOT_CALLABLE, methodType.getDisplayName());
      }
    } else {
      Node maybeGetProp = call.getFirstChild();
      if (maybeGetProp.isGetProp() && maybeGetProp.isQualifiedName()) {
        Node rootOfQName = NodeUtil.getRootOfQualifiedName(maybeGetProp);
        if (rootOfQName.isName()) {
          Node maybePrototype = rootOfQName.getNext();
          if (maybePrototype.isString() && maybePrototype.getString().equals("prototype")) {
            FunctionType methodType = maybeGetProp.getJSType().toMaybeFunctionType();
            if (methodType != null && methodType.isAbstract() && !methodType.isConstructor()
                && rootOfQName.getJSType() != null && methodType.getTypeOfThis().equals(
                    rootOfQName.getJSType().toMaybeFunctionType().getInstanceType())) {
                report(t, call, ABSTRACT_SUPER_METHOD_NOT_CALLABLE, methodType.getDisplayName());
              }
          }
        }
      }
    }
  }
private void checkAbstractMethodCall ( NodeTraversal t , Node call ) { if ( NodeUtil . isFunctionObjectCall ( call ) || NodeUtil . isFunctionObjectApply ( call ) ) { Node method = call . getFirstFirstChild ( ) ; if ( method . isGetProp ( ) && ( method . getFirstChild ( ) . isThis ( ) || method . getFirstChild ( ) . matchesQualifiedName ( Es6RewriteArrowFunction . THIS_VAR ) ) ) { return ; } FunctionType methodType = method . getJSType ( ) . toMaybeFunctionType ( ) ; if ( methodType != null && methodType . isAbstract ( ) && ! methodType . isConstructor ( ) ) { report ( t , call , ABSTRACT_SUPER_METHOD_NOT_CALLABLE , methodType . getDisplayName ( ) ) ; } } else { Node maybeGetProp = call . getFirstChild ( ) ; if ( maybeGetProp . isGetProp ( ) && maybeGetProp . isQualifiedName ( ) ) { Node rootOfQName = NodeUtil . getRootOfQualifiedName ( maybeGetProp ) ; if ( rootOfQName . isName ( ) ) { Node maybePrototype = rootOfQName . getNext ( ) ; if ( maybePrototype . isString ( ) && maybePrototype . getString ( ) . equals ( "prototype" ) ) { FunctionType methodType = maybeGetProp . getJSType ( ) . toMaybeFunctionType ( ) ; if ( methodType != null && methodType . isAbstract ( ) && ! methodType . isConstructor ( ) && rootOfQName . getJSType ( ) != null && methodType . getTypeOfThis ( ) . equals ( rootOfQName . getJSType ( ) . toMaybeFunctionType ( ) . getInstanceType ( ) ) ) { report ( t , call , ABSTRACT_SUPER_METHOD_NOT_CALLABLE , methodType . getDisplayName ( ) ) ; } } } } } }
Check that @abstract methods are not called
Check that @abstract methods are not called
// this.foo.apply(this) should be allowed // Check for cases like Base.prototype.foo() where foo is abstract