Compiler version
Minimized code
package example
object Main extends App with Test {
load("")()
}
trait Test {
def load[T](
doLoad: T
)(
description: T => Option[String] = (_: T) => None // <--- compile error here
): Unit = ???
}
(sbt project available here: https://github.com/yurique/scala3-weird)
Output
[error] 12 | description: T => Option[String] = (_: T) => None
[error] | ^^^^^^^^^^^^^^
[error] | Found: T => Option[String]
[error] | Required: <? >: ("" : String)> => Option[String]
[error] |
[error] | longer explanation available when compiling with `-explain`
[error] one error found
Expectation
The code should compile.
Notes
- this code compiles if the
load function is defined in an object (no in a trait)
- it compiles if I move the definition of the
Test trait below the definition of the Main object
- It also fails to compile with the same error if the function is defined:
- as a top-level definition
- inside a package object
- as a trait in a separate file
edit: smaller example - no custom case classes needed