Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate -Xfuture #7328

Merged
merged 2 commits into from Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion project/ScalaOptionParser.scala
Expand Up @@ -82,7 +82,7 @@ object ScalaOptionParser {
}

// TODO retrieve this data programmatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala
private def booleanSettingNames = List("-X", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xfuture", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-implicits", "-Xlog-reflective-calls",
private def booleanSettingNames = List("-X", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-implicits", "-Xlog-reflective-calls",
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xno-uescape", "-Xnojline", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
"-Ybreak-cycles", "-Ydebug", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug",
"-Yide-debug",
Expand Down
5 changes: 1 addition & 4 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -39,9 +39,6 @@ trait ScalaSettings extends AbsScalaSettings
*/
protected def defaultClasspath = Option(System.getenv("CLASSPATH")).getOrElse(".")

/** Enabled under -Xfuture. */
protected def futureSettings = List[BooleanSetting]()

/** If any of these settings is enabled, the compiler should print a message and exit. */
def infoSettings = List[Setting](version, help, Xhelp, Yhelp, showPlugins, showPhases, genPhaseGraph, printArgs)

Expand Down Expand Up @@ -461,7 +458,7 @@ trait ScalaSettings extends AbsScalaSettings

/** Groups of Settings.
*/
val future = BooleanSetting("-Xfuture", "Turn on future language features.") enablingIfNotSetByUser futureSettings
val future = BooleanSetting("-Xfuture", "Deprecated. The future is now.").withDeprecationMessage("Use -Xsource instead.")
val optimise = BooleanSetting("-optimise", "Compiler flag for the optimizer in Scala 2.11")
.withAbbreviation("-optimize")
.withDeprecationMessage("In 2.12, -optimise enables -opt:l:inline -opt-inline-from:**. Check -opt:help for using the Scala 2.12 optimizer.")
Expand Down
18 changes: 9 additions & 9 deletions src/compiler/scala/tools/nsc/typechecker/Adaptations.scala
Expand Up @@ -74,21 +74,21 @@ trait Adaptations {
}

if (args.isEmpty) {
if (settings.future)
if (settings.isScala300) {
context.error(t.pos, adaptWarningMessage("Adaptation of argument list by inserting () has been removed.", showAdaptation = false))
else {
false // drop adaptation
} 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")
true // keep adaptation
}
} 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.")
)

// return `true` if the adaptation should be kept
!(args.isEmpty && settings.future)
} 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."))
true // keep adaptation
}
}
}
}
3 changes: 0 additions & 3 deletions src/manual/scala/man1/scalac.scala
Expand Up @@ -205,9 +205,6 @@ object scalac extends Command {
Definition(
CmdOption("Xfull-lubs"),
"Retain pre 2.10 behavior of less aggressive truncation of least upper bounds."),
Definition(
CmdOption("Xfuture"),
"Turn on future language features."),
Definition(
CmdOption("Xgenerate-phase-graph", Argument("file")),
"Generate the phase graphs (outputs .dot files) to fileX.dot."),
Expand Down
4 changes: 2 additions & 2 deletions test/files/neg/t7294.scala
@@ -1,5 +1,5 @@
object Test {
// Treat TupleN as final under -Xfuture for the for the purposes
// of the "fruitless type test" warning.
// TupleN is final now, so we get a
// "fruitless type test" warning.
(1, 2) match { case Seq() => 0; case _ => 1 }
}
2 changes: 1 addition & 1 deletion test/files/neg/t8035-removed.scala
@@ -1,4 +1,4 @@
// scalac: -Xfuture
// scalac: -Xsource:3.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about 2.14 instead of 3.0 ? We need to spread the pain a bit :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This represents a lot of pain, for not much gain (that I can see). Open to discuss, but my initial position is mild skepticism. I'm not yet convinced this should even be in 3.0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it's already deprecated no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm not sure anymore deprecation is the right thing to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, I probably hold the minority opinion on this. The remaining discussion is to decide the version. We could do 2.14 if people think that's better.

Copy link
Member

@SethTisue SethTisue Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I'm surprised this is controversial at all, I would like to understand your (Adriaan's) thinking here. maybe we should discuss further in a more visible place? (scala/bug#8035, or Discourse?)

Copy link
Member

@xeno-by xeno-by Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to remove this in 2.14, I think we'll need to vote for that at a SIP meeting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since when is the committee concerned with the precise version number a deprecation happens in? It doesn't even get to specify the version in which a new feature will be implemented: https://docs.scala-lang.org/sips/sip-submission.html says

the committee asks the compiler maintainers to indicate the earliest version of Scala that can include the language change.

Note: asks the maintainers, it doesn't tell us. And we're also talking about the earliest version. Since deprecation is kind of the dual, we'd be asked about the latest version something should be deprecated. However, there isn't even a SIP process for deprecation -- that usually happens together with the new feature that replaces it. That particular feature will be discussed as part of the Scala 3 sip.

If you think the SIP committee mandate should be expanded to include require precise versions in which we should implement/remove things, please put that on the agenda for November. I'll say now that I'm not in favor.

//
object Foo {
List(1,2,3).toSet()
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t1503.scala
Expand Up @@ -5,7 +5,7 @@ object Whatever {
object Test extends App {
// this should make it abundantly clear Any is the best return type we can guarantee
def matchWhatever(x: Any): Any = x match { case n @ Whatever => n }
// until 2.13, when left to its own devices, and not under -Xfuture, the return type used to be Whatever.type
// until 2.13 the return type used to be Whatever.type
// now it is Any
def matchWhateverCCE(x: Any) = x match { case n @ Whatever => n }

Expand Down
4 changes: 2 additions & 2 deletions test/junit/scala/util/TryTest.scala
Expand Up @@ -5,7 +5,7 @@ import org.junit.runners.JUnit4
import org.junit.Test
import org.junit.Assert._

/* Test Try's withFilter method, which was added along with the -Xfuture fix for scala/bug#6455 */
/* Test Try's withFilter method, which was added along with the fix for scala/bug#6455 */
@RunWith(classOf[JUnit4])
class TryTest {
@Test
Expand All @@ -32,4 +32,4 @@ class TryTest {
for (x <- util.Try(1) if x == 1) ok = x == 1
assert(ok)
}
}
}