Skip to content

Commit efbe537

Browse files
committed
Add workaroud missing positions in case clases from tasty
1 parent 7650d38 commit efbe537

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class CompilationUnit(val source: SourceFile) {
1919

2020
def isJava = source.file.name.endsWith(".java")
2121

22+
def isFromTasty = untpdTree.isEmpty
23+
2224
/** Pickled TASTY binaries, indexed by class. */
2325
var pickled: Map[ClassSymbol, Array[Byte]] = Map()
2426
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ object Typer {
5858
}
5959

6060
/** Assert tree has a position, unless it is empty or a typed splice */
61-
def assertPositioned(tree: untpd.Tree)(implicit ctx: Context) =
62-
if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable)
61+
def assertPositioned(tree: untpd.Tree)(implicit ctx: Context) = {
62+
def fromTasty = ctx.compilationUnit.isFromTasty // FIXME missing positions when loading from tasty
63+
if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable && !fromTasty)
6364
assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}")
65+
}
6466

6567
private val ExprOwner = new Property.Key[Symbol]
6668
private val InsertedApply = new Property.Key[Unit]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package foo
2+
3+
case class Foo()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package foo
2+
3+
case class Foo(a: Int)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package foo
2+
3+
case class Bar(a: Int)
4+
object Bar

0 commit comments

Comments
 (0)