use of org.eclipse.ceylon.compiler.java.metadata.TypeParameters in project ceylon by eclipse.
the class ClassOrInterfaceImpl method $getClass.
@SuppressWarnings("hiding")
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Type"), @TypeParameter(value = "Arguments", satisfies = "ceylon.language::Sequential<ceylon.language::Anything>") })
@TypeInfo("ceylon.language.meta.model::MemberClass<Container,Type,Arguments>|ceylon.language::Null")
public <Container, Type, Arguments extends ceylon.language.Sequential<? extends java.lang.Object>> ceylon.language.meta.model.MemberClass<Container, Type, Arguments> $getClass(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, @Ignore TypeDescriptor $reifiedArguments, String name, @Name("types") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> types) {
checkInit();
final ClassOrInterfaceDeclarationImpl type = declaration.findType(name);
if (type == null)
return null;
if (type instanceof ClassDeclarationImpl == false)
throw new IncompatibleTypeException("Specified member is not a class: " + name);
MemberLookup<ClassDeclarationImpl, Container> lookup = lookupMember(ClassDeclarationImpl.$TypeDescriptor$, $reifiedContainer, (ClassDeclarationImpl) type);
if (lookup == null)
return null;
return lookup.declaration.memberClassApply($reifiedContainer, $reifiedType, $reifiedArguments, lookup.containerMetamodel, types);
}
use of org.eclipse.ceylon.compiler.java.metadata.TypeParameters in project ceylon by eclipse.
the class ClassDeclarationImpl method staticClassApply.
@SuppressWarnings("unchecked")
@Override
@TypeInfo("ceylon.language.meta.model::Class<Type,Arguments>")
@TypeParameters({ @TypeParameter("Type"), @TypeParameter(value = "Arguments", satisfies = "ceylon.language::Sequential<ceylon.language::Anything>") })
public <Type, Arguments extends Sequential<? extends Object>> ceylon.language.meta.model.Class<Type, Arguments> staticClassApply(@Ignore TypeDescriptor $reifiedType, @Ignore TypeDescriptor $reifiedArguments, @Name("containerType") @TypeInfo("ceylon.language.meta.model::Type<ceylon.language::Anything>") ceylon.language.meta.model.Type<? extends Object> containerType, @Name("typeArguments") @TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::Type<ceylon.language::Anything>>") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> typeArguments) {
if (!getStatic()) {
throw new ceylon.language.meta.model.TypeApplicationException("Cannot staticClassApply a non-static declaration: use " + (getToplevel() ? "apply" : "memberClassApply"));
}
List<org.eclipse.ceylon.model.typechecker.model.Type> producedTypes = Metamodel.getProducedTypes(typeArguments);
if (getStatic()) {
producedTypes.addAll(0, Metamodel.getModel(containerType).getTypeArgumentList());
}
Metamodel.checkTypeArguments(null, declaration, producedTypes);
org.eclipse.ceylon.model.typechecker.model.Type ct = Metamodel.getProducedType(Metamodel.getTypeDescriptor(containerType));
org.eclipse.ceylon.model.typechecker.model.Reference appliedType = declaration.appliedReference(ct, producedTypes);
// MemberClassImpl<Object, Type, Arguments> ret = (MemberClassImpl<Object, Type, Arguments>) Metamodel.getAppliedMetamodel(appliedType.getType());
// Metamodel.checkReifiedTypeArgument("staticClassApply", "Class<$1,$2>", Variance.OUT, appliedType.getType(), $reifiedType,
// Variance.IN, Metamodel.getProducedType(ret.$reifiedArguments), $reifiedArguments);
// return (ClassImpl)ret.$call$();
TypeDescriptor reifiedArguments;
if (!declaration.isAnonymous())
reifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.getUnit(), (Functional) declaration, appliedType.getType());
else
reifiedArguments = TypeDescriptor.NothingType;
TypeDescriptor reifiedType = Metamodel.getTypeDescriptorForProducedType(appliedType.getType());
return new org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.ClassImpl(reifiedType, reifiedArguments, appliedType.getType(), null, null);
}
use of org.eclipse.ceylon.compiler.java.metadata.TypeParameters in project ceylon by eclipse.
the class ClassDeclarationImpl method memberClassApply.
@SuppressWarnings({ "unchecked", "rawtypes" })
@TypeInfo("ceylon.language.meta.model::MemberClass<Container,Type,Arguments>")
@TypeParameters({ @TypeParameter("Container"), @TypeParameter("Type"), @TypeParameter(value = "Arguments", satisfies = "ceylon.language::Sequential<ceylon.language::Anything>") })
@Override
public <Container, Type, Arguments extends Sequential<? extends Object>> ceylon.language.meta.model.MemberClass<Container, Type, Arguments> memberClassApply(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, @Ignore TypeDescriptor $reifiedArguments, @Name("containerType") ceylon.language.meta.model.Type<? extends Object> containerType, @Name("typeArguments") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> typeArguments) {
if (getToplevel())
throw new ceylon.language.meta.model.TypeApplicationException("Cannot apply a toplevel declaration to a container type: use apply");
ceylon.language.meta.model.MemberClass<Container, Type, Arguments> member = (ceylon.language.meta.model.MemberClass) getAppliedClassOrInterface(null, null, typeArguments, containerType);
// This is all very ugly but we're trying to make it cheaper and friendlier than just checking the full type and showing
// implementation types to the user, such as AppliedMemberClass
TypeDescriptor actualReifiedContainer = ((MemberClassImpl) member).$reifiedContainer;
TypeDescriptor actualReifiedArguments = ((MemberClassImpl) member).$reifiedArguments;
org.eclipse.ceylon.model.typechecker.model.Type actualType = Metamodel.getModel((ceylon.language.meta.model.Type<?>) member);
Metamodel.checkReifiedTypeArgument("memberApply", "Member<$1,Class<$2,$3>>&Class<$2,$3>", Variance.IN, Metamodel.getProducedType(actualReifiedContainer), $reifiedContainer, Variance.OUT, actualType, $reifiedType, Variance.IN, Metamodel.getProducedType(actualReifiedArguments), $reifiedArguments);
return member;
}
use of org.eclipse.ceylon.compiler.java.metadata.TypeParameters in project ceylon by eclipse.
the class ClassOrInterfaceDeclarationImpl method memberApply.
@SuppressWarnings("rawtypes")
@TypeInfo("ceylon.language.meta.model::Member<Container,ceylon.language.meta.model::ClassOrInterface<Type>>&ceylon.language.meta.model::ClassOrInterface<Type>")
@TypeParameters({ @TypeParameter("Container"), @TypeParameter("Type") })
@Override
public <Container, Type extends Object> java.lang.Object memberApply(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, @Name("containerType") ceylon.language.meta.model.Type<? extends Object> containerType, @Name("typeArguments") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> typeArguments) {
if (getToplevel())
throw new ceylon.language.meta.model.TypeApplicationException("Cannot apply a toplevel declaration to a container type: use apply");
ceylon.language.meta.model.Member<? extends Container, ceylon.language.meta.model.ClassOrInterface<?>> member = getAppliedClassOrInterface(null, null, typeArguments, containerType);
// This is all very ugly but we're trying to make it cheaper and friendlier than just checking the full type and showing
// implementation types to the user, such as AppliedMemberClass
TypeDescriptor actualReifiedContainer;
if (member instanceof MemberClassImpl)
actualReifiedContainer = ((MemberClassImpl) member).$reifiedContainer;
else
actualReifiedContainer = ((MemberInterfaceImpl) member).$reifiedContainer;
org.eclipse.ceylon.model.typechecker.model.Type actualType = Metamodel.getModel((ceylon.language.meta.model.Type<?>) member);
Metamodel.checkReifiedTypeArgument("memberApply", "Member<$1,ClassOrInterface<$2>>&ClassOrInterface<$2>", Variance.IN, Metamodel.getProducedType(actualReifiedContainer), $reifiedContainer, Variance.OUT, actualType, $reifiedType);
return member;
}
use of org.eclipse.ceylon.compiler.java.metadata.TypeParameters in project ceylon by eclipse.
the class FunctionDeclarationImpl method apply.
@Override
@TypeInfo("ceylon.language.meta.model::Function<Return,Arguments>")
@TypeParameters({ @TypeParameter("Return"), @TypeParameter(value = "Arguments", satisfies = "ceylon.language::Sequential<ceylon.language::Anything>") })
public <Return extends Object, Arguments extends Sequential<? extends Object>> ceylon.language.meta.model.Function<Return, Arguments> apply(@Ignore TypeDescriptor $reifiedReturn, @Ignore TypeDescriptor $reifiedArguments, @Name("typeArguments") @TypeInfo("ceylon.language::Sequential<ceylon.language.meta.model::Type<ceylon.language::Anything>>") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> typeArguments) {
if (!getToplevel()) {
String msg;
if (getStatic()) {
msg = "Cannot apply a static declaration with no container type: use staticApply";
} else {
msg = "Cannot apply a member declaration with no container type: use memberApply";
}
throw new ceylon.language.meta.model.TypeApplicationException(msg);
}
List<org.eclipse.ceylon.model.typechecker.model.Type> producedTypes = Metamodel.getProducedTypes(typeArguments);
Metamodel.checkTypeArguments(null, declaration, producedTypes);
org.eclipse.ceylon.model.typechecker.model.Reference appliedFunction = declaration.appliedReference(null, producedTypes);
TypeDescriptor reifiedType = Metamodel.getTypeDescriptorForFunction(appliedFunction);
TypeDescriptor reifiedArguments = Metamodel.getTypeDescriptorForArguments(declaration.getUnit(), (Functional) declaration, appliedFunction);
Metamodel.checkReifiedTypeArgument("apply", "Function<$1,$2>", Variance.OUT, declaration.getUnit().getCallableReturnType(appliedFunction.getFullType()), $reifiedReturn, Variance.IN, Metamodel.getProducedTypeForArguments(declaration.getUnit(), (Functional) declaration, appliedFunction), $reifiedArguments);
return new FunctionImpl<Return, Arguments>(reifiedType, reifiedArguments, appliedFunction, this, null, null);
}
Aggregations