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

Properly implement type inference for C# member access expressions. #12110

Merged
merged 11 commits into from
Jun 21, 2016

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@CyrusNajmabadi
Copy link
Member Author

test vsi please

@CyrusNajmabadi
Copy link
Member Author

@dotnet-bot retest perf_correctness_prtest please
// Previous failure: http://dotnet-ci.cloudapp.net/job/dotnet_roslyn/job/master/job/perf_correctness_prtest/109/
// Retest reason:

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 ( ) ; } } ");
Copy link
Contributor

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?

@@ -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);
Copy link
Member

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?

Copy link
Member Author

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.

@CyrusNajmabadi
Copy link
Member Author

@dotnet-bot retest windows_eta_open_prtest please
// Previous failure: http://dotnet-ci.cloudapp.net/job/Private/job/dotnet_roslyn-internal/job/master/job/windows_eta_open_prtest/715/
// Retest reason:

@CyrusNajmabadi
Copy link
Member Author

CyrusNajmabadi commented Jun 21, 2016

@Pilchie @jmarolf I've improved inference in a couple of cases.

  1. If we see Foo.ContinueWith then we'll infer Task<object> for Foo.
  2. If we see Foo.Where(i => ...) or Foo.Select(i => ...) then we'll infer IEnumerable<T> where T is the type we infer for i.

@CyrusNajmabadi
Copy link
Member Author

test vsi please

@CyrusNajmabadi
Copy link
Member Author

@dotnet-bot retest windows_debug_unit64_prtest please
// Previous failure: http://dotnet-ci.cloudapp.net/job/dotnet_roslyn/job/master/job/windows_debug_unit64_prtest/694/
// Retest reason:

@CyrusNajmabadi
Copy link
Member Author

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 ( ) ; } } ");
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure.

@rchande
Copy link
Contributor

rchande commented Jun 21, 2016

👍

@CyrusNajmabadi CyrusNajmabadi merged commit 96568b8 into dotnet:master Jun 21, 2016
@CyrusNajmabadi CyrusNajmabadi deleted the typeInferenceWork branch June 21, 2016 20:02
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.

5 participants