@@ -980,7 +980,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
980
980
}
981
981
}
982
982
983
- def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type , isAnnotConstructor : Boolean = false )(implicit ctx : Context ): Tree = {
983
+ def applyOverloaded (receiver : Tree , method : TermName , args : List [Tree ], targs : List [Type ], expectedType : Type )(implicit ctx : Context ): Tree = {
984
984
val typer = ctx.typer
985
985
val proto = new FunProtoTyped (args, expectedType)(typer)
986
986
val denot = receiver.tpe.member(method)
@@ -998,7 +998,6 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
998
998
assert(alternatives.size == 1 ,
999
999
i " ${if (alternatives.isEmpty) " no" else " multiple" } overloads available for " +
1000
1000
i " $method on ${receiver.tpe.widenDealiasKeepAnnots} with targs: $targs%, %; args: $args%, % of types ${args.tpes}%, %; expectedType: $expectedType. " +
1001
- i " isAnnotConstructor = $isAnnotConstructor. \n " +
1002
1001
i " all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(" , " )}\n " +
1003
1002
i " matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(" , " )}. " ) // this is parsed from bytecode tree. there's nothing user can do about it
1004
1003
alternatives.head
@@ -1008,35 +1007,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
1008
1007
.select(TermRef (receiver.tpe, selected.termSymbol.asTerm))
1009
1008
.appliedToTypes(targs)
1010
1009
1011
- def adaptLastArg (lastParam : Tree , expectedType : Type ) = {
1012
- if (isAnnotConstructor && ! (lastParam.tpe <:< expectedType)) {
1013
- val defn = ctx.definitions
1014
- val prefix = args.take(selected.widen.paramInfoss.head.size - 1 )
1015
- expectedType match {
1016
- case defn.ArrayOf (el) =>
1017
- lastParam.tpe match {
1018
- case defn.ArrayOf (el2) if el2 <:< el =>
1019
- // we have a JavaSeqLiteral with a more precise type
1020
- // we cannot construct a tree as JavaSeqLiteral inferred to precise type
1021
- // if we add typed than it would be both type-correct and
1022
- // will pass Ycheck
1023
- prefix ::: List (tpd.Typed (lastParam, TypeTree (defn.ArrayOf (el))))
1024
- case _ =>
1025
- ???
1026
- }
1027
- case _ => args
1028
- }
1029
- } else args
1030
- }
1031
-
1032
- val callArgs : List [Tree ] = if (args.isEmpty) Nil else {
1033
- val expectedType = selected.widen.paramInfoss.head.last
1034
- val lastParam = args.last
1035
- adaptLastArg(lastParam, expectedType)
1036
- }
1037
-
1038
- val apply = untpd.Apply (fun, callArgs)
1039
- new typer.ApplyToTyped (apply, fun, selected, callArgs, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
1010
+ val apply = untpd.Apply (fun, args)
1011
+ new typer.ApplyToTyped (apply, fun, selected, args, expectedType).result.asInstanceOf [Tree ] // needed to handle varargs
1040
1012
}
1041
1013
1042
1014
@ tailrec
0 commit comments