@@ -507,7 +507,34 @@ trait Implicits { self: Typer =>
507
507
* which is itself parameterized by another string,
508
508
* indicating where the implicit parameter is needed
509
509
*/
510
- def inferImplicitArg (formal : Type , error : (String => String ) => Unit , pos : Position )(implicit ctx : Context ): Tree =
510
+ def inferImplicitArg (formal : Type , error : (String => String ) => Unit , pos : Position )(implicit ctx : Context ): Tree = {
511
+
512
+ /** If `formal` is of the form ClassTag[T], where `T` is a class type,
513
+ * synthesize a class tag for `T`.
514
+ */
515
+ def synthesizedClassTag (formal : Type , pos : Position )(implicit ctx : Context ): Tree = {
516
+ if (formal.isRef(defn.ClassTagClass ))
517
+ formal.argTypes match {
518
+ case arg :: Nil =>
519
+ fullyDefinedType(arg, " ClassTag argument" , pos) match {
520
+ case defn.ArrayOf (elemTp) =>
521
+ val etag = inferImplicitArg(defn.ClassTagType .appliedTo(elemTp), error, pos)
522
+ if (etag.isEmpty) etag else etag.select(nme.wrap)
523
+ case tp if hasStableErasure(tp) =>
524
+ ref(defn.ClassTagModule )
525
+ .select(nme.apply)
526
+ .appliedToType(tp)
527
+ .appliedTo(clsOf(erasure(tp)))
528
+ .withPos(pos)
529
+ case tp =>
530
+ EmptyTree
531
+ }
532
+ case _ =>
533
+ EmptyTree
534
+ }
535
+ else EmptyTree
536
+ }
537
+
511
538
inferImplicit(formal, EmptyTree , pos) match {
512
539
case SearchSuccess (arg, _, _, _) =>
513
540
arg
@@ -534,24 +561,6 @@ trait Implicits { self: Typer =>
534
561
EmptyTree
535
562
}
536
563
}
537
-
538
- /** If `formal` is of the form ClassTag[T], where `T` is a class type,
539
- * synthesize a class tag for `T`.
540
- */
541
- def synthesizedClassTag (formal : Type , pos : Position )(implicit ctx : Context ): Tree = {
542
- if (formal.isRef(defn.ClassTagClass ))
543
- formal.argTypes match {
544
- case arg :: Nil =>
545
- val tp = fullyDefinedType(arg, " ClassTag argument" , pos)
546
- if (hasStableErasure(tp))
547
- return ref(defn.ClassTagModule )
548
- .select(nme.apply)
549
- .appliedToType(tp)
550
- .appliedTo(clsOf(erasure(tp)))
551
- .withPos(pos)
552
- case _ =>
553
- }
554
- EmptyTree
555
564
}
556
565
557
566
private def assumedCanEqual (ltp : Type , rtp : Type )(implicit ctx : Context ) = {
0 commit comments