未验证 提交 fd533406 编写于 作者: M msftbot[bot] 提交者: GitHub

Merge pull request #48191 from dotnet/merges/release/dev16.8-to-master

Merge release/dev16.8 to master
......@@ -1220,6 +1220,7 @@ private Conversion ClassifyExplicitOnlyConversionFromExpression(BoundExpression
return GetExplicitUserDefinedConversion(sourceExpression, sourceType, destination, ref useSiteDiagnostics);
}
#nullable enable
private static bool HasImplicitEnumerationConversion(BoundExpression source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
......@@ -1241,9 +1242,11 @@ private static bool HasImplicitEnumerationConversion(BoundExpression source, Typ
var sourceConstantValue = source.ConstantValue;
return sourceConstantValue != null &&
IsNumericType(source.Type.GetSpecialTypeSafe()) &&
source.Type is object &&
IsNumericType(source.Type) &&
IsConstantNumericZero(sourceConstantValue);
}
#nullable disable
private static LambdaConversionResult IsAnonymousFunctionCompatibleWithDelegate(UnboundLambda anonymousFunction, TypeSymbol type)
{
......@@ -1787,6 +1790,7 @@ private static int GetNumericTypeIndex(SpecialType specialType)
}
}
#nullable enable
private static bool HasImplicitNumericConversion(TypeSymbol source, TypeSymbol destination)
{
Debug.Assert((object)source != null);
......@@ -1829,7 +1833,7 @@ private static bool HasExplicitNumericConversion(TypeSymbol source, TypeSymbol d
return s_explicitNumericConversions[sourceIndex, destinationIndex];
}
public static bool IsConstantNumericZero(ConstantValue value)
private static bool IsConstantNumericZero(ConstantValue value)
{
switch (value.Discriminator)
{
......@@ -1840,12 +1844,14 @@ public static bool IsConstantNumericZero(ConstantValue value)
case ConstantValueTypeDiscriminator.Int16:
return value.Int16Value == 0;
case ConstantValueTypeDiscriminator.Int32:
case ConstantValueTypeDiscriminator.NInt:
return value.Int32Value == 0;
case ConstantValueTypeDiscriminator.Int64:
return value.Int64Value == 0;
case ConstantValueTypeDiscriminator.UInt16:
return value.UInt16Value == 0;
case ConstantValueTypeDiscriminator.UInt32:
case ConstantValueTypeDiscriminator.NUInt:
return value.UInt32Value == 0;
case ConstantValueTypeDiscriminator.UInt64:
return value.UInt64Value == 0;
......@@ -1858,9 +1864,9 @@ public static bool IsConstantNumericZero(ConstantValue value)
return false;
}
public static bool IsNumericType(SpecialType specialType)
private static bool IsNumericType(TypeSymbol type)
{
switch (specialType)
switch (type.SpecialType)
{
case SpecialType.System_Char:
case SpecialType.System_SByte:
......@@ -1874,6 +1880,8 @@ public static bool IsNumericType(SpecialType specialType)
case SpecialType.System_Single:
case SpecialType.System_Double:
case SpecialType.System_Decimal:
case SpecialType.System_IntPtr when type.IsNativeIntegerType:
case SpecialType.System_UIntPtr when type.IsNativeIntegerType:
return true;
default:
return false;
......@@ -1972,16 +1980,16 @@ private static bool HasExplicitEnumerationConversion(TypeSymbol source, TypeSymb
Debug.Assert((object)destination != null);
// SPEC: The explicit enumeration conversions are:
// SPEC: From sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or decimal to any enum-type.
// SPEC: From any enum-type to sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, or decimal.
// SPEC: From sbyte, byte, short, ushort, int, uint, long, ulong, nint, nuint, char, float, double, or decimal to any enum-type.
// SPEC: From any enum-type to sbyte, byte, short, ushort, int, uint, long, ulong, nint, nuint, char, float, double, or decimal.
// SPEC: From any enum-type to any other enum-type.
if (IsNumericType(source.SpecialType) && destination.IsEnumType())
if (IsNumericType(source) && destination.IsEnumType())
{
return true;
}
if (IsNumericType(destination.SpecialType) && source.IsEnumType())
if (IsNumericType(destination) && source.IsEnumType())
{
return true;
}
......@@ -1993,6 +2001,7 @@ private static bool HasExplicitEnumerationConversion(TypeSymbol source, TypeSymb
return false;
}
#nullable disable
private Conversion ClassifyImplicitNullableConversion(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
......
......@@ -240,8 +240,8 @@ internal static bool ContainsOnlyEmptyConstraintClauses(this ImmutableArray<Type
}
// Returns true if constraintClauses was updated with value.
// Returns false if constraintClauses already had a value with expected 'IgnoresNullableContext'
// or was updated to a value with the expected 'IgnoresNullableContext' value on another thread.
// Returns false if constraintClauses already had a value with sufficient 'IgnoresNullableContext'
// or was updated to a value with sufficient 'IgnoresNullableContext' on another thread.
internal static bool InterlockedUpdate(ref ImmutableArray<TypeParameterConstraintClause> constraintClauses, ImmutableArray<TypeParameterConstraintClause> value)
{
bool canIgnoreNullableContext = value.IgnoresNullableContext();
......
......@@ -96,8 +96,8 @@ internal static bool HasValue(this TypeParameterBounds? boundsOpt, bool canIgnor
}
// Returns true if bounds was updated with value.
// Returns false if bounds already had a value with expected 'IgnoresNullableContext'
// or was updated to a value with the expected 'IgnoresNullableContext' value on another thread.
// Returns false if bounds already had a value with sufficient 'IgnoresNullableContext'
// or was updated to a value with sufficient 'IgnoresNullableContext' on another thread.
internal static bool InterlockedUpdate(ref TypeParameterBounds? bounds, TypeParameterBounds? value)
{
bool canIgnoreNullableContext = (value?.IgnoresNullableContext == true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册