diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 15 | ||||
-rwxr-xr-x | test/files/pos/t1545.scala (renamed from test/pending/neg/t1545.scala) | 0 | ||||
-rw-r--r-- | test/files/pos/t2669.scala | 28 |
3 files changed, 39 insertions, 4 deletions
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/pending/neg/t1545.scala b/test/files/pos/t1545.scala index d7c0245725..d7c0245725 100755 --- a/test/pending/neg/t1545.scala +++ b/test/files/pos/t1545.scala 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 +} |