File tree Expand file tree Collapse file tree 4 files changed +9
-8
lines changed Expand file tree Collapse file tree 4 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,10 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
215
215
case _ => false
216
216
}
217
217
218
+ /** Does this list contain a named argument tree? */
219
+ def hasNamedArg (args : List [Any ]) = args exists isNamedArg
220
+ val isNamedArg = (arg : Any ) => arg.isInstanceOf [Trees .NamedArg [_]]
221
+
218
222
/** Is this pattern node a catch-all (wildcard or variable) pattern? */
219
223
def isDefaultCase (cdef : CaseDef ) = cdef match {
220
224
case CaseDef (pat, EmptyTree , _) => isWildcardArg(pat)
Original file line number Diff line number Diff line change @@ -29,8 +29,6 @@ import language.implicitConversions
29
29
30
30
object Applications {
31
31
import tpd ._
32
- private val isNamedArg = (arg : Any ) => arg.isInstanceOf [Trees .NamedArg [_]]
33
- def hasNamedArg (args : List [Any ]) = args exists isNamedArg
34
32
35
33
def extractorMemberType (tp : Type , name : Name , errorPos : Position = NoPosition )(implicit ctx: Context ) = {
36
34
val ref = tp.member(name).suchThat(_.info.isParameterless)
@@ -1061,10 +1059,8 @@ trait Applications extends Compatibility { self: Typer =>
1061
1059
1062
1060
def narrowByShapes (alts : List [TermRef ]): List [TermRef ] = {
1063
1061
if (normArgs exists (_.isInstanceOf [untpd.Function ]))
1064
- if (args exists (_.isInstanceOf [Trees .NamedArg [_]]))
1065
- narrowByTrees(alts, args map treeShape, resultType)
1066
- else
1067
- narrowByTypes(alts, normArgs map typeShape, resultType)
1062
+ if (hasNamedArg(args)) narrowByTrees(alts, args map treeShape, resultType)
1063
+ else narrowByTypes(alts, normArgs map typeShape, resultType)
1068
1064
else
1069
1065
alts
1070
1066
}
Original file line number Diff line number Diff line change @@ -395,7 +395,7 @@ trait TypeAssigner {
395
395
errorType(s " named and positional type arguments may not be mixed " , arg.pos)
396
396
}
397
397
val ownType =
398
- if (args.head. isInstanceOf [ NamedArg ] ) (tycon.tpe /: args)(refineNamed)
398
+ if (hasNamedArg( args) ) (tycon.tpe /: args)(refineNamed)
399
399
else if (sameLength(tparams, args)) tycon.tpe.appliedTo(args.tpes)
400
400
else errorType(d " wrong number of type arguments for ${tycon.tpe}, should be ${tparams.length}" , tree.pos)
401
401
tree.withType(ownType)
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import SymDenotations._
17
17
import Annotations ._
18
18
import Names ._
19
19
import NameOps ._
20
+ import Applications ._
20
21
import Flags ._
21
22
import Decorators ._
22
23
import ErrorReporting ._
@@ -892,7 +893,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
892
893
else {
893
894
var args = tree.args
894
895
val args1 =
895
- if (args.head. isInstanceOf [untpd. NamedArg ] )
896
+ if (hasNamedArg( args) )
896
897
for (arg @ NamedArg (id, argtpt) <- args) yield {
897
898
val argtpt1 = typedType(argtpt)
898
899
cpy.NamedArg (arg)(id, argtpt1).withType(argtpt1.tpe)
You can’t perform that action at this time.
0 commit comments