Skip to content
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

Remove getFieldSymbolToBeInitialized #75872

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RikkiGibson
Copy link
Contributor

Closes #75245

It looks like this function is no longer needed because we recently added a mechanism to share a slot between property and backing field under appropriate conditions. Specifically, changes to NullableWalker.GetOrCreateSlot in #75246.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 12, 2024
@RikkiGibson RikkiGibson changed the title Remove get field symbol to be initialized Remove getFieldSymbolToBeInitialized Nov 12, 2024
@RikkiGibson
Copy link
Contributor Author

RikkiGibson commented Nov 12, 2024

Looks like there are some cases where preconditions are not properly set in absence of this call. Likely we need to add some similar tests with properties using field keyword and make sure behavior is consistent.

[xUnit.net 00:00:07.68]     Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.RequiredMembersTests.RequiredMemberSuppressesNullabilityWarnings_MemberNotNull_ChainedConstructor_03 [FAIL]
  Failed Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.RequiredMembersTests.RequiredMemberSuppressesNullabilityWarnings_MemberNotNull_ChainedConstructor_03 [24 ms]
  Error Message:
   
Expected:
                Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property1").WithLocation(11, 9),
                Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property2").WithLocation(12, 9)
Actual:
                // 0.cs(11,9): warning CS8602: Dereference of a possibly null reference.
                //         Property1.ToString();
                Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property1").WithLocation(11, 9)
Diff:
-->                 Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property2").WithLocation(12, 9)
  Stack Trace:
     at Microsoft.CodeAnalysis.DiagnosticExtensions.Verify(IEnumerable`1 actual, DiagnosticDescription[] expected, Boolean errorCodeOnly) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 99
   at Microsoft.CodeAnalysis.DiagnosticExtensions.Verify(IEnumerable`1 actual, DiagnosticDescription[] expected) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 48
   at Microsoft.CodeAnalysis.DiagnosticExtensions.Verify(ImmutableArray`1 actual, DiagnosticDescription[] expected) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 63
   at Microsoft.CodeAnalysis.DiagnosticExtensions.VerifyDiagnostics[TCompilation](TCompilation c, DiagnosticDescription[] expected) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 109
   at Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.RequiredMembersTests.RequiredMemberSuppressesNullabilityWarnings_MemberNotNull_ChainedConstructor_03() in /_/src/Compilers/CSharp/Test/Symbol/Symbols/RequiredMembersTests.cs:line 4542
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
[xUnit.net 00:00:08.51]     Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.RequiredMembersTests.RequiredMemberSuppressesNullabilityWarnings_MemberNotNull_ChainedConstructor_04 [FAIL]
  Failed Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.RequiredMembersTests.RequiredMemberSuppressesNullabilityWarnings_MemberNotNull_ChainedConstructor_04 [18 ms]
  Error Message:
   
Expected:
                Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property1").WithLocation(12, 9),
                Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property2").WithLocation(13, 9)
Actual:
                // 0.cs(12,9): warning CS8602: Dereference of a possibly null reference.
                //         Property1.ToString();
                Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property1").WithLocation(12, 9)
Diff:
-->                 Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "Property2").WithLocation(13, 9)
  Stack Trace:
     at Microsoft.CodeAnalysis.DiagnosticExtensions.Verify(IEnumerable`1 actual, DiagnosticDescription[] expected, Boolean errorCodeOnly) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 99
   at Microsoft.CodeAnalysis.DiagnosticExtensions.Verify(IEnumerable`1 actual, DiagnosticDescription[] expected) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 48
   at Microsoft.CodeAnalysis.DiagnosticExtensions.Verify(ImmutableArray`1 actual, DiagnosticDescription[] expected) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 63
   at Microsoft.CodeAnalysis.DiagnosticExtensions.VerifyDiagnostics[TCompilation](TCompilation c, DiagnosticDescription[] expected) in /_/src/Compilers/Test/Core/Diagnostics/DiagnosticExtensions.cs:line 109
   at Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.RequiredMembersTests.RequiredMemberSuppressesNullabilityWarnings_MemberNotNull_ChainedConstructor_04() in /_/src/Compilers/CSharp/Test/Symbol/Symbols/RequiredMembersTests.cs:line 4575
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
1 participant