Skip to content
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

missing unchecked warning for case _: Some[AbstractType] #8597

Closed
scabug opened this issue May 16, 2014 · 7 comments
Closed

missing unchecked warning for case _: Some[AbstractType] #8597

scabug opened this issue May 16, 2014 · 7 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented May 16, 2014

object Unchecked {
  def nowarn[T] = (null: Any) match { case _: Some[T]      => } 

  def warn1[T]  = (null: Any) match { case _: T            => }
  def warn2     = (null: Any) match { case _: Some[String] => } 
}

See matchesPattern

    /** Is this type a subtype of that type in a pattern context?
     *  Dummy type arguments on the right hand side are replaced with
     *  fresh existentials, except for Arrays.
     *
     *  See bug1434.scala for an example of code which would fail
     *  if only a <:< test were applied.
     */
    def matchesPattern(that: Type): Boolean = (this <:< that) || (that match {
      case ArrayTypeRef(elem2) if elem2.typeConstructor.isHigherKinded =>
        this match {
          case ArrayTypeRef(elem1) => elem1 matchesPattern elem2
          case _                   => false
        }
      case TypeRef(_, sym, args) =>
        val that1 = existentialAbstraction(args map (_.typeSymbol), that)
        (that ne that1) && (this <:< that1) && {
          debuglog(s"$this.matchesPattern($that) depended on discarding args and testing <:< $that1")
          true
        }
      case _ =>
        false
    })

And from the sounds of the comment, #1434

@scabug
Copy link
Author

scabug commented May 16, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8597?orig=1
Reporter: @retronym
Affected Versions: 2.10.4, 2.11.0

@scabug
Copy link
Author

scabug commented May 16, 2014

@retronym said:
See a similar mis-use of existentialAbstraction here: scala/scala#3519

@scabug
Copy link
Author

scabug commented May 16, 2014

@retronym said:
Avoiding regressing into a warning for:

final case class T2[+A, +B](a: A, b: B)

class A {
  def f3 = T2(1, 2) match {
    case _: T2[_, Int] => /* nowarn */
    case _             =>
  }
}

Represents the Pepsi challenge for this bug.

@scabug
Copy link
Author

scabug commented May 16, 2014

@retronym said:
WIP: https://github.com/retronym/scala/tree/ticket/8597 Passes pt --neg --pos

@scabug
Copy link
Author

scabug commented May 19, 2014

@retronym said:
scala/scala#3764

@scabug
Copy link
Author

scabug commented Nov 4, 2014

@retronym said:
Reassinging to 2.11.5, 2.11.4 has already been released.

@scabug
Copy link
Author

scabug commented Nov 9, 2014

@retronym said:
scala/scala#4115

@scabug scabug closed this as completed Nov 19, 2014
@scabug scabug added this to the 2.11.5 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants