diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-24 05:50:55 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-24 05:50:55 -0800 |
commit | 6fd92774fe1cbee4ec68af359fa57cbd4ad8fc01 (patch) | |
tree | 7f5913fa767f7205b54967e366222549f6a065b5 | |
parent | 884737c75dc7f2765a3d769342ecc832deeddb81 (diff) | |
parent | 8297843765c7195bb7c3ad30e91de6779b9bff99 (diff) | |
download | scala-6fd92774fe1cbee4ec68af359fa57cbd4ad8fc01.tar.gz scala-6fd92774fe1cbee4ec68af359fa57cbd4ad8fc01.tar.bz2 scala-6fd92774fe1cbee4ec68af359fa57cbd4ad8fc01.zip |
Merge pull request #1958 from JamesIry/SI-6434_2.10.x
SI-6434 Pretty print function types with by name arg as (=> A) => B
-rw-r--r-- | src/reflect/scala/reflect/internal/Types.scala | 6 | ||||
-rw-r--r-- | test/files/run/t6434.check | 10 | ||||
-rw-r--r-- | test/files/run/t6434.scala | 8 |
3 files changed, 22 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 => diff --git a/test/files/run/t6434.check b/test/files/run/t6434.check new file mode 100644 index 0000000000..f898b6b781 --- /dev/null +++ b/test/files/run/t6434.check @@ -0,0 +1,10 @@ +Type in expressions to have them evaluated. +Type :help for more information. + +scala> def f(x: => Int): Int = x +f: (x: => Int)Int + +scala> f _ +res0: (=> Int) => Int = <function1> + +scala> diff --git a/test/files/run/t6434.scala b/test/files/run/t6434.scala new file mode 100644 index 0000000000..e4a4579613 --- /dev/null +++ b/test/files/run/t6434.scala @@ -0,0 +1,8 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + def code = +"""def f(x: => Int): Int = x +f _ +""" +} |