Skip to content

Commit 7db8083

Browse files
committed
Add some documentation
1 parent 73a8c83 commit 7db8083

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/transform/ArrayApply.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class ArrayApply extends MiniPhase {
4141
}
4242

4343
/** Only optimize when classtag if it is one of
44-
* - `ClassTag.apply(classOf[X])`
45-
* - `ClassTag.apply(java.lang.XYZ.Type)`
46-
* - `ClassTag.{Byte, Boolean, ...}`
44+
* - `ClassTag.apply(classOf[XYZ])`
45+
* - `ClassTag.apply(java.lang.XYZ.Type)` for boxed primitives `XYZ``
46+
* - `ClassTag.XYZ` for primitive types
4747
*/
4848
private def elideClassTag(ct: Tree)(implicit ctx: Context): Boolean = ct match {
4949
case Apply(_, rc :: Nil) if ct.symbol == defn.ClassTagModule_apply =>
5050
rc match {
51-
case _: Literal => true // classOf[X]
52-
case rc: RefTree if rc.name == nme.TYPE_ =>
51+
case _: Literal => true // ClassTag.apply(classOf[XYZ])
52+
case rc: RefTree if rc.name == nme.TYPE_ => // ClassTag.apply(java.lang.XYZ.Type)
5353
val owner = rc.symbol.maybeOwner.companionModule
5454
owner == defn.BoxedBooleanModule || owner == defn.BoxedByteModule ||
5555
owner == defn.BoxedShortModule || owner == defn.BoxedCharModule ||
@@ -59,6 +59,7 @@ class ArrayApply extends MiniPhase {
5959
case _ => false
6060
}
6161
case Apply(ctm: RefTree, _) if ctm.symbol.maybeOwner.companionModule == defn.ClassTagModule =>
62+
// ClassTag.XYZ
6263
nme.ScalaValueNames.contains(ctm.name)
6364
case _ => false
6465
}

0 commit comments

Comments
 (0)