Skip to content

Fix #4315: handle local child from scalac #4334

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 2 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ 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

if (child.name == tpnme.LOCAL_CHILD) return child.typeRef
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment explaning


val childTp = if (child.isTerm) child.termRef else child.typeRef

val resTp = instantiate(childTp, parent)(ctx.fresh.setNewTyperState())
Expand Down
8 changes: 8 additions & 0 deletions tests/patmat/i4315.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import scala.concurrent.duration.{Duration, FiniteDuration}

class Test {
def test(d: Duration) = d match {
case finite: FiniteDuration =>
case d =>
}
}