-
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
Add and emit ref kind for ref readonly parameters #68179
Add and emit ref kind for ref readonly parameters #68179
Conversation
dad2351
to
030d450
Compare
030d450
to
7ad29e0
Compare
src/Compilers/CSharp/Portable/Symbols/AnonymousTypes/AnonymousTypeManager.Templates.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceComplexParameterSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenRefReadonlyParameterTests.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenRefReadonlyParameterTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenRefReadonlyParameterTests.cs
Outdated
Show resolved
Hide resolved
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.
Done with review pass (iteration 1). Minor comments only
src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenRefReadonlyParameterTests.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenRefReadonlyParameterTests.cs
Outdated
Show resolved
Hide resolved
Pretty much everything about state of a symbol is accessible through APIs. No need to call a method to check result of importing it. In reply to: 1598695510 Refers to: src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs:401 in 982dad6. [](commit_id = 982dad6, deletion_comment = False) |
Consider adding an assert that RefKind is not RefKind.RefReadOnlyParameter In reply to: 1598763691 Refers to: src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs:391 in ccc3b80. [](commit_id = ccc3b80, deletion_comment = False) |
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Metadata/PE/PEParameterSymbol.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/ParameterHelpers.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit2/Semantics/RefReadonlyParameterTests.cs
Outdated
Show resolved
Hide resolved
src/Compilers/VisualBasic/Test/Symbol/SymbolDisplay/SymbolDisplayTests.vb
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Emit2/CodeGen/CodeGenRefReadonlyParameterTests.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Emitter/Model/PEAssemblyBuilder.cs
Outdated
Show resolved
Hide resolved
{ | ||
var p = m.GlobalNamespace.GetMember<MethodSymbol>("<>f__AnonymousDelegate0.Invoke").Parameters.Single(); | ||
VerifyRefReadonlyParameter(p, | ||
// PROTOTYPE: Invoke method is virtual but no modreq is emitted. This happens for `in` parameters, 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.
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.
LGTM (commit 25)
{ | ||
if (refKind) | ||
{ | ||
Assert.Equal(RefKind.RefReadOnlyParameter, parameter.RefKind); |
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.
When refKind
is false, we do no check. In that case, could we tighten to check that the RefKind is not RefReadOnlyParameter?
Assert.Equal(refKind, RefKind.RefReadOnlyParameter == parameter.RefKind);
|
||
if (metadataIn) | ||
{ | ||
Assert.True(parameter.IsMetadataIn); |
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.
Same question here. Consider Assert.Equal(metadataIn, parameter.IsMetadataIn);
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.
LGTM Thanks (iteration 25) with two small test suggestions to consider
Speclet: https://github.com/jjonescz/csharplang/blob/0c269d235e0687419c1ec69743fb51cea8b4d466/proposals/ref-readonly-parameters.md
Test plan: #68056