-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganizes the local function documents into a spec document and a worklist document. Everything in the worklist has been given a separate bug number and been linked to the worklist. The spec has had a preliminary grammar added to it. There has also been a skipped test added for one of the bugs that was filed.
- Loading branch information
Showing
6 changed files
with
210 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
Local Function Status | ||
===================== | ||
|
||
This is a checklist for current and outstanding work on the local functions | ||
feature, as spec'd in [local-functions.md](./local-functions.md). | ||
|
||
-------------------- | ||
|
||
Known issues | ||
============ | ||
|
||
Compiler: | ||
|
||
- [ ] Parser builds nodes for local functions when feature not enabled (#9940) | ||
- [ ] Compiler crash: base call to state machine method, in state machine | ||
method (#9872) | ||
- [ ] Need custom warning for unused local function (#9661) | ||
- [ ] Generate quick action does not offer to generate local (#9352) | ||
- [ ] Parser ambiguity research (#10388) | ||
- [ ] Dynamic support (#10389) | ||
- [ ] Referring to local function in expression tree (#10390) | ||
- [ ] Resolve definite assignment rules (#10391) | ||
- [ ] Remove support for `var` return type (#10392) | ||
- [ ] Update error messages (#10393) | ||
|
||
IDE: | ||
|
||
- [ ] Some selections around local functions fail extract method refactoring | ||
[ ] (#8719) | ||
- [ ] Extracting local function passed to an Action introduces compiler error | ||
[ ] (#8718) | ||
- [ ] Ctrl+. on a delegate invocation crashes VS (via Extract method) (#8717) | ||
- [ ] Inline temp introductes compiler error (#8716) | ||
- [ ] Call hierarchy search never terminates on local functions (#8654) | ||
- [ ] Nav bar doesn't support local functions (#8648) | ||
- [ ] No outlining for local functions (#8647) | ||
- [ ] Squiggles all over the place when using an unsupported modifier (#8645) | ||
- [ ] Peek definition errors out on local function (#8644) | ||
- [ ] Void keyword not recommended while declaring local function (#8616) | ||
- [ ] Change signature doesn't update the signature of the local function (#8539) | ||
|
||
|
||
Feature Completeness Progress | ||
============================= | ||
|
||
- [x] N-level nested local functions | ||
- [x] Capture | ||
- Works alongside lambdas and behaves very similarly in fallback cases | ||
- Has zero-allocation closures (struct frames by ref) on functions never | ||
converted to a delegate and are not an iterator/async | ||
- [x] Standard parameter features | ||
- params | ||
- ref/out | ||
- named/optional | ||
- [x] Visibility | ||
- May revisit design (currently shadows, may do overloads) | ||
- [x] Generics | ||
- Nongeneric local functions in generic methods (same as lambdas). | ||
- Generic local functions in nongeneric methods. | ||
- Generic local functions in generic methods. | ||
- Arbitrary nesting of generic local functions. | ||
- Generic local functions with constraints. | ||
- [x] Inferred return type | ||
- [x] Iterators | ||
- [x] Async |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/Compilers/CSharp/Test/Syntax/Parsing/LocalFunctionParsingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.UnitTests | ||
{ | ||
public class LocalFunctionParsingTests : ParsingTests | ||
{ | ||
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/10388")] | ||
public void LocalFunctionsWithAwait() | ||
{ | ||
var file = ParseFileExperimental(@"class c | ||
{ | ||
void m1() { await await() => new await(); } | ||
void m2() { await () => new await(); } | ||
async void m3() { await () => new await(); } | ||
void m4() { async await() => new await(); } | ||
}"); | ||
|
||
Assert.NotNull(file); | ||
var c = (ClassDeclarationSyntax)file.Members.Single(); | ||
Assert.Equal(4, c.Members.Count); | ||
|
||
{ | ||
Assert.Equal(SyntaxKind.MethodDeclaration, c.Members[0].Kind()); | ||
var m1 = (MethodDeclarationSyntax)c.Members[0]; | ||
Assert.Equal(0, m1.Modifiers.Count); | ||
Assert.Equal(1, m1.Body.Statements.Count); | ||
Assert.Equal(SyntaxKind.LocalFunctionStatement, m1.Body.Statements[0].Kind()); | ||
var s1 = (LocalFunctionStatementSyntax)m1.Body.Statements[0]; | ||
Assert.False(s1.HasErrors); | ||
Assert.Equal(0, s1.Modifiers.Count); | ||
Assert.Equal("await", s1.ReturnType.ToString()); | ||
Assert.Equal("await", s1.Identifier.ToString()); | ||
Assert.Null(s1.TypeParameterList); | ||
Assert.Equal(0, s1.ParameterList.ParameterCount); | ||
Assert.Null(s1.Body); | ||
Assert.NotNull(s1.ExpressionBody); | ||
} | ||
|
||
{ | ||
Assert.Equal(SyntaxKind.MethodDeclaration, c.Members[1].Kind()); | ||
var m2 = (MethodDeclarationSyntax)c.Members[1]; | ||
Assert.Equal(0, m2.Modifiers.Count); | ||
Assert.Equal(2, m2.Body.Statements.Count); | ||
Assert.Equal(SyntaxKind.ExpressionStatement, m2.Body.Statements[0].Kind()); | ||
var s1 = (ExpressionStatementSyntax)m2.Body.Statements[0]; | ||
Assert.Equal(SyntaxKind.InvocationExpression, s1.Expression.Kind()); | ||
var e1 = (InvocationExpressionSyntax)s1.Expression; | ||
Assert.Equal("await", e1.Expression.ToString()); | ||
Assert.Equal(0, e1.ArgumentList.Arguments.Count); | ||
Assert.True(s1.SemicolonToken.IsMissing); | ||
Assert.Equal("=> ", s1.GetTrailingTrivia().ToFullString()); | ||
} | ||
|
||
{ | ||
Assert.Equal(SyntaxKind.MethodDeclaration, c.Members[2].Kind()); | ||
var m3 = (MethodDeclarationSyntax)c.Members[2]; | ||
Assert.Equal(1, m3.Modifiers.Count); | ||
Assert.Equal("async", m3.Modifiers.Single().ToString()); | ||
Assert.Equal(2, m3.Body.Statements.Count); | ||
Assert.Equal(SyntaxKind.ExpressionStatement, m3.Body.Statements[0].Kind()); | ||
var s1 = (ExpressionStatementSyntax)m3.Body.Statements[0]; | ||
Assert.Equal(SyntaxKind.AwaitExpression, s1.Expression.Kind()); | ||
var e1 = (AwaitExpressionSyntax)s1.Expression; | ||
Assert.Equal(SyntaxKind.SimpleLambdaExpression, e1.Expression.Kind()); | ||
Assert.True(s1.SemicolonToken.IsMissing); | ||
Assert.Equal("=> ", s1.GetTrailingTrivia().ToFullString()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters