Skip to content

Commit

Permalink
Rename public API based on API review decision (#73476)
Browse files Browse the repository at this point in the history
Closes #73330
  • Loading branch information
AlekseyTs authored May 15, 2024
1 parent f241b48 commit 7ba14d7
Show file tree
Hide file tree
Showing 73 changed files with 208 additions and 208 deletions.
30 changes: 15 additions & 15 deletions src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private readonly struct MixableDestination

internal MixableDestination(ParameterSymbol parameter, BoundExpression argument)
{
Debug.Assert(parameter.RefKind.IsWritableReference() && parameter.Type.IsRefLikeTypeOrAllowsByRefLike());
Debug.Assert(parameter.RefKind.IsWritableReference() && parameter.Type.IsRefLikeOrAllowsRefLikeType());
Debug.Assert(GetParameterValEscapeLevel(parameter).HasValue);
Argument = argument;
Parameter = parameter;
Expand Down Expand Up @@ -1897,7 +1897,7 @@ bool isRefEscape
}

// check receiver if ref-like
if (receiver?.Type?.IsRefLikeTypeOrAllowsByRefLike() == true)
if (receiver?.Type?.IsRefLikeOrAllowsRefLikeType() == true)
{
escapeScope = Math.Max(escapeScope, GetValEscape(receiver, scopeOfTheContainingExpression));
}
Expand Down Expand Up @@ -1941,7 +1941,7 @@ private uint GetInvocationEscapeWithUpdatedRules(
//
if (!returnsRefToRefStruct
|| ((param is null ||
(param is { RefKind: not RefKind.None, Type: { } type } && type.IsRefLikeTypeOrAllowsByRefLike())) &&
(param is { RefKind: not RefKind.None, Type: { } type } && type.IsRefLikeOrAllowsRefLikeType())) &&
isArgumentRefEscape == isRefEscape))
{
uint argEscape = isArgumentRefEscape ?
Expand Down Expand Up @@ -1973,7 +1973,7 @@ private static bool ReturnsRefToRefStruct(Symbol symbol)
};

return method is { RefKind: not RefKind.None, ReturnType: { } returnType } &&
returnType.IsRefLikeTypeOrAllowsByRefLike();
returnType.IsRefLikeOrAllowsRefLikeType();
}

/// <summary>
Expand Down Expand Up @@ -2068,7 +2068,7 @@ bool isRefEscape
}

// check receiver if ref-like
if (receiver?.Type?.IsRefLikeTypeOrAllowsByRefLike() == true)
if (receiver?.Type?.IsRefLikeOrAllowsRefLikeType() == true)
{
return CheckValEscape(receiver.Syntax, receiver, escapeFrom, escapeTo, false, diagnostics);
}
Expand Down Expand Up @@ -2115,7 +2115,7 @@ private bool CheckInvocationEscapeWithUpdatedRules(
//
if (!returnsRefToRefStruct
|| ((param is null ||
(param is { RefKind: not RefKind.None, Type: { } type } && type.IsRefLikeTypeOrAllowsByRefLike())) &&
(param is { RefKind: not RefKind.None, Type: { } type } && type.IsRefLikeOrAllowsRefLikeType())) &&
isArgumentRefEscape == isRefEscape))
{
bool valid = isArgumentRefEscape ?
Expand Down Expand Up @@ -2238,7 +2238,7 @@ private void GetInvocationArgumentsForEscape(

static bool isMixableParameter([NotNullWhen(true)] ParameterSymbol? parameter) =>
parameter is not null &&
parameter.Type.IsRefLikeTypeOrAllowsByRefLike() &&
parameter.Type.IsRefLikeOrAllowsRefLikeType() &&
parameter.RefKind.IsWritableReference();

static bool isMixableArgument(BoundExpression argument)
Expand Down Expand Up @@ -2362,9 +2362,9 @@ static bool hasRefLikeReturn(Symbol symbol)
return method.ContainingType.IsRefLikeType;
}

return method.ReturnType.IsRefLikeTypeOrAllowsByRefLike();
return method.ReturnType.IsRefLikeOrAllowsRefLikeType();
case PropertySymbol property:
return property.Type.IsRefLikeTypeOrAllowsByRefLike();
return property.Type.IsRefLikeOrAllowsRefLikeType();
default:
return false;
}
Expand Down Expand Up @@ -2424,15 +2424,15 @@ private void GetEscapeValuesForUpdatedRules(
escapeValues.Add(new EscapeValue(parameter: null, argument, EscapeLevel.ReturnOnly, isRefEscape: true));
}

if (argument.Type?.IsRefLikeTypeOrAllowsByRefLike() == true)
if (argument.Type?.IsRefLikeOrAllowsRefLikeType() == true)
{
escapeValues.Add(new EscapeValue(parameter: null, argument, EscapeLevel.CallingMethod, isRefEscape: false));
}

continue;
}

if (parameter.Type.IsRefLikeTypeOrAllowsByRefLike() && parameter.RefKind != RefKind.Out && GetParameterValEscapeLevel(parameter) is { } valEscapeLevel)
if (parameter.Type.IsRefLikeOrAllowsRefLikeType() && parameter.RefKind != RefKind.Out && GetParameterValEscapeLevel(parameter) is { } valEscapeLevel)
{
escapeValues.Add(new EscapeValue(parameter, argument, valEscapeLevel, isRefEscape: false));
}
Expand Down Expand Up @@ -2547,7 +2547,7 @@ private bool CheckInvocationArgMixing(

// collect all writeable ref-like arguments, including receiver
var receiverType = receiverOpt?.Type;
if (receiverType?.IsRefLikeTypeOrAllowsByRefLike() == true && !IsReceiverRefReadOnly(symbol))
if (receiverType?.IsRefLikeOrAllowsRefLikeType() == true && !IsReceiverRefReadOnly(symbol))
{
// PROTOTYPE(RefStructInterfaces): We do not have a test that demonstrates that the statement below makes a difference.
// If it is commented out, not a single test fails
Expand Down Expand Up @@ -2580,7 +2580,7 @@ private bool CheckInvocationArgMixing(

if (refKind.IsWritableReference()
&& !argument.IsDiscardExpression()
&& argument.Type?.IsRefLikeTypeOrAllowsByRefLike() == true)
&& argument.Type?.IsRefLikeOrAllowsRefLikeType() == true)
{
escapeTo = Math.Min(escapeTo, GetValEscape(argument, scopeOfTheContainingExpression));
}
Expand Down Expand Up @@ -3807,7 +3807,7 @@ internal uint GetValEscape(BoundExpression expr, uint scopeOfTheContainingExpres
}

// to have local-referring values an expression must have a ref-like type
if (expr.Type?.IsRefLikeTypeOrAllowsByRefLike() != true)
if (expr.Type?.IsRefLikeOrAllowsRefLikeType() != true)
{
return CallingMethodScope;
}
Expand Down Expand Up @@ -4412,7 +4412,7 @@ internal bool CheckValEscape(SyntaxNode node, BoundExpression expr, uint escapeF
}

// to have local-referring values an expression must have a ref-like type
if (expr.Type?.IsRefLikeTypeOrAllowsByRefLike() != true)
if (expr.Type?.IsRefLikeOrAllowsRefLikeType() != true)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ private BoundExpression BindDeconstructionVariable(
}

if (declTypeWithAnnotations.HasType &&
localSymbol.Scope == ScopedKind.ScopedValue && !declTypeWithAnnotations.Type.IsErrorTypeOrIsRefLikeTypeOrAllowsByRefLike())
localSymbol.Scope == ScopedKind.ScopedValue && !declTypeWithAnnotations.Type.IsErrorOrRefLikeOrAllowsRefLikeType())
{
diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@ private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, Bind
}
else
{
Debug.Assert(parameter.Type.IsRefLikeTypeOrAllowsByRefLike());
Debug.Assert(parameter.Type.IsRefLikeOrAllowsRefLikeType());
Error(diagnostics, ErrorCode.ERR_AnonDelegateCantUseRefLike, node, parameter.Name);
}
}
Expand All @@ -2069,7 +2069,7 @@ private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, Bind
}
else
{
Debug.Assert(parameter.Type.IsRefLikeTypeOrAllowsByRefLike());
Debug.Assert(parameter.Type.IsRefLikeOrAllowsRefLikeType());
Error(diagnostics, ErrorCode.ERR_UnsupportedPrimaryConstructorParameterCapturingRefLike, node, parameter.Name);
}
}
Expand Down Expand Up @@ -3126,7 +3126,7 @@ private BoundExpression BindOutVariableDeclarationArgument(

CheckRestrictedTypeInAsyncMethod(this.ContainingMemberOrLambda, declType.Type, diagnostics, typeSyntax);

if (localSymbol.Scope == ScopedKind.ScopedValue && !declType.Type.IsErrorTypeOrIsRefLikeTypeOrAllowsByRefLike())
if (localSymbol.Scope == ScopedKind.ScopedValue && !declType.Type.IsErrorOrRefLikeOrAllowsRefLikeType())
{
diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
}
Expand Down Expand Up @@ -8621,7 +8621,7 @@ private void CheckReceiverAndRuntimeSupportForSymbolAccess(SyntaxNode node, Boun
}
}

