diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 3e38a9119fbe..7f64f2cfb941 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1104,7 +1104,7 @@ class TreeUnpickler(reader: TastyReader, } def readCases(end: Addr)(implicit ctx: Context): List[CaseDef] = - collectWhile((nextByte == CASEDEF || nextByte == SHAREDterm) && currentAddr != end) { + collectWhile((nextUnsharedTag == CASEDEF) && currentAddr != end) { if (nextByte == SHAREDterm) { readByte() forkAt(readAddr()).readCase()(ctx.fresh.setNewScope) @@ -1114,7 +1114,7 @@ class TreeUnpickler(reader: TastyReader, def readCase()(implicit ctx: Context): CaseDef = { val start = currentAddr - readByte() + assert(readByte() == CASEDEF) val end = readEnd() val pat = readTerm() val rhs = readTerm() diff --git a/tests/pickling/i4006.scala b/tests/pickling/i4006.scala new file mode 100644 index 000000000000..ef86dbb052f1 --- /dev/null +++ b/tests/pickling/i4006.scala @@ -0,0 +1,4 @@ +class Foo { + inline def foo: Int = try { 1 } finally println("Hello") + foo +} diff --git a/tests/pickling/i4006b.scala b/tests/pickling/i4006b.scala new file mode 100644 index 000000000000..3c17a6522ac4 --- /dev/null +++ b/tests/pickling/i4006b.scala @@ -0,0 +1,4 @@ +class Foo { + inline def foo: Int = try { 1 } catch { case _ => 4 } finally println("Hello") + foo +} diff --git a/tests/pickling/i4006c.scala b/tests/pickling/i4006c.scala new file mode 100644 index 000000000000..9233ccdfc922 --- /dev/null +++ b/tests/pickling/i4006c.scala @@ -0,0 +1,4 @@ +class Foo { + inline def foo: Int = try { 1 } catch { case _ => 4 } + foo +}