I'd like to have a base case class I can extend at will into different types. I had something like this working previously, but I must have screwed something up, because now I'm getting compile errors.
trait JobLike case class Task(name: String) { def as[T <: JobLike]: Task with T = new Task(this.name) with T } The problem is, this gives me a compiler error like this:
java.lang.UnsupportedOperationException: addChild inapplicable for type T at scala.reflect.internal.Symbols$Symbol.addChild(Symbols.scala:1835) at scala.tools.nsc.typechecker.Namers$Namer.$anonfun$templateSig$1(Namers.scala:1119) at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:1107) at scala.tools.nsc.typechecker.Namers$Namer.classSig(Namers.scala:1178) at scala.tools.nsc.typechecker.Namers$Namer.memberSig(Namers.scala:1788) at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1751) at scala.tools.nsc.typechecker.Namers$Namer$MonoTypeCompleter.completeImpl(Namers.scala:836) ... at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:82) at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:85) at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96) at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:101) at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)</code> I swear, I had something working yesterday that basically did just this, but now it's throwing this error.
T is not a class typeso this looks like a kind of regression. Consider filing a bug report at github.com/scala/bug/issues