From 43ba65fa11456899b3c45be14bd3895d8d6b6b5a Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 28 Jul 2016 15:08:43 -0700 Subject: SI-7187 deprecate eta-expansion of zero-arg method values For backwards compatiblity with 2.11, we already don't adapt a zero-arg method value to a SAM. In 2.13, we won't do any eta-expansion for zero-arg method values, but we should deprecate first. --- test/files/neg/t7187.check | 6 ++++++ test/files/neg/t7187.flags | 1 + test/files/neg/t7187.scala | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 test/files/neg/t7187.check create mode 100644 test/files/neg/t7187.flags create mode 100644 test/files/neg/t7187.scala (limited to 'test/files/neg') diff --git a/test/files/neg/t7187.check b/test/files/neg/t7187.check new file mode 100644 index 0000000000..a30803c746 --- /dev/null +++ b/test/files/neg/t7187.check @@ -0,0 +1,6 @@ +t7187.scala:3: warning: Eta-expansion of zero-argument method values is deprecated. Did you intend to write EtaExpandZeroArg.this.foo()? + val f: () => Any = foo + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t7187.flags b/test/files/neg/t7187.flags new file mode 100644 index 0000000000..c6bfaf1f64 --- /dev/null +++ b/test/files/neg/t7187.flags @@ -0,0 +1 @@ +-deprecation -Xfatal-warnings diff --git a/test/files/neg/t7187.scala b/test/files/neg/t7187.scala new file mode 100644 index 0000000000..45d33f06af --- /dev/null +++ b/test/files/neg/t7187.scala @@ -0,0 +1,6 @@ +class EtaExpandZeroArg { + def foo(): () => String = () => "" + val f: () => Any = foo + + // f() would evaluate to instead of "" +} -- cgit v1.2.3