error in macro expansion of @GenServer
shengc opened this issue · 5 comments
shengc commented
// project 1
val definition =
Protocol
.empty
.codec[String]
.codec[Option[String]]
.codec[List[String]]
.codec[Map[String, String]]
.specify3("foo", Field.strict[String]("a"), Field.strict[String]("b"), Field.strict[String]("c"), Type[List[String]])
// project 2 depends on project 1
// I did use the full fqn of definition
@GenServer(definition) abstract class Foo
It throws exception,
[error] scala.reflect.macros.ParseException: ';' expected but ',' found.
[error] at scala.reflect.macros.contexts.Parsers$$anonfun$parse$1.apply(Parsers.scala:18)
[error] at scala.reflect.macros.contexts.Parsers$$anonfun$parse$1.apply(Parsers.scala:17)
[error] at scala.collection.mutable.LinkedHashSet.foreach(LinkedHashSet.scala:91)
[error] at scala.reflect.macros.contexts.Parsers$class.parse(Parsers.scala:17)
[error] at scala.reflect.macros.contexts.Context.parse(Context.scala:6)
[error] at scala.reflect.macros.contexts.Context.parse(Context.scala:6)
[error] at remotely.GenServer$.parseType(GenServer.scala:35)
[error] at remotely.GenServer$$anonfun$2.apply(GenServer.scala:59)
[error] at remotely.GenServer$$anonfun$2.apply(GenServer.scala:58)
[error] at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
[error] at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
[error] at scala.collection.immutable.Set$Set2.foreach(Set.scala:111)
[error] at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
[error] at scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)
[error] at scala.collection.SetLike$class.map(SetLike.scala:92)
[error] at scala.collection.AbstractSet.map(Set.scala:47)
[error] at remotely.GenServer$.impl(GenServer.scala:58)
[error] @GenServer(....definition
I tried a few specify1
, and they are all good though.
shengc commented
This is the culprit
https://github.com/oncue/remotely/blob/master/core/src/main/scala/Signatures.scala#L42
Multi arguments must be surrounded by a pair of ()
in order to let macro properly parse it
private def lhs = params match {
case p :: Nil => p.typeString
case _ => params.map(_.typeString).mkString("(", ",", ")")
}
runarorama commented
Awesome. Looking forward to the PR :)
shengc commented
@runarorama there is already a PR #90 to address this. Hopefully it can be merged soon !
shengc commented
@runarorama I changed my mind, that PR basically leaves lhs
useless, which I don't feel right.
ahjohannessen commented
Closed by 21edf82