-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Properly implement type inference for C# member access expressions. #12110
Properly implement type inference for C# member access expressions. #12110
Conversation
test vsi please |
@dotnet-bot retest perf_correctness_prtest please |
static void Main ( string [ ] args ) { | ||
bool x = await [|Foo|] ( ) . ConfigureAwait ( false ) ; | ||
} | ||
}", | ||
@"using System ; using System . Collections . Generic ; using System . Linq ; using System . Threading . Tasks ; class Program { static void Main ( string [ ] args ) { bool x = await Foo ( ) . ConfigureAwait ( false ) ; } private static Task < bool > Foo ( ) { throw new NotImplementedException ( ) ; } } "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the formatting here two, so they both match?
e24bef7
to
41a1d64
Compare
@@ -1591,7 +1591,7 @@ class C | |||
bool x = await [|M()|].ConfigureAwait(false); | |||
} | |||
}"; | |||
await TestAsync(text, "global::System.Threading.Tasks.Task<System.Boolean>"); | |||
await TestAsync(text, "global::System.Threading.Tasks.Task<System.Boolean>", testPosition: false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we test position anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because at the start position of that expression (which is what "testPosition" is testing) there is no reason to infer Task if you have a member access expression.
@dotnet-bot retest windows_eta_open_prtest please |
test vsi please |
@dotnet-bot retest windows_debug_unit64_prtest please |
retest perf_correctness_prtest please |
class C { | ||
static async void T ( ) { | ||
bool x = await M ( ) . ContinueWith ( a => { return true ; } ) . ContinueWith ( a => { return false ; } ) ; } | ||
private static Task<object> M ( ) { throw new NotImplementedException ( ) ; } } "); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now infers object
instead of bool
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The inference of 'bool' was specious. It basically was saying the equivalent of: i have "bool b = x.y.z", ergo 'x' and 'y' are bool". This simply is not an accurate or appropriate inference to make.
end sub | ||
end class" | ||
Await TestAsync(text, "Global.System.Collections.Generic.IEnumerable(Of System.Int32)", testPosition:=False) | ||
End Function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test for the
bool x = Bool.$$
case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure.
👍 |
No description provided.