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

Generalize dynamic static-only restriction to include field initializers #11256

Merged
merged 2 commits into from
May 12, 2016

Conversation

khyperia
Copy link
Contributor

Fixes #10463

Native compiler handled all cases, Roslyn generated invalid IL when using dynamic in a field initializer. Roslyn does already handle dynamic in a constructor initializer, like the following case:

public M() : base((object)Test((dynamic)2)) // as imagined inserted into test case in this PR

This PR simply hooks into that logic and extends it to field initializers as well (which also run before the base constructor call).

Ping @dotnet/roslyn-compiler for review.

@gafter
Copy link
Member

gafter commented May 12, 2016

:shipit: LGTM

@gafter
Copy link
Member

gafter commented May 12, 2016

:shipit:

@VSadov
Copy link
Member

VSadov commented May 12, 2016

LGTM

@khyperia khyperia merged commit 9335649 into dotnet:master May 12, 2016
@khyperia khyperia deleted the fix10463 branch May 12, 2016 18:27
{
object a = Test((dynamic)2);

static object Test(object obj) => obj;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a test with an instance method?

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there is a breaking change in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants