use of org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.AttributeImpl in project ceylon by eclipse.
the class ValueDeclarationImpl method memberApply.
@TypeInfo("ceylon.language.meta.model::Attribute<Container,Get,Set>")
@TypeParameters({ @TypeParameter("Container"), @TypeParameter("Get"), @TypeParameter(value = "Set", defaultValue = "ceylon.language::Nothing") })
@Override
public <Container, Get, Set> ceylon.language.meta.model.Attribute<Container, Get, Set> memberApply(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedGet, @Ignore TypeDescriptor $reifiedSet, @Name("containerType") ceylon.language.meta.model.Type<? extends Object> containerType) {
if (getToplevel())
throw new ceylon.language.meta.model.TypeApplicationException("Cannot apply a toplevel declaration to a container type: use apply");
Type qualifyingType = Metamodel.getModel(containerType);
Metamodel.checkQualifyingType(qualifyingType, declaration);
org.eclipse.ceylon.model.typechecker.model.Value modelDecl = (org.eclipse.ceylon.model.typechecker.model.Value) declaration;
// find the proper qualifying type
Type memberQualifyingType = qualifyingType.getSupertype((TypeDeclaration) modelDecl.getContainer());
org.eclipse.ceylon.model.typechecker.model.TypedReference typedReference = modelDecl.appliedTypedReference(memberQualifyingType, Collections.<Type>emptyList());
TypeDescriptor reifiedContainer = Metamodel.getTypeDescriptorForProducedType(qualifyingType);
org.eclipse.ceylon.model.typechecker.model.Type getType = typedReference.getType();
TypeDescriptor reifiedGet = Metamodel.getTypeDescriptorForProducedType(getType);
// immutable values have Set=Nothing
org.eclipse.ceylon.model.typechecker.model.Type setType = getVariable() ? getType : modelDecl.getUnit().getNothingType();
TypeDescriptor reifiedSet = getVariable() ? reifiedGet : TypeDescriptor.NothingType;
Metamodel.checkReifiedTypeArgument("memberApply", "Attribute<$1,$2,$3>", Variance.IN, memberQualifyingType, $reifiedContainer, Variance.OUT, getType, $reifiedGet, Variance.IN, setType, $reifiedSet);
return new AttributeImpl<Container, Get, Set>(reifiedContainer, reifiedGet, reifiedSet, this, typedReference, containerType);
}
Aggregations