diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-28 21:46:05 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-28 21:46:05 +0100 |
commit | 3c8196300d65738d6779ba8703e2a86ee3390ec7 (patch) | |
tree | d8edb5ee7eff6c2e012c0fef9e73938d7f3eeacc /src/dotty/tools/dotc/core/Definitions.scala | |
parent | 53c0d8996c5d065bff2f860948e5c563b187d221 (diff) | |
download | dotty-3c8196300d65738d6779ba8703e2a86ee3390ec7.tar.gz dotty-3c8196300d65738d6779ba8703e2a86ee3390ec7.tar.bz2 dotty-3c8196300d65738d6779ba8703e2a86ee3390ec7.zip |
New version of eta-expansion.
This version expands a method ref p.m to the untyped tree
p.m(_, ..., _)
(after lifting impure expressions from p). Afterwards the usual application mechanisms kick in. This fixes problems also present in Scala 2.x, where an eta-expanded function was not as flexible as an explicitly expanded one (for instance, eta expansion did not honor default parameters).
Diffstat (limited to 'src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Definitions.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala index e3915b861..7a30be9d3 100644 --- a/src/dotty/tools/dotc/core/Definitions.scala +++ b/src/dotty/tools/dotc/core/Definitions.scala @@ -322,10 +322,12 @@ class Definitions(implicit ctx: Context) { (tp derivesFrom ProductClass) && tp.baseClasses.exists(ProductClasses contains _) def isFunctionType(tp: Type) = { - val arity = tp.dealias.typeArgs.length - 1 + val arity = functionArity(tp) 0 <= arity && arity <= MaxFunctionArity && (tp isRef FunctionClass(arity)) } + def functionArity(tp: Type) = tp.dealias.typeArgs.length - 1 + // ----- Higher kinds machinery ------------------------------------------ private var _hkTraits: Set[Symbol] = Set() |