Example #1
0
        public MethodEnvironment EnterMethod(RootEnvironment rootEnv)
        {
            var typeEnv   = DefiningType.Enter(rootEnv);
            var methodDef = typeEnv.Type.ResolveMethod(signature);

            if (methodDef == null)
            {
                throw new InvalidOperationException("unable to resolve method reference");
            }
            var groundArguments = rootEnv.SubstituteTypes(MethodTypeArguments);

            return(typeEnv.AddMethod(methodDef).AddMethodBoundArguments(groundArguments));
        }
Example #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));
        }
Example #3
0
        internal override InvalidInfo CheckValid(ValidityContext vctxt, MessageContext ctxt, RootEnvironment rootEnv)
        {
            var v = base.CheckValid(vctxt, ctxt, rootEnv);

            if (v != null)
            {
                return(v);
            }
            if (MethodTypeArguments.Count != MethodTypeArity)
            {
                vctxt.Log
                    (new InvalidMemberRef
                        (ctxt,
                        this,
                        String.Format
                            ("Polymorphic method has {0} type parameters but is applied to {1} type arguments",
                            MethodTypeArity,
                            MethodTypeArguments.Count)));
                return(new InvalidInfo(MessageContextBuilders.Member(vctxt.Global, this)));
            }

            v = MethodTypeArguments.Select(t => t.CheckValid(vctxt, ctxt, rootEnv)).FirstOrDefault(v2 => v2 != null);
            if (v != null)
            {
                return(v);
            }
            var groundMethodTypeArguments = rootEnv.SubstituteTypes(MethodTypeArguments);
            var typeEnv   = DefiningType.Enter(rootEnv);
            var methodDef = typeEnv.Type.ResolveMethod(signature);

            if (methodDef == null)
            {
                throw new InvalidOperationException("unable to resolve method");
            }
            var methEnv = typeEnv.AddMethod(methodDef).AddMethodBoundArguments(groundMethodTypeArguments);

            return(signature.CheckValid(vctxt, ctxt, methEnv));
        }
Example #4
0
 public override TypeEnvironment Enter(RootEnvironment rootEnv)
 {
     return(name.Enter(rootEnv).AddTypeBoundArguments(rootEnv.SubstituteTypes(arguments)));
 }