use of org.eclipse.ceylon.langtools.tools.javac.code.Type in project ceylon by eclipse.
the class Types method firstUnimplementedAbstractImpl.
// where:
private MethodSymbol firstUnimplementedAbstractImpl(ClassSymbol impl, ClassSymbol c) {
MethodSymbol undef = null;
// since they cannot have abstract members.
if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) {
Scope s = c.members();
for (Scope.Entry e = s.elems; undef == null && e != null; e = e.sibling) {
if (e.sym.kind == MTH && (e.sym.flags() & (ABSTRACT | IPROXY | DEFAULT)) == ABSTRACT) {
MethodSymbol absmeth = (MethodSymbol) e.sym;
MethodSymbol implmeth = absmeth.implementation(impl, this, true);
if (implmeth == null || implmeth == absmeth) {
// look for default implementations
if (allowDefaultMethods) {
MethodSymbol prov = interfaceCandidates(impl.type, absmeth).head;
if (prov != null && prov.overrides(absmeth, impl, this, true)) {
implmeth = prov;
}
}
}
if (implmeth == null || implmeth == absmeth) {
undef = absmeth;
} else if (sourceLanguage.isCeylon())
implmeth.flags_field |= CEYLON_METHOD_OVERRIDE_CHECKED;
}
}
if (undef == null) {
Type st = supertype(c.type);
if (st.hasTag(CLASS))
undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol) st.tsym);
}
for (List<Type> l = interfaces(c.type); undef == null && l.nonEmpty(); l = l.tail) {
undef = firstUnimplementedAbstractImpl(impl, (ClassSymbol) l.head.tsym);
}
}
return undef;
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Type in project ceylon by eclipse.
the class Types method typaramsString.
// where
private String typaramsString(List<Type> tvars) {
StringBuilder s = new StringBuilder();
s.append('<');
boolean first = true;
for (Type t : tvars) {
if (!first)
s.append(", ");
first = false;
appendTyparamString(((TypeVar) t.unannotatedType()), s);
}
s.append('>');
return s.toString();
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Type in project ceylon by eclipse.
the class Types method substBound.
public TypeVar substBound(TypeVar t, List<Type> from, List<Type> to) {
Type bound1 = subst(t.bound, from, to);
if (bound1 == t.bound)
return t;
else {
// create new type variable without bounds
TypeVar tv = new TypeVar(t.tsym, null, syms.botType);
// the new bound should use the new type variable in place
// of the old
tv.bound = subst(bound1, List.<Type>of(t), List.<Type>of(tv));
// Fix for Ceylon: try really hard not to make recursive bounds
if (tv.bound == tv)
tv.bound = t;
return tv;
}
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Type in project ceylon by eclipse.
the class Types method removeWildcards.
public Type removeWildcards(Type site) {
Type capturedSite = capture(site);
if (capturedSite != site) {
Type formalInterface = site.tsym.type;
ListBuffer<Type> typeargs = new ListBuffer<>();
List<Type> actualTypeargs = site.getTypeArguments();
List<Type> capturedTypeargs = capturedSite.getTypeArguments();
// simply replace the wildcards with its bound
for (Type t : formalInterface.getTypeArguments()) {
if (actualTypeargs.head.hasTag(WILDCARD)) {
WildcardType wt = (WildcardType) actualTypeargs.head.unannotatedType();
Type bound;
switch(wt.kind) {
case EXTENDS:
case UNBOUND:
CapturedType capVar = (CapturedType) capturedTypeargs.head.unannotatedType();
// use declared bound if it doesn't depend on formal type-args
bound = capVar.bound.containsAny(capturedSite.getTypeArguments()) ? wt.type : capVar.bound;
break;
default:
bound = wt.type;
}
typeargs.append(bound);
} else {
typeargs.append(actualTypeargs.head);
}
actualTypeargs = actualTypeargs.tail;
capturedTypeargs = capturedTypeargs.tail;
}
return subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
} else {
return site;
}
}
use of org.eclipse.ceylon.langtools.tools.javac.code.Type in project ceylon by eclipse.
the class Types method asOuterSuper.
/**
* Return the base type of t or any of its outer types that starts
* with the given symbol. If none exists, return null.
*
* @param t a type
* @param sym a symbol
*/
public Type asOuterSuper(Type t, Symbol sym) {
switch(t.getTag()) {
case CLASS:
do {
Type s = asSuper(t, sym);
if (s != null)
return s;
t = t.getEnclosingType();
} while (t.hasTag(CLASS));
return null;
case ARRAY:
return isSubtype(t, sym.type) ? sym.type : null;
case TYPEVAR:
return asSuper(t, sym);
case ERROR:
return t;
default:
return null;
}
}
Aggregations