-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #11185: cache pretyped argument with adaptation in FunProto #12171
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
Conversation
class Test: | ||
def foo(a: Int, b: Int) = a + b | ||
|
||
Map(1 -> 2).map(foo _) |
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.
Just a random thought, but if the collections ever get rewritten again, map
might not be overloaded anymore. In which case this test no longer does what was intended.
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.
Good point, I'll add another test with overloading.
@@ -2101,7 +2101,9 @@ trait Applications extends Compatibility { | |||
else defn.FunctionOf(commonParamTypes, WildcardType) | |||
overload.println(i"pretype arg $arg with expected type $commonFormal") | |||
if (commonParamTypes.forall(isFullyDefined(_, ForceDegree.flipBottom))) | |||
withMode(Mode.ImplicitsEnabled)(pt.typedArg(arg, commonFormal)) | |||
withMode(Mode.ImplicitsEnabled) { |
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.
At first glance this looks too simplistic. We do a complicated dance not to overcommit by caching arguments that can be passed to several different expected types. How can we be sure that we can simply cache in this case? Maybe we can, but we'd need a detailed comment why.
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, a comment is deserved here. Currently I see the rationale is this: the expected type
for pretyping here come from all the overloading candidates and they (commandParamTypes
) are all fully defined.
I just checked: it does not work with master anymore. I think #12138 is to blame.
I rebased against master, it seems to work.
I just checked: it does not work with master anymore. I think #12138 is to blame. |
Fix #11185: cache pretyped argument with adaptation in FunProto