Skip to content

Commit d207e7e

Browse files
authored
Merge pull request #2510 from dotty-staging/fix-#2437
Fix #2437: Drop erroneous case in Pickler
2 parents a4d1894 + 6e1ac30 commit d207e7e

File tree

7 files changed

+22
-4
lines changed

7 files changed

+22
-4
lines changed

compiler/src/dotty/tools/dotc/core/Mode.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ object Mode {
8181
/** Read original positions when unpickling from TASTY */
8282
val ReadPositions = newMode(16, "ReadPositions")
8383

84+
/** Don't suppress exceptions thrown during show */
85+
val PrintShowExceptions = newMode(17, "PrintShowExceptions")
86+
8487
val PatternOrType = Pattern | Type
8588

8689
/** We are elaborating the fully qualified name of a package clause.
8790
* In this case, identifiers should never be imported.
8891
*/
89-
val InPackageClauseName = newMode(17, "InPackageClauseName")
92+
val InPackageClauseName = newMode(18, "InPackageClauseName")
9093
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ object TastyFormat {
431431
| ANNOTATEDtpt
432432
| ANDtpt
433433
| ORtpt
434-
| BYNAMEtpt => true
434+
| BYNAMEtpt
435+
| BIND => true
435436
case _ => false
436437
}
437438

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
249249
case BIND =>
250250
val sym = ctx.newSymbol(ctx.owner, readName().toTypeName, BindDefinedType, readType())
251251
registerSym(start, sym)
252+
if (currentAddr != end) readType()
252253
TypeRef.withFixedSym(NoPrefix, sym.name, sym)
253254
case POLYtype =>
254255
readMethodic(PolyType, _.toTypeName)

compiler/src/dotty/tools/dotc/printing/Formatting.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ object Formatting {
3131
case arg: Showable =>
3232
try arg.show
3333
catch {
34-
case NonFatal(ex) => s"[cannot display due to $ex, raw string = $toString]"
34+
case NonFatal(ex) if !ctx.mode.is(Mode.PrintShowExceptions) =>
35+
s"[cannot display due to $ex, raw string = $toString]"
3536
}
3637
case _ => arg.toString
3738
}

compiler/src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class Pickler extends Phase {
7979
ctx.fresh
8080
.setPeriod(Period(ctx.runId + 1, FirstPhaseId))
8181
.setReporter(new ThrowingReporter(ctx.reporter))
82-
.addMode(Mode.ReadPositions))
82+
.addMode(Mode.ReadPositions)
83+
.addMode(Mode.PrintShowExceptions))
8384
result
8485
}
8586

tests/pickling/i2437a.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test {
2+
def foo(arg: Any) = arg match {
3+
case bla: List[t] =>
4+
}
5+
}

tests/pickling/i2437b.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Foo[T]
2+
object Test {
3+
def foo[T](arg: Foo[T]) = arg match {
4+
case bla: Foo[_] =>
5+
}
6+
}

0 commit comments

Comments
 (0)