The super method must include the return type, otherwise its ambiguous
for methods with covariant return types.
14857
private static String superMethodName(Method method) {
        String returnType = method.getReturnType().getName();
        return "super$" + method.getName() + "$"
                + returnType.replace('.', '_').replace('[', '_').replace(';', '_');
    }
551910
private static Method resolveAmbiguousMethod(Set<Method> candidates,
            Class<?>[] paramTypes) {
        // Identify which parameter isn't an exact match
        Method m = candidates.iterator().next();

        int nonMatchIndex = 0;
        Class<?> nonMatchClass = null;

        for (int i = 0; i < paramTypes.length; i++) {
            if (m.getParameterTypes()[i] != paramTypes[i]) {
                nonMatchIndex = i;
                nonMatchClass = paramTypes[i];
                break;
            }
        }

        if (nonMatchClass == null) {
            // Null will always be ambiguous
            return null;
        }

        for (Method c : candidates) {
           if (c.getParameterTypes()[nonMatchIndex] ==
                   paramTypes[nonMatchIndex]) {
               // Methods have different non-matching parameters
               // Result is ambiguous
               return null;
           }
        }

        // Can't be null
        Class<?> superClass = nonMatchClass.getSuperclass();
        while (superClass != null) {
            for (Method c : candidates) {
                if (c.getParameterTypes()[nonMatchIndex].equals(superClass)) {
                    // Found a match
                    return c;
                }
            }
            superClass = superClass.getSuperclass();
        }

        // Treat instances of Number as a special case
        Method match = null;
        if (Number.class.isAssignableFrom(nonMatchClass)) {
            for (Method c : candidates) {
                Class<?> candidateType = c.getParameterTypes()[nonMatchIndex];
                if (Number.class.isAssignableFrom(candidateType) ||
                        candidateType.isPrimitive()) {
                    if (match == null) {
                        match = c;
                    } else {
                        // Match still ambiguous
                        match = null;
                        break;
                    }
                }
            }
        }

        return match;
    }
1103010
private static boolean methodReturnsValue(CtBehavior method) throws NotFoundException {

        if (method instanceof CtMethod == false) {
            return false;
        }

        CtClass returnType = ((CtMethod) method).getReturnType();
        String returnTypeName = returnType.getName();

        boolean isVoidMethod = "void".equals(returnTypeName);

        boolean methodReturnsValue = isVoidMethod == false;
        return methodReturnsValue;
    }
696069
public static <T> SuperclassIterable<T> ofIncludeSelf(Class<T> type) {
        return new SuperclassIterable<>(type, true);
    }
854627
@Override
	public JvmType getType() {
		if (this.type == null) {
//			// make sure scoping has taken place and installed an IJvmTypeProvider
//			if (returnType != null)
//				returnType.getType();
			JvmType newType = TypesFactory.eINSTANCE.createJvmVoid();
			((InternalEObject)newType).eSetProxyURI(computeTypeUri(isProcedure()));
			type = (JvmType) eResolveProxy((InternalEObject) newType);
		}
		return super.getType();
	}
517324
@Override
  public Description matchReturn(ReturnTree tree, VisitorState state) {
    if (!matchWithinClass) {
      return Description.NO_MATCH;
    }
    handler.onMatchReturn(this, tree, state);
    ExpressionTree retExpr = tree.getExpression();
    // let's do quick checks on returned expression first
    if (retExpr == null) {
      return Description.NO_MATCH;
    }
    // now let's check the enclosing method
    TreePath enclosingMethodOrLambda =
        NullabilityUtil.findEnclosingMethodOrLambdaOrInitializer(state.getPath());
    if (enclosingMethodOrLambda == null) {
      throw new RuntimeException("no enclosing method, lambda or initializer!");
    }
    if (!(enclosingMethodOrLambda.getLeaf() instanceof MethodTree
        || enclosingMethodOrLambda.getLeaf() instanceof LambdaExpressionTree)) {
      throw new RuntimeException(
          "return statement outside of a method or lambda! (e.g. in an initializer block)");
    }
    Tree leaf = enclosingMethodOrLambda.getLeaf();
    Symbol.MethodSymbol methodSymbol;
    if (leaf instanceof MethodTree) {
      MethodTree enclosingMethod = (MethodTree) leaf;
      methodSymbol = ASTHelpers.getSymbol(enclosingMethod);
    } else {
      // we have a lambda
      methodSymbol =
          NullabilityUtil.getFunctionalInterfaceMethod(
              (LambdaExpressionTree) leaf, state.getTypes());
    }
    return checkReturnExpression(tree, retExpr, methodSymbol, state);
  }
