Search in sources :

Example 1 with AttributeImpl

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);
}
Also used : AttributeImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.AttributeImpl) Type(org.eclipse.ceylon.model.typechecker.model.Type) Value(org.eclipse.ceylon.model.typechecker.model.Value) Type(org.eclipse.ceylon.model.typechecker.model.Type) OpenType(ceylon.language.meta.declaration.OpenType) TypeDescriptor(org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor) Value(org.eclipse.ceylon.model.typechecker.model.Value) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) TypeParameters(org.eclipse.ceylon.compiler.java.metadata.TypeParameters) TypeInfo(org.eclipse.ceylon.compiler.java.metadata.TypeInfo)

Aggregations

OpenType (ceylon.language.meta.declaration.OpenType)1 TypeInfo (org.eclipse.ceylon.compiler.java.metadata.TypeInfo)1 TypeParameters (org.eclipse.ceylon.compiler.java.metadata.TypeParameters)1 Metamodel (org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel)1 AttributeImpl (org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.AttributeImpl)1 TypeDescriptor (org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor)1 Type (org.eclipse.ceylon.model.typechecker.model.Type)1 Value (org.eclipse.ceylon.model.typechecker.model.Value)1