diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 9 | ||||
-rw-r--r-- | test/files/pos/bug1048.scala | 15 | ||||
-rw-r--r-- | test/files/run/bug1048.check | 2 | ||||
-rw-r--r-- | test/files/run/bug1048.scala | 21 | ||||
-rw-r--r-- | test/pending/pos/unapplyGeneric.scala | 11 |
5 files changed, 55 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 5bbc0b6430..97e07d9f3e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2566,10 +2566,13 @@ trait Typers extends Modes { val formals1 = formalTypes(formals0, args.length) if (sameLength(formals1, args)) { val args1 = typedArgs(args, mode, formals0, formals1) - assert(isFullyDefined(pt), tree+" ==> "+UnApply(fun1, args1)+", pt = "+pt) + // This used to be the following (failing) assert: + // assert(isFullyDefined(pt), tree+" ==> "+UnApply(fun1, args1)+", pt = "+pt) + // I modified as follows. See SI-1048. + val pt1 = if (isFullyDefined(pt)) pt else makeFullyDefined(pt) - val itype = glb(List(pt, arg.tpe)) - arg.tpe = pt // restore type (arg is a dummy tree, just needs to pass typechecking) + val itype = glb(List(pt1, arg.tpe)) + arg.tpe = pt1 // restore type (arg is a dummy tree, just needs to pass typechecking) UnApply(fun1, args1) setPos tree.pos setType itype } else { diff --git a/test/files/pos/bug1048.scala b/test/files/pos/bug1048.scala new file mode 100644 index 0000000000..f88dbbc88b --- /dev/null +++ b/test/files/pos/bug1048.scala @@ -0,0 +1,15 @@ +trait T[U] { + def x: T[V] forSome { type V <: U } +} + +object T { + def unapply[U](t: T[U]): Option[T[V] forSome { type V <: U }] = Some(t.x) +} + +object Test { + def f[W](t: T[W]) = t match { + case T(T(_)) => () + } +} + + diff --git a/test/files/run/bug1048.check b/test/files/run/bug1048.check new file mode 100644 index 0000000000..f1e5eeed2d --- /dev/null +++ b/test/files/run/bug1048.check @@ -0,0 +1,2 @@ +3 +2 diff --git a/test/files/run/bug1048.scala b/test/files/run/bug1048.scala new file mode 100644 index 0000000000..5eaeaa25c6 --- /dev/null +++ b/test/files/run/bug1048.scala @@ -0,0 +1,21 @@ +final case class W[A](v: A) + +object E { + def unapply(w: W[Any]): Option[Any] = None +} + +object Bug { + def bug[A](e: Either[W[_], A]) = e match { + case Left(E(x)) => 1 + case Right(x) => 2 + case _ => 3 + } +} + +object Test { + def main(args: Array[String]): Unit = { + println(Bug.bug(Left(W(5)))) + println(Bug.bug(Right(5))) + } +} + diff --git a/test/pending/pos/unapplyGeneric.scala b/test/pending/pos/unapplyGeneric.scala new file mode 100644 index 0000000000..bf88816885 --- /dev/null +++ b/test/pending/pos/unapplyGeneric.scala @@ -0,0 +1,11 @@ +object Bar { + def unapply[A,B](bar:Bar[A,B]) = Some(bar) +} + +class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B] + +object Test { + new Bar(2, 'a') match { + case Bar(x,y) => + } +} |