protected def toLuaValue(x: Any, eX: Elem[_]): LuaValue = eX match {
case UnitElement => LuaValue.NIL
case BooleanElement => LuaValue.valueOf(x.asInstanceOf[Boolean])
...
}
[error] /home/travis/build/scalan/scalan/lua-backend/core/src/main/scala/scalan/compilation/lua/LuaCompiler.scala:40: type mismatch;
[error] found : LuaCompiler.this.scalan.Elem[Unit]
[error] required: LuaCompiler.this.scalan.Elem[_$1] where type _$1
[error] case UnitElement => LuaValue.NIL
[error] ^
[error] /home/travis/build/scalan/scalan/lua-backend/core/src/main/scala/scalan/compilation/lua/LuaCompiler.scala:41: type mismatch;
[error] found : LuaCompiler.this.scalan.Elem[Boolean]
[error] required: LuaCompiler.this.scalan.Elem[_$1] where type _$1
[error] case BooleanElement => LuaValue.valueOf(x.asInstanceOf[Boolean])
[error] ^
...
which doesn't make sense to me: the types do match. In addition:
1. It used to work, and the commit which broke compilation just makes Elem extend an empty trait (https://github.com/scalan/scalan/commit/402aa0cb266c774bac39646193305f8215b3b905):
+ trait Dummy
- abstract class Elem[A] extends Serializable { _: scala.Equals =>
+ abstract class Elem[A] extends Serializable with Dummy { _: scala.Equals =>
2. Other similar matches on Elem[_] and Elem[A] weren't broken by this commit: https://github.com/scalan/scalan/blob/402aa0cb266c774bac39646193305f8215b3b905/core/src/main/scala/scalan/JNIExtractorOps.scala#L172-L182, https://github.com/scalan/scalan/blob/402aa0cb266c774bac39646193305f8215b3b905/core/src/main/scala/scalan/arrays/ArrayOps.scala#L359-L380, https://github.com/scalan/scalan/blob/402aa0cb266c774bac39646193305f8215b3b905/lms-backend/core/src/main/scala/scalan/compilation/lms/LmsBridge.scala#L295-L362
Is this a compiler bug? If so, is it known?
trait Elems {
trait Dummy
abstract class Elem[A] extends Serializable with Dummy
class BaseElem[A] extends Elem[A]
implicit val BooleanElement: Elem[Boolean] = new BaseElem[Boolean]
implicit val ByteElement: Elem[Byte] = new BaseElem[Byte]
implicit val ShortElement: Elem[Short] = new BaseElem[Short]
implicit val IntElement: Elem[Int] = new BaseElem[Int]
implicit val LongElement: Elem[Long] = new BaseElem[Long]
implicit val FloatElement: Elem[Float] = new BaseElem[Float]
implicit val DoubleElement: Elem[Double] = new BaseElem[Double]
implicit val UnitElement: Elem[Unit] = new BaseElem[Unit]
implicit val StringElement: Elem[String] = new BaseElem[String]
implicit val CharElement: Elem[Char] = new BaseElem[Char]
}
trait GoodMatch { self: Elems =>
private def boxed_class(e: Elem[_]): Class[_] = e match {
case BooleanElement => classOf[java.lang.Boolean]
case ByteElement => classOf[java.lang.Byte]
case ShortElement => classOf[java.lang.Short]
case IntElement => classOf[java.lang.Integer]
case LongElement => classOf[java.lang.Long]
case FloatElement => classOf[java.lang.Float]
case DoubleElement => classOf[java.lang.Double]
case CharElement => classOf[java.lang.Character]
case _ => ???
}
}
abstract class BadMatch[+A <: Elems](scalan: A) {
import scalan._
protected def toLuaValue(x: Any, eX: Elem[_]): String = eX match {
case UnitElement => ""
case _ => ???
}
// should check type before conversion?
protected def fromLuaValue[B](lv: Any, eA: Elem[B]): B = (eA match {
case UnitElement => ()
}).asInstanceOf[B]
}
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.