Search in sources :

Example 1 with Entry

use of org.eclipse.ceylon.langtools.tools.javac.code.Scope.Entry in project ceylon by eclipse.

the class CeylonModelLoader method isOverloadingMethod.

/**
 * Returns true if the given method is overloading an inherited method (from super class or interfaces).
 */
private boolean isOverloadingMethod(final MethodSymbol method) {
    /*
         * Copied from getOverriddenMethod and adapted for overloading
         */
    try {
        // interfaces have a different way to work
        if (method.owner.isInterface())
            return overloaded(method, method.owner.type.tsym, types);
        // so we stop there for it, especially since it does not have any overloading
        if (method.owner.type.tsym.getQualifiedName().toString().equals("ceylon.language.Exception"))
            return false;
        for (Type superType = types.supertype(method.owner.type); superType.tsym != null; superType = types.supertype(superType)) {
            TypeSymbol i = superType.tsym;
            String fqn = i.getQualifiedName().toString();
            // never go above this type since it has no supertype in Ceylon (does in Java though)
            if (fqn.equals("ceylon.language.Anything"))
                break;
            try {
                for (Entry e = i.members().lookup(method.name); e.scope != null; e = e.next()) {
                    // ignore some methods
                    if (isIgnored(e.sym))
                        continue;
                    if (!method.overrides(e.sym, (TypeSymbol) method.owner, types, false)) {
                        return true;
                    }
                }
                // try in the interfaces
                if (overloaded(method, i, types))
                    return true;
            } catch (Symbol.CompletionFailure x) {
            // just ignore unresolved interfaces, error will be logged when we try to add it
            }
            // so we stop there for it, especially since it does not have any overloading
            if (fqn.equals("ceylon.language.Exception"))
                break;
        }
        // try in the interfaces
        if (overloaded(method, method.owner.type.tsym, types))
            return true;
        return false;
    } catch (CompletionFailure x) {
        handleCompletionFailure(method, x);
        return false;
    }
}
Also used : MethodType(org.eclipse.ceylon.langtools.tools.javac.code.Type.MethodType) Type(org.eclipse.ceylon.langtools.tools.javac.code.Type) UnknownType(org.eclipse.ceylon.model.typechecker.model.UnknownType) ArrayType(org.eclipse.ceylon.langtools.tools.javac.code.Type.ArrayType) JavacType(org.eclipse.ceylon.compiler.java.loader.mirror.JavacType) FunctionalInterfaceType(org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType) Entry(org.eclipse.ceylon.langtools.tools.javac.code.Scope.Entry) CompletionFailure(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.CompletionFailure) MethodSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol) ClassSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.ClassSymbol) Symbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol) PackageSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.PackageSymbol) CompletionFailure(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.CompletionFailure) TypeSymbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol)

Aggregations

JavacType (org.eclipse.ceylon.compiler.java.loader.mirror.JavacType)1 Entry (org.eclipse.ceylon.langtools.tools.javac.code.Scope.Entry)1 Symbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol)1 ClassSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.ClassSymbol)1 CompletionFailure (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.CompletionFailure)1 MethodSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.MethodSymbol)1 PackageSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.PackageSymbol)1 TypeSymbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol.TypeSymbol)1 Type (org.eclipse.ceylon.langtools.tools.javac.code.Type)1 ArrayType (org.eclipse.ceylon.langtools.tools.javac.code.Type.ArrayType)1 MethodType (org.eclipse.ceylon.langtools.tools.javac.code.Type.MethodType)1 FunctionalInterfaceType (org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType)1 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)1