aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/NameOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-05-16 14:53:16 +0200
committerMartin Odersky <odersky@gmail.com>2015-05-21 17:41:13 +0200
commitacc1e15e675ce8c0b022ec4fc30d20d0e78d11c2 (patch)
tree39be457addf194d57a1ec05b6b3c6ccde8c486e6 /src/dotty/tools/dotc/core/NameOps.scala
parent42feebf6aeb2c523f1d69ff9fcad3ba22d9a1ba5 (diff)
downloaddotty-acc1e15e675ce8c0b022ec4fc30d20d0e78d11c2.tar.gz
dotty-acc1e15e675ce8c0b022ec4fc30d20d0e78d11c2.tar.bz2
dotty-acc1e15e675ce8c0b022ec4fc30d20d0e78d11c2.zip
Harden isLambdaArgName
Previously we could have returned true here yet a subsequent lambdaArgIndex would fail with a Numberformat error. This scenario is prevented now.
Diffstat (limited to 'src/dotty/tools/dotc/core/NameOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index 60aacd894..bf5e219cf 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -99,12 +99,18 @@ object NameOps {
/** Is this the name of a higher-kinded type parameter of a Lambda? */
def isLambdaArgName =
- name.length > 0 && name.head == 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) && {
+ val digits = name.drop(tpnme.LAMBDA_ARG_PREFIX.length)
+ digits.length <= 4 && digits.forall(_.isDigit)
+ }
/** The index of the higher-kinded type parameter with this name.
* Pre: isLambdaArgName.
*/
- def lambdaArgIndex: Int = name.drop(name.lastIndexOf('$') + 1).toString.toInt
+ def lambdaArgIndex: Int =
+ name.drop(tpnme.LAMBDA_ARG_PREFIX.length).toString.toInt
/** If the name ends with $nn where nn are
* all digits, strip the $ and the digits.