use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ExpressionVisitor method visitGenericBaseTypeReference.
private void visitGenericBaseTypeReference(Tree.StaticMemberOrTypeExpression that, TypeDeclaration type) {
if (type instanceof Class && type.isParameterized()) {
Class generic = (Class) type;
Scope scope = that.getScope();
Type outerType = scope.getDeclaringType(type);
Type target = type.appliedType(outerType, typeParametersAsArgList(generic));
that.setTarget(target);
Type functionType = genericFunctionType(generic, scope, type, target, unit);
that.setTypeModel(functionType);
checkNotJvm(that, "type functions are not supported on the JVM: '" + type.getName(unit) + "' is generic (specify explicit type arguments)");
}
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ExpressionVisitor method visitQualifiedTypeExpression.
private void visitQualifiedTypeExpression(Tree.QualifiedTypeExpression that, Type receivingType, TypeDeclaration memberType, List<Type> typeArgs, Tree.TypeArguments tal) {
checkMemberOperator(receivingType, that);
if (memberType instanceof Constructor) {
that.addError("constructor is not a type: '" + memberType.getName(unit) + "' is a constructor");
}
Type receiverType = accountForStaticReferenceReceiverType(that, unwrap(receivingType, that));
if (acceptsTypeArguments(memberType, receiverType, typeArgs, tal, that) || true) {
Type type = receiverType.getTypeMember(memberType, typeArgs);
that.setTarget(type);
Type fullType = type.getFullType(wrap(type, receivingType, that));
if (!dynamic && !that.getStaticMethodReference() && memberType instanceof Class && !isAbstraction(memberType) && isTypeUnknown(fullType) && !hasError(that)) {
// this occurs with an ambiguous reference
// to a member of an intersection type
String rtname = receiverType.getDeclaration().getName(unit);
that.addError("could not determine type of member class reference: '" + memberType.getName(unit) + "' of '" + rtname + "' is ambiguous");
}
that.setTypeModel(accountForStaticReferenceType(that, memberType, fullType));
}
if (that.getStaticMethodReference()) {
handleStaticReferenceImplicitTypeArguments(that);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ExpressionVisitor method visitExtendedTypePrimary.
void visitExtendedTypePrimary(Tree.ExtendedTypeExpression that) {
Declaration dec = that.getDeclaration();
if (dec instanceof Class) {
Class c = (Class) dec;
if (c.isAbstraction()) {
// if the constructor is overloaded
// resolve the right overloaded version
Declaration result = findMatchingOverloadedClass(c, that.getSignature(), that.getEllipsis());
if (result != null && result != dec) {
// patch the reference, which was already
// initialized to the abstraction
TypeDeclaration td = (TypeDeclaration) result;
that.setDeclaration(td);
c = (Class) td;
if (isOverloadedVersion(result)) {
// it is a Java constructor
if (result.isPackageVisibility() && !declaredInPackage(result, unit)) {
that.addError("constructor is not visible: '" + result.getName() + "' is package private");
}
}
}
// else report to user that we could not
// find a matching overloaded constructor
}
if (!c.isAbstraction() && c.getParameterList() == null) {
that.addError("class cannot be instantiated: '" + c.getName(unit) + "' does not have a parameter list or default constructor");
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ExpressionVisitor method visit.
@Override
public void visit(Tree.ObjectExpression that) {
Class ac = that.getAnonymousClass();
Declaration od = beginReturnDeclaration(ac);
Tree.Type rt = beginReturnScope(fakeVoid(that));
super.visit(that);
endReturnScope(rt, null);
endReturnDeclaration(od);
that.setTypeModel(unit.denotableType(ac.getType()));
}
use of org.eclipse.ceylon.model.typechecker.model.Class in project ceylon by eclipse.
the class ExpressionVisitor method visit.
@Override
public void visit(Tree.ObjectArgument that) {
Class ac = that.getAnonymousClass();
Declaration od = beginReturnDeclaration(ac);
Tree.Type rt = beginReturnScope(fakeVoid(that));
super.visit(that);
endReturnScope(rt, null);
endReturnDeclaration(od);
}
Aggregations