diff options
Diffstat (limited to 'src')
10 files changed, 36 insertions, 98 deletions
diff --git a/src/compiler/scala/tools/nsc/Reporting.scala b/src/compiler/scala/tools/nsc/Reporting.scala index e11cba466e..5bdbf4bb6a 100644 --- a/src/compiler/scala/tools/nsc/Reporting.scala +++ b/src/compiler/scala/tools/nsc/Reporting.scala @@ -26,27 +26,30 @@ trait Reporting extends scala.reflect.internal.Reporting { self: ast.Positions w protected def PerRunReporting = new PerRunReporting class PerRunReporting extends PerRunReportingBase { /** Collects for certain classes of warnings during this run. */ - private class ConditionalWarning(what: String, option: Settings#BooleanSetting)(reRunFlag: String = option.name) { + private class ConditionalWarning(what: String, doReport: () => Boolean, setting: Settings#Setting) { + def this(what: String, booleanSetting: Settings#BooleanSetting) { + this(what, () => booleanSetting, booleanSetting) + } val warnings = mutable.LinkedHashMap[Position, String]() def warn(pos: Position, msg: String) = - if (option) reporter.warning(pos, msg) + if (doReport()) reporter.warning(pos, msg) else if (!(warnings contains pos)) warnings += ((pos, msg)) def summarize() = - if (warnings.nonEmpty && (option.isDefault || option)) { + if (warnings.nonEmpty && (setting.isDefault || doReport())) { val numWarnings = warnings.size val warningVerb = if (numWarnings == 1) "was" else "were" val warningCount = countElementsAsString(numWarnings, s"$what warning") - reporter.warning(NoPosition, s"there $warningVerb $warningCount; re-run with $reRunFlag for details") + reporter.warning(NoPosition, s"there $warningVerb $warningCount; re-run with ${setting.name} for details") } } // This change broke sbt; I gave it the thrilling name of uncheckedWarnings0 so // as to recover uncheckedWarnings for its ever-fragile compiler interface. - private val _deprecationWarnings = new ConditionalWarning("deprecation", settings.deprecation)() - private val _uncheckedWarnings = new ConditionalWarning("unchecked", settings.unchecked)() - private val _featureWarnings = new ConditionalWarning("feature", settings.feature)() - private val _inlinerWarnings = new ConditionalWarning("inliner", settings.YinlinerWarnings)(if (settings.isBCodeActive) settings.YoptWarnings.name else settings.YinlinerWarnings.name) + private val _deprecationWarnings = new ConditionalWarning("deprecation", settings.deprecation) + private val _uncheckedWarnings = new ConditionalWarning("unchecked", settings.unchecked) + private val _featureWarnings = new ConditionalWarning("feature", settings.feature) + private val _inlinerWarnings = new ConditionalWarning("inliner", () => !settings.YoptWarningsSummaryOnly, settings.YoptWarnings) private val _allConditionalWarnings = List(_deprecationWarnings, _uncheckedWarnings, _featureWarnings, _inlinerWarnings) // TODO: remove in favor of the overload that takes a Symbol, give that argument a default (NoSymbol) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 831a0412cd..d4715471f6 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2811,11 +2811,6 @@ self => if (mods.isTrait) (Modifiers(Flags.TRAIT), List()) else (accessModifierOpt(), paramClauses(name, classContextBounds, ofCaseClass = mods.isCase)) var mods1 = mods - if (mods.isTrait) { - if (settings.YvirtClasses && in.token == SUBTYPE) mods1 |= Flags.DEFERRED - } else if (in.token == SUBTYPE) { - syntaxError("classes are not allowed to be virtual", skipIt = false) - } val template = templateOpt(mods1, name, constrMods withAnnotations constrAnnots, vparamss, tstart) val result = gen.mkClassDef(mods1, name, tparams, template) // Context bounds generate implicit parameters (part of the template) with types diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala index f423f3c7fe..2698225a06 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeHelpers.scala @@ -60,10 +60,7 @@ abstract class BCodeHelpers extends BCodeIdiomatic with BytecodeWriters { def isAnonymousOrLocalClass(classSym: Symbol): Boolean = { assert(classSym.isClass, s"not a class: $classSym") val r = exitingPickler(classSym.isAnonymousClass) || !classSym.originalOwner.isClass - if (r && settings.Ybackend.value == "GenBCode") { - // this assertion only holds in GenBCode. lambda lift renames symbols and may accidentally - // introduce `$lambda` into a class name, making `isDelambdafyFunction` true. under GenBCode - // we prevent this, see `nonAnon` in LambdaLift. + if (r) { // phase travel necessary: after flatten, the name includes the name of outer classes. // if some outer name contains $lambda, a non-lambda class is considered lambda. assert(exitingPickler(!classSym.isDelambdafyFunction), classSym.name) diff --git a/src/compiler/scala/tools/nsc/settings/FscSettings.scala b/src/compiler/scala/tools/nsc/settings/FscSettings.scala index fffbb4333f..d6013e0b00 100644 --- a/src/compiler/scala/tools/nsc/settings/FscSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/FscSettings.scala @@ -37,9 +37,7 @@ class FscSettings(error: String => Unit) extends Settings(error) { /** If a setting (other than a PathSetting) represents a path or paths. * For use in absolutization. */ - private def holdsPath = Set[Settings#Setting]( - d, dependencyfile, pluginsDir, Ygenjavap - ) + private def holdsPath = Set[Settings#Setting](d, dependencyfile, pluginsDir) override def processArguments(arguments: List[String], processAll: Boolean): (Boolean, List[String]) = { val (r, args) = super.processArguments(arguments, processAll) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 1446d22217..c524121646 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -34,9 +34,6 @@ trait ScalaSettings extends AbsScalaSettings /** Enabled under -Xfuture. */ protected def futureSettings = List[BooleanSetting]() - /** Enabled under -optimise. */ - def optimiseSettings = List[BooleanSetting](inline, inlineHandlers, Xcloselim, Xdce, YconstOptimization) - /** 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) @@ -167,18 +164,10 @@ trait ScalaSettings extends AbsScalaSettings val browse = PhasesSetting ("-Ybrowse", "Browse the abstract syntax tree after") val check = PhasesSetting ("-Ycheck", "Check the tree at the end of") val Yshow = PhasesSetting ("-Yshow", "(Requires -Xshow-class or -Xshow-object) Show after") - val Xcloselim = BooleanSetting ("-Yclosure-elim", "Perform closure elimination.") - val YconstOptimization = BooleanSetting ("-Yconst-opt", "Perform optimization with constant values.") val Ycompacttrees = BooleanSetting ("-Ycompact-trees", "Use compact tree printer when displaying trees.") val noCompletion = BooleanSetting ("-Yno-completion", "Disable tab-completion in the REPL.") - val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination.") val debug = BooleanSetting ("-Ydebug", "Increase the quantity of debugging output.") - //val doc = BooleanSetting ("-Ydoc", "Generate documentation") val termConflict = ChoiceSetting ("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error") - val inline = BooleanSetting ("-Yinline", "Perform inlining when possible.") - val inlineHandlers = BooleanSetting ("-Yinline-handlers", "Perform exception handler inlining when possible.") - val YinlinerWarnings= BooleanSetting ("-Yinline-warnings", "Emit inlining warnings. (Normally suppressed due to high volume)") - val Xlinearizer = ChoiceSetting ("-Ylinearizer", "which", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo") val log = PhasesSetting ("-Ylog", "Log operations during") val Ylogcp = BooleanSetting ("-Ylog-classpath", "Output information about what classpath is being applied.") val Ynogenericsig = BooleanSetting ("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.") @@ -195,7 +184,6 @@ trait ScalaSettings extends AbsScalaSettings val Yshowsymkinds = BooleanSetting ("-Yshow-symkinds", "Print abbreviated symbol kinds next to symbol names.") val Yshowsymowners = BooleanSetting ("-Yshow-symowners", "Print owner identifiers next to symbol names.") val skip = PhasesSetting ("-Yskip", "Skip") - val Ygenjavap = StringSetting ("-Ygen-javap", "dir", "Generate a parallel output directory of .javap files.", "") val Ygenasmp = StringSetting ("-Ygen-asmp", "dir", "Generate a parallel output directory of .asmp files (ie ASM Textifier output).", "") val Ydumpclasses = StringSetting ("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") val stopAfter = PhasesSetting ("-Ystop-after", "Stop after") withAbbreviation ("-stop") // backward compat @@ -214,10 +202,6 @@ trait ScalaSettings extends AbsScalaSettings val YclasspathImpl = ChoiceSetting ("-YclasspathImpl", "implementation", "Choose classpath scanning method.", List(ClassPathRepresentationType.Recursive, ClassPathRepresentationType.Flat), ClassPathRepresentationType.Recursive) val YdisableFlatCpCaching = BooleanSetting ("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.") - val YvirtClasses = false // too embryonic to even expose as a -Y //BooleanSetting ("-Yvirtual-classes", "Support virtual classes") - val YdisableUnreachablePrevention = BooleanSetting("-Ydisable-unreachable-prevention", "Disable the prevention of unreachable blocks in code generation.") - val YnoLoadImplClass = BooleanSetting ("-Yno-load-impl-class", "Do not load $class.class files.") - val exposeEmptyPackage = BooleanSetting ("-Yexpose-empty-package", "Internal only: expose the empty package.").internalOnly() val Ydelambdafy = ChoiceSetting ("-Ydelambdafy", "strategy", "Strategy used for translating lambdas into JVM code.", List("inline", "method"), "method") @@ -304,10 +288,9 @@ trait ScalaSettings extends AbsScalaSettings helpArg = "warning", descr = "Enable optimizer warnings", domain = YoptWarningsChoices, - default = Some(List(YoptWarningsChoices.atInlineFailed.name))) withPostSetHook (self => { - if (self.value subsetOf Set(YoptWarningsChoices.none, YoptWarningsChoices.atInlineFailedSummary)) YinlinerWarnings.value = false - else YinlinerWarnings.value = true - }) + default = Some(List(YoptWarningsChoices.atInlineFailed.name))) + + def YoptWarningsSummaryOnly = YoptWarnings.value subsetOf Set(YoptWarningsChoices.none, YoptWarningsChoices.atInlineFailedSummary) def YoptWarningEmitAtInlineFailed = !YoptWarnings.isSetByUser || @@ -352,22 +335,15 @@ trait ScalaSettings extends AbsScalaSettings str => Some(if(str.equalsIgnoreCase("off")) Int.MaxValue else str.toInt)) val Yquasiquotedebug = BooleanSetting("-Yquasiquote-debug", "Trace quasiquote-related activities.") - // TODO 2.12 Remove - val Yinferdebug = BooleanSetting("-Yinfer-debug", "Trace type inference and implicit search.") withDeprecationMessage("Use -Ytyper-debug") enabling(List(Ytyperdebug)) - /** Groups of Settings. */ val future = BooleanSetting("-Xfuture", "Turn on future language features.") enablingIfNotSetByUser futureSettings - val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize" enablingIfNotSetByUser optimiseSettings - val nooptimise = BooleanSetting("-Ynooptimise", "Clears all the flags set by -optimise. Useful for testing optimizations in isolation.") withAbbreviation "-Ynooptimize" disabling optimise::optimiseSettings + val optimise = BooleanSetting("-optimise", "Compiler flag for the optimizer in Scala 2.11") + .withAbbreviation("-optimize") + .withDeprecationMessage("In 2.12, -optimise enables -Yopt:l:classpath. Check -Yopt:help for using the Scala 2.12 optimizer.") + .withPostSetHook(_ => Yopt.tryToSet(List(YoptChoices.lClasspath.name))) val Xexperimental = BooleanSetting("-Xexperimental", "Enable experimental extensions.") enablingIfNotSetByUser experimentalSettings - /** - * Settings motivated by GenBCode - */ - val Ybackend = ChoiceSetting ("-Ybackend", "choice of bytecode emitter", "Choice of bytecode emitter.", - List("GenBCode"), - "GenBCode") // Feature extensions val XmacroSettings = MultiStringSetting("-Xmacro-settings", "option", "Custom settings for macros.") @@ -391,8 +367,6 @@ trait ScalaSettings extends AbsScalaSettings /** Test whether this is scaladoc we're looking at */ def isScaladoc = false - def isBCodeActive = Ybackend.value == "GenBCode" - object MacroExpand { val None = "none" val Normal = "normal" @@ -400,20 +374,18 @@ trait ScalaSettings extends AbsScalaSettings } def conflictWarning: Option[String] = { - def oldOptimiseFlagsInGenBCode: Option[String] = { - val optFlags: List[Setting] = if (optimise.value) List(optimise) else optimiseSettings.filter(_.value) - if (isBCodeActive && optFlags.nonEmpty) { - val msg = s"""Compiler settings for the 2.11 optimizer (${optFlags.map(_.name).mkString(", ")}) are incompatible with -Ybackend:GenBCode (which is the default in 2.12). - |The optimizer settings are ignored. See -Yopt:help for enabling the new optimizer in 2.12.""".stripMargin - Some(msg) - } else - None - } + // See cd878232b5 for an example how to warn about conflicting settings - List(oldOptimiseFlagsInGenBCode /*, moreToCome */).flatten match { + /* + def checkSomeConflict: Option[String] = ... + + List(/* checkSomeConflict, ... */).flatten match { case Nil => None case warnings => Some("Conflicting compiler settings were detected. Some settings will be ignored.\n" + warnings.mkString("\n")) } + */ + + None } } diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index 112dedce81..0fb6213d36 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -21,16 +21,8 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL { val phaseName: String = "cleanup" /* used in GenBCode: collects ClassDef symbols owning a main(Array[String]) method */ - private var entryPoints: List[Symbol] = null - def getEntryPoints: List[Symbol] = { - assert(settings.isBCodeActive, "Candidate Java entry points are collected here only when GenBCode in use.") - entryPoints sortBy ("" + _.fullName) // For predictably ordered error messages. - } - - override def newPhase(prev: scala.tools.nsc.Phase): StdPhase = { - entryPoints = if (settings.isBCodeActive) Nil else null; - super.newPhase(prev) - } + private var entryPoints: List[Symbol] = Nil + def getEntryPoints: List[Symbol] = entryPoints sortBy ("" + _.fullName) // For predictably ordered error messages. protected def newTransformer(unit: CompilationUnit): Transformer = new CleanUpTransformer(unit) @@ -378,11 +370,7 @@ abstract class CleanUp extends Statics with Transform with ast.TreeDSL { } override def transform(tree: Tree): Tree = tree match { - - case _: ClassDef - if (entryPoints != null) && - genBCode.isJavaEntryPoint(tree.symbol, currentUnit) - => + case _: ClassDef if genBCode.isJavaEntryPoint(tree.symbol, currentUnit) => // collecting symbols for entry points here (as opposed to GenBCode where they are used) // has the advantage of saving an additional pass over all ClassDefs. entryPoints ::= tree.symbol diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala index f7ec9391a7..5d93f9f20e 100644 --- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala +++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala @@ -569,8 +569,6 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre // The functional interface that can be used to adapt the lambda target method `target` to the // given function type. Returns `NoSymbol` if the compiler settings are unsuitable. private def java8CompatFunctionalInterface(target: Symbol, functionType: Type): (Symbol, Boolean) = { - val canUseLambdaMetafactory = settings.isBCodeActive - val sym = functionType.typeSymbol val pack = currentRun.runDefinitions.Scala_Java8_CompatPackage val name1 = specializeTypes.specializedFunctionName(sym, functionType.typeArgs) @@ -582,6 +580,6 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre } else { pack.info.decl(name1.toTypeName.prepend("J")) } - (if (canUseLambdaMetafactory) functionalInterface else NoSymbol, isSpecialized) + (functionalInterface, isSpecialized) } } diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index f6e2dd68f0..a372136781 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -246,9 +246,8 @@ abstract class LambdaLift extends InfoTransform { } // make sure that the name doesn't make the symbol accidentally `isAnonymousClass` (et.al) by - // introducing `$anon` in its name. to be cautious, we don't make this change in the default - // backend under 2.11.x, so only in GenBCode. - def nonAnon(s: String) = if (settings.Ybackend.value == "GenBCode") nme.ensureNonAnon(s) else s + // introducing `$anon` in its name. + def nonAnon(s: String) = nme.ensureNonAnon(s) def newName(sym: Symbol): Name = { val originalName = sym.name diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 7cd05b56c3..eea1f53cbc 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -236,10 +236,7 @@ abstract class UnCurry extends InfoTransform !(specialized =:= fun.tpe) } - def canUseDelamdafyMethod = ( - (inConstructorFlag == 0) // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation - && (!isSpecialized || settings.isBCodeActive) // DelambdafyTransformer currently only emits generic FunctionN-s, use the old style in the meantime - ) + def canUseDelamdafyMethod = inConstructorFlag == 0 // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation if (inlineFunctionExpansion || !canUseDelamdafyMethod) { val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe)) val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 42b939f18b..1c9167b2ea 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -167,12 +167,6 @@ object PathResolver { |}""".asLines } - // used in PathResolver constructor - private object NoImplClassJavaContext extends JavaContext { - override def isValidName(name: String): Boolean = - !ReflectionUtils.scalacShouldntLoadClassfile(name) - } - @deprecated("This method is no longer used be scalap and will be deleted", "2.11.5") def fromPathString(path: String, context: JavaContext = DefaultJavaContext): JavaClassPath = { val s = new Settings() @@ -313,10 +307,7 @@ abstract class PathResolverBase[BaseClassPathType <: ClassFileLookup[AbstractFil class PathResolver(settings: Settings, context: JavaContext) extends PathResolverBase[ClassPath[AbstractFile], JavaClassPath](settings, context) { - def this(settings: Settings) = - this(settings, - if (settings.YnoLoadImplClass) PathResolver.NoImplClassJavaContext - else DefaultJavaContext) + def this(settings: Settings) = this(settings, DefaultJavaContext) override protected def computeResult(): JavaClassPath = new JavaClassPath(containers.toIndexedSeq, context) |