Skip to content

Spurious unreachable/only null warning #4315

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

Closed
allanrenucci opened this issue Apr 13, 2018 · 2 comments
Closed

Spurious unreachable/only null warning #4315

allanrenucci opened this issue Apr 13, 2018 · 2 comments
Assignees

Comments

@allanrenucci
Copy link
Contributor

import scala.concurrent.duration.{Duration, FiniteDuration}

class Test {
  def test(d: Duration) = d match {
    case finite: FiniteDuration =>
    case d =>
  }
}
-- [E120] Only null matched Warning: tests/allan/Test.scala:7:9 ----------------
7 |    case d =>
  |         ^
  |         Only null is matched. Consider using `case null =>` instead.
one warning found
@allanrenucci
Copy link
Contributor Author

This only happen when Duration comes from Scala2:

First compile with scalac:

sealed abstract class Duration
object Duration {
  final class FiniteDuration extends Duration
  sealed abstract class Infinite extends Duration
  val Undefined: Infinite = new Infinite {}
  val Inf: Infinite = new Infinite  {}
}

Then from Dotty with Duration on the classpath

import Duration._

class Test {

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

@liufengyun
Copy link
Contributor

In Scalac, it registers anonymous classes as children, in Dotty currently we don't. Let's discuss this in next meeting.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Apr 17, 2018
liufengyun added a commit that referenced this issue Apr 19, 2018
Fix #4315: handle local child from scalac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants