diff options
author | James Iry <jamesiry@gmail.com> | 2013-01-23 11:57:06 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-01-23 11:57:06 -0800 |
commit | 8297843765c7195bb7c3ad30e91de6779b9bff99 (patch) | |
tree | 7f5913fa767f7205b54967e366222549f6a065b5 /src/reflect | |
parent | 884737c75dc7f2765a3d769342ecc832deeddb81 (diff) | |
download | scala-8297843765c7195bb7c3ad30e91de6779b9bff99.tar.gz scala-8297843765c7195bb7c3ad30e91de6779b9bff99.tar.bz2 scala-8297843765c7195bb7c3ad30e91de6779b9bff99.zip |
SI-6434 Pretty print function types with by name arg as (=> A) => B
We were pretty printing a function type with one by name arg as
=> A => B, but because => is right associative that's formally
equivalent to => (A => B) and that's entirely a different thing. This
commit changes the pretty printer in Typers.scala to check for a
byname argument on a function type and wrap it in parens. A REPL test
is included.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index c2637e6967..dbc00edb1a 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2481,8 +2481,10 @@ trait Types extends api.Types { self: SymbolTable => // from (T1, T2) => R. targs match { case in :: out :: Nil if !isTupleType(in) => - // A => B => C should be (A => B) => C or A => (B => C) - val in_s = if (isFunctionType(in)) "(" + in + ")" else "" + in + // A => B => C should be (A => B) => C or A => (B => C). + // Also if A is byname, then we want (=> A) => B because => is right associative and => A => B + // would mean => (A => B) which is a different type + val in_s = if (isFunctionType(in) || isByNameParamType(in)) "(" + in + ")" else "" + in val out_s = if (isFunctionType(out)) "(" + out + ")" else "" + out in_s + " => " + out_s case xs => |