Skip to content

Commit

Permalink
Closes t5399. Review by adriaanm
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jun 2, 2012
1 parent 85cd96d commit fc24db4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Expand Up @@ -2237,7 +2237,7 @@ trait Typers extends Modes with Adaptations with Taggings {
// takes untyped sub-trees of a match and type checks them
def typedMatch(selector: Tree, cases: List[CaseDef], mode: Int, pt: Type, tree: Tree = EmptyTree): Match = {
val selector1 = checkDead(typed(selector, EXPRmode | BYVALmode, WildcardType))
val selectorTp = packCaptured(selector1.tpe.widen)
val selectorTp = packCaptured(selector1.tpe.widen).skolemizeExistential(context.owner, selector)
val casesTyped = typedCases(cases, selectorTp, pt)

val (resTp, needAdapt) =
Expand Down
45 changes: 45 additions & 0 deletions test/files/pos/t5399.scala
@@ -0,0 +1,45 @@
class Test {
class A[T]
class B[T](val a: A[T])

case class CaseClass[T](x: T)

def break(existB: B[_]) =
CaseClass(existB.a) match { case CaseClass(_) => }
}

class Foo {
trait Init[T]
class ScopedKey[T] extends Init[T]

trait Setting[T] {
val key: ScopedKey[T]
}

case class ScopedKey1[T](val foo: Init[T]) extends ScopedKey[T]

val scalaHome: Setting[Option[String]] = null
val scalaVersion: Setting[String] = null

def testPatternMatch(s: Setting[_]) {
s.key match {
case ScopedKey1(scalaHome.key | scalaVersion.key) => ()
}
}
}

class Test2 {
type AnyCyclic = Execute[Task]#CyclicException[_]

trait Task[T]

trait Execute[A[_] <: AnyRef] {
class CyclicException[T](val caller: A[T], val target: A[T])
}

def convertCyclic(c: AnyCyclic): String =
(c.caller, c.target) match {
case (caller: Task[_], target: Task[_]) => "bazinga!"
}
}

0 comments on commit fc24db4

Please sign in to comment.