diff --git a/compiler/src/dotty/tools/dotc/core/Mode.scala b/compiler/src/dotty/tools/dotc/core/Mode.scala index 60ab93dba24d..8437dfca5436 100644 --- a/compiler/src/dotty/tools/dotc/core/Mode.scala +++ b/compiler/src/dotty/tools/dotc/core/Mode.scala @@ -81,10 +81,13 @@ object Mode { /** Read original positions when unpickling from TASTY */ val ReadPositions = newMode(16, "ReadPositions") + /** Don't suppress exceptions thrown during show */ + val PrintShowExceptions = newMode(17, "PrintShowExceptions") + val PatternOrType = Pattern | Type /** We are elaborating the fully qualified name of a package clause. * In this case, identifiers should never be imported. */ - val InPackageClauseName = newMode(17, "InPackageClauseName") + val InPackageClauseName = newMode(18, "InPackageClauseName") } diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index 9726315052c9..d5864afd827c 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -431,7 +431,8 @@ object TastyFormat { | ANNOTATEDtpt | ANDtpt | ORtpt - | BYNAMEtpt => true + | BYNAMEtpt + | BIND => true case _ => false } diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 602e5f2c7fd1..d1f800c9926f 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -249,6 +249,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi case BIND => val sym = ctx.newSymbol(ctx.owner, readName().toTypeName, BindDefinedType, readType()) registerSym(start, sym) + if (currentAddr != end) readType() TypeRef.withFixedSym(NoPrefix, sym.name, sym) case POLYtype => readMethodic(PolyType, _.toTypeName) diff --git a/compiler/src/dotty/tools/dotc/printing/Formatting.scala b/compiler/src/dotty/tools/dotc/printing/Formatting.scala index b35a07027da6..b8271ba19f25 100644 --- a/compiler/src/dotty/tools/dotc/printing/Formatting.scala +++ b/compiler/src/dotty/tools/dotc/printing/Formatting.scala @@ -31,7 +31,8 @@ object Formatting { case arg: Showable => try arg.show catch { - case NonFatal(ex) => s"[cannot display due to $ex, raw string = $toString]" + case NonFatal(ex) if !ctx.mode.is(Mode.PrintShowExceptions) => + s"[cannot display due to $ex, raw string = $toString]" } case _ => arg.toString } diff --git a/compiler/src/dotty/tools/dotc/transform/Pickler.scala b/compiler/src/dotty/tools/dotc/transform/Pickler.scala index e62cb0225b89..76b1658d1558 100644 --- a/compiler/src/dotty/tools/dotc/transform/Pickler.scala +++ b/compiler/src/dotty/tools/dotc/transform/Pickler.scala @@ -79,7 +79,8 @@ class Pickler extends Phase { ctx.fresh .setPeriod(Period(ctx.runId + 1, FirstPhaseId)) .setReporter(new ThrowingReporter(ctx.reporter)) - .addMode(Mode.ReadPositions)) + .addMode(Mode.ReadPositions) + .addMode(Mode.PrintShowExceptions)) result } diff --git a/tests/pickling/i2437a.scala b/tests/pickling/i2437a.scala new file mode 100644 index 000000000000..670ef51589fb --- /dev/null +++ b/tests/pickling/i2437a.scala @@ -0,0 +1,5 @@ +object Test { + def foo(arg: Any) = arg match { + case bla: List[t] => + } +} diff --git a/tests/pickling/i2437b.scala b/tests/pickling/i2437b.scala new file mode 100644 index 000000000000..6dbc79475583 --- /dev/null +++ b/tests/pickling/i2437b.scala @@ -0,0 +1,6 @@ +class Foo[T] +object Test { + def foo[T](arg: Foo[T]) = arg match { + case bla: Foo[_] => + } +}