From 4a1b22e19fcca892917868beb355daef27dc7b8f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 24 Nov 2009 15:50:06 +0000 Subject: Closed #2629 #2639 #2669 --- src/compiler/scala/tools/nsc/symtab/Types.scala | 15 +++++++++---- test/files/pos/t1545.scala | 16 ++++++++++++++ test/files/pos/t2669.scala | 28 +++++++++++++++++++++++++ test/pending/neg/t1545.scala | 16 -------------- 4 files changed, 55 insertions(+), 20 deletions(-) create mode 100755 test/files/pos/t1545.scala create mode 100644 test/files/pos/t2669.scala delete mode 100755 test/pending/neg/t1545.scala diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index bbbf4dfdec..823ed8ed6c 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -4321,15 +4321,21 @@ A type's typeSymbol should never be inspected directly. if (bound.typeSymbol != AnyClass) tvar addHiBound bound.instantiateTypeParams(tparams, tvars) for (tparam2 <- tparams) - if (tparam2.info.bounds.lo =:= tparam.tpe) // declaration tp2 :> tparam implies ?tparam <: tp2 - tvar addHiBound tparam2.tpe.instantiateTypeParams(tparams, tvars) + tparam2.info.bounds.lo.dealias match { + case TypeRef(_, `tparam`, _) => + tvar addHiBound tparam2.tpe.instantiateTypeParams(tparams, tvars) + case _ => + } } else { if (bound.typeSymbol != NothingClass && bound.typeSymbol != tparam) { tvar addLoBound bound.instantiateTypeParams(tparams, tvars) } for (tparam2 <- tparams) - if (tparam2.info.bounds.hi =:= tparam.tpe) - tvar addLoBound tparam2.tpe.instantiateTypeParams(tparams, tvars) + tparam2.info.bounds.hi.dealias match { + case TypeRef(_, `tparam`, _) => + tvar addLoBound tparam2.tpe.instantiateTypeParams(tparams, tvars) + case _ => + } } } tvar.constr.inst = NoType // necessary because hibounds/lobounds may contain tvar @@ -4345,6 +4351,7 @@ A type's typeSymbol should never be inspected directly. } } + // println("solving "+tvars+"/"+tparams+"/"+(tparams map (_.info))) for ((tvar, (tparam, variance)) <- config) solveOne(tvar, tparam, variance) diff --git a/test/files/pos/t1545.scala b/test/files/pos/t1545.scala new file mode 100755 index 0000000000..d7c0245725 --- /dev/null +++ b/test/files/pos/t1545.scala @@ -0,0 +1,16 @@ +object Main extends Application { + + case class Foo (field : Option[String]) + + val x : PartialFunction[Foo,Int] = + { + c => c.field match { + case Some (s) => 42 + case None => 99 + } + } + + println (x (Foo (None))) // prints 99 + println (x (Foo (Some ("foo")))) // prints 42 + +} diff --git a/test/files/pos/t2669.scala b/test/files/pos/t2669.scala new file mode 100644 index 0000000000..72e931178c --- /dev/null +++ b/test/files/pos/t2669.scala @@ -0,0 +1,28 @@ +// #2629, #2639, #2669 +object Test2669 { + + def test[T](l: java.util.ArrayList[_ <: T]) = 1 + test(new java.util.ArrayList[String]()) + +} + +import java.util.ArrayList + +object Test2629 { + def main(args: Array[String]): Unit = { + val l = new ArrayList[String](1) + val m = new ArrayList(l) + + println(l.size) + println(m.size) + } +} + + +import java.util.Vector + +// scalac cannot detect lack of type params, but then throws AssertionError later: +class TVector2639 { + val b = new Vector // this line passed without error detected + val a = new Vector(1) // this line caused throwing AssertionError when scalac +} diff --git a/test/pending/neg/t1545.scala b/test/pending/neg/t1545.scala deleted file mode 100755 index d7c0245725..0000000000 --- a/test/pending/neg/t1545.scala +++ /dev/null @@ -1,16 +0,0 @@ -object Main extends Application { - - case class Foo (field : Option[String]) - - val x : PartialFunction[Foo,Int] = - { - c => c.field match { - case Some (s) => 42 - case None => 99 - } - } - - println (x (Foo (None))) // prints 99 - println (x (Foo (Some ("foo")))) // prints 42 - -} -- cgit v1.2.3