Skip to content

Commit 4a64a17

Browse files
bishaboshaWojciechMazur
authored andcommitted
add test and better debug info in error message
[Cherry-picked ab1ab3c]
1 parent eabf647 commit 4a64a17

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
@@ -61,6 +61,15 @@ class TreeUnpickler(reader: TastyReader,
6161
/** A map from addresses of definition entries to the symbols they define */
6262
private val symAtAddr = new mutable.HashMap[Addr, Symbol]
6363

64+
private def addrOfSymbol(sym: Symbol): Option[Addr] = symAtAddr.iterator.collectFirst {
65+
case (addr, s) if s == sym => addr
66+
}
67+
68+
private def locatedSymbol(sym: Symbol)(using Context): String =
69+
addrOfSymbol(sym) match
70+
case Some(addr) => i"local $sym @ ${addr.index}"
71+
case None => i"external $sym"
72+
6473
/** A temporary map from addresses of definition entries to the trees they define.
6574
* Used to remember trees of symbols that are created by a completion. Emptied
6675
* once the tree is inlined into a larger tree.
@@ -275,7 +284,7 @@ class TreeUnpickler(reader: TastyReader,
275284
/** The symbol defined by current definition */
276285
def symbolAtCurrent()(using Context): Symbol = symAtAddr.get(currentAddr) match {
277286
case Some(sym) =>
278-
assert(ctx.owner == sym.owner, i"owner discrepancy for $sym, expected: ${ctx.owner}, found: ${sym.owner}")
287+
assert(ctx.owner == sym.owner, i"owner discrepancy for ${locatedSymbol(sym)}, expected: ${locatedSymbol(ctx.owner)}, found: ${locatedSymbol(sym.owner)}")
279288
sym
280289
case None =>
281290
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)