use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class ExpressionVisitor method visit.
@Override
public void visit(Tree.QualifiedType that) {
super.visit(that);
TypeDeclaration type = that.getDeclarationModel();
if (type != null) {
type = (TypeDeclaration) handleNativeHeader(type, that, true);
if (!type.isVisible(that.getScope())) {
if (type instanceof Constructor) {
that.addError("constructor is not visible: " + qualifiedDescription(that), 400);
} else {
that.addError("member type is not visible: " + qualifiedDescription(that), 400);
}
} else if (type.isPackageVisibility() && !declaredInPackage(type, unit)) {
that.addError("member type is not visible: " + qualifiedDescription(that) + " is package private");
} else // in fact this restriction is OK
if (type.isProtectedVisibility() && !declaredInPackage(type, unit)) {
that.addError("member type is not visible: " + qualifiedDescription(that) + " is protected");
}
// Note: we should remove this check if we ever
// make qualified member types like T.Member
// into a sort of virtual type
Tree.StaticType outerType = that.getOuterType();
if (outerType instanceof Tree.SimpleType) {
Tree.SimpleType st = (Tree.SimpleType) outerType;
TypeDeclaration std = st.getDeclarationModel();
if (std.isAlias()) {
Type et = std.getExtendedType();
if (et != null) {
std = et.resolveAliases().getDeclaration();
}
}
if (std instanceof TypeParameter) {
outerType.addError("type parameter should not occur as qualifying type: '" + std.getName(unit) + "' is a type parameter");
}
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class ExpressionVisitor method getInvokedProducedReference.
private Reference getInvokedProducedReference(Declaration dec, Tree.MemberOrTypeExpression mte) {
Tree.TypeArguments tas;
if (mte instanceof Tree.StaticMemberOrTypeExpression) {
Tree.StaticMemberOrTypeExpression smte = (Tree.StaticMemberOrTypeExpression) mte;
tas = smte.getTypeArguments();
} else {
tas = null;
}
List<TypeParameter> tps = dec.getTypeParameters();
if (isPackageQualified(mte)) {
Tree.QualifiedMemberOrTypeExpression qmte = (Tree.QualifiedMemberOrTypeExpression) mte;
Type invokedType = qmte.getPrimary().getTypeModel();
if (invokedType != null) {
invokedType = invokedType.resolveAliases();
}
Type receiverType = unwrap(invokedType, qmte);
return receiverType.getTypedReference(dec, getTypeArguments(tas, receiverType, tps));
} else {
Type receiverType = mte.getScope().getDeclaringType(dec);
return dec.appliedReference(receiverType, getTypeArguments(tas, receiverType, tps));
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.BaseType that) {
super.visit(that);
final Scope scope = that.getScope();
final String name = name(that.getIdentifier());
if (inExtends) {
final Tree.TypeArgumentList tal = that.getTypeArgumentList();
final boolean packageQualified = that.getPackageQualified();
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
return packageQualified ? getPackageTypeDeclaration(name, null, false, unit) : getTypeDeclaration(scope, name, null, false, unit);
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
return getTypeArgumentMap(dec, null, AnalyzerUtil.getTypeArguments(tal, null, tps));
}
@Override
public Map<TypeParameter, SiteVariance> initVarianceOverrides() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
return getVarianceMap(dec, null, AnalyzerUtil.getVariances(tal, tps));
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.QualifiedType that) {
super.visit(that);
final String name = name(that.getIdentifier());
final Tree.StaticType outerType = that.getOuterType();
if (inExtends) {
final Tree.TypeArgumentList tal = that.getTypeArgumentList();
Type t = new LazyType(unit) {
@Override
public TypeDeclaration initDeclaration() {
if (outerType == null) {
return null;
} else {
TypeDeclaration dec = outerType.getTypeModel().getDeclaration();
return AnalyzerUtil.getTypeMember(dec, name, null, false, unit, scope);
}
}
@Override
public Map<TypeParameter, Type> initTypeArguments() {
if (outerType == null) {
return emptyMap();
} else {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
Type ot = outerType.getTypeModel();
return getTypeArgumentMap(dec, ot, AnalyzerUtil.getTypeArguments(tal, ot, tps));
}
}
@Override
public Map<TypeParameter, SiteVariance> initVarianceOverrides() {
TypeDeclaration dec = getDeclaration();
List<TypeParameter> tps = dec.getTypeParameters();
Type ot = outerType.getTypeModel();
return getVarianceMap(dec, ot, AnalyzerUtil.getVariances(tal, tps));
}
};
that.setTypeModel(t);
}
}
use of org.eclipse.ceylon.model.typechecker.model.TypeParameter in project ceylon by eclipse.
the class DeclarationVisitor method visit.
@Override
public void visit(Tree.TypeParameterDeclaration that) {
Tree.TypeVariance tv = that.getTypeVariance();
final TypeParameter p = new TypeParameter();
defaultExtendedToAnything(p);
p.setDeclaration(declaration);
if (tv != null) {
String v = tv.getText();
p.setCovariant("out".equals(v));
p.setContravariant("in".equals(v));
}
that.setDeclarationModel(p);
visitDeclaration(that, p);
super.visit(that);
Tree.TypeSpecifier ts = that.getTypeSpecifier();
if (ts != null) {
p.setDefaulted(true);
Tree.StaticType type = ts.getType();
if (type != null) {
Type dta = type.getTypeModel();
p.setDefaultTypeArgument(dta);
}
}
}
Aggregations