I have the following code that fails to compile.
package com.example
import scala.reflect.ClassTag
abstract class RDD[T: ClassTag]
class Dependency[T](_rdd: RDD[T]) {
def rdd: RDD[T] = _rdd
}
class FakeRDD[T: ClassTag](deps: Dependency[_]) extends RDD[T]
object Hello {
def main(args: Array[String]): Unit = {
new FakeRDD(null)
new FakeRDD(new Dependency(new FakeRDD(null))) // fails to compile
println("Hello, Scala!")
}
}
The error is from the line that has a trailing comment “fails to compile”. The error message is:
Hello.scala:16: No ClassTag available for T
However, if I use multiple lines, it can compile:
val d = new Dependency(new FakeRDD(null))
new FakeRDD(d)