Beispiel #1
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            if (Index >= rootEnv.SkolemDefs.Count)
            {
                vctxt.Log(new InvalidTypeRef(ctxt, this, "skolemized type index is out of range"));
                return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
            }

            return(vctxt.ImplementableTypeRef(ctxt, rootEnv, this));
        }
Beispiel #2
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            var v = arguments.Select(a => a.CheckValid(vctxt, ctxt, rootEnv)).FirstOrDefault(v2 => v2 != null);

            if (v != null)
            {
                return(v);
            }

            var groundArguments = rootEnv.SubstituteTypes(arguments);
            var tyconEnv        = name.Enter(rootEnv);

            if (!tyconEnv.Type.PrimAreValidArguments(vctxt, ctxt, this, tyconEnv.ToGround(), groundArguments))
            {
                return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
            }

            return(vctxt.ImplementableTypeRef(ctxt, rootEnv, this));
        }
Beispiel #3
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            switch (ParameterFlavor)
            {
            case ParameterFlavor.Type:
            {
                var typeEnv = rootEnv as TypeEnvironment;
                if (typeEnv == null)
                {
                    throw new InvalidOperationException("not in type environment");
                }
                if (Index >= typeEnv.TypeBoundArguments.Count)
                {
                    vctxt.Log(new InvalidTypeRef(ctxt, this, "type-bound type parameter index is out of range"));
                    return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
                }
                break;
            }

            case ParameterFlavor.Method:
            {
                var methEnv = rootEnv as MethodEnvironment;
                if (methEnv == null)
                {
                    throw new InvalidOperationException("not in method environment");
                }
                if (Index >= methEnv.MethodBoundArguments.Count)
                {
                    vctxt.Log(new InvalidTypeRef(ctxt, this, "method-bound type parameter index is out of range"));
                    return(new InvalidInfo(MessageContextBuilders.Type(vctxt.Global, this)));
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(vctxt.ImplementableTypeRef(ctxt, rootEnv, this));
        }