summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala6
-rw-r--r--test/files/neg/t2775.check4
-rw-r--r--test/files/neg/t2775.scala1
3 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 707c91e6ad..eea5be32b7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -771,8 +771,12 @@ self: Analyzer =>
else if (sym.isTypeParameterOrSkolem)
EmptyTree // a manifest should have been found by normal searchImplicit
else {
- // the following is tricky! We want to find the parameterized version of
+ // The following is tricky! We want to find the parameterized version of
// what will become the erasure of the upper bound.
+ // But there is a case where the erasure is not a superclass of the current type:
+ // Any erases to Object. So an abstract type having Any as upper bound will not see
+ // Object as a baseType. That's why we do the basetype trick only when we must,
+ // i.e. when the baseclass is parameterized.
var era = erasure.erasure(tp1)
if (era.typeSymbol.typeParams.nonEmpty)
era = tp1.baseType(era.typeSymbol)
diff --git a/test/files/neg/t2775.check b/test/files/neg/t2775.check
new file mode 100644
index 0000000000..a30d35fdd9
--- /dev/null
+++ b/test/files/neg/t2775.check
@@ -0,0 +1,4 @@
+t2775.scala:1: error: cannot find class manifest for element type B.this.T
+trait B[S] { type T = S; val c = new Array[T](1) }
+ ^
+one error found
diff --git a/test/files/neg/t2775.scala b/test/files/neg/t2775.scala
new file mode 100644
index 0000000000..9e4f2f606d
--- /dev/null
+++ b/test/files/neg/t2775.scala
@@ -0,0 +1 @@
+trait B[S] { type T = S; val c = new Array[T](1) }