Skip to content

Commit

Permalink
Move IDS_FeatureRefLocalsReturns out of the parser (#65710)
Browse files Browse the repository at this point in the history
* Move IDS_FeatureFileScopedNamespace check out of the parser

* Move IDS_FeatureExternAlias check out of the parser

* Move IDS_FeatureUsingStatic check out of the parser

* Move IDS_FeatureGlobalUsing check out of the parser

fix

* Move IDS_FeatureNamedArgument check out of the parser

fix

* Move IDS_FeatureAsync check out of the parser

fix

* Move IDS_FeatureStaticClasses check out of the parser

* Move IDS_FeatureReadOnlyStructs check out of the parser

* Move IDS_FeatureDefaultTypeParameterConstraint check out of the parser

fix

* Move IDS_FeatureExpressionBodiedIndexer check out of the parser

* Move IDS_FeatureExpressionBodiedProperty check out of the parser

* Move IDS_FeatureAutoPropertyInitializer check out of the parser

* Move IDS_FeatureOptionalParameter check out of the parser

fix

* Move IDS_FeatureFixedBuffer check out of the parser

* Move IDS_FeatureGenerics check out of the parser

* Move IDS_FeatureStaticLocalFunctions check out of the parser

fix

fix

fix

* Move IDS_FeatureExternLocalFunctions check out of the parser

fix

* Move IDS_FeatureLocalFunctions check out of the parser

fix

* Move IDS_FeatureThrowExpression check out of the parser

fix

fix

* Move IDS_FeaturePatternMatching check out of the parser

fix

fix

fix

fix

fix

fix

* Move IDS_FeatureNullPropagatingOperator check out of the parser

fix

fix

* Move IDS_FeatureNullableReferenceTypes check out of the parser

fix

* Move IDS_FeatureDefault check out of the parser

* Move IDS_FeatureDefaultLiteral check out of the parser

fix

fix

* Move IDS_FeatureAnonymousTypes check out of the parser

* Move IDS_FeatureImplicitObjectCreation check out of the parser

fix

fix

* Move IDS_FeatureRecords check out of the parser

* Move IDS_FeatureDictionaryInitializer check out of the parser

fix

* Move IDS_FeatureImplicitArray check out of the parser

fix

* Move IDS_FeatureStackAllocInitializer check out of the parser

* Move IDS_FeatureAnonDelegates check out of the parser

* Move IDS_FeatureAsync and IDS_FeatureStaticAnonymousFunction check out of the parser

* Move IDS_FeatureLambda check out of the parser

fix

* Move IDS_FeatureQueryExpression check out of the parser

fix

* Move IDS_FeatureRefStructs check out of the parser

* Move IDS_FeatureRecursivePatterns check out of the parser

fix

fix

fix

* Move IDS_FeatureExtendedPropertyPatterns check out of the parser

fix

* Move IDS_FeatureParenthesizedPattern check out of the parser

fix

fix

* Move IDS_FeatureTypePattern check out of the parser

fix

fix

fix

* Move IDS_FeatureRecursivePatterns check out of the parser

fix

* Move IDS_FeatureOrPattern check out of the parser

fix

* Move IDS_FeatureAndPattern check out of the parser

fix

* Move IDS_FeatureRelationalPattern IDS_FeatureNotPattern and check out of the parser

fix

fix

* Move IDS_FeatureTypeVariance check out of the parser

* Remove version check when we're always going to report a parse error anyways

* Move IDS_FeatureFunctionPointers check out of the parser

fix

fix

* Move IDS_FeatureExceptionFilter check out of the parser

fix

fix

* Move IDS_FeatureRefForEach check out of the parser

* Move IDS_FeatureIterators check out of the parser

* Move IDS_FeatureAsync check out of the parser

* Move IDS_FeatureCoalesceAssignmentExpression check out of the parser

fix

* Move IDS_FeaturePatternMatching check out of the parser

* Move IDS_FeatureReadOnlyReferences check out of the parser

* Move IDS_FeatureOutVar check out of the parser

fix

* Move IDS_FeatureRefReassignment check out of the parser

fix

* Remove blank lines

* UPdate comments

* Renames

* Fix errant semicolon

* Fix indentation

* Simplify code

* Fixup change

* Fix

* Move IDS_TopLevelStatements check out of the parser

* Move IDS_FeatureModuleAttrLoc check out of the parser

* Move IDS_FeatureRecordXXX check out of the parser

* Move IDS_FeatureExpressionBodiedXXX check out of the parser

* Move IDS_FeatureStaticAbstractMembersInInterfaces check out of the parser

* Move IDS_FeaturePropertyAccessorMods check out of the parser

* Move IDS_FeatureXXXInitializer check out of the parser

* Simplify

* Simplify

* Simplify

* Lint

* Lint

* Fix test

* FIx tests

* Fix record check

* Unify checks

* Fix speculation

* Restore

* Fix tests

* Remove errant code

* Move modifiers check

* Move IDS_FeaturePartialTypes check out of parser

* Remove unnecessary check

* Move IDS_FeatureReadOnlyMembers checks out of parser

* Move IDS_FeatureGlobalNamespace checks out of parser

* Move IDS_FeatureNullable checks out of parser

* lint

* lint

* invert

* Move IDS_FeatureRefLocalsReturns out of the parser

* Move IDS_FeatureRefLocalsReturns out of the parser

* Move IDS_FeatureTuples out of the parser

* Move IDS_FeatureTuples out of the parser

* Move IDS_FeatureTuples out of the parser

* Fix test

* Update comments

* Simplify

* Simplify

* Clarify code

* Formatting

* Move one more case

* Move one more case

* Fix test

* Update test

* Work on ref-types

* Remove from parser

* Restore

* Simplify

* Add comment

* Update src/Compilers/CSharp/Portable/Syntax/SyntaxNodeExtensions.cs

* Remove redundant lang-version check

* Update src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberFieldSymbol.cs

* Update src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs

Co-authored-by: Rikki Gibson <[email protected]>

* Rename for clarity

* PR feedback

* PR feedback

* Copy paste error

* PR feedback

* No extension

* PR feedback

Co-authored-by: Rikki Gibson <[email protected]>
  • Loading branch information
CyrusNajmabadi and RikkiGibson authored Dec 3, 2022
1 parent ae68c26 commit eebc8b7
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 98 deletions.
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 @@ -761,7 +761,7 @@ private DeconstructionVariable BindDeconstructionVariables(
bool isVar;
bool isConst = false;
AliasSymbol alias;
var declType = BindVariableTypeWithAnnotations(component.Designation, diagnostics, component.Type.SkipScoped(out _).SkipRef(out _), ref isConst, out isVar, out alias);
var declType = BindVariableTypeWithAnnotations(component.Designation, diagnostics, component.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
Debug.Assert(isVar == !declType.HasType);
if (component.Designation.Kind() == SyntaxKind.ParenthesizedVariableDesignation)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ private BoundExpression BindDeclarationExpressionAsError(DeclarationExpressionSy
bool isVar;
bool isConst = false;
AliasSymbol alias;
var declType = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type.SkipScoped(out _).SkipRef(out _), ref isConst, out isVar, out alias);
var declType = BindVariableTypeWithAnnotations(node.Designation, diagnostics, node.Type.SkipScoped(out _).SkipRef(), ref isConst, out isVar, out alias);
Error(diagnostics, ErrorCode.ERR_DeclarationExpressionNotPermitted, node);
return BindDeclarationVariablesForErrorRecovery(declType, node.Designation, node, diagnostics);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ static void checkAttributes(AnonymousFunctionExpressionSyntax syntax, SyntaxList
MessageID.IDS_FeatureLambdaReturnType.CheckFeatureAvailability(diagnostics, syntax);

Debug.Assert(syntax is not ScopedTypeSyntax);
syntax = syntax.SkipScoped(out _).SkipRef(out RefKind refKind);
if ((syntax as IdentifierNameSyntax)?.Identifier.ContextualKind() == SyntaxKind.VarKeyword)
syntax = syntax.SkipScoped(out _).SkipRefInLocalOrReturn(diagnostics, out RefKind refKind);
if (syntax is IdentifierNameSyntax { Identifier.RawContextualKind: (int)SyntaxKind.VarKeyword })
{
diagnostics.Add(ErrorCode.ERR_LambdaExplicitReturnTypeVar, syntax.Location);
}
Expand Down
9 changes: 6 additions & 3 deletions src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,10 @@ private BoundStatement BindDeclarationStatementParts(LocalDeclarationStatementSy
typeSyntax = scopedType.Type;
}

typeSyntax = typeSyntax.SkipRef(out _);
// Slightly odd, but we unwrap ref here (and report a lang-version diagnostic when appropriate). Ideally,
// this would be in the constructor of SourceLocalSymbol, but it lacks a diagnostics bag passed to it to add
// this diagnostic.
typeSyntax = typeSyntax.SkipRefInLocalOrReturn(diagnostics, out _);

bool isVar;
AliasSymbol alias;
Expand Down Expand Up @@ -795,7 +798,7 @@ declarationNode is VariableDesignationSyntax ||
// we want to treat the declaration as an explicitly typed declaration.

Debug.Assert(typeSyntax is not ScopedTypeSyntax);
TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(out _), diagnostics, out isVar, out alias);
TypeWithAnnotations declType = BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(), diagnostics, out isVar, out alias);
Debug.Assert(declType.HasType || isVar);

if (isVar)
Expand Down Expand Up @@ -2726,7 +2729,7 @@ internal BoundStatement BindForOrUsingOrFixedDeclarations(VariableDeclarationSyn
// Fixed and using variables are not allowed to be ref-like, but regular variables are
if (localKind == LocalDeclarationKind.RegularVariable)
{
typeSyntax = typeSyntax.SkipRef(out _);
typeSyntax = typeSyntax.SkipRef();
}

AliasSymbol alias;
Expand Down
4 changes: 4 additions & 0 deletions src/Compilers/CSharp/Portable/Binder/ForLoopBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ private BoundForStatement BindForParts(ForStatementSyntax node, Binder originalB
var type = _syntax.Declaration.Type.SkipScoped(out _);

if (type is RefTypeSyntax)
{
// Checking for 'ref for' (7.3) automatically checks for 'ref' (7.0), so no need for an explicit
// check feature as well here.
MessageID.IDS_FeatureRefFor.CheckFeatureAvailability(diagnostics, type);
}

initializer = originalBinder.BindForOrUsingOrFixedDeclarations(node.Declaration, LocalDeclarationKind.RegularVariable, diagnostics, out _);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal BoundExpression SetInferredTypeWithAnnotations(TypeWithAnnotations type
if (localSymbol.Scope == DeclarationScope.ValueScoped && !type.Type.IsErrorTypeOrRefLikeType())
{
diagnosticsOpt.Add(ErrorCode.ERR_ScopedRefAndRefStructOnly,
(typeOrDesignationSyntax is TypeSyntax typeSyntax ? typeSyntax.SkipScoped(out _).SkipRef(out _) : typeOrDesignationSyntax).Location);
(typeOrDesignationSyntax is TypeSyntax typeSyntax ? typeSyntax.SkipScoped(out _).SkipRef() : typeOrDesignationSyntax).Location);
}
}
}
Expand Down
17 changes: 4 additions & 13 deletions src/Compilers/CSharp/Portable/Parser/LanguageParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7093,19 +7093,10 @@ private TypeSyntax ParseType(ParseTypeMode mode = ParseTypeMode.Normal)
{
if (this.CurrentToken.Kind == SyntaxKind.RefKeyword)
{
var refKeyword = this.EatToken();
refKeyword = this.CheckFeatureAvailability(refKeyword, MessageID.IDS_FeatureRefLocalsReturns);

SyntaxToken readonlyKeyword = null;
if (this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword)
{
readonlyKeyword = this.EatToken();
readonlyKeyword = this.CheckFeatureAvailability(readonlyKeyword, MessageID.IDS_FeatureReadOnlyReferences);
}

var type = ParseTypeCore(ParseTypeMode.AfterRef);

return _syntaxFactory.RefType(refKeyword, readonlyKeyword, type);
return _syntaxFactory.RefType(
this.EatToken(),
this.CurrentToken.Kind == SyntaxKind.ReadOnlyKeyword ? this.EatToken() : null,
ParseTypeCore(ParseTypeMode.AfterRef));
}

return ParseTypeCore(mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static GlobalExpressionVariable Create(
Debug.Assert(nodeToBind.Kind() == SyntaxKind.VariableDeclarator || nodeToBind is ExpressionSyntax);

var syntaxReference = syntax.GetReference();
return (typeSyntax == null || typeSyntax.SkipScoped(out _).SkipRef(out _).IsVar)
return (typeSyntax == null || typeSyntax.SkipScoped(out _).SkipRef().IsVar)
? new InferrableGlobalExpressionVariable(containingType, modifiers, typeSyntax, name, syntaxReference, location, containingFieldOpt, nodeToBind)
: new GlobalExpressionVariable(containingType, modifiers, typeSyntax, name, syntaxReference, location);
}
Expand Down Expand Up @@ -88,7 +88,7 @@ internal override TypeWithAnnotations GetFieldType(ConsList<FieldSymbol> fieldsB

if (typeSyntax != null)
{
type = binder.BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(out _), diagnostics, out isVar);
type = binder.BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(), diagnostics, out isVar);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,7 @@ public LocalFunctionSymbol(
ReportAttributesDisallowed(param.AttributeLists, _declarationDiagnostics);
}

if (syntax.ReturnType.Kind() == SyntaxKind.RefType)
{
var returnType = (RefTypeSyntax)syntax.ReturnType;
if (returnType.ReadOnlyKeyword.Kind() == SyntaxKind.ReadOnlyKeyword)
{
_refKind = RefKind.RefReadOnly;
}
else
{
_refKind = RefKind.Ref;
}
}
else
{
_refKind = RefKind.None;
}

syntax.ReturnType.SkipRefInLocalOrReturn(_declarationDiagnostics, out _refKind);
_binder = binder;
}

Expand Down Expand Up @@ -235,7 +219,7 @@ internal void ComputeReturnType()
var diagnostics = BindingDiagnosticBag.GetInstance(_declarationDiagnostics);
TypeSyntax returnTypeSyntax = Syntax.ReturnType;
Debug.Assert(returnTypeSyntax is not ScopedTypeSyntax);
TypeWithAnnotations returnType = WithTypeParametersBinder.BindType(returnTypeSyntax.SkipScoped(out _).SkipRef(out _), diagnostics);
TypeWithAnnotations returnType = WithTypeParametersBinder.BindType(returnTypeSyntax.SkipScoped(out _).SkipRef(), diagnostics);

var compilation = DeclaringCompilation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ internal static void AddDelegateMembers(
TypeSyntax returnTypeSyntax = syntax.ReturnType;
Debug.Assert(returnTypeSyntax is not ScopedTypeSyntax);

returnTypeSyntax = returnTypeSyntax.SkipScoped(out _).SkipRef(out RefKind refKind);
returnTypeSyntax = returnTypeSyntax.SkipScoped(out _).SkipRefInLocalOrReturn(diagnostics, out RefKind refKind);
var returnType = binder.BindType(returnTypeSyntax, diagnostics);

// reuse types to avoid reporting duplicate errors if missing:
Expand Down
29 changes: 12 additions & 17 deletions src/Compilers/CSharp/Portable/Symbols/Source/SourceLocalSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,18 @@ private SourceLocalSymbol(
typeSyntax = typeSyntax.SkipScoped(out isScoped);
isScoped = isScoped && allowScoped;

if (allowRefKind && typeSyntax is RefTypeSyntax refTypeSyntax)
{
this._refKind = refTypeSyntax.ReadOnlyKeyword.Kind() == SyntaxKind.ReadOnlyKeyword ?
RefKind.RefReadOnly :
RefKind.Ref;
this._scope = isScoped ? DeclarationScope.RefScoped : DeclarationScope.Unscoped;
}
else
{
this._refKind = RefKind.None;
this._scope = isScoped ? DeclarationScope.ValueScoped : DeclarationScope.Unscoped;
}
// Diagnostics for ref-locals is reported by caller in BindDeclarationStatementParts.
if (allowRefKind)
typeSyntax.SkipRefInLocalOrReturn(diagnostics: null, out _refKind);

_scope = _refKind != RefKind.None
? isScoped ? DeclarationScope.RefScoped : DeclarationScope.Unscoped
: isScoped ? DeclarationScope.ValueScoped : DeclarationScope.Unscoped;

this._declarationKind = declarationKind;

// create this eagerly as it will always be needed for the EnsureSingleDefinition
_locations = ImmutableArray.Create<Location>(identifierToken.GetLocation());
_locations = ImmutableArray.Create(identifierToken.GetLocation());

_refEscapeScope = this._refKind == RefKind.None ?
scopeBinder.LocalScopeDepth :
Expand Down Expand Up @@ -208,7 +203,7 @@ public static SourceLocalSymbol MakeDeconstructionLocal(
Debug.Assert(closestTypeSyntax != null);
Debug.Assert(nodeBinder != null);

return closestTypeSyntax.SkipScoped(out _).SkipRef(out _).IsVar
return closestTypeSyntax.SkipScoped(out _).SkipRef().IsVar
? new DeconstructionLocalSymbol(containingSymbol, scopeBinder, nodeBinder, closestTypeSyntax, identifierToken, kind, deconstruction)
: new SourceLocalSymbol(containingSymbol, scopeBinder, allowRefKind: false, allowScoped: true, closestTypeSyntax, identifierToken, kind);
}
Expand Down Expand Up @@ -239,7 +234,7 @@ internal static LocalSymbol MakeLocalSymbolWithEnclosingContext(
Contains(nodeToBind.Ancestors().OfType<StatementSyntax>().First().Kind()) ||
nodeToBind is ExpressionSyntax);
Debug.Assert(!(nodeToBind.Kind() == SyntaxKind.SwitchExpressionArm) || nodeBinder is SwitchExpressionArmBinder);
return typeSyntax?.SkipScoped(out _).SkipRef(out _).IsVar != false && kind != LocalDeclarationKind.DeclarationExpressionVariable
return typeSyntax?.SkipScoped(out _).SkipRef().IsVar != false && kind != LocalDeclarationKind.DeclarationExpressionVariable
? new LocalSymbolWithEnclosingContext(containingSymbol, scopeBinder, nodeBinder, typeSyntax, identifierToken, kind, nodeToBind, forbiddenZone)
: new SourceLocalSymbol(containingSymbol, scopeBinder, allowRefKind: false, allowScoped: true, typeSyntax, identifierToken, kind);
}
Expand Down Expand Up @@ -383,7 +378,7 @@ public bool IsVar
return true;
}

TypeSyntax typeSyntax = _typeSyntax.SkipScoped(out _).SkipRef(out _);
TypeSyntax typeSyntax = _typeSyntax.SkipScoped(out _).SkipRef();

if (typeSyntax.IsVar)
{
Expand Down Expand Up @@ -419,7 +414,7 @@ private TypeWithAnnotations GetTypeSymbol()
}
else
{
declType = typeBinder.BindTypeOrVarKeyword(_typeSyntax.SkipScoped(out _).SkipRef(out _), diagnostics, out isVar);
declType = typeBinder.BindTypeOrVarKeyword(_typeSyntax.SkipScoped(out _).SkipRef(), diagnostics, out isVar);
}

if (isVar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4477,7 +4477,8 @@ private void AddNonTypeMembers(
{
var fieldSyntax = (FieldDeclarationSyntax)m;

_ = fieldSyntax.Declaration.Type.SkipScoped(out _).SkipRef(out RefKind refKind);
// Lang version check for ref-fields is done inside SourceMemberFieldSymbol;
_ = fieldSyntax.Declaration.Type.SkipScoped(out _).SkipRefInField(out var refKind);

if (IsImplicitClass && reportMisplacedGlobalCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,31 +489,26 @@ private TypeAndRefKind GetTypeAndRefKind(ConsList<FieldSymbol> fieldsBeingBound)
binder = binder.WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.SuppressConstraintChecks, this);
if (!ContainingType.IsScriptClass)
{
var typeOnly = typeSyntax.SkipScoped(out _).SkipRef(out refKind);
var typeOnly = typeSyntax.SkipScoped(out _).SkipRefInField(out refKind);
Debug.Assert(refKind is RefKind.None or RefKind.Ref or RefKind.RefReadOnly);
type = binder.BindType(typeOnly, diagnosticsForFirstDeclarator);
if (refKind != RefKind.None)
{
MessageID.IDS_FeatureRefFields.CheckFeatureAvailability(diagnostics, compilation, typeSyntax.SkipScoped(out _).Location);
if (!compilation.Assembly.RuntimeSupportsByRefFields)
{
diagnostics.Add(ErrorCode.ERR_RuntimeDoesNotSupportRefFields, ErrorLocation);
}

if (!containingType.IsRefLikeType)
{
diagnostics.Add(ErrorCode.ERR_RefFieldInNonRefStruct, ErrorLocation);
}

if (type.Type?.IsRefLikeType == true)
{
diagnostics.Add(ErrorCode.ERR_RefFieldCannotReferToRefStruct, typeSyntax.SkipScoped(out _).Location);
}
}
}
else
{
bool isVar;
type = binder.BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRef(out RefKind refKindToAssert), diagnostics, out isVar);
type = binder.BindTypeOrVarKeyword(typeSyntax.SkipScoped(out _).SkipRefInField(out RefKind refKindToAssert), diagnostics, out isVar);
Debug.Assert(refKindToAssert == RefKind.None); // Otherwise we might need to report an error
Debug.Assert(type.HasType || isVar);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private SourceOrdinaryMethodSymbol(
bool hasBody = hasBlockBody || _isExpressionBodied;
_hasAnyBody = hasBody;
Debug.Assert(syntax.ReturnType is not ScopedTypeSyntax);
_refKind = syntax.ReturnType.SkipScoped(out _).GetRefKind();
_refKind = syntax.ReturnType.SkipScoped(out _).GetRefKindInLocalOrReturn(diagnostics);

CheckForBlockAndExpressionBody(
syntax.Body, syntax.ExpressionBody, syntax, diagnostics);
Expand Down Expand Up @@ -144,7 +144,7 @@ protected override (TypeWithAnnotations ReturnType, ImmutableArray<ParameterSymb
var returnTypeSyntax = syntax.ReturnType;
Debug.Assert(returnTypeSyntax is not ScopedTypeSyntax);

returnTypeSyntax = returnTypeSyntax.SkipScoped(out _).SkipRef(out RefKind refKind);
returnTypeSyntax = returnTypeSyntax.SkipScoped(out _).SkipRef();
TypeWithAnnotations returnType = signatureBinder.BindType(returnTypeSyntax, diagnostics);

// span-like types are returnable in general
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private SourcePropertySymbol(
isAutoProperty: isAutoProperty,
isExpressionBodied: isExpressionBodied,
isInitOnly: isInitOnly,
syntax.Type.SkipScoped(out _).GetRefKind(),
syntax.Type.SkipScoped(out _).GetRefKindInLocalOrReturn(diagnostics),
memberName,
syntax.AttributeLists,
location,
Expand Down Expand Up @@ -448,7 +448,7 @@ private TypeWithAnnotations ComputeType(Binder binder, SyntaxNode syntax, Bindin
var typeSyntax = GetTypeSyntax(syntax);
Debug.Assert(typeSyntax is not ScopedTypeSyntax);

typeSyntax = typeSyntax.SkipScoped(out _).SkipRef(out _);
typeSyntax = typeSyntax.SkipScoped(out _).SkipRef();
var type = binder.BindType(typeSyntax, diagnostics);
CompoundUseSiteInfo<AssemblySymbol> useSiteInfo = binder.GetNewCompoundUseSiteInfo(diagnostics);

Expand Down Expand Up @@ -560,7 +560,7 @@ protected override bool HasPointerTypeSyntactically
{
var typeSyntax = GetTypeSyntax(CSharpSyntaxNode);
Debug.Assert(typeSyntax is not ScopedTypeSyntax);
typeSyntax = typeSyntax.SkipScoped(out _).SkipRef(out _);
typeSyntax = typeSyntax.SkipScoped(out _).SkipRef();
return typeSyntax.Kind() switch { SyntaxKind.PointerType => true, SyntaxKind.FunctionPointerType => true, _ => false };
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Portable/Syntax/SyntaxFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ internal static bool IsIdentifierVarOrPredefinedType(this Syntax.InternalSyntax.
internal static bool IsDeclarationExpressionType(SyntaxNode node, [NotNullWhen(true)] out DeclarationExpressionSyntax? parent)
{
parent = node.ModifyingScopedOrRefTypeOrSelf().Parent as DeclarationExpressionSyntax;
return node == parent?.Type.SkipScoped(out _).SkipRef(out _);
return node == parent?.Type.SkipScoped(out _).SkipRef();
}

/// <summary>
Expand Down
Loading

0 comments on commit eebc8b7

Please sign in to comment.