use of org.eclipse.ceylon.model.typechecker.model.LazyType 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.LazyType 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.LazyType 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);
}
}
use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class RefinementVisitor method createRefiningParameter.
private void createRefiningParameter(final Reference rm, Function method, final Parameter p, ParameterList l, Tree.ParameterList tpl, int j, final Map<TypeParameter, Type> subs, Unit unit) {
if (tpl == null || tpl.getParameters().size() <= j) {
Parameter vp = new Parameter();
Value v = new Value();
vp.setModel(v);
v.setInitializerParameter(vp);
vp.setSequenced(p.isSequenced());
vp.setAtLeastOne(p.isAtLeastOne());
// vp.setDefaulted(p.isDefaulted());
vp.setName(p.getName());
v.setName(p.getName());
vp.setDeclaration(method);
v.setContainer(method);
v.setScope(method);
l.getParameters().add(vp);
v.setType(new LazyType(unit) {
private Type type() {
return rm.getTypedParameter(p).getFullType().substitute(subs, null);
}
@Override
public Type initQualifyingType() {
Type type = type();
return type == null ? null : type.getQualifyingType();
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
Type type = type();
return type == null ? null : type.getTypeArguments();
}
@Override
public TypeDeclaration initDeclaration() {
Type type = type();
return type == null ? null : type.getDeclaration();
}
@Override
public Map<TypeParameter, SiteVariance> getVarianceOverrides() {
Type type = type();
return type == null ? null : type.getVarianceOverrides();
}
});
} else {
Tree.Parameter tp = tpl.getParameters().get(j);
Parameter rp = tp.getParameterModel();
rp.setDefaulted(p.isDefaulted());
rp.setDeclaration(method);
l.getParameters().add(rp);
}
}
use of org.eclipse.ceylon.model.typechecker.model.LazyType in project ceylon by eclipse.
the class DeclarationVisitor method visit.
public void visit(final Tree.OptionalType that) {
super.visit(that);
final Tree.StaticType definiteType = that.getDefiniteType();
if (inExtends) {
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
List<Type> types = new ArrayList<Type>(2);
types.add(unit.getNullType());
if (definiteType != null) {
types.add(definiteType.getTypeModel());
}
UnionType ut = new UnionType(unit);
ut.setCaseTypes(types);
return ut;
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
return emptyMap();
}
};
that.setTypeModel(t);
}
}
Aggregations