-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Type inference fails with SAM and wildcard subtyping, works in 2.13 #18096
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
Comments
@smarter asking your opinion here |
Shouldn't this be |
@mdedetrich or |
I updated the expectation, sorry for the confusion |
Minimised further trait F1[-T1, +R] extends AnyRef { def apply(v1: T1): R }
class R { def l: List[Any] = Nil }
class S { def m[T](f: F1[R, ? <: List[T]]): S = this }
class T1 { def t1(s: S) = s.m((r: R) => r.l) } |
I'm working on a fix for #16065 that also fixes this issue. |
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 13, 2023
When typing a closure with an expected type containing a wildcard, the closure type itself should not contain wildcards, because it might be expanded to an anonymous class extending the closure type (this happens on non-JVM backends as well as on the JVM itself in situations where a SAM trait does not compile down to a SAM interface). We were already approximating wildcards in the method type returned by the SAMType extractor, but to fix this issue we had to change the extractor to perform the approximation on the expected type itself to generate a valid parent type. The SAMType extractor now returns both the approximated parent type and the type of the method itself. The wildcard approximation analysis relies on a new `VarianceMap` opaque type extracted from Inferencing#variances. Fixes scala#16065. Fixes scala#18096.
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 13, 2023
When typing a closure with an expected type containing a wildcard, the closure type itself should not contain wildcards, because it might be expanded to an anonymous class extending the closure type (this happens on non-JVM backends as well as on the JVM itself in situations where a SAM trait does not compile down to a SAM interface). We were already approximating wildcards in the method type returned by the SAMType extractor, but to fix this issue we had to change the extractor to perform the approximation on the expected type itself to generate a valid parent type. The SAMType extractor now returns both the approximated parent type and the type of the method itself. The wildcard approximation analysis relies on a new `VarianceMap` opaque type extracted from Inferencing#variances. Fixes scala#16065. Fixes scala#18096.
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 14, 2023
When typing a closure with an expected type containing a wildcard, the closure type itself should not contain wildcards, because it might be expanded to an anonymous class extending the closure type (this happens on non-JVM backends as well as on the JVM itself in situations where a SAM trait does not compile down to a SAM interface). We were already approximating wildcards in the method type returned by the SAMType extractor, but to fix this issue we had to change the extractor to perform the approximation on the expected type itself to generate a valid parent type. The SAMType extractor now returns both the approximated parent type and the type of the method itself. The wildcard approximation analysis relies on a new `VarianceMap` opaque type extracted from Inferencing#variances. Fixes scala#16065. Fixes scala#18096.
smarter
added a commit
to dotty-staging/dotty
that referenced
this issue
Jul 15, 2023
When typing a closure with an expected type containing a wildcard, the closure type itself should not contain wildcards, because it might be expanded to an anonymous class extending the closure type (this happens on non-JVM backends as well as on the JVM itself in situations where a SAM trait does not compile down to a SAM interface). We were already approximating wildcards in the method type returned by the SAMType extractor, but to fix this issue we had to change the extractor to perform the approximation on the expected type itself to generate a valid parent type. The SAMType extractor now returns both the approximated parent type and the type of the method itself. The wildcard approximation analysis relies on a new `VarianceMap` opaque type extracted from Inferencing#variances. Fixes scala#16065. Fixes scala#18096.
smarter
added a commit
that referenced
this issue
Jul 15, 2023
When typing a closure with an expected type containing a wildcard, the closure type itself should not contain wildcards, because it might be expanded to an anonymous class extending the closure type (this happens on non-JVM backends as well as on the JVM itself in situations where a SAM trait does not compile down to a SAM interface). We were already approximating wildcards in the method type returned by the SAMType extractor, but to fix this issue we had to change the extractor to perform the approximation on the expected type itself to generate a valid parent type. The SAMType extractor now returns both the approximated parent type and the type of the method itself. The wildcard approximation analysis relies on a new `VarianceMap` opaque type extracted from Inferencing#variances. Fixes #16065. Fixes #18096.
Kordyjan
pushed a commit
that referenced
this issue
Nov 30, 2023
[Cherry-picked 89735d0][modified] When typing a closure with an expected type containing a wildcard, the closure type itself should not contain wildcards, because it might be expanded to an anonymous class extending the closure type (this happens on non-JVM backends as well as on the JVM itself in situations where a SAM trait does not compile down to a SAM interface). We were already approximating wildcards in the method type returned by the SAMType extractor, but to fix this issue we had to change the extractor to perform the approximation on the expected type itself to generate a valid parent type. The SAMType extractor now returns both the approximated parent type and the type of the method itself. The wildcard approximation analysis relies on a new `VarianceMap` opaque type extracted from Inferencing#variances. Fixes #16065. Fixes #18096.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see original forum post reported by @mdedetrich
Compiler version
3.3.0
Minimized code
Output
adding the explicit type
pekko.Function[StreamingPullResponse, java.util.List[pekko.ReceivedMessage]]
fixes the error,also inference works if the signature of mapConcat changes to
Expectation
it should compile, like it did in scala 2.13.10
The text was updated successfully, but these errors were encountered: