Skip to content

Commit 036ab3b

Browse files
committed
Fix the source of inlined trees after Erasure
To ensure that the sources change, the trees need to be copied with the new source rather than preserving it.
1 parent 7ff971f commit 036ab3b

File tree

6 files changed

+165
-131
lines changed

6 files changed

+165
-131
lines changed

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dotty.tools.FatalError
66
import config.CompilerCommand
77
import core.Comments.{ContextDoc, ContextDocstrings}
88
import core.Contexts.{Context, ContextBase}
9-
import core.Mode
9+
import core.{Mode, TypeError}
1010
import reporting._
1111

1212
import scala.util.control.NonFatal
@@ -37,6 +37,9 @@ class Driver {
3737
case ex: FatalError =>
3838
ctx.error(ex.getMessage) // signals that we should fail compilation.
3939
ctx.reporter
40+
case ex: TypeError =>
41+
println(s"${ex.toMessage} while compiling ${fileNames.mkString(", ")}")
42+
throw ex
4043
case ex: Throwable =>
4144
println(s"$ex while compiling ${fileNames.mkString(", ")}")
4245
throw ex

compiler/src/dotty/tools/dotc/ast/Positioned.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
113113

114114
/** Clone this node but assign it a fresh id which marks it as a node in `file`. */
115115
def cloneIn(src: SourceFile): this.type = {
116+
assert(this ne tpd.EmptyTree)
117+
assert(this ne tpd.EmptyValDef)
118+
assert(this ne tpd.ContextualEmptyTree)
116119
val newpd: this.type = clone.asInstanceOf[this.type]
117120
newpd.uniqueId = src.nextId
118121
newpd

0 commit comments

Comments
 (0)