Search code examples
scalascala-2.10scalatest

Why does the Scala compiler error with "Synthetic tree contains nonsynthetic tree"?


I have a following test

test("should create cached thread pool") {
    val globalContextMock: LogContextPropagatingEC = mock[LogContextPropagatingEC]
    val util = new PaymentExecutionContextImpl with ApplicationConfigTest2 {
        override protected lazy val globalExecutionContext = globalContextMock
    }
    val systemContext = util.systemExecutionContext
    assert(!systemContext.eq(globalContextMock), "system execution context should be a new instance, different form global mock")
}

which causes Scala compile the following error:

RangePositions$ValidateException: Synthetic tree [1889] contains nonsynthetic tree [1874]

Anyone knows what causes the issue?


Solution

  • You're compiling with -Yrangepos? If so, and you're using 2.10, it's a bug/issue with the compiler verifying trees that were (probably) modified by macros.