Skip to content

Conversation

@krwq
Copy link
Member

@krwq krwq commented Aug 26, 2020

@krwq
Copy link
Member Author

krwq commented Aug 26, 2020

@danmosemsft this one has a bit smaller scope I think but it does affect Code Contracts (is anyone even using it still?)

@krwq krwq force-pushed the nullability-compiler-bug-regression-contracts branch from 5fa6bde to 2482f61 Compare August 26, 2020 09:27
{
Assembly? caller = stack.GetFrame(i)!.GetMethod()?.DeclaringType!.Assembly;
MethodBase stackMethod = stack.GetFrame(i)!.GetMethod();
Assembly? caller = (stackMethod != null) ? stackMethod.DeclaringType!.Assembly : null;
Copy link
Member

Choose a reason for hiding this comment

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

DeclaringType can be null. I do not think there is anything guaranteeing that it will be non-null here. This is one of those cases nullable annotations caught a real bug.

Should the fix be to just change ! after DeclaringType to ?? No need to split it into multiple lines.

Copy link
Member Author

Choose a reason for hiding this comment

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

We try to avoid any product changes during nullability annotations as those are always risky and can get lost in a large PR. In this case since PR is only affecting this specific change so I think we should fix it.

@jkotas
Copy link
Member

jkotas commented Aug 27, 2020

a product bug which luckily got caught by tests

What are the tests that caught this?

@krwq
Copy link
Member Author

krwq commented Aug 27, 2020

@jkotas the test was related to #41261 not to this issue. The investigation related to the failure led to finding this issue.

@krwq krwq merged commit 2337a35 into dotnet:master Aug 27, 2020
@carlossanlop
Copy link
Contributor

/backport to release/5.0

@github-actions
Copy link
Contributor

Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/227480299

@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants