aboutsummaryrefslogblamecommitdiff
path: root/tests/neg/boundspropagation.scala
blob: bc39e042e9177e8702fee0eac4259e959a116e62 (plain) (tree)

























                                       













                                                                     
// scalac fails for test2/3
// dotc fails for all three
object test1 {
  class Tree[-T >: Null]


  def f(x: Any): Tree[Null] = x match {
    case y: Tree[_] => y
  }
}
object test2 {
  class Tree[T >: Null]


  def f(x: Any): Tree[Null] = x match {
    case y: Tree[_] => y
  }
}
object test3 {
  class Tree[+T >: Null]


  def f(x: Any): Tree[Null] = x match {
    case y: Tree[_] => y
  }
}

// Example contributed by Jason. I believe this should not typecheck,
// even though scalac does typecheck it.
object test4 {
  class Base {
    type N

    class Tree[-S, -T >: Option[S]]

    def g(x: Any): Tree[_, _ <: Option[N]] = x match {
      case y: Tree[_, _] => y
    }
  }
}