Test plan for static local functions #32069
Labels
Area-Compilers
Test
Test failures in roslyn-CI
Test-Gap
Describes a specific feature or scenario that does not have test coverage
Milestone
Feature
Static Local Functions
This feature allows for the following changes to local functions:
static
modifier to be applied to local function declarations. Such a function will not be allowed to captureany state from the enclosing functions: locals, parameters or
this
. Additionally the function is guaranteed to beemitted as
static
in the binary.static
or not, to shadow identifiers in the enclosing scope.csharplang
.csharplang
.Code Examples
Static enforcement
Shadowing
Compiler Scenarios
static
static
local functionthis
, local or parameter (function or lambda)private
data from enclosing scope as long as it'sstatic
static static
<return type> static
static
in the binarystatic
Local Functions are not being emitted as static #38143static
local functionsLookupSymbols
,GetSymbolInfo
,GetOperation
in particular)from
group by
out
variable declarationCan't shadow in lambda expressions (not part of this implementation)nameof
on identifiers that shadow (variables and type parameter)static
from a local function in a valid program should not change the meaning of the programEmittedAsStatic_03
StaticWithTypeParameterReferences
ShadowNames_TypeParameter
void Local(object Local) { }
.ShadowNames_ThisLocalFunction
StaticWithLocalFunctionVariableReference_01
,_02
nameof(identifier)
should bind to shadowing symboltypeof(T)
should bind to type parameterT
even ifT
is shadowed by a variablesizeof(T)
should bind to type parameterT
even ifT
is shadowed by a variable_
should bind to_
symbol in outer scope even in static local function.UnderscoreInOuterScope
var
should bind tovar
symbol in outer scope even in static local function.VarInOuterScope
await
should be contextual keyword in the same way regardless of whether local function is static.AwaitWithinAsyncOuterScope_02
ExpressionTreeLocalFunctionUsage_02
call
rather thancallvirt
for local functions regardless of whether local function is static.EmitCallInstruction
IDE Scenarios
static
modifier for local functionstatic
static
when typing out a local function declaration (issue Auto-complete does not includestatic
for local function #32174, PR Recommend keyword static for static local functions #32187)this
(filed issuethis
keyword should not be recommended within a static local function #35644)The text was updated successfully, but these errors were encountered: