Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename public API based on API review decision #73476

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1909,7 +1909,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 @@ -1953,7 +1953,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 @@ -1985,7 +1985,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 @@ -2080,7 +2080,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 @@ -2127,7 +2127,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 @@ -2250,7 +2250,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 @@ -2374,9 +2374,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 @@ -2436,15 +2436,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 @@ -2559,7 +2559,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 @@ -2592,7 +2592,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 @@ -3819,7 +3819,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 @@ -4424,7 +4424,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
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,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 @@ -8673,7 +8673,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 @@ -3570,28 +3570,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 @@ -1100,7 +1100,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 @@ -1585,7 +1585,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 @@ -1604,7 +1604,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