Compiler version
3.3.7, 3.7.4, 3.8.3
Minimized code
//> using scala 3.8.3
enum Animal:
case Cat(meow: String)
def meow(cat: Animal.Cat): String = cat.meow
@main
def main: Unit = {
val cat: Animal.Cat = Animal.Cat("meow")
val catWithBetterMeow = cat.copy(meow = "_€%")
println(meow(catWithBetterMeow))
}
Output
[error] ./copy-issue.scala:14:16
[error] Found: (catWithBetterMeow : Animal)
[error] Required: Animal.Cat
[error] println(meow(catWithBetterMeow))
[error] ^^^^^^^^^^^^^^^^^
Expectation
For the type of catWithBetterMeow to be inferred as Animal.Cat and that the program compiled.
We can explicitly annotate it with val catWithBetterMeow: Animal.Cat in which case it compiles fine.
Compiler version
3.3.7, 3.7.4, 3.8.3
Minimized code
Output
Expectation
For the type of
catWithBetterMeowto be inferred asAnimal.Catand that the program compiled.We can explicitly annotate it with
val catWithBetterMeow: Animal.Catin which case it compiles fine.