File tree Expand file tree Collapse file tree 3 files changed +45
-5
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -554,11 +554,15 @@ trait Implicits { self: Typer =>
554554 val etag = inferImplicitArg(defn.ClassTagType .appliedTo(elemTp), pos)
555555 if (etag.tpe.isError) EmptyTree else etag.select(nme.wrap)
556556 case tp if hasStableErasure(tp) && ! defn.isBottomClass(tp.typeSymbol) =>
557- ref(defn.ClassTagModule )
558- .select(nme.apply)
559- .appliedToType(tp)
560- .appliedTo(clsOf(erasure(tp)))
561- .withPos(pos)
557+ val sym = tp.typeSymbol
558+ if (sym == defn.UnitClass || sym == defn.AnyClass || sym == defn.AnyValClass )
559+ ref(defn.ClassTagModule ).select(sym.name.toTermName).withPos(pos)
560+ else
561+ ref(defn.ClassTagModule )
562+ .select(nme.apply)
563+ .appliedToType(tp)
564+ .appliedTo(clsOf(erasure(tp)))
565+ .withPos(pos)
562566 case tp =>
563567 EmptyTree
564568 }
Original file line number Diff line number Diff line change 1+ true
2+ true
3+ true
4+ true
5+ true
6+ true
7+ true
8+ true
9+ true
10+ true
11+ true
12+ true
13+ true
14+ true
Original file line number Diff line number Diff line change 1+ import scala .reflect .ClassTag
2+ import scala .runtime .BoxedUnit
3+
4+ object Test {
5+ def main (args : Array [String ]): Unit = {
6+ println(implicitly[ClassTag [Unit ]] == ClassTag .Unit )
7+ println(implicitly[ClassTag [Boolean ]] == ClassTag .Boolean )
8+ println(implicitly[ClassTag [Byte ]] == ClassTag .Byte )
9+ println(implicitly[ClassTag [Char ]] == ClassTag .Char )
10+ println(implicitly[ClassTag [Short ]] == ClassTag .Short )
11+ println(implicitly[ClassTag [Int ]] == ClassTag .Int )
12+ println(implicitly[ClassTag [Long ]] == ClassTag .Long )
13+ println(implicitly[ClassTag [Float ]] == ClassTag .Float )
14+ println(implicitly[ClassTag [Double ]] == ClassTag .Double )
15+ println(implicitly[ClassTag [Object ]] == ClassTag .Object )
16+ println(implicitly[ClassTag [Any ]] == ClassTag .Any )
17+ println(implicitly[ClassTag [AnyRef ]] == ClassTag .AnyRef )
18+ println(implicitly[ClassTag [AnyVal ]] == ClassTag .AnyVal )
19+
20+ println(implicitly[ClassTag [BoxedUnit ]] != ClassTag .Unit )
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments