Boo.Lang.Compiler.TypeSystem.GenericParameterInferrer.InferConstructedType C# (CSharp) Method

InferConstructedType() private method

private InferConstructedType ( IType formalType, IType actualType, Inference inference ) : bool
formalType IType
actualType IType
inference Inference
return bool
        private bool InferConstructedType(IType formalType, IType actualType, Inference inference)
        {
            // look for a single occurance of the formal
            // constructed type in the actual type's hierarchy
            IType constructedActualType = GenericsServices.FindConstructedType(
                actualType,
                formalType.ConstructedInfo.GenericDefinition);

            if (constructedActualType == null)
            {
                return false;
            }

            // Exact inference requires the constructed occurance to be
            // the actual type itself
            if (inference == Inference.Exact && actualType != constructedActualType)
            {
                return false;
            }

            for (int i = 0; i < formalType.ConstructedInfo.GenericArguments.Length; ++i)
            {
                bool inferenceSuccessful = Infer(
                    formalType.ConstructedInfo.GenericArguments[i],
                    constructedActualType.ConstructedInfo.GenericArguments[i],
                    Inference.Exact); // Generic arguments must match exactly, no variance allowed

                if (!inferenceSuccessful) return false;
            }
            return true;
        }