812084
function findMethodWithValidDescription(type, methodName, condition) {
    type = findTypeMetaInfo(type);
    if (!type) {
        return;
    }
    var methods = type.methodsClass || type.methods || [];
    var method = methods.find(m => m.name === methodName && condition(m));
    if (method) {
        return method;
    }

    var parents = (type.implements || []).concat();
    if (type.extends) {
        parents.push(type.extends);
    }
    for (var i = 0; i < parents.length; i++) {
        method = findMethodWithValidDescription(parents[i], methodName, condition);
        if (method) {
            return method;
        }
    }
}
1126492
FunctionType buildAndRegister() {
    if (returnType == null) {
      provideDefaultReturnType();
      checkNotNull(returnType);
    }

    if (parametersNode == null) {
      throw new IllegalStateException(
          "All Function types must have params and a return type");
    }

    FunctionType fnType;
    if (isConstructor) {
      fnType = getOrCreateConstructor();
    } else if (isInterface) {
      fnType = getOrCreateInterface();
    } else {
      fnType =
          FunctionType.builder(typeRegistry)
              .withName(fnName)
              .withSourceNode(contents.getSourceNode())
              .withParamsNode(parametersNode)
              .withReturnType(returnType, returnTypeInferred)
              .withTypeOfThis(thisType)
              .withTemplateKeys(templateTypeNames)
              .withIsAbstract(isAbstract)
              .withClosurePrimitiveId(closurePrimitiveId)
              .build();
      maybeSetBaseType(fnType);
    }

    if (implementedInterfaces != null && fnType.isConstructor()) {
      fnType.setImplementedInterfaces(implementedInterfaces);
    }

    if (extendedInterfaces != null) {
      fnType.setExtendedInterfaces(extendedInterfaces);
    }

    if (isRecord) {
      fnType.setImplicitMatch(true);
    }

    return fnType;
  }
211358
@Override  // for covariant return type
    @SuppressWarnings("unchecked")
    public ChronoLocalDateTime<EthiopicDate> atTime(LocalTime localTime) {
        return (ChronoLocalDateTime<EthiopicDate>) super.atTime(localTime);
    }
270304
private Pair<Type, Identifier> parseMixedType(EnclosingScope scope) {
		Token lookahead;
		int start = index;

		if ((lookahead = tryAndMatch(true, Function, Method)) != null) {
			// At this point, we *might* have a mixed function / method type
			// definition. To disambiguate, we need to see whether an identifier
			// follows or not.
			// Similar to normal method declarations, the lifetime parameters
			// go before the method name. We do not allow to have captured
			// lifetimes for mixed method types.
			Tuple<Identifier> lifetimes = new Tuple<>();
			if (lookahead.kind == Method && tryAndMatch(true, LeftAngle) != null) {
				// mixed method type with lifetime parameters
				scope = scope.newEnclosingScope();
				lifetimes = parseLifetimeParameters(scope);
			}
			// Now try to parse the identifier
			Identifier id = parseOptionalIdentifier(scope);

			if (id != null) {
				// Yes, we have found a mixed function / method type definition.
				// Therefore, we continue to pass the remaining type parameters.
				Tuple<Type> paramTypes = parseParameterTypes(scope);
				Tuple<Type> returnTypes = new Tuple<>();

				if (lookahead.kind == Function) {
					// Functions require a return type (since otherwise they are
					// just nops)
					match(MinusGreater);
					// Third, parse the return type
					returnTypes = parseOptionalParameterTypes(scope);
				} else if (tryAndMatch(true, MinusGreater) != null) {
					// Third, parse the (optional) return type. Observe that
					// this is forced to be a
					// unit type. This means that any tuple return types must be
					// in braces. The reason for this is that a trailing comma
					// may be part of an enclosing record type and we must
					// disambiguate
					// this.
					returnTypes = parseOptionalParameterTypes(scope);
				}

				// Done
				Type type;
				if (lookahead.kind == Token.Kind.Function) {
					type = new Type.Function(paramTypes, returnTypes);
				} else {
					type = new Type.Method(paramTypes, returnTypes, new Tuple<>(),
							lifetimes);
				}
				return new Pair<>(annotateSourceLocation(type,start), id);
			} else {
				// In this case, we failed to match a mixed type. Therefore, we
				// backtrack and parse as two separate items (i.e. type
				// identifier).
				index = start; // backtrack
			}
		}

		// This is the normal case, where we expect an identifier to follow the
		// type.
		Type type = parseType(scope);
		Identifier id = parseIdentifier();
		return new Pair<>(type, id);
	}
