Search in sources :

Example 1 with MemberInterfaceImpl

use of org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberInterfaceImpl in project ceylon by eclipse.

the class ClassOrInterfaceImpl method applyClassOrInterface.

@SuppressWarnings("rawtypes")
private <Container, Kind extends ceylon.language.meta.model.ClassOrInterface<?>> ceylon.language.meta.model.Member<Container, Kind> applyClassOrInterface(@Ignore TypeDescriptor $reifiedContainer, @Ignore TypeDescriptor $reifiedKind, ClassOrInterfaceDeclarationImpl type, Sequential<? extends ceylon.language.meta.model.Type<?>> types) {
    if (type == null)
        return null;
    ceylon.language.meta.model.Type<Container> appliedContainer = getAppliedContainer($reifiedContainer, type);
    Member<Container, Kind> member = type.getAppliedClassOrInterface(this.$reifiedType, $reifiedKind, types, appliedContainer);
    // 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;
    TypeDescriptor actualKind;
    if (member instanceof MemberClassImpl) {
        actualReifiedContainer = ((MemberClassImpl) member).$reifiedContainer;
        actualKind = TypeDescriptor.klass(ceylon.language.meta.model.Class.class, ((MemberClassImpl) member).$reifiedType, ((MemberClassImpl) member).$reifiedArguments);
    } else {
        actualReifiedContainer = ((MemberInterfaceImpl) member).$reifiedContainer;
        actualKind = TypeDescriptor.klass(ceylon.language.meta.model.Interface.class, ((MemberInterfaceImpl) member).$reifiedType);
    }
    Metamodel.checkReifiedTypeArgument("getClassOrInterface", "Member<$1,$2>&$2", Variance.IN, Metamodel.getProducedType(actualReifiedContainer), $reifiedContainer, Variance.OUT, Metamodel.getProducedType(actualKind), $reifiedKind);
    return member;
}
Also used : MemberClassImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberClassImpl) TypeDescriptor(org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor) MemberInterfaceImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberInterfaceImpl) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) ClassOrInterface(org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)

Example 2 with MemberInterfaceImpl

use of org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberInterfaceImpl 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;
}
Also used : ClassOrInterface(ceylon.language.meta.model.ClassOrInterface) TypeDescriptor(org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor) MemberInterfaceImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberInterfaceImpl) Type(org.eclipse.ceylon.model.typechecker.model.Type) Metamodel(org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel) MemberClassImpl(org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberClassImpl) TypeParameters(org.eclipse.ceylon.compiler.java.metadata.TypeParameters) TypeInfo(org.eclipse.ceylon.compiler.java.metadata.TypeInfo)

Aggregations

Metamodel (org.eclipse.ceylon.compiler.java.runtime.metamodel.Metamodel)2 MemberClassImpl (org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberClassImpl)2 MemberInterfaceImpl (org.eclipse.ceylon.compiler.java.runtime.metamodel.meta.MemberInterfaceImpl)2 TypeDescriptor (org.eclipse.ceylon.compiler.java.runtime.model.TypeDescriptor)2 ClassOrInterface (ceylon.language.meta.model.ClassOrInterface)1 TypeInfo (org.eclipse.ceylon.compiler.java.metadata.TypeInfo)1 TypeParameters (org.eclipse.ceylon.compiler.java.metadata.TypeParameters)1 ClassOrInterface (org.eclipse.ceylon.model.typechecker.model.ClassOrInterface)1 Type (org.eclipse.ceylon.model.typechecker.model.Type)1