@@ -679,7 +679,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
679
679
}
680
680
}
681
681
682
- def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type )(implicit ctx : Context ): Tree = {
682
+ def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type , isAnnotConstructor : Boolean = false )(implicit ctx : Context ): Tree = {
683
683
val typer = ctx.typer
684
684
val proto = new FunProtoTyped (args, expectedType, typer)
685
685
val alts = receiver.tpe.member(method).alternatives.map(_.termRef)
@@ -691,9 +691,29 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
691
691
val fun = receiver
692
692
.select(TermRef .withSig(receiver.tpe.normalizedPrefix, selected.termSymbol.asTerm))
693
693
.appliedToTypes(targs)
694
- val apply = untpd.Apply (fun, args)
695
694
696
- new typer.ApplyToTyped (apply, fun, selected, args, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
695
+ val callArgs : List [Tree ] = if (args.isEmpty) Nil else {
696
+ val lastParamType = selected.widen.paramTypess.head.last
697
+ val lastParam = args.last
698
+ if (isAnnotConstructor && ! (lastParam.tpe <:< lastParamType)) {
699
+ val defn = ctx.definitions
700
+ val prefix = args.take(selected.widen.paramTypess.head.size - 1 )
701
+ lastParamType match {
702
+ case defn.ArrayType (el) =>
703
+ lastParam.tpe match {
704
+ case defn.ArrayType (el2) if (el2 <:< el) => // we have a JavaSeqLiteral with a more precise type
705
+ prefix ::: List (tpd.Typed (lastParam, TypeTree (defn.ArrayType (el))))
706
+ case _ =>
707
+ ???
708
+ }
709
+ // case defn.ArrayType(el) if(lastParam)
710
+ case _ => args
711
+ }
712
+ } else args
713
+ }
714
+
715
+ val apply = untpd.Apply (fun, callArgs)
716
+ new typer.ApplyToTyped (apply, fun, selected, callArgs, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
697
717
}
698
718
699
719
@ tailrec
0 commit comments