diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index 2cb690805a9c..bb53e9f81562 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -497,6 +497,17 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic { def refine(parent: Type, child: Symbol): Type = { if (child.isTerm && child.is(Case, butNot = Module)) return child.termRef // enum vals always match + // is a place holder from Scalac, it is hopeless to instantiate it. + // + // Quote from scalac (from nsc/symtab/classfile/Pickler.scala): + // + // ...When a sealed class/trait has local subclasses, a single + // class symbol is added as pickled child + // (instead of a reference to the anonymous class; that was done + // initially, but seems not to work, ...). + // + if (child.name == tpnme.LOCAL_CHILD) return child.typeRef + val childTp = if (child.isTerm) child.termRef else child.typeRef val resTp = instantiate(childTp, parent)(ctx.fresh.setNewTyperState()) diff --git a/tests/patmat/i4315.scala b/tests/patmat/i4315.scala new file mode 100644 index 000000000000..d06d53493d45 --- /dev/null +++ b/tests/patmat/i4315.scala @@ -0,0 +1,8 @@ +import scala.concurrent.duration.{Duration, FiniteDuration} + +class Test { + def test(d: Duration) = d match { + case finite: FiniteDuration => + case d => + } +}