softwaremill / softwaremill/macwire

macwire fails to find lazy vals for injection if there is a block comment above them in the publish phase

Open
#21 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.3k
Forks
77
Avg merge
9m
Merged PRs (30d)
4

Description

This is using macwire 0.7.1 and scala 2.11.2.

When we have a code block like this:

/**
  * some comment what this service does.
  */
  lazy val service: Service = MyService

as part of the dependencies, then

  • compiling normally works as expected
  • the publish command, which re-compiles everything, fails to find service in the compilation phase.

The reason is the block comment which seems to interfere with the macros somehow. When the block comment is deleted everything works as expected. Still, this bug is rather annoying when wanting to publish a well-commented library....

publish
[info] Packaging /Users/joe/Documents/git/brokenMacwireParsing/target/scala-2.11/brokenmacwireparsing_2.11-1.0-sources.jar ...
[info] Done packaging.
[info] Packaging /Users/joe/Documents/git/brokenMacwireParsing/target/scala-2.11/brokenmacwireparsing_2.11-1.0.jar ...
[info] Main Scala API documentation to /Users/joe/Documents/git/brokenMacwireParsing/target/scala-2.11/api...
[info] Wrote /Users/joe/Documents/git/brokenMacwireParsing/target/scala-2.11/brokenmacwireparsing_2.11-1.0.pom
[info] Done packaging.
[info] :: delivering :: brokenmacwireparsing#brokenmacwireparsing_2.11;1.0 :: 1.0 :: release :: Fri Oct 10 17:04:11 CEST 2014
[info]  delivering ivy file to /Users/joe/Documents/git/brokenMacwireParsing/target/scala-2.11/ivy-1.0.xml
[debug] Trying to find parameters to create new instance of: [com.example.Hello]
   [debug] Trying to find value [service] of type: [com.example.Service]
      [debug] Looking in the enclosing method
      [debug] Looking in the enclosing class/trait
      [debug] Checking def: [$init$]
      [debug] Checking val: [hello]
      [debug] Looking in parents
      [debug] Checking parent: [AnyRef]
[error] /Users/joe/Documents/git/brokenMacwireParsing/src/main/scala/com/example/Hello.scala:18: Cannot find a value of type: [com.example.Service]
[error]   lazy val hello: Hello = wire[Hello]
[error]  

See the specially created repo reproducing this bug here, including macwire debug output:

https://github.com/jschaul/macwire-bug-demonstration

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Use the linked macwire-bug-demonstration repository to reproduce the failure with macwire 0.7.1 and Scala 2.11.2; compare normal compilation with publish and inspect the macwire debug output for Hello.scala. Done means the documented block comment no longer prevents service from being found during publish, while the existing injection still compiles.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.