-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Argument types are erroneously inferred as Nothing
when a method is explicitly eta-expanded as in f(_)
#16405
Comments
neko-kai
added
itype:bug
stat:needs triage
Every issue needs to have an "area" and "itype" label
labels
Nov 23, 2022
neko-kai
changed the title
Argument types are erroneously inferred as
Argument types are erroneously inferred as Nov 23, 2022
Nothing
when a method explicitly eta-expanded using placeholders as in f(_)
Nothing
when a method is explicitly eta-expanded as in f(_)
szymon-rd
added
area:typer
area:inline
and removed
stat:needs triage
Every issue needs to have an "area" and "itype" label
labels
Nov 24, 2022
Thank you for reporting and minimization! |
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 5, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we delay the resolution from the source method until later, after which it is resolved according to the target method. We also modify the targettype resolution method a bit, as just applying the above procedure would fail some of the tests, eg. val y1: Function1[_, Nothing] = x => x would be typed as Function1[Any, Nothing], which was incorrect.
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 5, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we delay the resolution from the source method until later, after which it is resolved according to the target method. We also modify the target type resolution method a bit, as just applying the above procedure would fail some of the tests, eg. val y1: Function1[_, Nothing] = x => x would be typed as Function1[Any, Nothing], which was incorrect.
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 9, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we save that fact for later (while still resolving the prototype parameter to Nothing) and we in that case we prioritize according to the target method, after which we fallback to the default procedure.
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 9, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we save that fact for later (while still resolving the prototype parameter to Nothing) and we in that case we prioritize according to the target method, after which we fallback to the default procedure.
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 9, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we save that fact for later (while still resolving the prototype parameter to Nothing) and we in that case we prioritize according to the target method, after which we fallback to the default procedure.
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 9, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we save that fact for later (while still resolving the prototype parameter to Nothing) and we in that case we prioritize according to the target method, after which we fallback to the default procedure.
jchyb
added a commit
to jchyb/dotty
that referenced
this issue
Jan 11, 2023
This was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (resolving type wildcards to Nothing) and only after that, it could look at the target method. Now, in the case of wildcards we save that fact for later (while still resolving the prototype parameter to Nothing) and we in that case we prioritize according to the target method, after which we fallback to the default procedure.
odersky
added a commit
that referenced
this issue
Jan 26, 2023
Fixes #16405, which was a problem because it could it get in the way of some metaprogramming techniques. The main issue was the fact that when typing functions, the type inference would first look at the types from the source method (in decomposeProtoFunction resolving found type wildcards to Nothing) and only after that, it could look at the target method. This is a continuation and simplification of #16625
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiler version
3.2.1 and 3.2.2-RC1
Minimized code
Runnable: https://scastie.scala-lang.org/WNexehduQzOT4XJ2XfUB7Q
Output
Expectation
Expected there to be no difference between
exampleFn
andexampleFn(_, _)
form in type inference in general and when callingargumentTypesOf
.Expected all variants of argumentTypesOf* to not infer Nothing regardless of using wildcards anywhere in the parameter type.
This code is a minimized version of real library code in https://github.com/izumi/izumi which we're trying to port to Scala 3
The text was updated successfully, but these errors were encountered: