Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@boopickleWireProtocol macro expansion error due to empty parameter list in event sourced entity api #68

Open
SemanticBeeng opened this issue Apr 1, 2019 · 7 comments

Comments

@SemanticBeeng
Copy link

SemanticBeeng commented Apr 1, 2019

@notxcain I am getting this as soon as I add a method in my event sourced entity api returning *Status. The *Status is implemented similar to BookingStatus from @vpavkin 's tutorial.

The only thing I can see different is that my *Status is in a different sbt module than the entity.
But also tried moving it to same sbt module and getting same

Any idea of what might cause this?
Not likely this to be an aecor bug but maybe others will run into it so worth having it here.

[error] <macro>:2:4: exception during macro expansion: 
[error] org.scalameta.invariants.InvariantFailedException: invariant failed:
[error] when verifying args.length.>(1).||(args.length.==(1).&&(scala.meta.classifiers.`package`.XtensionClassifiable[scala.meta.Term](args.head)(scala.meta.Tree.classifiable[scala.meta.Term]).is[scala.meta.internal.ast.Quasi](scala.meta.internal.ast.Quasi.ClassifierClass[scala.meta.Term])))
[error] found that args.length.>(1) is false
[error] and also scala.meta.classifiers.`package`.XtensionClassifiable[scala.meta.Term](args.head)(scala.meta.Tree.classifiable[scala.meta.Term]).is[scala.meta.internal.ast.Quasi](scala.meta.internal.ast.Quasi.ClassifierClass[scala.meta.Term]) is false
[error] where args = List("status")
[error] 	at org.scalameta.invariants.InvariantFailedException$.raise(Exceptions.scala:15)
[error] 	at scala.meta.Term$Tuple$.internal$44(Trees.scala:78)
[error] 	at scala.meta.Term$Tuple$.apply(Trees.scala:75)
[error] 	at aecor.macros.BoopickleWireProtocolMacro$.$anonfun$apply$4(boopickleWireProtocol.scala:60)
[error] 	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
[error] 	at scala.collection.immutable.List.foreach(List.scala:389)
[error] 	at scala.collection.TraversableLike.map(TraversableLike.scala:234)
[error] 	at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
[error] 	at scala.collection.immutable.List.map(List.scala:295)
[error] 	at aecor.macros.BoopickleWireProtocolMacro$.apply(boopickleWireProtocol.scala:58)
[error] 	at aecor.macros.boopickleWireProtocol$inline$.apply(boopickleWireProtocol.scala:16)
[error]   @boopickleWireProtocol trait Session[F[_]] {
@vpavkin
Copy link
Collaborator

vpavkin commented Apr 1, 2019

@SemanticBeeng Hi.
Could you pls post source file that causes the error?

@vpavkin
Copy link
Collaborator

vpavkin commented Apr 1, 2019

Ok, DM exchanged showed that the problem is with methods shaped the following way (with an empty param list:

def status(): F[Unit)

Quick workaround is to remove the parens. I'll try to tune the macro to handle this case properly.

@SemanticBeeng Could you please alter the ticket title (I can't)?

@SemanticBeeng
Copy link
Author

Vladimir advised the macro crash is due to the empty parameter list in def status() : below.
Fixed to make it like def expiresIn :

  def expiresIn: F[com.kse.shared.domain.TimeMs]

  def keepAlive(period: com.kse.shared.domain.TimeMs): F[Unit]

  def status(): F[domain.SessionStatus]

  def terminate(reason: String): F[Unit]
}

Will keep it open to fix this rough edge of the macro.
Many thanks.

@SemanticBeeng SemanticBeeng changed the title @boopickleWireProtocol macro expansion error @boopickleWireProtocol macro expansion error due to empty parameter list in event sourced entity api Apr 1, 2019
@notxcain
Copy link
Owner

notxcain commented Apr 1, 2019

Actually I’d rather forbid empty params list methods at all :) They are used to mark something impure, which should not be a case.

@SemanticBeeng
Copy link
Author

SemanticBeeng commented Apr 1, 2019

I would be perfectly okay to close, ofc.
A nicer error message would have helped but not sure if the job of the macro is to be aware of event sourced entity design style.

@vpavkin
Copy link
Collaborator

vpavkin commented Apr 1, 2019

It's more about code-style that communicates purity. Aecor calls itself opinionated, so I see no problem with a readable, opinionated error-message.

@notxcain
Copy link
Owner

notxcain commented Apr 1, 2019

A nice error message would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants