use of org.eclipse.ceylon.model.typechecker.model.Type in project ceylon by eclipse.
the class AbstractTransformer method hasMatchingSignature.
private boolean hasMatchingSignature(java.util.List<Type> signature, java.util.List<Type> typedSignature) {
if (signature.size() != typedSignature.size())
return false;
for (int i = 0; i < signature.size(); i++) {
Type signatureArg = signature.get(i);
Type typedSignatureArg = typedSignature.get(i);
if (signatureArg != null && typedSignatureArg != null && !ModelUtil.matches(signatureArg, typedSignatureArg, typeFact()))
return false;
}
return true;
}
use of org.eclipse.ceylon.model.typechecker.model.Type in project ceylon by eclipse.
the class AbstractTransformer method getPinnedType.
private Type getPinnedType(TypedReference ref, Type type) {
if (isPinnedType(ref.getDeclaration().getRefinedDeclaration()) && willEraseToObject(type)) {
Type rt = ref.getType();
Type st = rt.getSupertype(typeFact().getSequenceDeclaration());
if (st != null) {
return st;
}
return rt.getSupertype(typeFact().getSequentialDeclaration());
} else {
return type;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Type in project ceylon by eclipse.
the class AbstractTransformer method hasSubstitutedBounds.
boolean hasSubstitutedBounds(Type pt) {
TypeDeclaration declaration = pt.getDeclaration();
java.util.List<TypeParameter> tps = declaration.getTypeParameters();
final Map<TypeParameter, Type> tas = pt.getTypeArguments();
boolean isCallable = isCeylonCallable(pt);
for (TypeParameter tp : tps) {
Type ta = tas.get(tp);
// error recovery
if (ta == null)
continue;
if (!tp.getSatisfiedTypes().isEmpty()) {
for (Type bound : tp.getSatisfiedTypes()) {
bound = bound.substitute(pt);
if (expressionGen().needsCast(ta, bound, false, false, false))
return true;
}
}
if (hasSubstitutedBounds(ta))
return true;
// Callable ignores type parameters after the first
if (isCallable)
break;
}
return false;
}
use of org.eclipse.ceylon.model.typechecker.model.Type in project ceylon by eclipse.
the class AbstractTransformer method makeTypesListAttr.
private JCExpression makeTypesListAttr(java.util.List<Type> types) {
if (types.isEmpty())
return null;
ListBuffer<JCExpression> upperBounds = new ListBuffer<JCTree.JCExpression>();
for (Type type : types) {
String typeSig = serialiseTypeSignature(type);
upperBounds.append(make().Literal(typeSig));
}
JCExpression caseAttribute = make().Assign(naming.makeUnquotedIdent("value"), make().NewArray(null, null, upperBounds.toList()));
return caseAttribute;
}
use of org.eclipse.ceylon.model.typechecker.model.Type in project ceylon by eclipse.
the class AbstractTransformer method getTypeArguments.
private java.util.List<Type> getTypeArguments(Function method) {
java.util.List<TypeParameter> typeParameters = method.getTypeParameters();
java.util.List<Type> typeArguments = new ArrayList<Type>(typeParameters.size());
for (TypeParameter tp : typeParameters) typeArguments.add(tp.getType());
return typeArguments;
}
Aggregations