Skip to content

Commit c6a6d12

Browse files
committed
More robust TypeVar printing.
Avoid the crash if origin is not associated with a bound in the current constraint.
1 parent 9587095 commit c6a6d12

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
144144
case tp: TypeVar =>
145145
if (tp.isInstantiated)
146146
toTextLocal(tp.instanceOpt) ~ "'" // debug for now, so that we can see where the TypeVars are.
147-
else
148-
"(" ~ toText(tp.origin) ~ "?" ~
149-
toText(ctx.typerState.constraint.bounds(tp.origin)) ~ ")"
147+
else {
148+
val bounds = ctx.typerState.constraint.at(tp.origin) match {
149+
case bounds: TypeBounds => bounds
150+
case _ => TypeBounds.empty
151+
}
152+
"(" ~ toText(tp.origin) ~ "?" ~ toText(bounds) ~ ")"
153+
}
150154
case _ =>
151155
tp.fallbackToText(this)
152156
}

0 commit comments

Comments
 (0)