We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
type Upgrade[T] = T match case Int => Double case Char => String case Boolean => Boolean // compiles val upgrade: [t] => t => Upgrade[t] = new PolyFunction: def apply[T](x: T): Upgrade[T] = x match case x: Int => x.toDouble case x: Char => x.toString case x: Boolean => !x // does not compile val upgrade2: [t] => t => Upgrade[t] = [t] => (x: t) => x match case x: Int => x.toDouble case x: Char => x.toString case x: Boolean => !x
[error] -- [E007] Type Mismatch Error: /.../Tuples.scala:42:27 e / compileIncremental 0s [error] 42 | case x: Boolean => !x [error] | ^ [error] | Found: Object with PolyFunction {...} [error] | Required: PolyFunction{apply: [t](x$1: t): tlp.Tuples.Upgrade[t]}
it should compile.
btw, polyfunction lambda with "regular" return types works just fine.
The text was updated successfully, but these errors were encountered:
This might be somehow related to #6904
Sorry, something went wrong.
the issue appears to be that the right hand side of your polymorphic function lambda can't infer Upgrade[T]. adding an explicit ascription works:
Upgrade[T]
val upgrade2 = [t] => (x: t) => (x match case x: Int => x.toDouble case x: Char => x.toString case x: Boolean => !x): Upgrade[t]
Add a regression test for scala#10369
e9b4975
Was fixed in `3.2.1-RC1`. Add a regression test for scala#10369.
Successfully merging a pull request may close this issue.
Minimized code
Output
Expectation
it should compile.
btw, polyfunction lambda with "regular" return types works just fine.
The text was updated successfully, but these errors were encountered: