aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-07-26 23:48:16 +0200
committerGitHub <noreply@github.com>2016-07-26 23:48:16 +0200
commit1b0315caaf5edfab2583ea9d2609427ab5cde04e (patch)
treef223cd0ec00359f85cbabfc07267745f050ea496 /src
parent0ba8d7de28333886b88432ba4a9cdf05b222e85a (diff)
parent15fb8e160210e20ec9bec949f23e08ef045b1545 (diff)
downloaddotty-1b0315caaf5edfab2583ea9d2609427ab5cde04e.tar.gz
dotty-1b0315caaf5edfab2583ea9d2609427ab5cde04e.tar.bz2
dotty-1b0315caaf5edfab2583ea9d2609427ab5cde04e.zip
Merge pull request #1412 from dotty-staging/fix-#1284
Fix #1284: Make classTag depend directly on erasure
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/TypeErasure.scala18
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala16
2 files changed, 25 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala
index a1dab16cb..1a7342a12 100644
--- a/src/dotty/tools/dotc/core/TypeErasure.scala
+++ b/src/dotty/tools/dotc/core/TypeErasure.scala
@@ -277,6 +277,22 @@ object TypeErasure {
else tp1
}
}
+
+ /** Does the (possibly generic) type `tp` have the same erasure in all its
+ * possible instantiations?
+ */
+ def hasStableErasure(tp: Type)(implicit ctx: Context): Boolean = tp match {
+ case tp: TypeRef =>
+ tp.info match {
+ case TypeAlias(alias) => hasStableErasure(alias)
+ case _: ClassInfo => true
+ case _ => false
+ }
+ case tp: PolyParam => false
+ case tp: TypeProxy => hasStableErasure(tp.superType)
+ case tp: AndOrType => hasStableErasure(tp.tp1) && hasStableErasure(tp.tp2)
+ case _ => false
+ }
}
import TypeErasure._
@@ -493,4 +509,6 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
println(s"no sig for $tp")
throw ex
}
+
+
}
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index feed398aa..1eba64e2e 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -10,6 +10,7 @@ import printing.Showable
import Contexts._
import Types._
import Flags._
+import TypeErasure.{erasure, hasStableErasure}
import Mode.ImplicitsEnabled
import Denotations._
import NameOps._
@@ -479,15 +480,12 @@ trait Implicits { self: Typer =>
formal.argTypes match {
case arg :: Nil =>
val tp = fullyDefinedType(arg, "ClassTag argument", pos)
- tp.underlyingClassRef(refinementOK = false) match {
- case tref: TypeRef =>
- return ref(defn.ClassTagModule)
- .select(nme.apply)
- .appliedToType(tp)
- .appliedTo(clsOf(tref))
- .withPos(pos)
- case _ =>
- }
+ if (hasStableErasure(tp))
+ return ref(defn.ClassTagModule)
+ .select(nme.apply)
+ .appliedToType(tp)
+ .appliedTo(clsOf(erasure(tp)))
+ .withPos(pos)
case _ =>
}
EmptyTree