Permalink
Browse files

SI-8126 Add a '-Xsource' flag allowing compilation in e.g. 2.10 mode

This is aimed at letting the 2.11+ compiler operate, at least until
phase:typer, on a 2.10 codebase.
  • Loading branch information...
1 parent 681308a commit d43618a92cef21f4d4bb921b61d319eb358eae29 @huitseeker huitseeker committed Dec 19, 2013
Showing with 43 additions and 36 deletions.
  1. +43 −36 src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
@@ -73,48 +73,55 @@ trait ScalaSettings extends AbsScalaSettings
val nospecialization = BooleanSetting ("-no-specialization", "Ignore @specialize annotations.")
val language = MultiStringSetting("-language", "feature", "Enable one or more language features.")
+ /*
+ * The previous "-source" option is intended to be used mainly
+ * though this helper.
+ */
+ lazy val isScala211: Boolean = (source.value >= ScalaVersion("2.11.0"))
+
/**
* -X "Advanced" settings
*/
- val Xhelp = BooleanSetting ("-X", "Print a synopsis of advanced options.")
- val checkInit = BooleanSetting ("-Xcheckinit", "Wrap field accessors to throw an exception on uninitialized access.")
- val developer = BooleanSetting ("-Xdev", "Indicates user is a developer - issue warnings about anything which seems amiss")
- val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions or assumptions.")
- val elidebelow = IntSetting ("-Xelide-below", "Calls to @elidable methods are omitted if method priority is lower than argument",
+ val Xhelp = BooleanSetting ("-X", "Print a synopsis of advanced options.")
+ val checkInit = BooleanSetting ("-Xcheckinit", "Wrap field accessors to throw an exception on uninitialized access.")
+ val developer = BooleanSetting ("-Xdev", "Indicates user is a developer - issue warnings about anything which seems amiss")
+ val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions or assumptions.")
+ val elidebelow = IntSetting ("-Xelide-below", "Calls to @elidable methods are omitted if method priority is lower than argument",
elidable.MINIMUM, None, elidable.byName get _)
- val noForwarders = BooleanSetting ("-Xno-forwarders", "Do not generate static forwarders in mirror classes.")
- val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot.", "")
- val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more detail on why some implicits are not applicable.")
- val logImplicitConv = BooleanSetting ("-Xlog-implicit-conversions", "Print a message whenever an implicit conversion is inserted.")
- val logReflectiveCalls = BooleanSetting("-Xlog-reflective-calls", "Print a message when a reflective method call is generated")
- val logFreeTerms = BooleanSetting ("-Xlog-free-terms", "Print a message when reification creates a free term.")
- val logFreeTypes = BooleanSetting ("-Xlog-free-types", "Print a message when reification resorts to generating a free type.")
- val maxClassfileName = IntSetting ("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, Some((72, 255)), _ => None)
- val Xmigration = ScalaVersionSetting("-Xmigration", "version", "Warn about constructs whose behavior may have changed since version.", AnyScalaVersion)
- val nouescape = BooleanSetting ("-Xno-uescape", "Disable handling of \\u unicode escapes.")
- val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing.")
- val Xverify = BooleanSetting ("-Xverify", "Verify generic signatures in generated bytecode (asm backend only.)")
- val plugin = MultiStringSetting("-Xplugin", "paths", "Load a plugin from each classpath.")
- val disable = MultiStringSetting("-Xplugin-disable", "plugin", "Disable plugins by name.")
- val showPlugins = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins.")
- val require = MultiStringSetting("-Xplugin-require", "plugin", "Abort if a named plugin is not loaded.")
- val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search for plugin archives.", Defaults.scalaPluginPath)
- val Xprint = PhasesSetting ("-Xprint", "Print out program after")
- val writeICode = PhasesSetting ("-Xprint-icode", "Log internal icode to *.icode files after", "icode")
- val Xprintpos = BooleanSetting ("-Xprint-pos", "Print tree positions, as offsets.")
- val printtypes = BooleanSetting ("-Xprint-types", "Print tree types (debugging option).")
- val prompt = BooleanSetting ("-Xprompt", "Display a prompt after each error (debugging option).")
- val resident = BooleanSetting ("-Xresident", "Compiler stays resident: read source filenames from standard input.")
- val script = StringSetting ("-Xscript", "object", "Treat the source file as a script and wrap it in a main method.", "")
- val mainClass = StringSetting ("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d <jar>)", "")
- val Xshowcls = StringSetting ("-Xshow-class", "class", "Show internal representation of class.", "")
- val Xshowobj = StringSetting ("-Xshow-object", "object", "Show internal representation of object.", "")
- val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases.")
- val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
- val strictInference = BooleanSetting ("-Xstrict-inference", "Don't infer known-unsound types")
+ val noForwarders = BooleanSetting ("-Xno-forwarders", "Do not generate static forwarders in mirror classes.")
+ val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot.", "")
+ val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more detail on why some implicits are not applicable.")
+ val logImplicitConv = BooleanSetting ("-Xlog-implicit-conversions", "Print a message whenever an implicit conversion is inserted.")
+ val logReflectiveCalls = BooleanSetting ("-Xlog-reflective-calls", "Print a message when a reflective method call is generated")
+ val logFreeTerms = BooleanSetting ("-Xlog-free-terms", "Print a message when reification creates a free term.")
+ val logFreeTypes = BooleanSetting ("-Xlog-free-types", "Print a message when reification resorts to generating a free type.")
+ val maxClassfileName = IntSetting ("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, Some((72, 255)), _ => None)
+ val Xmigration = ScalaVersionSetting ("-Xmigration", "version", "Warn about constructs whose behavior may have changed since version.", AnyScalaVersion)
+ val nouescape = BooleanSetting ("-Xno-uescape", "Disable handling of \\u unicode escapes.")
+ val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing.")
+ val Xverify = BooleanSetting ("-Xverify", "Verify generic signatures in generated bytecode (asm backend only.)")
+ val plugin = MultiStringSetting ("-Xplugin", "paths", "Load a plugin from each classpath.")
+ val disable = MultiStringSetting ("-Xplugin-disable", "plugin", "Disable plugins by name.")
+ val showPlugins = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins.")
+ val require = MultiStringSetting ("-Xplugin-require", "plugin", "Abort if a named plugin is not loaded.")
+ val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search for plugin archives.", Defaults.scalaPluginPath)
+ val Xprint = PhasesSetting ("-Xprint", "Print out program after")
+ val writeICode = PhasesSetting ("-Xprint-icode", "Log internal icode to *.icode files after", "icode")
+ val Xprintpos = BooleanSetting ("-Xprint-pos", "Print tree positions, as offsets.")
+ val printtypes = BooleanSetting ("-Xprint-types", "Print tree types (debugging option).")
+ val prompt = BooleanSetting ("-Xprompt", "Display a prompt after each error (debugging option).")
+ val resident = BooleanSetting ("-Xresident", "Compiler stays resident: read source filenames from standard input.")
+ val script = StringSetting ("-Xscript", "object", "Treat the source file as a script and wrap it in a main method.", "")
+ val mainClass = StringSetting ("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d <jar>)", "")
+ val Xshowcls = StringSetting ("-Xshow-class", "class", "Show internal representation of class.", "")
+ val Xshowobj = StringSetting ("-Xshow-object", "object", "Show internal representation of object.", "")
+ val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases.")
+ val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
+ val strictInference = BooleanSetting ("-Xstrict-inference", "Don't infer known-unsound types")
+ val source = ScalaVersionSetting ("-Xsource", "version", "Treat compiler input as Scala source for the specified version, see SI-8126.", ScalaVersion("2.11")) withPostSetHook ( _ => isScala211)
val XnoPatmatAnalysis = BooleanSetting ("-Xno-patmat-analysis", "Don't perform exhaustivity/unreachability analysis. Also, ignore @switch annotation.")
- val XfullLubs = BooleanSetting ("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.")
+ val XfullLubs = BooleanSetting ("-Xfull-lubs", "Retains pre 2.10 behavior of less aggressive truncation of least upper bounds.")
/** Compatibility stubs for options whose value name did
* not previously match the option name.

0 comments on commit d43618a

Please sign in to comment.