use of com.redhat.ceylon.model.loader.model.LazyClass in project ceylon-compiler by ceylon.
the class Strategy method generateJpaCtor.
static boolean generateJpaCtor(ClassOrInterface declarationModel) {
if (declarationModel instanceof Class && !(declarationModel instanceof ClassAlias) && declarationModel.isToplevel()) {
Class cls = (Class) declarationModel;
if (cls.getCaseValues() != null && !cls.getCaseValues().isEmpty()) {
return false;
}
if (hasNullaryNonJpaConstructor(cls)) {
// The class will already have a nullary ctor
return false;
}
boolean hasDelegatableSuper = false;
Class superClass = (Class) cls.getExtendedType().getDeclaration();
if (superClass instanceof LazyClass && !((LazyClass) superClass).isCeylon()) {
if (superClass.isAbstraction()) {
for (Declaration s : superClass.getOverloads()) {
if (s instanceof Class && isNullary((Class) s)) {
hasDelegatableSuper = true;
break;
}
}
} else {
// If the superclass is Java then generate a Jpa constructor
// if there's a nullary superclass constructor we can call
hasDelegatableSuper = isNullary(superClass);
}
} else {
hasDelegatableSuper = hasNullaryNonJpaConstructor(superClass) || hasJpaConstructor(superClass);
}
boolean constrained = (cls.getCaseValues() != null && !cls.getCaseValues().isEmpty()) || cls.hasEnumerated() && Decl.hasOnlyValueConstructors(cls);
return hasDelegatableSuper && !constrained;
} else {
return false;
}
}
use of com.redhat.ceylon.model.loader.model.LazyClass in project ceylon-compiler by ceylon.
the class DeclarationErrorVisitor method visit.
public void visit(Tree.ExtendedType that) {
that.getType().visit(this);
// error if we tried to generate a ctor for this class.
if (that.getType().getDeclarationModel() instanceof LazyClass && !((LazyClass) that.getType().getDeclarationModel()).isCeylon()) {
boolean hasPrivateCtor = false;
List<Declaration> overloads = ((LazyClass) that.getType().getDeclarationModel()).getOverloads();
if (overloads != null) {
for (Declaration ctor : overloads) {
if (!ctor.isShared()) {
hasPrivateCtor = true;
break;
}
}
}
if (hasPrivateCtor) {
that.getInvocationExpression().visit(this);
}
}
}
Aggregations