use of ceylon.language.impl.MemberImpl in project ceylon by eclipse.
the class PartialImpl method initializeTuple.
protected <Id> void initializeTuple(TypeDescriptor $reified$Id, DeserializationContextImpl<Id> context, ceylon.language.Tuple<?, ?, ?> instance) {
NativeMap<ReachableReference, Id> state = (NativeMap<ReachableReference, Id>) getState();
ValueDeclaration firstAttribute = Util.assertExists((ValueDeclaration) ((ClassDeclaration) Metamodel.getOrCreateMetamodel(Tuple.class)).getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "first"));
MemberImpl firstMember = new MemberImpl(firstAttribute);
java.lang.Object first = getReferredInstance(context, state, firstMember);
ValueDeclaration restAttribute = Util.assertExists((ValueDeclaration) ((ClassDeclaration) Metamodel.getOrCreateMetamodel(Tuple.class)).getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "rest"));
MemberImpl restMember = new MemberImpl(restAttribute);
Id restId = state.get(restMember);
java.lang.Object referredRest = context.leakInstance(restId);
if (referredRest instanceof Partial && !((PartialImpl) referredRest).getInitialized()) {
// Safe because tuples are immutable => no cycles
((PartialImpl) referredRest).initialize($reified$Id, context);
}
java.lang.Object rest = getReferredInstance(context, state, restMember);
((Tuple<?, ?, ?>) instance).$completeInit$(first, rest);
// now check compatibility (do this after initialization
// because Tuple$getType$ requires the tuple is initialized!
Type firstMemberType = Metamodel.getModuleManager().getCachedType(getClassTypeDescriptor().getTypeArgument(1));
Type firstInstanceType = Metamodel.getModuleManager().getCachedType(Metamodel.getTypeDescriptor(first));
if (!firstInstanceType.isSubtypeOf(firstMemberType)) {
throw notAssignable(firstMember, firstMemberType, firstInstanceType);
}
Type restInstanceType = Metamodel.getModuleManager().getCachedType(Metamodel.getTypeDescriptor(rest));
Type restMemberType = Metamodel.getModuleManager().getCachedType(getClassTypeDescriptor().getTypeArgument(2));
if (!restInstanceType.isSubtypeOf(restMemberType)) {
throw notAssignable(restMember, restMemberType, restInstanceType);
}
}
use of ceylon.language.impl.MemberImpl in project ceylon by eclipse.
the class Tuple method $references$.
@Ignore
@Override
public java.util.Collection<ReachableReference> $references$() {
// could put the elements with int indexes and the rest as a String!
ArrayList<ReachableReference> s = new ArrayList<ReachableReference>(2);
ClassDeclaration cd = (ClassDeclaration) Metamodel.getOrCreateMetamodel(Tuple.class);
s.add(new MemberImpl(Util.assertExists(cd.<ValueDeclaration>getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "first"))));
s.add(new MemberImpl(Util.assertExists(cd.<ValueDeclaration>getMemberDeclaration(ValueDeclaration.$TypeDescriptor$, "rest"))));
return s;
}
Aggregations