1152568
@Override
    public ClassNode visitTypeDeclaration(TypeDeclarationContext ctx) {
        if (asBoolean(ctx.classDeclaration())) { // e.g. class A {}
            ctx.classDeclaration().putNodeMetaData(TYPE_DECLARATION_MODIFIERS, this.visitClassOrInterfaceModifiersOpt(ctx.classOrInterfaceModifiersOpt()));
            return configureAST(this.visitClassDeclaration(ctx.classDeclaration()), ctx);
        }

        throw createParsingFailedException("Unsupported type declaration: " + ctx.getText(), ctx);
    }
681742
@Override
    protected TypeQualifierAnnotation combine(TypeQualifierAnnotation a, TypeQualifierAnnotation b) {
        return TypeQualifierAnnotation.combineParameterAnnotations(a, b);
    }
733873
function(name, func, superPrototype) {
		return function PseudoClass_setStaticSuper() {
			// Store the old super
			var previousSuper = this._super;

			// Use the method from the superclass' prototype
			// This strategy allows monkey patching (modification of superclass prototypes)
			this._super = superPrototype[name];

			// Call the actual function
			var ret = func.apply(this, arguments);

			// Restore the previous value of super
			// This is required so that calls to methods that use _super within methods that use _super work
			this._super = previousSuper;

			return ret;
		};
	}
781439
private void appendClassAnnotations(StringBuilder sb, FunctionType funType) {
    FunctionType superConstructor = funType.getInstanceType().getSuperClassConstructor();
    if (superConstructor != null) {
      ObjectType superInstance = superConstructor.getInstanceType();
      if (!superInstance.toString().equals("Object")) {
        sb.append(" * ");
        appendAnnotation(sb, "extends", superInstance.toAnnotationString(Nullability.IMPLICIT));
        sb.append("\n");
      }
    }
    // Avoid duplicates, add implemented type to a set first
    Set<String> interfaces = new TreeSet<>();
    for (ObjectType interfaze : funType.getAncestorInterfaces()) {
      interfaces.add(interfaze.toAnnotationString(Nullability.IMPLICIT));
    }
    for (String interfaze : interfaces) {
      sb.append(" * ");
      appendAnnotation(sb, "implements", interfaze);
      sb.append("\n");
    }
  }
1186772
function _gpfClassSuperCreateWithSameSignature (superMethod) {
    var definition = _gpfFunctionDescribe(superMethod);
    definition.body = "return _superMethod_.apply(this, arguments);";
    return _gpfFunctionBuild(definition, {
        _superMethod_: superMethod
    });
}
105771
@Override  // override with covariant return type
    public JapaneseDate date(TemporalAccessor temporal) {
        if (temporal instanceof JapaneseDate) {
            return (JapaneseDate) temporal;
        }
        return new JapaneseDate(LocalDate.from(temporal));
    }
537086
final void checkReturnType(TypeElement autoValueClass, ExecutableElement getter) {
    TypeMirror type = getter.getReturnType();
    if (type.getKind() == TypeKind.ARRAY) {
      TypeMirror componentType = ((ArrayType) type).getComponentType();
      if (componentType.getKind().isPrimitive()) {
        warnAboutPrimitiveArrays(autoValueClass, getter);
      } else {
        errorReporter.reportError(
            "An @"
                + simpleAnnotationName
                + " class cannot define an array-valued property unless it is a primitive array",
            getter);
      }
    }
  }