apalache-mc / apalache

APALACHE: symbolic model checker for TLA+ and Quint
https://apalache-mc.org/
Apache License 2.0
441 stars 40 forks source link

Relax compiler warnings for imports used in scaladoc #2004

Open Kukovec opened 2 years ago

Kukovec commented 2 years ago

If a scaladoc references e.g. [[object]] while using a top-level import a.b.c.object, instead of [[a.b.c.object]], this triggers a compiler warning ("unused import") if object is not used in the code. We should figure out how to treat documentation references as use cases, or relax the requirements on unused imports.

Kukovec commented 2 years ago

@shonfeder for visibility.

thpani commented 2 years ago

I think we might need to annotate those imports with @nowarn("cat=unused-imports").

From the compiler's standpoint, it is completely right to warn about an unused import if that name only occurs in a comment. OTOH, we cannot disable -Ywarn-unused, because Scalafix' RemoveUnused relies on those warnings.

@nowarn is the best solution I can think of, but maybe someone has a better idea.

Kukovec commented 2 years ago

Is there no granularity between "unused imports" and "unused variables" for -Ywarn-unused?

thpani commented 2 years ago

I suppose we could list them explicitly: https://docs.scala-lang.org/overviews/compiler-options/index.html#Warning_Settings

But we'd give up scalafix cleaning up unused imports across the codebase.

shonfeder commented 2 years ago

I don't think I would be in favor of any changes that reduced the quality of our linting or static analysis for the sake of making links in the API docs work. I'm also not in favor of importing modules just so we can reference in the docs, this seems to me like polluting our implementation for the sake of small, marginal utility in the API docs.

If you want a shorter way to refer to values, how about using @define?: https://stackoverflow.com/a/32607798/1187277