未验证 提交 eba60b41 编写于 作者: A AlekseyTs 提交者: GitHub

Cleanup prototype comments in Symbols (#30055)

上级 c187f454
......@@ -216,7 +216,7 @@ internal virtual Symbol ContainingMemberOrLambda
/// <summary>
/// Are we in a context where un-annotated types should be interpreted as non-null?
/// </summary>
internal Symbol NonNullTypesContext => ContainingMember();
internal Symbol NonNullTypesContext => ContainingMember().OriginalDefinition;
/// <summary>
/// Is the contained code within a member method body?
......
......@@ -663,7 +663,7 @@ internal BaseMethodWrapperSymbol(NamedTypeSymbol containingType, MethodSymbol me
}
else
{
typeMap = typeMap.WithAlphaRename(methodBeingWrapped, this, nonNullTypesContext: methodBeingWrapped, out typeParameters);
typeMap = typeMap.WithAlphaRename(methodBeingWrapped, this, nonNullTypesContext: NonNullTypesTrueContext.Instance, out typeParameters);
}
AssignTypeMapAndTypeParameters(typeMap, typeParameters);
......
......@@ -125,7 +125,7 @@ internal TypeSymbolWithAnnotations SubstituteType(TypeSymbol previous)
break;
}
// PROTOTYPE(NullableReferenceTypes): we're dropping annotation and context
// https://github.com/dotnet/roslyn/issues/30072: we're dropping annotation and context
return TypeSymbolWithAnnotations.Create(result);
}
......
......@@ -72,7 +72,7 @@ internal static string MakeMethodKey(PEMethodSymbol method, ParamInfo<TypeSymbol
builder.Append(')');
return pooledBuilder.ToStringAndFree();
// PROTOTYPE(NullableReferenceTypes): Many cases are not yet handled
// https://github.com/dotnet/roslyn/issues/29821: Many cases are not yet handled
// generic type args
// ref kind
// 'this'
......@@ -113,7 +113,7 @@ internal static string MakeMethodKey(MethodSymbol method)
builder.Append(')');
return pooledBuilder.ToStringAndFree();
// PROTOTYPE(NullableReferenceTypes): Many cases are not yet handled
// https://github.com/dotnet/roslyn/issues/29821: Many cases are not yet handled
// generic type args
// ref kind
// 'this'
......
......@@ -223,7 +223,7 @@ private static bool MethodSymbolMatchesParamInfo(MethodSymbol candidateMethod, P
// IndexedTypeParameterSymbol is not going to be exposed anywhere,
// so we'll cheat and use it here for comparison purposes.
TypeMap candidateMethodTypeMap = new TypeMap(
nonNullTypesContext: candidateMethod,
nonNullTypesContext: NonNullTypesFalseContext.Instance, // The NonNullType context doesn't really matter here, because nullability of reference types is not considered for the purpose of the method.
candidateMethod.TypeParameters,
IndexedTypeParameterSymbol.Take(candidateMethod.Arity), true);
......
......@@ -30,7 +30,6 @@ internal static TypeSymbolWithAnnotations TransformType(TypeSymbolWithAnnotation
{
int position = 0;
TypeSymbolWithAnnotations result;
// PROTOTYPE(NullableReferenceTypes): handle NonNullTypesContext from metadata
if (metadataType.ApplyNullableTransforms(nullableTransformFlags, metadataType.NonNullTypesContext, ref position, out result) &&
(nullableTransformFlags.IsDefault || position == nullableTransformFlags.Length))
{
......
......@@ -218,8 +218,6 @@ private void EnsureSignatureIsLoaded()
// Decode nullable before tuple types to avoid converting between
// NamedTypeSymbol and TupleTypeSymbol unnecessarily.
// PROTOTYPE(NullableReferenceTypes): Avoid setting IsNullable in TypeSymbolWithAnnotations.Create
// only to undo that in TransformOrEraseNullability. Same comment applies to other uses of TransformOrEraseNullability.
type = NullableTypeDecoder.TransformType(type, _handle, moduleSymbol);
type = TupleTypeDecoder.DecodeTupleTypesIfApplicable(type, _handle, moduleSymbol);
......
......@@ -650,7 +650,6 @@ internal override FlowAnalysisAnnotations FlowAnalysisAnnotations
const WellKnownAttributeFlags assertsTrue = WellKnownAttributeFlags.AssertsTrue;
const WellKnownAttributeFlags assertsFalse = WellKnownAttributeFlags.AssertsFalse;
// PROTOTYPE(NullableReferenceTypes): the flags could be packed more
if (!_packedFlags.TryGetWellKnownAttribute(notNullWhenTrue, out bool hasNotNullWhenTrue) ||
!_packedFlags.TryGetWellKnownAttribute(notNullWhenFalse, out bool hasNotNullWhenFalse) ||
!_packedFlags.TryGetWellKnownAttribute(assertsTrue, out bool hasAssertsTrue) ||
......
......@@ -683,7 +683,7 @@ internal override bool MustCallMethodsDirectly
var ordinal = i - 1;
bool isBad;
// PROTOTYPE(NullableReferenceTypes): handle extra annotations
// https://github.com/dotnet/roslyn/issues/29821: handle extra annotations
parameters[ordinal] = PEParameterSymbol.Create(moduleSymbol, property, isPropertyVirtual, ordinal, paramHandle, propertyParam, extraAnnotations: default, out isBad);
if (isBad)
......
......@@ -206,7 +206,7 @@ private ImmutableArray<TypeSymbolWithAnnotations> GetDeclaredConstraintTypes()
}
}
// PROTOTYPE(NullableReferenceTypes): Test different [NonNullTypes] on method and containing type.
// https://github.com/dotnet/roslyn/issues/30075: Test different [NonNullTypes] on method and containing type.
var type = TypeSymbolWithAnnotations.Create(this, typeSymbol);
type = NullableTypeDecoder.TransformType(type, constraintHandle, moduleSymbol);
......@@ -382,7 +382,7 @@ public override ImmutableArray<CSharpAttributeData> GetAttributes()
private TypeParameterBounds GetBounds(ConsList<TypeParameterSymbol> inProgress, bool early)
{
// PROTOTYPE(NullableReferenceTypes): Re-enable asserts.
// https://github.com/dotnet/roslyn/issues/30081: Re-enable asserts.
//Debug.Assert(!inProgress.ContainsReference(this));
//Debug.Assert(!inProgress.Any() || ReferenceEquals(inProgress.Head.ContainingSymbol, this.ContainingSymbol));
......
......@@ -749,7 +749,7 @@ public MethodSymbol Construct(params TypeSymbol[] typeArguments)
return this.Construct(ImmutableArray.Create(typeArguments));
}
// PROTOTYPE(NullableReferenceTypes): Replace with Construct(ImmutableArray<TypeSymbolWithAnnotations>).
// https://github.com/dotnet/roslyn/issues/30071: Replace with Construct(ImmutableArray<TypeSymbolWithAnnotations>).
/// <summary>
/// Apply type substitution to a generic method to create an method symbol with the given type parameters supplied.
/// </summary>
......
......@@ -843,7 +843,7 @@ internal override TypeSymbol SetUnknownNullabilityForReferenceTypes()
/// parameters in the type.</param>
public NamedTypeSymbol Construct(params TypeSymbol[] typeArguments)
{
// PROTOTYPE(NullableReferenceTypes): We should fix the callers to pass an explicit context.
// https://github.com/dotnet/roslyn/issues/30064: We should fix the callers to pass an explicit context.
return ConstructWithoutModifiers(typeArguments.AsImmutableOrNull(), false, NonNullTypesFalseContext.Instance);
}
......@@ -865,7 +865,7 @@ public NamedTypeSymbol Construct(INonNullTypesContext nonNullTypesContext, param
/// parameters in the type.</param>
public NamedTypeSymbol Construct(ImmutableArray<TypeSymbol> typeArguments, INonNullTypesContext nonNullTypesContext = null)
{
// PROTOTYPE(NullableReferenceTypes): We should fix the callers to pass an explicit context.
// https://github.com/dotnet/roslyn/issues/30064: We should fix the callers to pass an explicit context.
return ConstructWithoutModifiers(typeArguments, false, nonNullTypesContext ?? NonNullTypesFalseContext.Instance);
}
......@@ -875,7 +875,7 @@ public NamedTypeSymbol Construct(ImmutableArray<TypeSymbol> typeArguments, INonN
/// <param name="typeArguments"></param>
public NamedTypeSymbol Construct(IEnumerable<TypeSymbol> typeArguments)
{
// PROTOTYPE(NullableReferenceTypes): We should fix the callers to pass an explicit context.
// https://github.com/dotnet/roslyn/issues/30064: We should fix the callers to pass an explicit context.
return ConstructWithoutModifiers(typeArguments.AsImmutableOrNull(), false, NonNullTypesFalseContext.Instance);
}
......@@ -1053,7 +1053,7 @@ internal int AllTypeArgumentCount()
internal ImmutableArray<TypeSymbolWithAnnotations> GetTypeParametersAsTypeArguments()
{
// PROTOTYPE(NullableReferenceTypes): Set IsNullable=null always, even in C#8,
// https://github.com/dotnet/roslyn/issues/30068: Set IsNullable=null always, even in C#8,
// and set TypeSymbolWithAnnotations.WithCustomModifiers.Is() => false.
return this.TypeParameters.SelectAsArray((typeParameter, module) => TypeSymbolWithAnnotations.Create(nonNullTypesContext: module, typeParameter), ContainingModule);
}
......
......@@ -90,7 +90,7 @@ internal static TypeSymbol CopyTypeCustomModifiers(TypeSymbol sourceType, TypeSy
}
// Preserve nullable modifiers as well.
// PROTOTYPE(NullableReferenceTypes): Is it reasonable to copy annotations from the source?
// https://github.com/dotnet/roslyn/issues/30077: Is it reasonable to copy annotations from the source?
// If the destination had some of those annotations but not all, then clearly the destination
// was incorrect. Or if the destination is C#7, then the destination will advertise annotations
// that the author did not write and did not validate.
......
......@@ -134,7 +134,7 @@ internal override FlowAnalysisAnnotations FlowAnalysisAnnotations
FlowAnalysisAnnotations? annotations = TryGetExtraAttributeAnnotations();
if (annotations.HasValue)
{
// PROTOTYPE(NullableReferenceTypes): Make sure this is covered by test
// https://github.com/dotnet/roslyn/issues/30078: Make sure this is covered by test
return annotations.Value;
}
......
......@@ -50,7 +50,7 @@ protected void InitializeParameters(ImmutableArray<ParameterSymbol> parameters)
// reuse types to avoid reporting duplicate errors if missing:
var voidType = TypeSymbolWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Void, diagnostics, syntax));
// PROTOTYPE(NullableReferenceTypes): Should the 'object' parameter be considered nullable?
// https://github.com/dotnet/roslyn/issues/30079: Should the 'object' parameter be considered nullable?
var objectType = TypeSymbolWithAnnotations.Create(nonNullTypesContext: delegateType, binder.GetSpecialType(SpecialType.System_Object, diagnostics, syntax));
var intPtrType = TypeSymbolWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_IntPtr, diagnostics, syntax));
......
......@@ -1414,7 +1414,7 @@ protected void AfterMembersChecks(DiagnosticBag diagnostics)
this.DeclaringCompilation.EnsureIsReadOnlyAttributeExists(diagnostics, location, modifyCompilation: true);
}
// PROTOTYPE(NullableReferenceTypes): Report diagnostics for base type and interfaces at more specific locations.
// https://github.com/dotnet/roslyn/issues/30080: Report diagnostics for base type and interfaces at more specific locations.
var baseType = BaseTypeNoUseSiteDiagnostics;
var interfaces = InterfacesNoUseSiteDiagnostics();
if (baseType?.ContainsNullableReferenceTypes() == true ||
......
......@@ -215,7 +215,7 @@ internal override void EnsureAllConstraintsAreResolved(bool early)
private TypeParameterBounds GetBounds(ConsList<TypeParameterSymbol> inProgress, bool early)
{
// PROTOTYPE(NullableReferenceTypes): Re-enable asserts.
// https://github.com/dotnet/roslyn/issues/30081: Re-enable asserts.
//Debug.Assert(!inProgress.ContainsReference(this));
//Debug.Assert(!inProgress.Any() || ReferenceEquals(inProgress.Head.ContainingSymbol, this.ContainingSymbol));
......
......@@ -15,7 +15,7 @@ internal sealed class TypeParameterBounds
{
public static readonly TypeParameterBounds Unset = new TypeParameterBounds();
// PROTOTYPE(NullableReferenceTypes): Add static Create methods and have Create
// https://github.com/dotnet/roslyn/issues/30061: Add static Create methods and have Create
// return an EarlyEmpty singleton instance for the common case of no constraint types.
/// <summary>
......
......@@ -41,7 +41,7 @@ public static bool CanBeConst(this TypeSymbol typeSymbol)
return typeSymbol.IsReferenceType || typeSymbol.IsEnumType() || typeSymbol.SpecialType.CanBeConst();
}
// PROTOTYPE(NullableReferenceTypes): Should probably rename this method to have more specific name.
// https://github.com/dotnet/roslyn/issues/30056: Should probably rename this method to have more specific name.
// At the moment it is used only for Nullable Reference Types feature and
// its implementation is specialized for this feature.
public static bool IsUnconstrainedTypeParameter(this TypeSymbol type)
......@@ -51,7 +51,7 @@ public static bool IsUnconstrainedTypeParameter(this TypeSymbol type)
return false;
}
var typeParameter = (TypeParameterSymbol)type;
// PROTOTYPE(NullableReferenceTypes): Test `where T : unmanaged`. See
// https://github.com/dotnet/roslyn/issues/30056: Test `where T : unmanaged`. See
// UninitializedNonNullableFieldTests.TypeParameterConstraints for instance.
return !typeParameter.IsValueType && !(typeParameter.IsReferenceType && typeParameter.IsNotNullableIfReferenceType == true);
}
......@@ -576,7 +576,7 @@ private static bool IsTypeLessVisibleThan(TypeSymbol type, Symbol sym, ref HashS
/// completes without the predicate returning true for any type, this method returns null.
/// </summary>
public static TypeSymbol VisitType<T>(
// PROTOTYPE(NullableReferenceTypes): If TypeSymbolWithAnnotations
// https://github.com/dotnet/roslyn/issues/30059: If TypeSymbolWithAnnotations
// is a struct, use a single type argument and a single predicate.
this TypeSymbolWithAnnotations typeWithAnnotationsOpt,
TypeSymbol typeOpt,
......
......@@ -148,8 +148,7 @@ private TypeSymbolWithAnnotations(TypeSymbol defaultType, INonNullTypesContext n
internal static TypeSymbolWithAnnotations Create(INonNullTypesContext nonNullTypesContext, TypeSymbol typeSymbol, bool isAnnotated = false, ImmutableArray<CustomModifier> customModifiers = default)
{
Debug.Assert(nonNullTypesContext != null);
// PROTOTYPE(NullableReferenceTypes): Enable the assert below.
//Debug.Assert((nonNullTypesContext as Symbol)?.IsDefinition != false);
Debug.Assert((nonNullTypesContext as Symbol)?.IsDefinition != false);
if (typeSymbol is null)
{
......@@ -164,7 +163,7 @@ internal static TypeSymbolWithAnnotations Create(INonNullTypesContext nonNullTyp
customModifiers.NullToEmpty());
}
// PROTOTYPE(NullableReferenceTypes): Check we are not using this method on type references in
// https://github.com/dotnet/roslyn/issues/30050: Check we are not using this method on type references in
// member signatures visible outside the assembly. Consider overriding, implementing, NoPIA embedding, etc.
/// <summary>
......@@ -269,7 +268,7 @@ public TypeSymbolWithAnnotations SetIsAnnotated(CSharpCompilation compilation)
public TypeSymbol TypeSymbol => _extensions?.GetResolvedType(_defaultType);
public TypeSymbol NullableUnderlyingTypeOrSelf => _extensions.GetNullableUnderlyingTypeOrSelf(_defaultType);
// PROTOTYPE(NullableReferenceTypes): IsNullable depends on IsValueType which
// https://github.com/dotnet/roslyn/issues/30051: IsNullable depends on IsValueType which
// can lead to cycles when IsNullable is queried early. Replace this property with
// the Annotation property that depends on IsAnnotated and NonNullTypes only.
// Should review all the usages of IsNullable outside of NullableWalker.
......@@ -472,13 +471,13 @@ internal TypeSymbolWithAnnotations SubstituteTypeCore(AbstractTypeMap typeMap, b
var newTypeWithModifiers = typeMap.SubstituteType(this.TypeSymbol, withTupleUnification);
bool newIsAnnotated = this.IsAnnotated || newTypeWithModifiers.IsAnnotated;
// PROTOTYPE(NullableReferenceTypes): Can we use Equals instead?
// https://github.com/dotnet/roslyn/issues/30052: Can we use Equals instead?
if (this.TypeSymbolEquals(newTypeWithModifiers, TypeCompareKind.CompareNullableModifiersForReferenceTypes) &&
newTypeWithModifiers.CustomModifiers.IsEmpty &&
newIsAnnotated == this.IsAnnotated &&
newCustomModifiers == this.CustomModifiers)
{
// PROTOTYPE(NullableReferenceTypes): We're dropping newTypeWithModifiers.NonNullTypes!
// https://github.com/dotnet/roslyn/issues/30052: We're dropping newTypeWithModifiers.NonNullTypes!
return this; // substitution had no effect on the type or modifiers
}
......@@ -809,7 +808,7 @@ internal override TypeSymbolWithAnnotations WithNonNullTypesContext(TypeSymbolWi
internal override TypeSymbol AsTypeSymbolOnly(TypeSymbol typeSymbol) => typeSymbol;
// PROTOTYPE(NullableReferenceTypes): Use WithCustomModifiers.Is() => false
// https://github.com/dotnet/roslyn/issues/30054: Use WithCustomModifiers.Is() => false
// and set IsNullable=null always for GetTypeParametersAsTypeArguments.
internal override bool Is(TypeSymbol typeSymbol, TypeParameterSymbol other) =>
typeSymbol.Equals(other, TypeCompareKind.CompareNullableModifiersForReferenceTypes) && _customModifiers.IsEmpty;
......@@ -929,7 +928,7 @@ internal override TypeSymbol AsTypeSymbolOnly(TypeSymbol typeSymbol)
return resolvedType;
}
// PROTOTYPE(NullableReferenceTypes): This implementation looks
// https://github.com/dotnet/roslyn/issues/30054: This implementation looks
// incorrect since a type parameter cannot be Nullable<T>.
internal override bool Is(TypeSymbol typeSymbol, TypeParameterSymbol other)
{
......
......@@ -155,7 +155,7 @@ internal override bool IsCallerMemberName
internal override FlowAnalysisAnnotations FlowAnalysisAnnotations
{
// PROTOTYPE(NullableReferenceTypes): Consider moving to leaf types
// https://github.com/dotnet/roslyn/issues/30073: Consider moving to leaf types
get { return _underlyingParameter.FlowAnalysisAnnotations; }
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册