-
Notifications
You must be signed in to change notification settings - Fork 676
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
Return appropriate derived class when method returns self #4622
Conversation
return _method.ReturnTypes.GetInstanceType(); | ||
// Check if method returns self | ||
var returnType = _method.ReturnTypes.GetInstanceType(); | ||
if (args.Length > 0 && returnType.FirstOrDefault() is BuiltinInstanceInfo biif && biif.PythonType == _method.Function?.DeclaringType) { |
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.
There's a .Split
extension method for returnType
here that makes it easier to handle multiple return values properly (split with a predicate, then union and return). Otherwise, I like the approach
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.
Looks good to me. Worth bearing in mind that when we decide to support all parameter mappings through return values for the single-pass analysis that this change will be largely undone. It may also miss some current cases or lose some information if there are multiple return types.
Fixes #4614
Will add test next