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

Support vals in @Id annotations when compiled under scaladoc #1306

Open
neko-kai opened this issue Nov 4, 2020 · 0 comments
Open

Support vals in @Id annotations when compiled under scaladoc #1306

neko-kai opened this issue Nov 4, 2020 · 0 comments
Assignees
Projects
Milestone

Comments

@neko-kai
Copy link
Member

neko-kai commented Nov 4, 2020

Issue described in https://t.me/izumi_ru/3971

[info] Main Scala API documentation to /home/circleci/project/target/scala-2.13/api...
[error] /home/circleci/project/src/main/scala/com/ponv/Scenarios.scala:16:26: exception during macro expansion: 
[error] izumi.distage.model.exceptions.BadIdAnnotationException: Wrong annotation value, only constants are supported. Got: @izumi.distage.model.definition.Id(izumi.distage.model.definition.Id(com.ponv.Loggers.Welcome))
[error]  at izumi.distage.reflection.ReflectionProviderDefaultImpl.withIdKeyFromAnnotation(ReflectionProviderDefaultImpl.scala:34)

BadIdAnnotation is thrown in scaladoc mode during compilation with the following construct:

final val X = "x"

new ModuleDef {
  make[Any].from { d: Dep1 @Id(X) => ??? }
}

This happens because normally @Id(X) would be expanded to @Id("x") before the macro is called, however, this does not happen in scaladoc mode, because scaladoc erases literal singleton types for the purpose of showing widened String type in the documentation, this causes X to not be inlined. (this was already discussed in this tracker before somewhere and this was the response to the bug in the scala tracker)

We should somehow detect that we're running under scaladoc in FunctoidMacro and NOT throw the error in that case. We may possibly be able to detect it by checking for empty positions in c.enclosingPosition / or .pos methods on trees – normal mode always has good positions, but scaladoc mode often has empty broken positions – but there may be better ways to detect scaladoc too.

@neko-kai neko-kai added this to the 1.1 milestone Nov 4, 2020
@neko-kai neko-kai added this to To do in DIStage via automation Nov 4, 2020
@pshirshov pshirshov added the complex A hard problem label Jan 24, 2023
@pshirshov pshirshov modified the milestones: 1.1, 1.3 Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
DIStage
  
To do
Development

No branches or pull requests

2 participants