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

Regression in Scala 2.13-M4: scaladoc silently ignores -Ymacro-annotations flag #11076

Closed
Atry opened this issue Aug 14, 2018 · 2 comments
Closed

Comments

@Atry
Copy link

Atry commented Aug 14, 2018

Given a macro annotation that renames any class to the_class_name_is_modified_by_myAnnotation

object MyMacro {
  def macroTransform(c: Context)(annottees: c.Tree*): c.Tree = {
    import c._, universe._
    q"class the_class_name_is_modified_by_myAnnotation"
  }


  final class myAnnotation extends StaticAnnotation {
    def macroTransform(annottees: Any*): Any = macro MyMacro.macroTransform
  }

}

and another project that use the annotation

object MyClass {
  @mypackage.MyMacro.myAnnotation
  class MyInnerClass

  def main(args: Array[String]): Unit = {
    new the_class_name_is_modified_by_myAnnotation
  }
}

new the_class_name_is_modified_by_myAnnotation should compile when -Ymacro-annotations is set. However, -Ymacro-annotations is ignored by scaladoc in Scala 2.13.0-M4, while the same macro annotation works when paradise plug-in is enabled in Scala 2.12.6.

git clone https://github.com/Atry/scaladoc-macro-annotations.git && cd scaladoc-macro-annotations && sbt +doc
Cloning into 'scaladoc-macro-annotations'...
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 16 (delta 0), reused 16 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), done.
[info] Loading settings for project global-plugins from idea.sbt,plugins.sbt ...
[info] Loading global plugins from /Users/twer/.sbt/1.0/plugins
[info] Loading project definition from /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/project
[info] Updating ProjectRef(uri("file:/private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/project/"), "scaladoc-macro-annotations-build")...
[info] Done updating.
[info] Loading settings for project scaladoc-macro-annotations from build.sbt ...
[info] Set current project to scaladoc-macro-annotations (in build file:/private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/)
[info] Setting Scala version to 2.12.6 on 2 projects.
[info] Reapplying settings...
[info] Set current project to scaladoc-macro-annotations (in build file:/private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/)
[info] Updating macros...
[info] Done updating.
[info] Updating ...
[info] Main Scala API documentation to /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/macros/target/scala-2.12/api...
[info] Done updating.
[info] Compiling 1 Scala source to /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/macros/target/scala-2.12/classes ...
model contains 4 documentable templates
[warn] there was one deprecation warning (since 2.11.0); re-run with -deprecation for details
[warn] one warning found
[info] Done compiling.
[info] Main Scala API documentation successful.
[info] Main Scala API documentation to /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/target/scala-2.12/api...
model contains 4 documentable templates
[info] Main Scala API documentation successful.
[success] Total time: 3 s, completed Aug 15, 2018 12:41:49 AM
[info] Setting Scala version to 2.13.0-M4 on 2 projects.
[info] Reapplying settings...
[info] Set current project to scaladoc-macro-annotations (in build file:/private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/)
[info] Updating macros...
[info] Done updating.
[info] Updating ...
[info] Main Scala API documentation to /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/macros/target/scala-2.13.0-M4/api...
[info] Done updating.
[info] Compiling 1 Scala source to /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/macros/target/scala-2.13.0-M4/classes ...
model contains 4 documentable templates
[warn] there was one deprecation warning (since 2.11.0); re-run with -deprecation for details
[warn] one warning found
[info] Done compiling.
[info] Main Scala API documentation to /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/target/scala-2.13.0-M4/api...
[error] /private/tmp/scaladoc-macro-annotations/scaladoc-macro-annotations/src/main/scala/myapp/MyClass.scala:8:9: not found: type the_class_name_is_modified_by_myAnnotation
[error]     new the_class_name_is_modified_by_myAnnotation
[error]         ^
[info] No documentation generated with unsuccessful compiler run
[error] one error found
[info] Main Scala API documentation successful.
[error] (Compile / doc) Scaladoc generation failed
[error] Total time: 6 s, completed Aug 15, 2018 12:41:56 AM
Atry added a commit to ThoughtWorksInc/Dsl.scala that referenced this issue Aug 14, 2018
@hrhino hrhino added the macros label Aug 14, 2018
@SethTisue SethTisue added this to the 2.13.0-RC1 milestone Aug 14, 2018
@xuwei-k
Copy link

xuwei-k commented Aug 15, 2018

related(?) #11045

@adriaanm
Copy link
Contributor

adriaanm commented Jan 8, 2019

Yes, duplicate of #11045

@adriaanm adriaanm closed this as completed Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants