use of org.eclipse.ceylon.compiler.java.metadata.TypeInfo in project ceylon by eclipse.
the class ClassOrInterfaceImpl method getDeclaredClassOrInterface.
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Kind", satisfies = "ceylon.language.meta.model::ClassOrInterface<ceylon.language::Anything,ceylon.language::Nothing>") })
@TypeInfo("ceylon.language.meta.model::Member<Container,Kind>|ceylon.language::Null")
public <Container, Kind extends ceylon.language.meta.model.ClassOrInterface<? extends java.lang.Object>> ceylon.language.meta.model.Member<Container, Kind> getDeclaredClassOrInterface(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedKind, String name, @Name("types") @Sequenced Sequential<? extends ceylon.language.meta.model.Type<?>> types) {
checkInit();
// do not return the attribute if the container is not a subtype of this type
org.eclipse.ceylon.model.typechecker.model.Type reifiedContainer = Metamodel.getProducedType($reifiedContainer);
if (!reifiedContainer.isSubtypeOf(producedType))
throw new IncompatibleTypeException("Specified container type '" + reifiedContainer.asString() + "' is not a valid subtype of this type");
final ClassOrInterfaceDeclarationImpl type = declaration.findDeclaredType(name);
if (type == null)
return null;
return applyClassOrInterface($reifiedContainer, $reifiedKind, type, types);
}
use of org.eclipse.ceylon.compiler.java.metadata.TypeInfo in project ceylon by eclipse.
the class ClassOrInterfaceImpl method getInterface.
@SuppressWarnings({ "unchecked", "hiding" })
@Override
@TypeParameters({ @TypeParameter(value = "Container"), @TypeParameter(value = "Type") })
@TypeInfo("ceylon.language.meta.model::MemberInterface<Container,Type>|ceylon.language::Null")
public <Container, Type> ceylon.language.meta.model.MemberInterface<Container, Type> getInterface(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedType, 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 InterfaceDeclarationImpl == false)
throw new IncompatibleTypeException("Specified member is not an interface: " + name);
MemberLookup<InterfaceDeclarationImpl, Container> lookup = lookupMember(InterfaceDeclarationImpl.$TypeDescriptor$, $reifiedContainer, (InterfaceDeclarationImpl) type);
if (lookup == null)
return null;
return (ceylon.language.meta.model.MemberInterface<Container, Type>) lookup.declaration.memberApply($reifiedContainer, $reifiedType, lookup.containerMetamodel, types);
}
use of org.eclipse.ceylon.compiler.java.metadata.TypeInfo 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.TypeInfo 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.TypeInfo 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;
}
Aggregations