Iterable methodOverrides()

in lib/src/builder.dart [933:958]


  Iterable<Method> methodOverrides(Iterable<MethodElement> methods) sync* {
    for (final method in methods) {
      if (method.isPrivate) {
        continue;
      }
      final methodName = method.name;
      if (methodName == 'noSuchMethod') {
        continue;
      }
      if (methodName == 'toString' && method.parameters.isEmpty) {
        // Do not needlessly override this method with a simple call to
        // `super.toString`, unless the class has added parameters.
        continue;
      }
      if (methodName == '==') {
        // Never override this operator; user code cannot add parameters or
        // narrow the return type.
        continue;
      }
      if (typeSystem._returnTypeIsNonNullable(method) ||
          typeSystem._hasNonNullableParameter(method) ||
          _needsOverrideForVoidStub(method)) {
        yield Method((mBuilder) => _buildOverridingMethod(mBuilder, method));
      }
    }
  }