Skip to content

Commit ab1ab3c

Browse files
committed
add test and better debug info in error message
1 parent 6b52789 commit ab1ab3c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ class TreeUnpickler(reader: TastyReader,
6565
/** A map from addresses of definition entries to the symbols they define */
6666
private val symAtAddr = new mutable.HashMap[Addr, Symbol]
6767

68+
private def addrOfSymbol(sym: Symbol): Option[Addr] = symAtAddr.iterator.collectFirst {
69+
case (addr, s) if s == sym => addr
70+
}
71+
72+
private def locatedSymbol(sym: Symbol)(using Context): String =
73+
addrOfSymbol(sym) match
74+
case Some(addr) => i"local $sym @ ${addr.index}"
75+
case None => i"external $sym"
76+
6877
/** A temporary map from addresses of definition entries to the trees they define.
6978
* Used to remember trees of symbols that are created by a completion. Emptied
7079
* once the tree is inlined into a larger tree.
@@ -297,7 +306,7 @@ class TreeUnpickler(reader: TastyReader,
297306
/** The symbol defined by current definition */
298307
def symbolAtCurrent()(using Context): Symbol = symAtAddr.get(currentAddr) match {
299308
case Some(sym) =>
300-
assert(ctx.owner == sym.owner, i"owner discrepancy for $sym, expected: ${ctx.owner}, found: ${sym.owner}")
309+
assert(ctx.owner == sym.owner, i"owner discrepancy for ${locatedSymbol(sym)}, expected: ${locatedSymbol(ctx.owner)}, found: ${locatedSymbol(sym.owner)}")
301310
sym
302311
case None =>
303312
createSymbol()

tests/pos/i19629.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
trait CP[A,B]
2+
trait TypeEqK[F[_], G[_]]
3+
4+
trait Knit[CP[_, _], F[_]] {
5+
type Res
6+
7+
def visit[R](
8+
caseInFst: [F1[_], Y] => (k: Knit[CP, F1]) => (ev: TypeEqK[F, [x] =>> CP[F1[x], Y]]) => R
9+
): R
10+
}

0 commit comments

Comments
 (0)