diff options
author | Dmitry Petrashko <dark@d-d.me> | 2016-12-16 10:53:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-16 10:53:13 +0100 |
commit | 8643876e31d6668555cf903c0a21ee49122f4f17 (patch) | |
tree | eb3523d93595008b2741117d92a9ff1d37d950fd /compiler/src/dotty/tools/dotc/core | |
parent | a5620ab882b95ef60acf42814ac5568d5f93bdd4 (diff) | |
parent | b1553cb9c5894e2e91925a67afd2c986675e5c46 (diff) | |
download | dotty-8643876e31d6668555cf903c0a21ee49122f4f17.tar.gz dotty-8643876e31d6668555cf903c0a21ee49122f4f17.tar.bz2 dotty-8643876e31d6668555cf903c0a21ee49122f4f17.zip |
Merge pull request #1801 from dotty-staging/fix-#1790
Fix #1790: Change by-name pattern matching.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Definitions.scala | 12 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/StdNames.scala | 1 |
2 files changed, 11 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index e4e5761b2..9759e39fc 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -675,7 +675,9 @@ class Definitions { private def isVarArityClass(cls: Symbol, prefix: Name) = { val name = scalaClassName(cls) - name.startsWith(prefix) && name.drop(prefix.length).forall(_.isDigit) + name.startsWith(prefix) && + name.length > prefix.length && + name.drop(prefix.length).forall(_.isDigit) } def isBottomClass(cls: Symbol) = @@ -735,6 +737,14 @@ class Definitions { def isProductSubType(tp: Type)(implicit ctx: Context) = (tp derivesFrom ProductType.symbol) && tp.baseClasses.exists(isProductClass) + def productArity(tp: Type)(implicit ctx: Context) = + if (tp derivesFrom ProductType.symbol) + tp.baseClasses.find(isProductClass) match { + case Some(prod) => prod.typeParams.length + case None => -1 + } + else -1 + def isFunctionType(tp: Type)(implicit ctx: Context) = isFunctionClass(tp.dealias.typeSymbol) && { val arity = functionArity(tp) diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index 741ff8b1f..e71893c1e 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -424,7 +424,6 @@ object StdNames { val info: N = "info" val inlinedEquals: N = "inlinedEquals" val isArray: N = "isArray" - val isDefined: N = "isDefined" val isDefinedAt: N = "isDefinedAt" val isDefinedAtImpl: N = "$isDefinedAt" val isEmpty: N = "isEmpty" |