aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/ast/TreeInfo.scala4
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala8
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala3
4 files changed, 9 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala
index 2b0f0aee3..c1efd0b0b 100644
--- a/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -215,6 +215,10 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
case _ => false
}
+ /** Does this list contain a named argument tree? */
+ def hasNamedArg(args: List[Any]) = args exists isNamedArg
+ val isNamedArg = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[_]]
+
/** Is this pattern node a catch-all (wildcard or variable) pattern? */
def isDefaultCase(cdef: CaseDef) = cdef match {
case CaseDef(pat, EmptyTree, _) => isWildcardArg(pat)
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 217b75f61..c7acd3c1f 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -29,8 +29,6 @@ import language.implicitConversions
object Applications {
import tpd._
- private val isNamedArg = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[_]]
- def hasNamedArg(args: List[Any]) = args exists isNamedArg
def extractorMemberType(tp: Type, name: Name, errorPos: Position = NoPosition)(implicit ctx:Context) = {
val ref = tp.member(name).suchThat(_.info.isParameterless)
@@ -1061,10 +1059,8 @@ trait Applications extends Compatibility { self: Typer =>
def narrowByShapes(alts: List[TermRef]): List[TermRef] = {
if (normArgs exists (_.isInstanceOf[untpd.Function]))
- if (args exists (_.isInstanceOf[Trees.NamedArg[_]]))
- narrowByTrees(alts, args map treeShape, resultType)
- else
- narrowByTypes(alts, normArgs map typeShape, resultType)
+ if (hasNamedArg(args)) narrowByTrees(alts, args map treeShape, resultType)
+ else narrowByTypes(alts, normArgs map typeShape, resultType)
else
alts
}
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 5282ca5d3..9ee67684d 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -395,7 +395,7 @@ trait TypeAssigner {
errorType(s"named and positional type arguments may not be mixed", arg.pos)
}
val ownType =
- if (args.head.isInstanceOf[NamedArg]) (tycon.tpe /: args)(refineNamed)
+ if (hasNamedArg(args)) (tycon.tpe /: args)(refineNamed)
else if (sameLength(tparams, args)) tycon.tpe.appliedTo(args.tpes)
else errorType(d"wrong number of type arguments for ${tycon.tpe}, should be ${tparams.length}", tree.pos)
tree.withType(ownType)
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 42b556fa0..0ff2241fb 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -17,6 +17,7 @@ import SymDenotations._
import Annotations._
import Names._
import NameOps._
+import Applications._
import Flags._
import Decorators._
import ErrorReporting._
@@ -892,7 +893,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
else {
var args = tree.args
val args1 =
- if (args.head.isInstanceOf[untpd.NamedArg])
+ if (hasNamedArg(args))
for (arg @ NamedArg(id, argtpt) <- args) yield {
val argtpt1 = typedType(argtpt)
cpy.NamedArg(arg)(id, argtpt1).withType(argtpt1.tpe)