Hi!
Say I define a trait with a parameter:
trait Foo(val num: Int)
I then extend it in a class that has an identically named parameter:
class Bar(num: Int) extends Foo(num):
def bar = this.num
Trying to instantiate this class with Bar(123)
produces a ClassFormatError
, which complains about duplicate field names. Here’s a Scastie.
If Foo
was a class instead, the code would work.
Is this a known issue?
(I know that renaming and override val
are possible solutions here, but it would be very nice if the code worked on traits like it works on classes.)
Thank you!