Closed MateuszKubuszok closed 6 months ago
Thanks for the report and the diagnostic work. -Wmacros:both
says also lint the tree produced by the macro; I see from the stack trace that it is sorting the warnings by position; presumably it's not careful enough about unpositioned trees.
I see some safety checks for pos.isDefined
.
The workaround of course would be not to lint trees that are unpositioned.
The unpositioned symbol is the unused active$macro$1
parameter, and the bug is to try to use its referenced
which is NoSymbol
and has no position either.
The broader question is whether it's doing too much work just to sort by position; positions should be ordered even if "undefined".
{
final class $anon extends AnyRef with io.scalaland.chimney.Patcher[ChimneyBug.State.Active,ChimneyBug.Event.A] {
def <init>(): <$anon: io.scalaland.chimney.Patcher[ChimneyBug.State.Active,ChimneyBug.Event.A]> = {
$anon.super.<init>();
()
};
def patch(active$macro$1: ChimneyBug.State.Active, a$macro$1: ChimneyBug.Event.A): ChimneyBug.State.Active = new ChimneyBug.State.Active(a$macro$1.a)
};
new $anon()
}
Worth adding that for 2.13.14, -Wmacros:default
does not check the synthetic parameter introduced by the expansion, so that would pass even without the fix.
Reproduction steps
Scala version: I reproduced it on were 2.13.3 and 2.13.12.
Problem
User reported that updating Chimney the newest version resulted in compilation errors. After discussion I managed to reproduce the error:
Despite my best efforts I couldn't find any relation with what Chimney does, and this error. Using flags for debugging the compilation like
-Xlog-implicits
,-verbose
,-Yquasiquote-debug
,-Xprint-pos
showed nothing, as if error happened before the macro expansion even started. Increasing stack with-Xss64m
doesn't change the outcome.It might be an error in Chimney, or it might be a particular combination of: an implicit provided by a macro, checking for unused definitions and putting macros into checking unused. Stack trace suggest that error happens in the typer while checking for unused private definitions. Removing any the the flags (
-Wmacros:both
,-Xlint:unused
) makes the error disappear. That's why I created this ticket because I think that without a compiler developer's help I will not be able to tell if the bug is in Chimney or on the compiler.