-
Notifications
You must be signed in to change notification settings - Fork 40
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
@accessible macro highlights as error but runs in tests #429
Comments
Thanks so much for the reports! I'll try looking into this as well, though I admit the macro stuff is black magic to me! But a question: is |
@hmemcpy it's part of my code base. Playing around with aspects to make my postgres tests easier to write/reason about |
It looks like I get the same issues in src/main too. Is there anything else I can add to help diagnosing this? |
@Ellzord I'll take a look today or tomorrow and will come back to you |
I've tried to make my code as close as possible to yours but it still works fine 🤔 import zio._
import zio.macros.accessible
import zio.prelude.Newtype
object model {
object PositionId extends Newtype[Int]
type PositionId = PositionId.Type
object EventId extends Newtype[Int]
type EventId = EventId.Type
final case class Context(value: Int)
final case class Position(value: Int)
}
import model._
@accessible
trait Repository {
def save(Position: Position)(implicit context: Context): UIO[PositionId]
def save(Positions: Chunk[Position])(implicit context: Context): UIO[Chunk[PositionId]]
def findByEventId(eventId: EventId)(implicit context: Context): UIO[Chunk[Position]]
}
object Repository {
val live = ???
}
object ZIO2 {
implicit val context: Context = Context(1)
for {
_ <- Repository.save(Position(1))
_ <- Repository.save(Chunk(Position(1)))
_ <- Repository.findByEventId(EventId(1))
} yield ()
} Could you please check if the code above is highlighted? If not, it'll be really great if you could simplify and share your code in scastie, because I'm out of ideas on how to reproduce it |
@myazinn I've made an example project that shows the problem. It turns out it's related to having different modules. When I try your example in one module it all works fine but if I split it up I get the errors. I've attached the project in a zip. Is that okay? |
That's awesome, thank you! I'll take a look today |
@Ellzord yes, now I can see errors Also, just in case here's a minimized code snippet that reproduces the issue // separate package object
package bug
package object plugin {
final case class UserId(id: Int)
}
// another file
package bug.plugin
import zio.UIO
import zio.macros.accessible
@accessible
trait Repo {
def find(id: UserId): UIO[Unit]
}
object Test extends App {
println(Repo.find(UserId(1)))
} |
In this code the first error is the method is overloaded (Position and Chunk[Position]), the second error it doesn't like the new type and considers it to be Nothing, and in the hover you can see it thinks the return type is Chunk[Any].
I'm unable to reopen the issue myself, can you do this for me? If it helps this is in src/test while a previous example it was in src/main.
Originally posted by @Ellzord in #366 (comment)
The text was updated successfully, but these errors were encountered: