diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-08 19:19:57 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-08 19:19:57 +0100 |
commit | 2edbc4f04325cb248b34d0b82b9c09dd591f553d (patch) | |
tree | b50dac32d54ec52d10290fd347ffa06f0cd7b1a4 /src | |
parent | a98d5a2b8788344d2027f01e94a3961179537fb4 (diff) | |
download | dotty-2edbc4f04325cb248b34d0b82b9c09dd591f553d.tar.gz dotty-2edbc4f04325cb248b34d0b82b9c09dd591f553d.tar.bz2 dotty-2edbc4f04325cb248b34d0b82b9c09dd591f553d.zip |
Defensive programming in Applications
- now handles the case where names in NamedArgs are wrong
- assertion check that default getter is indeed present
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index ac02b9c59..5e56d9eb8 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -159,8 +159,8 @@ trait Applications extends Compatibility { self: Typer => case (arg @ NamedArg(aname, _)) :: args1 => if (toDrop contains aname) // argument is already passed recur(pnames, args1, nameToArg, toDrop - aname) - else if (nameToArg contains aname) // argument is missing, pass an empty tree - genericEmptyTree :: recur(pnamesRest, args, nameToArg, toDrop) + else if ((nameToArg contains aname) && pnames.nonEmpty) // argument is missing, pass an empty tree + genericEmptyTree :: recur(pnames.tail, args, nameToArg, toDrop) else { // name not (or no longer) available for named arg def msg = if (methodType.paramNames contains aname) @@ -219,7 +219,9 @@ trait Applications extends Compatibility { self: Typer => case _ => NoType } } else mpre - ref(pre, pre.member(getterName).symbol) + val getter = pre.member(getterName) + assert(getter.exists, getterName) + ref(pre, getter.symbol) } else NoType } |