Java Code Examples for com.sun.tools.javac.code.Symbol#isInheritedIn()
The following examples show how to use
com.sun.tools.javac.code.Symbol#isInheritedIn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavacElements.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
@DefinedBy(Api.LANGUAGE_MODEL) public boolean hides(Element hiderEl, Element hideeEl) { Symbol hider = cast(Symbol.class, hiderEl); Symbol hidee = cast(Symbol.class, hideeEl); // Fields only hide fields; methods only methods; types only types. // Names must match. Nothing hides itself (just try it). if (hider == hidee || hider.kind != hidee.kind || hider.name != hidee.name) { return false; } // Only static methods can hide other methods. // Methods only hide methods with matching signatures. if (hider.kind == MTH) { if (!hider.isStatic() || !types.isSubSignature(hider.type, hidee.type)) { return false; } } // Hider must be in a subclass of hidee's class. // Note that if M1 hides M2, and M2 hides M3, and M3 is accessible // in M1's class, then M1 and M2 both hide M3. ClassSymbol hiderClass = hider.owner.enclClass(); ClassSymbol hideeClass = hidee.owner.enclClass(); if (hiderClass == null || hideeClass == null || !hiderClass.isSubClass(hideeClass, types)) { return false; } // Hidee must be accessible in hider's class. // The method isInheritedIn is poorly named: it checks only access. return hidee.isInheritedIn(hiderClass, types); }
Example 2
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
public boolean accepts(Symbol s) { return s.kind == MTH && (s.flags() & SYNTHETIC) == 0 && !shouldSkip(s) && s.isInheritedIn(site.tsym, types) && !s.isConstructor(); }
Example 3
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Check that a class does not inherit two concrete methods * with the same signature. * @param pos Position to be used for error reporting. * @param site The class type to be checked. */ public void checkCompatibleConcretes(DiagnosticPosition pos, Type site) { Type sup = types.supertype(site); if (!sup.hasTag(CLASS)) return; for (Type t1 = sup; t1.hasTag(CLASS) && t1.tsym.type.isParameterized(); t1 = types.supertype(t1)) { for (Symbol s1 : t1.tsym.members().getSymbols(NON_RECURSIVE)) { if (s1.kind != MTH || (s1.flags() & (STATIC|SYNTHETIC|BRIDGE)) != 0 || !s1.isInheritedIn(site.tsym, types) || ((MethodSymbol)s1).implementation(site.tsym, types, true) != s1) continue; Type st1 = types.memberType(t1, s1); int s1ArgsLength = st1.getParameterTypes().length(); if (st1 == s1.type) continue; for (Type t2 = sup; t2.hasTag(CLASS); t2 = types.supertype(t2)) { for (Symbol s2 : t2.tsym.members().getSymbolsByName(s1.name)) { if (s2 == s1 || s2.kind != MTH || (s2.flags() & (STATIC|SYNTHETIC|BRIDGE)) != 0 || s2.type.getParameterTypes().length() != s1ArgsLength || !s2.isInheritedIn(site.tsym, types) || ((MethodSymbol)s2).implementation(site.tsym, types, true) != s2) continue; Type st2 = types.memberType(t2, s2); if (types.overrideEquivalent(st1, st2)) log.error(pos, Errors.ConcreteInheritanceConflict(s1, t1, s2, t2, sup)); } } } } }
Example 4
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** Return the first method in t2 that conflicts with a method from t1. */ private Symbol firstDirectIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) { for (Symbol s1 : t1.tsym.members().getSymbols(NON_RECURSIVE)) { Type st1 = null; if (s1.kind != MTH || !s1.isInheritedIn(site.tsym, types) || (s1.flags() & SYNTHETIC) != 0) continue; Symbol impl = ((MethodSymbol)s1).implementation(site.tsym, types, false); if (impl != null && (impl.flags() & ABSTRACT) == 0) continue; for (Symbol s2 : t2.tsym.members().getSymbolsByName(s1.name)) { if (s1 == s2) continue; if (s2.kind != MTH || !s2.isInheritedIn(site.tsym, types) || (s2.flags() & SYNTHETIC) != 0) continue; if (st1 == null) st1 = types.memberType(t1, s1); Type st2 = types.memberType(t2, s2); if (types.overrideEquivalent(st1, st2)) { List<Type> tvars1 = st1.getTypeArguments(); List<Type> tvars2 = st2.getTypeArguments(); Type rt1 = st1.getReturnType(); Type rt2 = types.subst(st2.getReturnType(), tvars2, tvars1); boolean compat = types.isSameType(rt1, rt2) || !rt1.isPrimitiveOrVoid() && !rt2.isPrimitiveOrVoid() && (types.covariantReturnType(rt1, rt2, types.noWarnings) || types.covariantReturnType(rt2, rt1, types.noWarnings)) || checkCommonOverriderIn(s1,s2,site); if (!compat) { log.error(pos, Errors.TypesIncompatibleDiffRet(t1, t2, s2.name + "(" + types.memberType(t2, s2).getParameterTypes() + ")")); return s2; } } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) && !checkCommonOverriderIn(s1, s2, site)) { log.error(pos, Errors.NameClashSameErasureNoOverride( s1.name, types.memberType(site, s1).asMethodType().getParameterTypes(), s1.location(), s2.name, types.memberType(site, s2).asMethodType().getParameterTypes(), s2.location())); return s2; } } } return null; }
Example 5
Source File: Check.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 4 votes |
public boolean accepts(Symbol s) { return s.kind == MTH && (s.flags() & DEFAULT) != 0 && s.isInheritedIn(site.tsym, types) && !s.isConstructor(); }