Esempio n. 1
0
 public override void ValidateConstraintForType(TypeVariableReference type, ITypeUnificationResult unificationResult)
 {
     if (!type.Lifetime.DoesOutlastLifetimeGraph(_lifetimeGraph))
     {
         unificationResult.AddFailedTypeConstraint(this);
     }
 }
Esempio n. 2
0
 public override void ValidateConstraintForType(TypeVariableReference type, ITypeUnificationResult unificationResult)
 {
     if (!type.RenderNIType().TypeHasDisplayTrait())
     {
         unificationResult.AddFailedTypeConstraint(this);
     }
 }
Esempio n. 3
0
        public override void ValidateConstraintForType(TypeVariableReference type, ITypeUnificationResult unificationResult)
        {
            NIType implementedIteratorInterface;

            // TODO: using NITypes here to destructure the iterator interface and reconstruct a TypeReference for the item type
            // is an incomplete solution; it will not work for item types that have bounded lifetimes. Also, currently there's
            // no way to create TypeReferences for non-reference types that have bounded lifetimes, as an iterator implementation
            // whose items are references will necessarily have.
            //
            // What is needed is a way of defining a generic parameterized TypeVariableReference, and then a reference to a specialization of that type.
            // Then, as long as the parameterized type can include an interface implementation, we should be able to get the specialized
            // interface implementation from the specialization.
            if (type.RenderNIType().TryGetImplementedIteratorInterface(out implementedIteratorInterface))
            {
                NIType itemType;
                implementedIteratorInterface.TryDestructureIteratorType(out itemType);
                TypeVariableReference itemTypeReference = type.TypeVariableSet.CreateTypeVariableReferenceFromNIType(
                    itemType,
                    new Dictionary <NIType, TypeVariableReference>());
                type.TypeVariableSet.Unify(_itemTypeVariable, itemTypeReference, unificationResult);
            }
            else
            {
                unificationResult.AddFailedTypeConstraint(this);
            }
        }
Esempio n. 4
0
 public override void ValidateConstraintForType(TypeVariableReference type, ITypeUnificationResult unificationResult)
 {
     // TODO: probably not great to render an NIType at this stage
     if (!type.RenderNIType().WireTypeMayFork())
     {
         unificationResult.AddFailedTypeConstraint(this);
     }
 }