Fix TypeWithAnnotations.ToTypeWithState() for (untyped) null literal#46344
Merged
cston merged 1 commit intodotnet:masterfrom Jul 27, 2020
Merged
Fix TypeWithAnnotations.ToTypeWithState() for (untyped) null literal#46344cston merged 1 commit intodotnet:masterfrom
cston merged 1 commit intodotnet:masterfrom
Conversation
cston
commented
Jul 27, 2020
| // (10,9): warning CS8602: Dereference of a possibly null reference. | ||
| // F(() => { if (x.Length == 0) return null; return x; }).ToString(); | ||
| Diagnostic(ErrorCode.WRN_NullReferenceReturn, "null").WithLocation(10, 45)); | ||
| Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "F(() => { if (x.Length == 0) return null; return x; })").WithLocation(10, 9)); |
jcouv
reviewed
Jul 27, 2020
| var comp = CreateCompilation(source, parseOptions: TestOptions.RegularPreview); | ||
| comp.VerifyEmitDiagnostics(); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
Could we add similar tests with default? File an issue if misbehaving.
Contributor
Author
There was a problem hiding this comment.
return default; results in "warning CS8603: Possible null reference return" with 16.7 and this PR.
return default(T); compiles without warnings with both.
Added tests in #46405.
Member
|
This needs to merge to master. We are reverting the feature in preview1 (see #46358). |
333fred
added a commit
to 333fred/roslyn
that referenced
this pull request
Jul 28, 2020
…-pointers * upstream/master: (207 commits) Update argument state when parameter has not-null type (dotnet#46072) Fix TypeWithAnnotations.ToTypeWithState() for (untyped) null literal (dotnet#46344) Update README (dotnet#46136) Revert "Revert "Support nullable annotations on unconstrained type parameters"" Revert "Support nullable annotations on unconstrained type parameters (dotnet#45993)" Fix type in publish data Update VSIXExpInstaller version to one available on ADO Update publish data for 16.8 Update version of RichCodeNav.EnvVarDump A fixed initializer must be bound to its natural type (dotnet#46293) Update features merged into 16.7p4 (dotnet#46229) Async-streams: disposal should continue without jump within a finally (dotnet#46188) Recommend default in type constraint, but not record (dotnet#46311) Add use site diagnostics to IsUnmanaged (dotnet#46114) Add another flaky test. Ensure NuGet connections use TLS 1.2 Update to Microsoft.CodeAnalysis.Testing 1.0.1-beta1.20374.2 Skip flaky test. Fix build break. (dotnet#46303) Skip a flaky test Relates to dotnet#46304 ...
333fred
added a commit
to 333fred/roslyn
that referenced
this pull request
Jul 28, 2020
…to function-pointer-type-lookup * upstream/features/function-pointers: (212 commits) Correct public API number. Update argument state when parameter has not-null type (dotnet#46072) Fix TypeWithAnnotations.ToTypeWithState() for (untyped) null literal (dotnet#46344) Update README (dotnet#46136) Revert "Revert "Support nullable annotations on unconstrained type parameters"" Revert "Support nullable annotations on unconstrained type parameters (dotnet#45993)" Fix type in publish data Update VSIXExpInstaller version to one available on ADO Update publish data for 16.8 Update version of RichCodeNav.EnvVarDump A fixed initializer must be bound to its natural type (dotnet#46293) Update features merged into 16.7p4 (dotnet#46229) Async-streams: disposal should continue without jump within a finally (dotnet#46188) Recommend default in type constraint, but not record (dotnet#46311) Add use site diagnostics to IsUnmanaged (dotnet#46114) Add another flaky test. Ensure NuGet connections use TLS 1.2 Update to Microsoft.CodeAnalysis.Testing 1.0.1-beta1.20374.2 Skip flaky test. Fix build break. (dotnet#46303) ...
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #46342