Closed ahjohannessen closed 9 years ago
@timperrett @jedesah WDYT?
In fact, only @GenClient
and @GenServer
usage that works for 1.4.0 based projects are those that have the top-level package remotely
.
In order to summerize a bit, the code that causes issues is located in Gen.scala
and is used by GenClient
and GenServer
:
def liftField(c: Context)(field: Field[Any]): c.universe.Tree = {
import c.universe._
q"_root_.remotely.Field(${field.name}, ${field.typeString})"
}
Even if Gen
is in package remotely
and the problematic constructor of Field
is private[remotely]
we get an error stating that:
constructor Field in class Field cannot be accessed in object Client
Why that is confuses me a bit, but my PR solves the issue at hand. I can understand why that constructor is meant to be private, but as of now 1.4.0 is not usable, and I think that this is a reasonable fix for the time being despite it allows people to shoot themselves in the foot.
Alternatively:
case class Field[+A] private[remotely](name: String, typeString: String)
object Field {
def loose[A](name: String, typeString: String) = Field[A](name, typeString)
def strict[A:TypeTag](name: String) = Field[A](name, Remote.toTag[A])
}
and adjust liftField
to do this:
q"_root_.remotely.Field.loose[Any](${field.name}, ${field.typeString})"
in order to signal that is irregular usage by way of explicitly using loose
, but honestly I don't know how much that is good for, especially, if the API grows such that the user is not directly exposed to Field
normally.
@ahjohannessen I agree with you that this is a very simple change that solves a major problem so we should do it now and consider if there is a better way later. Can you insert a comment above Field
to remind us why it was made public?
Sure thing @jedesah :)
@jedesah I have updated it with this comment:
// TODO: ctor should really be private[remotely], but due
// to macro code generation issue in liftField (Gen.scala)
// we open it for the time being. See Github issue #89.
and consider if there is a better way later
Definitely important
@jedesah @timperrett If this gets merged and accepted, please publish a 1.4.1 soon :)
@ahjohannessen here you go: https://bintray.com/oncue/releases/remotely/1.4.1/view
@jedesah @timperrett thanks guys :+1:
change constructor accessibility of
Field
to be public rather thanprivate[remotely]
due to macro code generation issues.Reason that
private[remotely]
works fine forremotely
tests and example projects is because all share the same package.Note: I do not have any better solution than loosen the accessibility restriction as of now, but I wish to put focus on the matter such that we can get a quick bugfix in 1.4.1.
An example project that illustrates the issue can be found at:
https://github.com/ahjohannessen/remotely-14
and further discussion around the issue can be found here: http://bit.ly/1McVPL2 and here: https://gitter.im/scalamacros/paradise?at=55c37b2d7a6037e67c59d24d