public ItemAsTypeParameterType ( int i ) : Microsoft.CSharp.RuntimeBinder.Semantics.TypeParameterType | ||
i | int | |
return | Microsoft.CSharp.RuntimeBinder.Semantics.TypeParameterType |
public TypeArray typeVars; // All the type variables for a generic method, as declarations. // If there is a type variable in the method which is used in no parameter, // then inference must fail. Since this is expensive to check, we cache // the result of the first call. public bool InferenceMustFail() { if (checkedInfMustFail) { return(inferenceMustFail); } Debug.Assert(!inferenceMustFail); checkedInfMustFail = true; for (int ivar = 0; ivar < typeVars.Size; ivar++) { TypeParameterType var = typeVars.ItemAsTypeParameterType(ivar); // See if type var is used in a parameter. for (int ipar = 0; ; ipar++) { if (ipar >= Params.Size) { // This type variable is not in any parameter. inferenceMustFail = true; return(true); } if (TypeManager.TypeContainsType(Params.Item(ipar), var)) { break; } } } // All type variables are used in a parameter. return(false); }
//////////////////////////////////////////////////////////////////////////////// // Check whether typeArgs satisfies the constraints of typeVars. The // typeArgsCls and typeArgsMeth are used for substitution on the bounds. The // tree and symErr are used for error reporting. private static bool CheckConstraintsCore(CSemanticChecker checker, ErrorHandling errHandling, Symbol symErr, TypeArray typeVars, TypeArray typeArgs, TypeArray typeArgsCls, TypeArray typeArgsMeth, CheckConstraintsFlags flags) { Debug.Assert(typeVars.Count == typeArgs.Count); Debug.Assert(typeVars.Count > 0); Debug.Assert(flags == CheckConstraintsFlags.None || flags == CheckConstraintsFlags.NoErrors); bool fError = false; for (int i = 0; i < typeVars.Count; i++) { // Empty bounds should be set to object. TypeParameterType var = typeVars.ItemAsTypeParameterType(i); CType arg = typeArgs[i]; bool fOK = CheckSingleConstraint(checker, errHandling, symErr, var, arg, typeArgsCls, typeArgsMeth, flags); fError |= !fOK; } return(!fError); }
//////////////////////////////////////////////////////////////////////////////// // Check whether typeArgs satisfies the constraints of typeVars. The // typeArgsCls and typeArgsMeth are used for substitution on the bounds. The // tree and symErr are used for error reporting. private static bool CheckConstraintsCore(CSemanticChecker checker, ErrorHandling errHandling, Symbol symErr, TypeArray typeVars, TypeArray typeArgs, TypeArray typeArgsCls, TypeArray typeArgsMeth, CheckConstraintsFlags flags) { Debug.Assert(typeVars.size == typeArgs.size); Debug.Assert(typeVars.size > 0); Debug.Assert(flags == CheckConstraintsFlags.None || flags == CheckConstraintsFlags.NoErrors); bool fError = false; for (int i = 0; i < typeVars.size; i++) { // Empty bounds should be set to object. TypeParameterType var = typeVars.ItemAsTypeParameterType(i); CType arg = typeArgs.Item(i); bool fOK = CheckSingleConstraint(checker, errHandling, symErr, var, arg, typeArgsCls, typeArgsMeth, flags); fError |= !fOK; } return !fError; }