if (receiverOpt is { Type: TypeParameterSymbol { AllowsByRefLike: true } } &&
if (receiverOpt is { Type: TypeParameterSymbol { AllowsRefLikeType: true } } &&
isNotImplementableInstanceMember(symbol))
{
Error(diagnostics, ErrorCode.ERR_BadNonVirtualInterfaceMemberAccessOnAllowsRefLike, node);
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/Binder_Operators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3515,28 +3515,28 @@ internal static ConstantValue GetIsOperatorConstantResult(
// a restricted type cannot be boxed or unboxed into.
if (targetType.IsRestrictedType() || operandType.IsRestrictedType())
{
if (targetType is TypeParameterSymbol { AllowsByRefLike: true })
if (targetType is TypeParameterSymbol { AllowsRefLikeType: true })
{
if (!operandType.IsRefLikeType && operandType is not TypeParameterSymbol)
{
return null;
}
}
else if (operandType is not TypeParameterSymbol { AllowsByRefLike: true })
else if (operandType is not TypeParameterSymbol { AllowsRefLikeType: true })
{
if (targetType.IsRefLikeType)
{
if (operandType is TypeParameterSymbol)
{
Debug.Assert(operandType is TypeParameterSymbol { AllowsByRefLike: false });
Debug.Assert(operandType is TypeParameterSymbol { AllowsRefLikeType: false });
return ConstantValue.False;
}
}
else if (operandType.IsRefLikeType)
{
if (targetType is TypeParameterSymbol)
{
Debug.Assert(targetType is TypeParameterSymbol { AllowsByRefLike: false });
Debug.Assert(targetType is TypeParameterSymbol { AllowsRefLikeType: false });
return ConstantValue.False;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ protected BoundLocalDeclaration BindVariableDeclaration(

CheckRestrictedTypeInAsyncMethod(this.ContainingMemberOrLambda, declTypeOpt.Type, localDiagnostics, typeSyntax);

if (localSymbol.Scope == ScopedKind.ScopedValue && !declTypeOpt.Type.IsErrorTypeOrIsRefLikeTypeOrAllowsByRefLike())
if (localSymbol.Scope == ScopedKind.ScopedValue && !declTypeOpt.Type.IsErrorOrRefLikeOrAllowsRefLikeType())
{
localDiagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
}
Expand Down Expand Up @@ -1581,7 +1581,7 @@ private void ValidateAssignment(
leftEscape = GetValEscape(op1, _localScopeDepth);
rightEscape = GetValEscape(op2, _localScopeDepth);

Debug.Assert(leftEscape == rightEscape || op1.Type.IsRefLikeTypeOrAllowsByRefLike());
Debug.Assert(leftEscape == rightEscape || op1.Type.IsRefLikeOrAllowsRefLikeType());

// We only check if the safe-to-escape of e2 is wider than the safe-to-escape of e1 here,
// we don't check for equality. The case where the safe-to-escape of e2 is narrower than
Expand All @@ -1600,7 +1600,7 @@ private void ValidateAssignment(
}
}

if (!hasErrors && op1.Type.IsRefLikeTypeOrAllowsByRefLike())
if (!hasErrors && op1.Type.IsRefLikeOrAllowsRefLikeType())
{
var leftEscape = GetValEscape(op1, _localScopeDepth);
ValidateEscape(op2, leftEscape, isByRef: false, diagnostics);
Expand Down
6 changes: 3 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private BoundForEachStatement BindForEachPartsWorker(BindingDiagnosticBag diagno

CheckRestrictedTypeInAsyncMethod(this.ContainingMemberOrLambda, declType.Type, diagnostics, typeSyntax);

if (local.Scope == ScopedKind.ScopedValue && !declType.Type.IsErrorTypeOrIsRefLikeTypeOrAllowsByRefLike())
if (local.Scope == ScopedKind.ScopedValue && !declType.Type.IsErrorOrRefLikeOrAllowsRefLikeType())
{
diagnostics.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly, typeSyntax.Location);
}
Expand Down Expand Up @@ -1066,7 +1066,7 @@ private EnumeratorResult SatisfiesIEnumerableInterfaces(SyntaxNode collectionSyn

NamedTypeSymbol collectionType = (NamedTypeSymbol)builder.CollectionType;

if (unwrappedCollectionExprType.IsRefLikeTypeOrAllowsByRefLike())
if (unwrappedCollectionExprType.IsRefLikeOrAllowsRefLikeType())
{
builder.CollectionType = unwrappedCollectionExprType;
}
Expand Down Expand Up @@ -1241,7 +1241,7 @@ private void GetDisposalInfoForEnumerator(SyntaxNode syntax, ref ForEachEnumerat
{
Debug.Assert(!enumeratorType.IsRefLikeType); // Ref like types are supposed to be structs, therefore, sealed.

if (enumeratorType is TypeParameterSymbol { AllowsByRefLike: true })
if (enumeratorType is TypeParameterSymbol { AllowsRefLikeType: true })
{
Error(diagnostics, ErrorCode.ERR_BadAllowByRefLikeEnumerator, expr.Syntax, enumeratorType);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/CSharp/Portable/Binder/RefSafetyAnalysis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ private void RemoveLocalScopes(LocalSymbol local)
Debug.Assert(localSymbol.RefKind == RefKind.None ||
refEscapeScope >= GetRefEscape(initializer, _localScopeDepth));

if (node.DeclaredTypeOpt?.Type.IsRefLikeTypeOrAllowsByRefLike() == true)
if (node.DeclaredTypeOpt?.Type.IsRefLikeOrAllowsRefLikeType() == true)
{
ValidateEscape(initializer, valEscapeScope, isByRef: false, _diagnostics);
}
Expand Down Expand Up @@ -580,7 +580,7 @@ static uint getDeclarationValEscape(BoundTypeExpression typeExpression, uint val
{
// PROTOTYPE(RefStructInterfaces): We do not have a test that demonstrates the statement below makes a difference
// for ref like types. If 'CallingMethodScope' is always returned, not a single test fails.
return typeExpression.Type.IsRefLikeTypeOrAllowsByRefLike() ? valEscape : CallingMethodScope;
return typeExpression.Type.IsRefLikeOrAllowsRefLikeType() ? valEscape : CallingMethodScope;
}
}

Expand All @@ -605,7 +605,7 @@ static uint getPositionalValEscape(Symbol? symbol, uint valEscape)
{
return symbol is null
? valEscape
: symbol.GetTypeOrReturnType().IsRefLikeTypeOrAllowsByRefLike() ? valEscape : CallingMethodScope;
: symbol.GetTypeOrReturnType().IsRefLikeOrAllowsRefLikeType() ? valEscape : CallingMethodScope;
}
}

Expand All @@ -618,7 +618,7 @@ static uint getMemberValEscape(BoundPropertySubpatternMember? member, uint valEs
{
if (member is null) return valEscape;
valEscape = getMemberValEscape(member.Receiver, valEscape);
return member.Type.IsRefLikeTypeOrAllowsByRefLike() ? valEscape : CallingMethodScope;
return member.Type.IsRefLikeOrAllowsRefLikeType() ? valEscape : CallingMethodScope;
}
}

Expand Down
Loading

0 comments on commit 7ba14d7

Please sign in to comment.