diff --git a/spec/06-expressions.md b/spec/06-expressions.md index 1794f1621e48..b40d7bb28400 100644 --- a/spec/06-expressions.md +++ b/spec/06-expressions.md @@ -1400,16 +1400,16 @@ type $T$ by evaluating the expression to which $m$ is bound. If the method takes only implicit parameters, implicit arguments are passed following the rules [here](07-implicits.html#implicit-parameters). +###### Empty Application +Otherwise, if $e$ has method type $()T$, it is implicitly applied to the empty +argument list, yielding $e()$. + ###### Eta Expansion Otherwise, if the method is not a constructor, and the expected type $\mathit{pt}$ is a function type $(\mathit{Ts}') \Rightarrow T'$, [eta-expansion](#eta-expansion) is performed on the expression $e$. -###### Empty Application -Otherwise, if $e$ has method type $()T$, it is implicitly applied to the empty -argument list, yielding $e()$. - ### Overloading Resolution If an identifier or selection $e$ references several members of a diff --git a/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala b/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala index b1901c04bbad..ba88172ae90c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Adaptations.scala @@ -70,16 +70,11 @@ trait Adaptations { if (settings.noAdaptedArgs) context.warning(t.pos, adaptWarningMessage("No automatic adaptation here: use explicit parentheses.")) - else if (args.isEmpty) { - if (settings.future) - context.error(t.pos, adaptWarningMessage("Adaptation of argument list by inserting () has been removed.", showAdaptation = false)) - else { - val msg = "Adaptation of argument list by inserting () is deprecated: " + ( - if (isLeakyTarget) "leaky (Object-receiving) target makes this especially dangerous." - else "this is unlikely to be what you want.") - context.deprecationWarning(t.pos, t.symbol, adaptWarningMessage(msg), "2.11.0") - } - } else if (settings.warnAdaptedArgs) + else if (args.isEmpty) + context.error(t.pos, + adaptWarningMessage(s"Adaptation of argument list by inserting () has been removed.", + showAdaptation = false)) + else if (settings.warnAdaptedArgs) context.warning(t.pos, adaptWarningMessage( s"Adapting argument list by creating a ${args.size}-tuple: this may not be what you want.") ) diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check index aa7694e9fb66..46f6690b08dc 100644 --- a/test/files/neg/checksensible.check +++ b/test/files/neg/checksensible.check @@ -1,21 +1,3 @@ -checksensible.scala:45: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. - signature: Any.==(x$1: Any): Boolean - given arguments: - after adaptation: Any.==((): Unit) - () == () - ^ -checksensible.scala:48: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. - signature: Object.!=(x$1: Any): Boolean - given arguments: - after adaptation: Object.!=((): Unit) - scala.runtime.BoxedUnit.UNIT != () - ^ -checksensible.scala:49: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. - signature: Any.!=(x$1: Any): Boolean - given arguments: - after adaptation: Any.!=((): Unit) - (scala.runtime.BoxedUnit.UNIT: java.io.Serializable) != () // shouldn't warn - ^ checksensible.scala:13: warning: comparing a fresh object using `eq' will always yield false (new AnyRef) eq (new AnyRef) ^ @@ -62,59 +44,53 @@ checksensible.scala:44: warning: comparing values of types Unit and Boolean usin () == true ^ checksensible.scala:45: warning: comparing values of types Unit and Unit using `==' will always yield true - () == () - ^ -checksensible.scala:46: warning: comparing values of types Unit and Unit using `==' will always yield true () == println ^ -checksensible.scala:47: warning: comparing values of types Unit and scala.runtime.BoxedUnit using `==' will always yield true +checksensible.scala:46: warning: comparing values of types Unit and scala.runtime.BoxedUnit using `==' will always yield true () == scala.runtime.BoxedUnit.UNIT // these should warn for always being true/false ^ -checksensible.scala:48: warning: comparing values of types scala.runtime.BoxedUnit and Unit using `!=' will always yield false - scala.runtime.BoxedUnit.UNIT != () - ^ -checksensible.scala:51: warning: comparing values of types Int and Unit using `!=' will always yield true +checksensible.scala:48: warning: comparing values of types Int and Unit using `!=' will always yield true (1 != println) ^ -checksensible.scala:52: warning: comparing values of types Int and Symbol using `!=' will always yield true +checksensible.scala:49: warning: comparing values of types Int and Symbol using `!=' will always yield true (1 != 'sym) ^ -checksensible.scala:58: warning: comparing a fresh object using `==' will always yield false +checksensible.scala:55: warning: comparing a fresh object using `==' will always yield false ((x: Int) => x + 1) == null ^ -checksensible.scala:59: warning: comparing a fresh object using `==' will always yield false +checksensible.scala:56: warning: comparing a fresh object using `==' will always yield false Bep == ((_: Int) + 1) ^ -checksensible.scala:61: warning: comparing a fresh object using `==' will always yield false +checksensible.scala:58: warning: comparing a fresh object using `==' will always yield false new Object == new Object ^ -checksensible.scala:62: warning: comparing a fresh object using `==' will always yield false +checksensible.scala:59: warning: comparing a fresh object using `==' will always yield false new Object == "abc" ^ -checksensible.scala:63: warning: comparing a fresh object using `!=' will always yield true +checksensible.scala:60: warning: comparing a fresh object using `!=' will always yield true new Exception() != new Exception() ^ -checksensible.scala:66: warning: comparing values of types Int and Null using `==' will always yield false +checksensible.scala:63: warning: comparing values of types Int and Null using `==' will always yield false if (foo.length == null) "plante" else "plante pas" ^ -checksensible.scala:71: warning: comparing values of types Bip and Bop using `==' will always yield false +checksensible.scala:68: warning: comparing values of types Bip and Bop using `==' will always yield false (x1 == x2) ^ -checksensible.scala:81: warning: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false +checksensible.scala:78: warning: comparing values of types EqEqRefTest.this.C3 and EqEqRefTest.this.Z1 using `==' will always yield false c3 == z1 ^ -checksensible.scala:82: warning: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `==' will always yield false +checksensible.scala:79: warning: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `==' will always yield false z1 == c3 ^ -checksensible.scala:83: warning: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `!=' will always yield true +checksensible.scala:80: warning: comparing values of types EqEqRefTest.this.Z1 and EqEqRefTest.this.C3 using `!=' will always yield true z1 != c3 ^ -checksensible.scala:84: warning: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true +checksensible.scala:81: warning: comparing values of types EqEqRefTest.this.C3 and String using `!=' will always yield true c3 != "abc" ^ -checksensible.scala:95: warning: comparing values of types Unit and Int using `!=' will always yield true +checksensible.scala:92: warning: comparing values of types Unit and Int using `!=' will always yield true while ((c = in.read) != -1) ^ error: No warnings can be incurred under -Xfatal-warnings. -36 warnings found +31 warnings found one error found diff --git a/test/files/neg/checksensible.scala b/test/files/neg/checksensible.scala index b6083f75e4ab..2073ede5ff14 100644 --- a/test/files/neg/checksensible.scala +++ b/test/files/neg/checksensible.scala @@ -42,11 +42,8 @@ class EqEqValTest { 1 != true () == true - () == () () == println () == scala.runtime.BoxedUnit.UNIT // these should warn for always being true/false - scala.runtime.BoxedUnit.UNIT != () - (scala.runtime.BoxedUnit.UNIT: java.io.Serializable) != () // shouldn't warn (1 != println) (1 != 'sym) diff --git a/test/files/neg/t4851.check b/test/files/neg/t4851.check index 721923e0ba3f..1a117b2c6a2d 100644 --- a/test/files/neg/t4851.check +++ b/test/files/neg/t4851.check @@ -1,13 +1,11 @@ -S.scala:2: warning: Adaptation of argument list by inserting () is deprecated: leaky (Object-receiving) target makes this especially dangerous. +S.scala:2: error: Adaptation of argument list by inserting () has been removed. signature: J(x: Any): J given arguments: - after adaptation: new J((): Unit) val x1 = new J ^ -S.scala:3: warning: Adaptation of argument list by inserting () is deprecated: leaky (Object-receiving) target makes this especially dangerous. +S.scala:3: error: Adaptation of argument list by inserting () has been removed. signature: J(x: Any): J given arguments: - after adaptation: new J((): Unit) val x2 = new J() ^ S.scala:4: warning: Adapting argument list by creating a 5-tuple: this may not be what you want. @@ -28,16 +26,14 @@ S.scala:7: warning: Adapting argument list by creating a 3-tuple: this may not b after adaptation: new Some((1, 2, 3): (Int, Int, Int)) val y2 = new Some(1, 2, 3) ^ -S.scala:9: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. +S.scala:9: error: Adaptation of argument list by inserting () has been removed. signature: J2(x: T): J2[T] given arguments: - after adaptation: new J2((): Unit) val z1 = new J2 ^ -S.scala:10: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. +S.scala:10: error: Adaptation of argument list by inserting () has been removed. signature: J2(x: T): J2[T] given arguments: - after adaptation: new J2((): Unit) val z2 = new J2() ^ S.scala:14: warning: Adapting argument list by creating a 3-tuple: this may not be what you want. @@ -46,6 +42,5 @@ S.scala:14: warning: Adapting argument list by creating a 3-tuple: this may not after adaptation: Test.anyId((1, 2, 3): (Int, Int, Int)) val w1 = anyId(1, 2 ,3) ^ -error: No warnings can be incurred under -Xfatal-warnings. -8 warnings found -one error found +four warnings found +four errors found diff --git a/test/files/neg/t8035-deprecated.check b/test/files/neg/t8035-deprecated.check deleted file mode 100644 index 35aba5551db1..000000000000 --- a/test/files/neg/t8035-deprecated.check +++ /dev/null @@ -1,21 +0,0 @@ -t8035-deprecated.scala:2: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. - signature: GenSetLike.apply(elem: A): Boolean - given arguments: - after adaptation: GenSetLike((): Unit) - List(1,2,3).toSet() - ^ -t8035-deprecated.scala:5: warning: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want. - signature: A(x: T): Foo.A[T] - given arguments: - after adaptation: new A((): Unit) - new A - ^ -t8035-deprecated.scala:9: warning: Adaptation of argument list by inserting () is deprecated: leaky (Object-receiving) target makes this especially dangerous. - signature: Format.format(x$1: Any): String - given arguments: - after adaptation: Format.format((): Unit) - sdf.format() - ^ -error: No warnings can be incurred under -Xfatal-warnings. -three warnings found -one error found diff --git a/test/files/neg/t8035-deprecated.flags b/test/files/neg/t8035-deprecated.flags deleted file mode 100644 index c6bfaf1f64a4..000000000000 --- a/test/files/neg/t8035-deprecated.flags +++ /dev/null @@ -1 +0,0 @@ --deprecation -Xfatal-warnings diff --git a/test/files/neg/t8035-deprecated.scala b/test/files/neg/t8035-deprecated.scala deleted file mode 100644 index 6423157530db..000000000000 --- a/test/files/neg/t8035-deprecated.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Foo { - List(1,2,3).toSet() - - class A[T](val x: T) - new A - - import java.text.SimpleDateFormat - val sdf = new SimpleDateFormat("yyyyMMdd-HH0000") - sdf.format() -} diff --git a/test/files/neg/t8035-removed.flags b/test/files/neg/t8035-removed.flags deleted file mode 100644 index 29f4ede37ab4..000000000000 --- a/test/files/neg/t8035-removed.flags +++ /dev/null @@ -1 +0,0 @@ --Xfuture