Here is the example filled out, just for educational value.
Maybe your stack trace is more interesting, but it seems you can try again after blowing up in a lazy initializer, so it's not true that "it stays null forever." (I guess you mean it blows up forever, too.) Probably someone has mentioned that on SO.
package nullinit
trait TickerCollection[T] {
val items: List[T]
val mapping: T => PublishDataTicker
lazy val publishedDataTickers = {
println("I'm really trying! Mapping is "+ mapping)
items.zip(items.map { mapping } )
}
}
trait CurveType
trait PublishDataTicker
trait SingleCurveAssociatedTickerCollection[T<:MyClass] extends TickerCollection[T] {
val curveType: CurveType
val mapping: T => PublishDataTicker = item => item.tickerFor(curveType)
}
trait ItemsProvider extends TickerCollection[MyClass] {
val items: List[MyClass] = List(new MyClass)
try {
println("My tickers "+ publishedDataTickers)
} catch { case t => println("Catch the wave."); t.printStackTrace() }
}
class MyClass {
def tickerFor(t: CurveType): PublishDataTicker = new PublishDataTicker { }
}
class MyImpl extends ItemsProvider with SingleCurveAssociatedTickerCollection[MyClass] {
val curveType = new CurveType { }
}
object Test {
def main(args: Array[String]) {
val x = new MyImpl
println("My tickers2 "+ x.publishedDataTickers)