From a1c00ae4b2df051c33384269b6b983746e537aee Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 17 Dec 2013 14:20:49 -0800 Subject: Dotless type application for infix operators. When you have an aesthetic expresion like def f(xs: Iterator[Int]) = ( xs takeWhile (_ < 1000) map (_ * -1) filter (_ % 2 == 0) flatMap (x => List(x, x)) reduceOption (_ + _) maxBy (_.toString) ) And then for whatever reason you have to perform explicit type application in the midst of that expression, it's aggravating in the extreme that it has (had) to be rewritten in its entirety to accommodate that change. So now you can perform type application in the middle of it. For reasons not entirely clear to me postfix operators are excluded. The discussion as well as the approval for the infix variation of it can be found at: https://groups.google.com/forum/#!msg/scala-language/eJl1wnkEz9M/hR984-lqC5EJ --- test/files/neg/dotless-targs.check | 4 ++++ test/files/neg/dotless-targs.scala | 5 +++++ test/files/pos/dotless-targs.scala | 9 +++++++++ 3 files changed, 18 insertions(+) create mode 100644 test/files/neg/dotless-targs.check create mode 100644 test/files/neg/dotless-targs.scala create mode 100644 test/files/pos/dotless-targs.scala (limited to 'test/files') diff --git a/test/files/neg/dotless-targs.check b/test/files/neg/dotless-targs.check new file mode 100644 index 0000000000..4aab939f61 --- /dev/null +++ b/test/files/neg/dotless-targs.check @@ -0,0 +1,4 @@ +dotless-targs.scala:2: error: type application is not allowed for postfix operators + def f1 = "f1" isInstanceOf[String] // not ok + ^ +one error found diff --git a/test/files/neg/dotless-targs.scala b/test/files/neg/dotless-targs.scala new file mode 100644 index 0000000000..eff63cbec4 --- /dev/null +++ b/test/files/neg/dotless-targs.scala @@ -0,0 +1,5 @@ +class A { + def f1 = "f1" isInstanceOf[String] // not ok + def f2 = "f2".isInstanceOf[String] // ok + def f3 = "f3" toList // ok +} diff --git a/test/files/pos/dotless-targs.scala b/test/files/pos/dotless-targs.scala new file mode 100644 index 0000000000..8c0e244e4e --- /dev/null +++ b/test/files/pos/dotless-targs.scala @@ -0,0 +1,9 @@ +class A { + def fn1 = List apply 1 + def fn2 = List apply[Int] 2 + + def g1: Char = "g1" toList 0 + def g2: Char = "g2" apply 1 + + def h1 = List apply[List[Int]] (List(1), List(2)) mapConserve[List[Any]] (x => x) +} -- cgit v1.2.3