use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.IterableType that) {
super.visit(that);
if (inExtends) {
final Tree.Type elem = that.getElementType();
Type t = new LazyType(unit) {
Type iterableType() {
final Type elementType;
final boolean atLeastOne;
if (elem == null) {
elementType = unit.getNothingType();
atLeastOne = false;
} else if (elem instanceof Tree.SequencedType) {
Tree.SequencedType set = (Tree.SequencedType) elem;
elementType = set.getType().getTypeModel();
atLeastOne = set.getAtLeastOne();
} else {
elementType = null;
atLeastOne = false;
}
if (elementType != null) {
return atLeastOne ? unit.getNonemptyIterableType(elementType) : unit.getIterableType(elementType);
} else {
Type ut = new UnknownType(unit).getType();
return unit.getIterableType(ut);
}
}
@Override
public boolean isUnknown() {
return false;
}
@Override
public TypeDeclaration initDeclaration() {
return iterableType().getDeclaration();
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
return iterableType().getTypeArguments();
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(final Tree.UnionType that) {
super.visit(that);
final List<Tree.StaticType> sts = that.getStaticTypes();
if (inExtends) {
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
List<Type> types = new ArrayList<Type>(sts.size());
for (Tree.StaticType st : sts) {
Type t = st.getTypeModel();
if (t != null) {
types.add(t);
}
}
UnionType ut = new UnionType(unit);
ut.setCaseTypes(types);
return ut;
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
return emptyMap();
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.FunctionType that) {
super.visit(that);
if (inExtends) {
final Tree.StaticType rt = that.getReturnType();
if (rt != null) {
final List<Tree.Type> args = that.getArgumentTypes();
Type t = new LazyType(unit) {
@Override
public boolean isUnknown() {
return false;
}
@Override
public TypeDeclaration initDeclaration() {
return unit.getCallableDeclaration();
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
HashMap<TypeParameter, Type> map = new HashMap<TypeParameter, Type>();
List<TypeParameter> ctps = unit.getCallableDeclaration().getTypeParameters();
map.put(ctps.get(0), rt.getTypeModel());
map.put(ctps.get(1), getTupleType(args, unit));
return map;
}
};
that.setTypeModel(t);
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.SuperType that) {
super.visit(that);
if (inExtends) {
final Scope scope = that.getScope();
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
ClassOrInterface ci = getContainingClassOrInterface(scope);
if (ci == null) {
return null;
} else {
if (ci.isClassOrInterfaceMember()) {
ClassOrInterface oci = (ClassOrInterface) ci.getContainer();
return intersectionOfSupertypes(oci).getDeclaration();
} else {
return null;
}
}
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
return emptyMap();
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(Tree.SequencedType that) {
super.visit(that);
if (inExtends) {
final Type type = that.getType().getTypeModel();
final boolean atLeastOne = that.getAtLeastOne();
Type t = new LazyType(unit) {
@Override
public boolean isUnknown() {
return false;
}
@Override
public TypeDeclaration initDeclaration() {
return atLeastOne ? unit.getSequenceDeclaration() : unit.getSequentialDeclaration();
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
Interface dec = atLeastOne ? unit.getSequenceDeclaration() : unit.getSequentialDeclaration();
List<TypeParameter> stps = dec.getTypeParameters();
return singletonMap(stps.get(0), type);
}
};
that.setTypeModel(t);
}
}
Aggregations