Position not set of class dotty.tools.dotc.ast.Trees$TypeApply

I’m writing a quote a big macro with refinement types and got stuck recently with this error:

java.lang.AssertionError: assertion failed: position not set for Columns_this.asInstanceOf[io.foldables.ratio.queries.Columns] # -1 of class dotty.tools.dotc.ast.Trees$TypeApply in rs$line$4 while typechecking rs$line$4
[error] java.lang.AssertionError: assertion failed: position not set for Columns_this.asInstanceOf[io.foldables.ratio.queries.Columns] # -1 of class dotty.tools.dotc.ast.Trees$TypeApply in rs$line$4
[error] 	at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] 	at dotty.tools.dotc.typer.Typer$.assertPositioned(Typer.scala:71)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3020)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
[error] 	at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSelect(Inliner.scala:763)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2864)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957)
[error] 	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
[error] 	at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:900)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
[error] 	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
[error] 	at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSelect(Inliner.scala:763)
[error] 	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2864)
[error] 	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957)
...

I spent quite a lot of time already on isolating this problem with no luck. What strikes me even more is that the macro has been working before and I have no idea what has changed since then.

Can someone maybe make sense of the error a little bit, like what is the aforementioned position? Or why it crashes the whole sbt console instead of just printing the compiler error?

Did you switch on fork := true?

How do you build your project? Are you sure you do sbt clean compile and not some partial (maybe incremental) recompilation? Curious what rs$line$4 is.

I experienced issues with empty position during incremental compilation in Scala 3 macro to list source code of file - Stack Overflow

Hey @DmytroMitin!

Not in this module, no. I just thought that if the console crashes (and does not with other errors) - it means it’s a compiler bug, like something very unexpected.

Tried many ways. Tried to delete target/, tried sbt clean compile That particular error comes from sbt console when I tried to access a particular property of Selectable (my Columns trait, which is the exact place where this problem arises). If I uncomment a place in my code where I access it, I get a slightly more verbose message:

java.lang.AssertionError: assertion failed: position not set for Columns_this.asInstanceOf[io.foldables.ratio.queries.Columns] # -1 of class dotty.tools.dotc.ast.Trees$TypeApply in /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Foo.scala while typechecking /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Foo.scala
[info] exception occurred while typechecking /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Foo.scala
java.lang.AssertionError: assertion failed: position not set for Columns_this.asInstanceOf[io.foldables.ratio.queries.Columns] # -1 of class dotty.tools.dotc.ast.Trees$TypeApply in /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Foo.scala while compiling /Users/chuwy/workspace/ratio/modules/queries/jvm/target/scala-3.2.2/src_managed/main/sbt-buildinfo/BuildInfo.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Action.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Columns.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Fable.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Foo.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/NameStrategy.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Primitive.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Repl.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Table.scala, /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/TypedColumn.scala
[error] ## Exception when compiling 10 sources to /Users/chuwy/workspace/ratio/modules/queries/jvm/target/scala-3.2.2/classes
[error] java.lang.AssertionError: assertion failed: position not set for Columns_this.asInstanceOf[io.foldables.ratio.queries.Columns] # -1 of class dotty.tools.dotc.ast.Trees$TypeApply in /Users/chuwy/workspace/ratio/modules/queries/shared/src/main/scala/io/foldables/ratio/queries/Foo.scala
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
[error] dotty.tools.dotc.typer.Typer$.assertPositioned(Typer.scala:71)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3020)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
[error] dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSelect(Inliner.scala:763)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2864)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957)
[error] dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:126)
[error] dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:900)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)

Finally, solved.

In my Columns selectable trait I had an inline method and then suddenly made it private. And this is what caused this error. Removing private solved the problem I spent so many hours on.

1 Like