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

Assertion failure compiling macros with Scala 2.12 #29

Open
Facsimiler opened this issue Jan 2, 2017 · 3 comments
Open

Assertion failure compiling macros with Scala 2.12 #29

Facsimiler opened this issue Jan 2, 2017 · 3 comments

Comments

@Facsimiler
Copy link

Facsimiler commented Jan 2, 2017

Hi!

I recently switched to using Scala 2.12, and have since found that Unidoc fails when processing sources containing macro definitions. Specifically, an assertion error results.

The Ymacro-no-expand option has been deprecated in favor of Ymacro-expand:none as of Scala 2.12, so I'm using that, but otherwise, there aren't too many changes I can recall from the sources I used with Scala 2.11.

Unidoc worked fine with the same code under Scala 2.12. Am I missing something?

Here's what I'm seeing:

java.lang.AssertionError: assertion failed:

     while compiling: /home/some-user/src/some-project/some-module/macro/src/main/scala/some-url/util/package.scala
        during phase: globalPhase=terminal, enteringPhase=typer
     library version: version 2.12.1
    compiler version: version 2.12.1
  reconstructed args: -Ymacro-expand:none -diagrams -doc-footer Copyright © Some copyright message. -deprecation -groups -doc-title Some API Documentation -Xfatal-warnings -doc-version 0.0.4-SNAPSHOT -no-prefixes -classpath /some/path/macro/target/scala-2.12/classes:/home/some-user/.ivy2/cache/org.scoverage/scalac-scoverage-runtime_2.12/jars/scalac-scoverage-runtime_2.12-1.3.0.jar:/home/some-user/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.1.jar -bootclasspath /usr/lib/jvm/java-8-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-8-oracle/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-8-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-8-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-8-oracle/jre/classes:/home/some-user/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.12.1.jar -d /home/some-user/src/some-project/target/scala-2.12/api -implicits

  last tree to typer: Ident(<argument>)
       tree position: <unknown>
            tree tpe: some-url.util.Resource
              symbol: <none>
   symbol definition: <none> (a NoSymbol)
      symbol package: <none>
       symbol owners: 
           call site: package <root> in <none>

