Skip to content

Fix NotNullIfNotNull delegate conversion#53409

Merged
RikkiGibson merged 2 commits intodotnet:mainfrom
RikkiGibson:fix-49865
May 20, 2021
Merged

Fix NotNullIfNotNull delegate conversion#53409
RikkiGibson merged 2 commits intodotnet:mainfrom
RikkiGibson:fix-49865

Conversation

@RikkiGibson
Copy link
Member

Fixes #49865

@RikkiGibson RikkiGibson requested a review from a team as a code owner May 14, 2021 00:20
@ghost ghost added the Area-Compilers label May 14, 2021
var overrideParam = overrideParameters[i + overrideParameterOffset];
if (notNullIfParameterNotNull.Contains(overrideParam.Name) && !baseParameters[i].TypeWithAnnotations.NullableAnnotation.IsAnnotated())
var baseParam = baseParameters[i];
if (notNullIfParameterNotNull.Contains(overrideParam.Name) && NullableWalker.GetParameterState(baseParam.TypeWithAnnotations, baseParam.FlowAnalysisAnnotations).IsNotNull)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that nullable variance checks are shared between method overrides and method group conversions. The delegate type is analogous to a "base" method while the method group is analogous to an "override" method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a way to observe the impact of the change on an override scenario. Consider adding such tests.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM THanks (iteration 2) with a test suggestion to consider

@jcouv jcouv self-assigned this May 18, 2021
@jcouv jcouv added this to the 17.0 milestone May 18, 2021
@RikkiGibson
Copy link
Member Author

@cston @dotnet/roslyn-compiler Could you please give this a second review?

@RikkiGibson
Copy link
Member Author

I think there are still more bugs here, particularly with generic return types, but I am going to merge this since it gets us closer to correctness.

@RikkiGibson RikkiGibson merged commit fd8f251 into dotnet:main May 20, 2021
@ghost ghost modified the milestones: 17.0, Next May 20, 2021
@RikkiGibson RikkiGibson deleted the fix-49865 branch May 20, 2021 20:12
333fred added a commit that referenced this pull request May 20, 2021
* upstream/main: (1224 commits)
  Fix NotNullIfNotNull delegate conversion (#53409)
  Verify quick info session in InvokeQuickInfo
  Remove unnecessary retry
  Enable nullable reference types
  Fix timeout behavior in GetQuickInfo
  Only generate build number on first run
  Update contrib documentation (#53504)
  update test to wait for workspace to be updated
  SImplify
  Fix out of bound crash in lsp navto.
  Revert changes to TypeScriptWaitContext wrappers
  Switch to ROSLYN_TEST_CI for CI detection
  Disable modification to CodeStyleOption<T>
  SImplify
  Simplify LoggerTestChannel using BlockingCollection
  Only require telemetry validation in CI
  Fix out of bound crash in lsp navto.
  Track fire-and-forget operations
  Avoid global option corruption
  Fix locked comment
  ...
333fred added a commit that referenced this pull request May 24, 2021
…ures/interpolated-string

* upstream/main: (92 commits)
  Keep casts when necessary to prefer a constant pattern over a type pattern
  Remove SyntaxKind.DataKeyword (#53614)
  Display 'readonly' for record structs (#53634)
  Update Building, Debugging, and Testing on Windows.md (#53543)
  Update dependencies from https://github.com/dotnet/arcade build 20210521.3 (#53617)
  Introduce resx for BuildValidator and MS.CA.Rebuild to allow localization (#53447)
  Report obsoletion diagnostics for slice and indexer (#53463)
  Update BasicGenerateConstructorDialog.cs
  Add searchbox in generate overrides dialog
  Allow `with` on anonymous types (#53248)
  Report diagnostic on correct node (#53538)
  Fix NotNullIfNotNull delegate conversion (#53409)
  Verify quick info session in InvokeQuickInfo
  Remove unnecessary retry
  Ensure no navbar IO on the UI thread
  Enable nullable reference types
  Fix timeout behavior in GetQuickInfo
  Add a semantic model based GetQuickInfoAsync entry point into QuickInfoServiceWithProviders
  Move semantic model based quick info API up to CommonQuickInfoProvider type
  Fix dnceng build by forcing the use of xcopy msbuild
  ...
@RikkiGibson RikkiGibson modified the milestones: Next, 17.0.P2 Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants