Skip to content

Fix #2437: Drop erroneous case in Pickler #2510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Mode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ object TastyFormat {
| ANNOTATEDtpt
| ANDtpt
| ORtpt
| BYNAMEtpt => true
| BYNAMEtpt
| BIND => true
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/printing/Formatting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions tests/pickling/i2437a.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object Test {
def foo(arg: Any) = arg match {
case bla: List[t] =>
}
}
6 changes: 6 additions & 0 deletions tests/pickling/i2437b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Foo[T]
object Test {
def foo[T](arg: Foo[T]) = arg match {
case bla: Foo[_] =>
}
}