<Cannot read source file>
    at scala.tools.nsc.doc.model.ModelFactory.findTemplateMaybe(ModelFactory.scala:811)
    at scala.tools.nsc.doc.model.MemberLookup.internalLink(MemberLookup.scala:15)
    at scala.tools.nsc.doc.model.MemberLookup.internalLink$(MemberLookup.scala:14)
    at scala.tools.nsc.doc.DocFactory$$anon$1.internalLink(DocFactory.scala:68)
    at scala.tools.nsc.doc.base.MemberLookupBase.$anonfun$memberLookup$6(MemberLookupBase.scala:59)
    at scala.tools.nsc.doc.base.MemberLookupBase.memberLookup(MemberLookupBase.scala:59)
    at scala.tools.nsc.doc.base.MemberLookupBase.memberLookup$(MemberLookupBase.scala:48)
    at scala.tools.nsc.doc.DocFactory$$anon$1.memberLookup(DocFactory.scala:68)
    at scala.tools.nsc.doc.base.CommentFactoryBase.$anonfun$parseAtSymbol$16(CommentFactoryBase.scala:371)
    at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
    at scala.collection.immutable.Map$Map2.foreach(Map.scala:146)
    at scala.collection.TraversableLike.map(TraversableLike.scala:234)
    at scala.collection.TraversableLike.map$(TraversableLike.scala:227)
    at scala.collection.AbstractTraversable.map(Traversable.scala:104)
    at scala.tools.nsc.doc.base.CommentFactoryBase.linkedExceptions$1(CommentFactoryBase.scala:370)
    at scala.tools.nsc.doc.base.CommentFactoryBase.parse0$1(CommentFactoryBase.scala:388)
    at scala.tools.nsc.doc.base.CommentFactoryBase.parseAtSymbol(CommentFactoryBase.scala:416)
    at scala.tools.nsc.doc.base.CommentFactoryBase.parseAtSymbol$(CommentFactoryBase.scala:200)
    at scala.tools.nsc.doc.DocFactory$$anon$1.parseAtSymbol(DocFactory.scala:68)
    at scala.tools.nsc.doc.model.CommentFactory.parse(CommentFactory.scala:85)
    at scala.tools.nsc.doc.model.CommentFactory.parse$(CommentFactory.scala:83)
    at scala.tools.nsc.doc.DocFactory$$anon$1.parse(DocFactory.scala:68)
    at scala.tools.nsc.doc.model.CommentFactory.defineComment(CommentFactory.scala:75)
    at scala.tools.nsc.doc.model.CommentFactory.defineComment$(CommentFactory.scala:38)
    at scala.tools.nsc.doc.DocFactory$$anon$1.defineComment(DocFactory.scala:68)
    at scala.tools.nsc.doc.model.CommentFactory.$anonfun$comment$1(CommentFactory.scala:31)
    at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:79)
    at scala.tools.nsc.doc.model.CommentFactory.comment(CommentFactory.scala:31)
    at scala.tools.nsc.doc.model.CommentFactory.comment$(CommentFactory.scala:29)
    at scala.tools.nsc.doc.DocFactory$$anon$1.comment(DocFactory.scala:68)
    at scala.tools.nsc.doc.model.ModelFactoryImplicitSupport.makeImplicitConversions(ModelFactoryImplicitSupport.scala:102)
    at scala.tools.nsc.doc.model.ModelFactoryImplicitSupport.makeImplicitConversions$(ModelFactoryImplicitSupport.scala:85)
    at scala.tools.nsc.doc.DocFactory$$anon$1.makeImplicitConversions(DocFactory.scala:68)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.<init>(ModelFactory.scala:346)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$$anon$7.<init>(ModelFactory.scala:642)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createDocTemplate$1(ModelFactory.scala:642)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createTemplate(ModelFactory.scala:689)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember0$1(ModelFactory.scala:783)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember(ModelFactory.scala:796)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.$anonfun$ownMembers$1(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.<init>(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$PackageImpl.<init>(ModelFactory.scala:465)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$$anon$4.<init>(ModelFactory.scala:675)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createTemplate(ModelFactory.scala:675)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember0$1(ModelFactory.scala:783)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember(ModelFactory.scala:796)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.$anonfun$ownMembers$1(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.<init>(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$PackageImpl.<init>(ModelFactory.scala:465)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$$anon$4.<init>(ModelFactory.scala:675)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createTemplate(ModelFactory.scala:675)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember0$1(ModelFactory.scala:783)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember(ModelFactory.scala:796)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.$anonfun$ownMembers$1(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.<init>(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$PackageImpl.<init>(ModelFactory.scala:465)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$$anon$4.<init>(ModelFactory.scala:675)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createTemplate(ModelFactory.scala:675)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember0$1(ModelFactory.scala:783)
    at scala.tools.nsc.doc.model.ModelFactory.makeMember(ModelFactory.scala:796)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.$anonfun$ownMembers$1(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$DocTemplateImpl.<init>(ModelFactory.scala:356)
    at scala.tools.nsc.doc.model.ModelFactory$PackageImpl.<init>(ModelFactory.scala:465)
    at scala.tools.nsc.doc.model.ModelFactory$RootPackageImpl.<init>(ModelFactory.scala:473)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$$anon$1.<init>(ModelFactory.scala:657)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createTemplate(ModelFactory.scala:657)
    at scala.tools.nsc.doc.model.ModelFactory$modelCreation$.createRootPackage(ModelFactory.scala:605)
    at scala.tools.nsc.doc.model.ModelFactory$$anon$21.<init>(ModelFactory.scala:50)
    at scala.tools.nsc.doc.model.ModelFactory.makeModel(ModelFactory.scala:47)
    at scala.tools.nsc.doc.DocFactory.makeUniverse(DocFactory.scala:81)
    at scala.tools.nsc.doc.DocFactory.generate$1(DocFactory.scala:124)
    at scala.tools.nsc.doc.DocFactory.document(DocFactory.scala:131)
    at xsbt.Runner.run(ScaladocInterface.scala:26)
    at xsbt.ScaladocInterface.run(ScaladocInterface.scala:10)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:107)
    at sbt.compiler.AnalyzingCompiler.doc(AnalyzingCompiler.scala:73)
    at sbt.compiler.AnalyzingCompiler.doc(AnalyzingCompiler.scala:68)
    at sbt.Doc$$anonfun$scaladoc$1.apply(Doc.scala:23)
    at sbt.Doc$$anonfun$scaladoc$1.apply(Doc.scala:23)
    at sbt.RawCompileLike$$anonfun$prepare$1.apply(RawCompileLike.scala:64)
    at sbt.RawCompileLike$$anonfun$prepare$1.apply(RawCompileLike.scala:56)
    at sbt.RawCompileLike$$anonfun$cached$1$$anonfun$2$$anonfun$apply$1.apply(RawCompileLike.scala:49)
    at sbt.RawCompileLike$$anonfun$cached$1$$anonfun$2$$anonfun$apply$1.apply(RawCompileLike.scala:47)
    at sbt.Tracked$$anonfun$outputChanged$1.apply(Tracked.scala:84)
    at sbt.Tracked$$anonfun$outputChanged$1.apply(Tracked.scala:79)
    at sbt.RawCompileLike$$anonfun$cached$1.apply(RawCompileLike.scala:54)
    at sbt.RawCompileLike$$anonfun$cached$1.apply(RawCompileLike.scala:39)
    at sbtunidoc.Plugin$Unidoc$.apply(Plugin.scala:134)
    at sbtunidoc.Plugin$$anonfun$baseCommonUnidocTasks$2.apply(Plugin.scala:27)
    at sbtunidoc.Plugin$$anonfun$baseCommonUnidocTasks$2.apply(Plugin.scala:27)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

This is then followed by a repeat of the original error message heading, without the stack trace. I'm not sure what line of the file is causing the failure.

Any ideas?

UPDATE: Incidentally, if I generate documentation using "doc" instead, I don't get any errors.

@Sciss
Copy link

Sciss commented Mar 14, 2017

I'm having the same problem, both in Scala 2.11.8 and 2.12.1. My error looks slightly different:

[info] Main Scala API documentation to /home/hhrutz/Documents/devel/Mellite/site/target/scala-2.12/unidoc...
[error] /home/hhrutz/.sbt/0.13/staging/826f0b08a174143cc2c0/mellite/src/main/scala-2.12/de/sciss/mellite/gui/impl/FScapeOutputsViewImpl.scala:106: can't expand macros compiled by previous versions of Scala
[error]         if (res === OptionPane.Result.Ok) {
[error]                                       ^
[error] /home/hhrutz/.sbt/0.13/staging/826f0b08a174143cc2c0/mellite/src/main/scala/de/sciss/mellite/ProcActions.scala:133: can't expand macros compiled by previous versions of Scala
[error]       if (key !== Proc.mainIn) {
[error]                        ^
[error] /home/hhrutz/.sbt/0.13/staging/826f0b08a174143cc2c0/mellite/src/main/scala/de/sciss/mellite/gui/ActionArtifactLocation.scala:86: can't expand macros compiled by previous versions of Scala
[error]         if (optRes === 0) {
[error]                        ^

@Sciss
Copy link

Sciss commented Mar 14, 2017

In my case, adding scala-reflect to the unidoc project solved the issue for me:

+    libraryDependencies ++= Seq(
+      "org.scala-lang" %  "scala-reflect" % scalaVersion.value % "provided"
+    ),

@Facsimiler
Copy link
Author

I just revisited this issue, which is still present in Scala 2.12.8, and found that if I remove the -implicits flag, the assertion error no longer occurs.

@Sciss It appears that our issues are different. I tried adding the scala-reflect dependency, and it made no difference.

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

2 participants