-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Scoped implicitly-typed lambda parameters #64680
Changes from all commits
4b76f8a
fd3c176
838b4be
32954a5
a14ae68
bd27664
c4a6441
9ca7eeb
db9e1ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ protected SourceComplexParameterSymbolBase( | |
SyntaxReference syntaxRef, | ||
bool isParams, | ||
bool isExtensionMethodThis, | ||
DeclarationScope scope) | ||
DeclarationScope? scope) | ||
: base(owner, parameterType, ordinal, refKind, scope, name, locations) | ||
{ | ||
Debug.Assert((syntaxRef == null) || (syntaxRef.GetSyntax().IsKind(SyntaxKind.Parameter))); | ||
|
@@ -198,7 +198,7 @@ internal bool HasEnumeratorCancellationAttribute | |
|
||
#nullable enable | ||
|
||
internal sealed override DeclarationScope EffectiveScope | ||
internal override DeclarationScope EffectiveScope | ||
{ | ||
get | ||
{ | ||
|
@@ -1479,7 +1479,7 @@ internal SourceComplexParameterSymbol( | |
SyntaxReference syntaxRef, | ||
bool isParams, | ||
bool isExtensionMethodThis, | ||
DeclarationScope scope) | ||
DeclarationScope? scope) | ||
: base(owner, ordinal, parameterType, refKind, name, locations, syntaxRef, isParams, isExtensionMethodThis, scope) | ||
{ | ||
} | ||
|
@@ -1502,7 +1502,7 @@ internal SourceComplexParameterSymbolWithCustomModifiersPrecedingRef( | |
SyntaxReference syntaxRef, | ||
bool isParams, | ||
bool isExtensionMethodThis, | ||
DeclarationScope scope) | ||
DeclarationScope? scope) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
: base(owner, ordinal, parameterType, refKind, name, locations, syntaxRef, isParams, isExtensionMethodThis, scope) | ||
{ | ||
Debug.Assert(!refCustomModifiers.IsEmpty); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ internal abstract class SourceParameterSymbol : SourceParameterSymbolBase | |
private readonly string _name; | ||
private readonly ImmutableArray<Location> _locations; | ||
private readonly RefKind _refKind; | ||
private readonly DeclarationScope _scope; | ||
private readonly DeclarationScope? _scope; | ||
|
||
public static SourceParameterSymbol Create( | ||
Binder context, | ||
|
@@ -101,7 +101,7 @@ protected SourceParameterSymbol( | |
TypeWithAnnotations parameterType, | ||
int ordinal, | ||
RefKind refKind, | ||
DeclarationScope scope, | ||
DeclarationScope? scope, | ||
string name, | ||
ImmutableArray<Location> locations) | ||
: base(owner, ordinal) | ||
|
@@ -225,13 +225,16 @@ public sealed override RefKind RefKind | |
/// <summary> | ||
/// The declared scope. From source, this is from the <c>scope</c> keyword only. | ||
/// </summary> | ||
internal DeclarationScope DeclaredScope => _scope; | ||
internal DeclarationScope? DeclaredScope => _scope; | ||
|
||
internal abstract override DeclarationScope EffectiveScope { get; } | ||
|
||
protected DeclarationScope CalculateEffectiveScopeIgnoringAttributes() | ||
{ | ||
var declaredScope = this.DeclaredScope; | ||
// DeclaredScope is only null in LambdaParameterSymbol where EffectiveScope can be provided rather than computed | ||
Debug.Assert(this.DeclaredScope is not null); | ||
var declaredScope = this.DeclaredScope.Value; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather leave as-is. I thought this was nullable-enabled code. |
||
|
||
return declaredScope == DeclarationScope.Unscoped && ParameterHelpers.IsRefScopedByDefault(this) ? | ||
DeclarationScope.RefScoped : | ||
declaredScope; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change needed? Can we get here from a
LambdaParameterSymbol
? #ResolvedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithCustomModifiersAndParamsCore
copiesthis.DeclaredSymbol
(which isNullable<DeclarationScope>
) using this constructor.It similarly calls the
SourceComplexParameterSymbolWithCustomModifiersPrecedingRef
constructor.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithCustomModifiersAndParamsCore()
should not be used forLambdaParameterSymbol
though. If it is, we'd presumably need to copyEffectiveScope
as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithCustomModifiersAndParamsCore
isn't used for lambdas. It's used for OHI scenarios.