Skip to content

Incorrectly setting sources for macros from separate compilation #7342

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

Macros_1.scala:

import scala.quoted.{ QuoteContext, Expr }

inline def g(em: Expr[String])(given QuoteContext) = '{$em}

Macros_2.scala:

import scala.quoted.{ QuoteContext, Expr }

def h(m: Expr[String])(given QuoteContext): Expr[Any] = g(m)

Compile them separately and Macros_2.scala should be compiled with -Ycheck:all, e.g.:

sbt:dotty> ;dotty-bootstrapped/dotc ../pg/i2/Macros_1.scala ;dotty-bootstrapped/dotc -Ycheck:all -classpath . ../pg/i2/Macros_2.scala

You will get:

Ycheck failure
checking ../pg/i2/Macros_2.scala after phase inlinedPositions
*** error while checking ../pg/i2/Macros_2.scala after phase inlinedPositions ***
exception occurred while compiling ../pg/i2/Macros_2.scala
java.lang.AssertionError: assertion failed: wrong source set for {
  m
} # 2061 of class dotty.tools.dotc.ast.Trees$Inlined, set to /Users/anatolii/Projects/dotty/dotty/../pg/i2/Macros_1.scala but context had ../pg/i2/Macros_2.scala while compiling ../pg/i2/Macros_2.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: wrong source set for {
  m
} # 2061 of class dotty.tools.dotc.ast.Trees$Inlined, set to /Users/anatolii/Projects/dotty/dotty/../pg/i2/Macros_1.scala but context had ../pg/i2/Macros_2.scala
	at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:33)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:48)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:48)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1449)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1483)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:50)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply$$anonfun$1(Trees.scala:1368)
	at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:169)
	at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:165)
	at scala.collection.immutable.List.foldLeft(List.scala:79)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1368)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1454)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1483)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:50)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1452)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1483)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:50)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.apply(Trees.scala:1482)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply$$anonfun$1(Trees.scala:1368)
	at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:169)
	at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:165)
	at scala.collection.immutable.List.foldLeft(List.scala:79)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.apply(Trees.scala:1368)
	at dotty.tools.dotc.ast.Trees$Instance$TreeAccumulator.foldOver(Trees.scala:1458)
	at dotty.tools.dotc.ast.Trees$Instance$TreeTraverser.traverseChildren(Trees.scala:1483)
	at dotty.tools.dotc.transform.YCheckPositions$$anon$1.traverse(YCheckPositions.scala:50)
	at dotty.tools.dotc.transform.YCheckPositions.checkPostCondition(YCheckPositions.scala:53)
	at dotty.tools.dotc.transform.TreeChecker.dotty$tools$dotc$transform$TreeChecker$Checker$$_$typedUnadapted$$anonfun$1(TreeChecker.scala:318)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.immutable.List.foreach(List.scala:305)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:318)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2153)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2165)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:286)
	at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:2241)
	at dotty.tools.dotc.transform.TreeChecker.check(TreeChecker.scala:121)
	at dotty.tools.dotc.transform.TreeChecker.run(TreeChecker.scala:94)
	at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:315)
	at scala.collection.immutable.List.map(List.scala:219)
	at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:316)
	at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:159)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
	at dotty.tools.dotc.Run.runPhases$5(Run.scala:169)
	at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:177)
	at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:184)
	at dotty.tools.dotc.Run.compileSources(Run.scala:121)
	at dotty.tools.dotc.Run.compile(Run.scala:104)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
	at dotty.tools.dotc.Driver.process(Driver.scala:178)
	at dotty.tools.dotc.Driver.process(Driver.scala:147)
	at dotty.tools.dotc.Driver.process(Driver.scala:159)
	at dotty.tools.dotc.Driver.main(Driver.scala:186)
	at dotty.tools.dotc.Main.main(Main.scala)

This could be what is blocking #7333.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions