-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support modifiers with simple lambda parameters. #75400
Conversation
if (p.Default != null) | ||
{ | ||
if (firstDefault == -1) |
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.
this logic moved from teh caller. no need for it to do a secondary pass to report errors when it can just do that here.
@@ -350,27 +365,6 @@ private UnboundLambda BindAnonymousFunction(AnonymousFunctionExpressionSyntax sy | |||
|
|||
var lambda = AnalyzeAnonymousFunction(syntax, diagnostics); | |||
var data = lambda.Data; | |||
if (data.HasExplicitlyTypedParameterList) |
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.
this logic moved into AnalyzeAnonymousFunction. In particular, we want check parameters unilaterally even if there are types or no types (since we want to check modifier usage in the latter case). so the HasExplicitlyTypedParameterList had to go.
if (lambdaParameterType.IsErrorType()) | ||
{ | ||
continue; | ||
} |
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.
this waas already checked above on line 2107. no need to check again.
89e3513
to
a5ac0b2
Compare
{ | ||
void M() | ||
{ | ||
D d = (scoped {{(escaped ? "@" : "")}}scoped) => { }; |
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.
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.
It's less about this being a context (like query-expressions) where a word just unilaterally becomes a keyword. Instead, it's more like: in the case where it could multiple things (like a modifier vs the type), then it's only a modifier (even though that breaks from prior interpretations).
The 'identifier' part is always mandatory, and never ambiguous. So it's just an identifier there.
src/Compilers/CSharp/Test/Semantic/Semantics/SimpleLambdaParametersWithModifiersTests.cs
Outdated
Show resolved
Hide resolved
Assert.Equal(MethodKind.LambdaMethod, symbol.MethodKind); | ||
Assert.Equal(RefKind.RefReadOnlyParameter, symbol.Parameters.Single().RefKind); | ||
Assert.Equal(SpecialType.System_Int32, symbol.Parameters.Single().Type.SpecialType); | ||
} |
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.
@@ -122,6 +122,7 @@ | |||
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs" /> | |||
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnusedParametersAndValues\CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs" /> | |||
<Compile Include="$(MSBuildThisFileDirectory)UseCollectionInitializer\CSharpUseCollectionInitializerDiagnosticAnalyzer.cs" /> | |||
<Compile Include="$(MSBuildThisFileDirectory)UseImplicitlyTypedLambdaExpression\UseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs" /> |
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.
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.
no. this was for anotehr branch. removing.
* upstream/main: (172 commits) Move impl of ILspWorkpace to EditorTestWorkspace/LspTestWorkspace (dotnet#76753) Field-backed properties: report diagnostic for variable named field declared in accessor (dotnet#76671) Add more tests Update 'use nameof instead of typeof' to support generic types Update dependencies from https://github.com/dotnet/arcade build 20250115.2 Add docs invert Update src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems Update options Fixup tests fixup options Update tests Add test Fix trivia Handle params Support modifiers with simple lambda parameters. (dotnet#75400) Handle params Use helper Add fixes Flesh out ...
Implementation of https://github.com/dotnet/csharplang/blob/main/proposals/simple-lambda-parameters-with-modifiers.md.
This is in the any-time bucket here: dotnet/csharplang#338