diff options
author | Martin Odersky <odersky@gmail.com> | 2014-06-26 12:22:30 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-06-26 12:22:30 +0200 |
commit | c1721485725bb1050730beb2055700d5fa17c4dd (patch) | |
tree | 9ca66fd431392052719ac9573537a6b30b38a759 /src/dotty/tools/dotc | |
parent | b3364db33ff2ee2d57b4d0eaed03632099244f63 (diff) | |
download | dotty-c1721485725bb1050730beb2055700d5fa17c4dd.tar.gz dotty-c1721485725bb1050730beb2055700d5fa17c4dd.tar.bz2 dotty-c1721485725bb1050730beb2055700d5fa17c4dd.zip |
Avoid crashing on name tests when name is empty.
Guard every occurrence of name.head with a test whether name.length > 0
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/NameOps.scala | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala index 55354cc17..5bdafcf8a 100644 --- a/src/dotty/tools/dotc/core/NameOps.scala +++ b/src/dotty/tools/dotc/core/NameOps.scala @@ -66,13 +66,13 @@ object NameOps { def isSingletonName = name endsWith SINGLETON_SUFFIX def isModuleClassName = name endsWith MODULE_SUFFIX def isImportName = name startsWith IMPORT - def isInheritedName = name.head == '(' && name.startsWith(nme.INHERITED) + def isInheritedName = name.length > 0 && name.head == '(' && name.startsWith(nme.INHERITED) def isModuleVarName(name: Name): Boolean = name.stripAnonNumberSuffix endsWith MODULE_VAR_SUFFIX /** Is name a variable name? */ - def isVariableName: Boolean = { + def isVariableName: Boolean = name.length > 0 && { val first = name.head (((first.isLower && first.isLetter) || first == '_') && (name != false_) @@ -84,12 +84,12 @@ object NameOps { case raw.NE | raw.LE | raw.GE | EMPTY => false case _ => - name.last == '=' && name.head != '=' && isOperatorPart(name.head) + name.length > 0 && name.last == '=' && name.head != '=' && isOperatorPart(name.head) } /** Is this the name of a higher-kinded type parameter of a Lambda? */ def isLambdaArgName = - name(0) == tpnme.LAMBDA_ARG_PREFIXhead && name.startsWith(tpnme.LAMBDA_ARG_PREFIX) + name.length > 0 && name.head == tpnme.LAMBDA_ARG_PREFIXhead && name.startsWith(tpnme.LAMBDA_ARG_PREFIX) /** The index of the higher-kinded type parameter with this name. * Pre: isLambdaArgName. |