summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/internal/Types.scala12
-rw-r--r--test/files/pos/t4938.scala4
2 files changed, 14 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala
index a6b1e2fb44..9683087a95 100644
--- a/src/compiler/scala/reflect/internal/Types.scala
+++ b/src/compiler/scala/reflect/internal/Types.scala
@@ -5822,10 +5822,18 @@ A type's typeSymbol should never be inspected directly.
}
} else {
val args = (sym.typeParams, argss.transpose).zipped map { (tparam, as) =>
- if (depth == 0)
- if (tparam.variance == variance) AnyClass.tpe
+ if (depth == 0) {
+ if (tparam.variance == variance) {
+ // Take the intersection of the upper bounds of the type parameters
+ // rather than falling all the way back to "Any", otherwise we end up not
+ // conforming to bounds.
+ val bounds0 = sym.typeParams map (_.info.bounds.hi) filterNot (_.typeSymbol == AnyClass)
+ if (bounds0.isEmpty) AnyClass.tpe
+ else intersectionType(bounds0)
+ }
else if (tparam.variance == -variance) NothingClass.tpe
else NoType
+ }
else {
if (tparam.variance == variance) lub(as, decr(depth))
else if (tparam.variance == -variance) glb(as, decr(depth))
diff --git a/test/files/pos/t4938.scala b/test/files/pos/t4938.scala
new file mode 100644
index 0000000000..6e41312851
--- /dev/null
+++ b/test/files/pos/t4938.scala
@@ -0,0 +1,4 @@
+class A {
+ import scala.collection.mutable._
+ val xs = List(Set(), Seq())
+}