Skip to content

Conversation

@nicolasstucki
Copy link
Contributor

Fixes #15159
Updates buggy tests of #13230

@nicolasstucki
Copy link
Contributor Author

I found 2 bugs in Scaladoc.

  • When getting the module of an enumeration case the the prefix should be the module, but it is using the type of the class.
java.lang.AssertionError: assertion failed: val A is not a member of tests.commonlinks.SomeOtherEnum
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.memberType(QuotesImpl.scala:1741)
        at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.memberType(QuotesImpl.scala:1740)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.unwrapMemberInfo(ClassLikeSupport.scala:488)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.unwrapMemberInfo$(ClassLikeSupport.scala:15)
        at dotty.tools.scaladoc.tasty.TastyParser.unwrapMemberInfo(TastyParser.scala:169)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseValDef(ClassLikeSupport.scala:445)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseValDef$(ClassLikeSupport.scala:15)
        at dotty.tools.scaladoc.tasty.TastyParser.parseValDef(TastyParser.scala:169)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.$anonfun$15(ClassLikeSupport.scala:305)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseEnum(ClassLikeSupport.scala:305)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseEnum$(ClassLikeSupport.scala:15)
        at dotty.tools.scaladoc.tasty.TastyParser.parseEnum(TastyParser.scala:169)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseClasslike(ClassLikeSupport.scala:289)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseClasslike$(ClassLikeSupport.scala:15)
        at dotty.tools.scaladoc.tasty.TastyParser.parseClasslike(TastyParser.scala:169)
        at dotty.tools.scaladoc.tasty.TastyParser$Traverser$2$.traverseTree(TastyParser.scala:223)
        ...
  • When selecting an exported member the symbol should be the one of the generated export method. Scaladoc seems to try to get member based on the original symbol on the object that exports it.
java.lang.AssertionError: assertion failed: val aValInt is not a member of tests.exports2.B
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.memberType(QuotesImpl.scala:1741)
        at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.memberType(QuotesImpl.scala:1740)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.unwrapMemberInfo(ClassLikeSupport.scala:488)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.unwrapMemberInfo$(ClassLikeSupport.scala:15)
        at dotty.tools.scaladoc.tasty.TastyParser.unwrapMemberInfo(TastyParser.scala:169)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseValDef(ClassLikeSupport.scala:445)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseValDef$(ClassLikeSupport.scala:15)
        at dotty.tools.scaladoc.tasty.TastyParser.parseValDef(TastyParser.scala:169)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseMember$$anonfun$1(ClassLikeSupport.scala:179)
        at dotty.tools.scaladoc.tasty.TastyParser.processTreeOpt(TastyParser.scala:204)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseMember(ClassLikeSupport.scala:185)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseMember$$anonfun$1$$anonfun$7(ClassLikeSupport.scala:163)
        at scala.Option.flatMap(Option.scala:283)
        at dotty.tools.scaladoc.tasty.ClassLikeSupport.parseMember$$anonfun$1(ClassLikeSupport.scala:169)

@nicolasstucki
Copy link
Contributor Author

@pikinier20 could you investigate those bugs?

@nicolasstucki
Copy link
Contributor Author

Thank you @pikinier20

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Jun 2, 2022

We still have an issue with protoquill. I will investigate. It is probably the same bug in the macro implementation.

@nicolasstucki
Copy link
Contributor Author

@deusaquilus in this PR I found a bug in protoquill. I added an assertion to make sure that the selected member exists. The seems to try to create the type Mod.modVal.ModVal$ which is a nonsensical type. What was this code trying to compute?

[error] -- Error: /__w/dotty/dotty/community-build/community-projects/protoquill/quill-sql/src/test/scala/io/getquill/metaprog/StaticSpliceSpec.scala:13:56 
[error] 13 |    ctx.run { query[Person].filter(p => p.name == static(Mod.modVal)) }.string mustEqual
[error]    |                                                  ^^^^^^^^^^^^^^^^^^
[error]    |Exception occurred while executing macro expansion.
[error]    |java.lang.AssertionError: assertion failed: module class Mod$ is not a member of (io.getquill.util.prep.Mod.modVal : String)
[error]    |	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error]    |	at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.memberType(QuotesImpl.scala:1741)
[error]    |	at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeReprMethods$.memberType(QuotesImpl.scala:1740)
[error]    |	at io.getquill.context.StaticSpliceMacro$TermOwnerIsModule$.unapply$$anonfun$2(StaticSpliceMacro.scala:78)
[error]    |	at scala.Option.flatMap(Option.scala:283)
[error]    |	at io.getquill.context.StaticSpliceMacro$TermOwnerIsModule$.unapply(StaticSpliceMacro.scala:82)
[error]    |	at io.getquill.context.StaticSpliceMacro$.apply(StaticSpliceMacro.scala:114)
[error]    |
[error]    |----------------------------------------------------------------------------
[error]    |Inline stack trace
[error]    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]    |This location contains code that was inlined from Dsl.scala:62
[error] 62 |  inline def static[T](inline value: T): T = ${ StaticSpliceMacro('value) }
[error]    |                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]    |This location contains code that was inlined from Dsl.scala:62
[error]  3 |export Dsl._
[error]    |       ^^^
[error]     ----------------------------------------------------------------------------

@ckipp01
Copy link
Member

ckipp01 commented May 10, 2023

Hey @nicolasstucki do you plan on returning back to this? Are you waiting on anything else for it? How can I help move this forward?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

quotes.reflect.memberType can return ClassInfo

3 participants