-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
Minimized code
found by @texasbruce in #640 (comment)
trait A(val s: String) { println(s) }
trait B extends A { override val s = "B" } // requires override val s
class C extends B
@main def Test = C()
Output
prints null
Expectation
this error appears if we remove the override
-- Error: example.scala:3:6 ----------------------------------------------------
3 |class C extends B
| ^
| parameterized trait A is indirectly implemented,
| needs to be implemented directly so that arguments can be passed
1 error found
Notes
we can still prevent compilation with the init checker:
-- Error: example.scala:2:33 ---------------------------------------------------
2 |trait B extends A { override val s = "B" } // requires override val s
| ^
| Access non-initialized field s. Calling trace:
| -> trait A(val s: String) { println(s) } [ example.scala:1 ]
1 error found
neontorrent