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

Verify semantic model on suppressed expressions #32661

Closed
jcouv opened this issue Jan 19, 2019 · 2 comments · Fixed by #38756
Closed

Verify semantic model on suppressed expressions #32661

jcouv opened this issue Jan 19, 2019 · 2 comments · Fixed by #38756
Assignees
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Jan 19, 2019

From discussion with Neal, we think the suppression expression should have matching Type and ConvertedType, which would be the converted type of the underlying expression.
In (Delegate)(() = {}!) and Delegate x = () => {}!;, the suppressed expressions would have type and converted type Delegate.

Other interesting scenarios involving conversions from expressions: null, default, lambdas, method groups, interpolated strings.

Look for uses of BoundNode.Kind and BoundKind.MethodGroup (for instance, GetTypeInfoForNode)

@333fred
Copy link
Member

333fred commented May 2, 2019

After further discussions with @AlekseyTs, @jcouv, and @gafter, we've decided that the existing Type and ConvertedType fields are correct for suppressed expressions. These examples as written are correct:

Action a = () => {}!; // Type of null, ConvertedType of Action when called on both the inner lambda syntax and when called on the ! syntax
string? s = null;
object o = s!; // Type of string, ConvertedType of object when called on both the inner local reference and when called on the ! syntax.

Currently, the Nullability and ConvertedNullability on these syntax nodes are the same. As a future feature, we would like to have the underlying syntax have the original null state before suppression, but we think that such a feature will be ok to add in the future. This work is tracked by #35412.

@333fred 333fred closed this as completed May 2, 2019
@jcouv
Copy link
Member Author

jcouv commented Sep 18, 2019

There are references to this issue left.

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