com-lihaoyi / scalatags

ScalaTags is a small XML/HTML construction library for Scala.
https://com-lihaoyi.github.io/scalatags/
MIT License
758 stars 117 forks source link

`Tag` type alias doesn't seem to work when writing cross-backend code #140

Closed lihaoyi closed 8 years ago

lihaoyi commented 8 years ago
@ import $ivy.`com.lihaoyi::scalatags:0.6.0`
import $ivy.$

@
class Templates[Builder, Output <: FragT, FragT](val bundle: scalatags.generic.Bundle[Builder, Output, FragT]){
  import bundle.all._
  val x: Tag = div("hello")
}
cmd1.sc:3: type mismatch;
 found   : Templates.this.bundle.all.div.Self
 required: Templates.this.bundle.all.Tag
  val x: Tag = div("hello")
                  ^
Compilation Failed

You can of course use asInstanceOf to shut it up, and generally you should probably be working with Frags anyway (which does work correctly). Regardless, there are good uses for the Tag type (e.g. if you want to construct a fragment, and then add additional children or attributes to it) so this really should just work