From 571ed0312031a0826f65d40b27933d16b9617fbe Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Fri, 21 Aug 2015 14:00:46 +1000 Subject: Desugar module var and accessor in refchecks/lazyvals Rather than leaving it until mixin. The broader motivation is to simplify the mixin phase of the compiler before we get rid of implementatation classes in favour of using JDK8 default interface methods. The current code in mixin is used for both lazy val and modules, and puts the "slow path" code that uses the monitor into a dedicated method (`moduleName$lzyCompute`). I tracked this back to a3d4d17b77. I can't tell from that commit whether the performance sensititivity was related to modules or lazy vals, from the commit message I'd say the latter. As the initialization code for a module is just a constructor call, rather than an arbitraryly large chunk of code for a lazy initializer, this commit opts to inline the `lzycompute` method. During refchecks, mixin module accessors are added to classes, so that mixed in and defined modules are translated uniformly. Trait owned modules get an accessor method with an empty body (that shares the module symbol), but no module var. Defer synthesis of the double checked locking idiom to the lazyvals phase, which gets us a step closer to a unified translation of modules and lazy vals. I had to change the `atOwner` methods to to avoid using the non-existent module class of a module accessor method as the current owner. This fixes a latent bug. Without this change, retypechecking of the module accessor method during erasure crashes with an accessibility error selecting the module var. In the process, I've tweaked a tree generation utility method to wvoid synthesizing redundant blocks in module desugaring. --- src/reflect/scala/reflect/internal/StdNames.scala | 2 +- src/reflect/scala/reflect/internal/Symbols.scala | 2 +- src/reflect/scala/reflect/internal/transform/Erasure.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index f1016e1b76..9a31634751 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -876,7 +876,7 @@ trait StdNames { val toCharacter: NameType = "toCharacter" val toInteger: NameType = "toInteger" - def newLazyValSlowComputeName(lzyValName: Name) = lzyValName append LAZY_SLOW_SUFFIX + def newLazyValSlowComputeName(lzyValName: Name) = (lzyValName stripSuffix MODULE_VAR_SUFFIX append LAZY_SLOW_SUFFIX).toTermName // ASCII names for operators val ADD = encode("+") diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index c3b2a8da08..3d87035f88 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -323,7 +323,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => def newModuleVarSymbol(accessor: Symbol): TermSymbol = { val newName = nme.moduleVarName(accessor.name.toTermName) val newFlags = MODULEVAR | ( if (this.isClass) PrivateLocal | SYNTHETIC else 0 ) - val newInfo = accessor.tpe.finalResultType + val newInfo = thisType.memberType(accessor).finalResultType val mval = newVariable(newName, accessor.pos.focus, newFlags.toLong) addAnnotation VolatileAttr if (this.isClass) diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index 9853a0fa0c..f661978fcd 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -123,7 +123,7 @@ trait Erasure { case tref @ TypeRef(pre, sym, args) => if (sym == ArrayClass) if (unboundedGenericArrayLevel(tp) == 1) ObjectTpe - else if (args.head.typeSymbol.isBottomClass) arrayType(ObjectTpe) + else if (args.head.typeSymbol.isBottomClass) arrayType(ObjectTpe) else typeRef(apply(pre), sym, args map applyInArray) else if (sym == AnyClass || sym == AnyValClass || sym == SingletonClass) ObjectTpe else if (sym == UnitClass) BoxedUnitTpe -- cgit v1.2.3 From e843f3d33baf09e3ad3e84f9bc74c498fcbd21e2 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Fri, 6 Nov 2015 13:36:06 +0100 Subject: Use BTypes when building the lambdaMetaFactoryBootstrapHandle All class internal names that are referenced from a class being compiled should be referenced through their ClassBType. This makes sure that the ClassBType is cached in `classBTypeFromInternalName`, which is required during classfile writing: when ASM computes stack map frames, we need to answer subtyping queries, for which we need to look up the ClassBTypes. --- .../scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala | 11 +++++++++-- src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala | 6 ++++++ src/reflect/scala/reflect/internal/Definitions.scala | 1 - src/reflect/scala/reflect/runtime/JavaUniverseForce.scala | 1 - 4 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala index f1e5e1958d..790469d874 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeBodyBuilder.scala @@ -1345,6 +1345,13 @@ abstract class BCodeBodyBuilder extends BCodeSkelBuilder { lazy val lambdaMetaFactoryBootstrapHandle = new asm.Handle(asm.Opcodes.H_INVOKESTATIC, - definitions.LambdaMetaFactory.fullName('/'), sn.AltMetafactory.toString, - "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;") + coreBTypes.jliLambdaMetafactoryRef.internalName, sn.AltMetafactory.toString, + MethodBType( + List( + coreBTypes.jliMethodHandlesLookupRef, + coreBTypes.StringRef, + coreBTypes.jliMethodTypeRef, + ArrayBType(ObjectRef)), + coreBTypes.jliCallSiteRef + ).descriptor) } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala b/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala index 79aa4308c5..028eea9da2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/CoreBTypes.scala @@ -117,6 +117,9 @@ class CoreBTypes[BTFS <: BTypesFromSymbols[_ <: Global]](val bTypes: BTFS) { lazy val jliSerializedLambdaRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.invoke.SerializedLambda]) lazy val jliMethodHandlesRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.invoke.MethodHandles]) lazy val jliMethodHandlesLookupRef : ClassBType = classBTypeFromSymbol(exitingPickler(rootMirror.getRequiredClass("java.lang.invoke.MethodHandles.Lookup"))) // didn't find a reliable non-stringly-typed way that works for inner classes in the backend + lazy val jliMethodTypeRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.invoke.MethodType]) + lazy val jliCallSiteRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.invoke.CallSite]) + lazy val jliLambdaMetafactoryRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.invoke.LambdaMetafactory]) lazy val srLambdaDeserializerRef : ClassBType = classBTypeFromSymbol(requiredModule[scala.runtime.LambdaDeserializer.type].moduleClass) lazy val srBoxesRunTimeRef : ClassBType = classBTypeFromSymbol(requiredClass[scala.runtime.BoxesRunTime]) @@ -240,6 +243,9 @@ final class CoreBTypesProxy[BTFS <: BTypesFromSymbols[_ <: Global]](val bTypes: def jliSerializedLambdaRef : ClassBType = _coreBTypes.jliSerializedLambdaRef def jliMethodHandlesRef : ClassBType = _coreBTypes.jliMethodHandlesRef def jliMethodHandlesLookupRef : ClassBType = _coreBTypes.jliMethodHandlesLookupRef + def jliMethodTypeRef : ClassBType = _coreBTypes.jliMethodTypeRef + def jliCallSiteRef : ClassBType = _coreBTypes.jliCallSiteRef + def jliLambdaMetafactoryRef : ClassBType = _coreBTypes.jliLambdaMetafactoryRef def srLambdaDeserializerRef : ClassBType = _coreBTypes.srLambdaDeserializerRef def srBoxesRunTimeRef : ClassBType = _coreBTypes.srBoxesRunTimeRef diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 5ce5c39145..35b08e72c4 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -518,7 +518,6 @@ trait Definitions extends api.StandardDefinitions { lazy val ScalaSignatureAnnotation = requiredClass[scala.reflect.ScalaSignature] lazy val ScalaLongSignatureAnnotation = requiredClass[scala.reflect.ScalaLongSignature] - lazy val LambdaMetaFactory = getClassIfDefined("java.lang.invoke.LambdaMetafactory") lazy val MethodHandle = getClassIfDefined("java.lang.invoke.MethodHandle") // Option classes diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index 0132fff17c..a9b91b5ec3 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -313,7 +313,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => definitions.QuasiquoteClass_api_unapply definitions.ScalaSignatureAnnotation definitions.ScalaLongSignatureAnnotation - definitions.LambdaMetaFactory definitions.MethodHandle definitions.OptionClass definitions.OptionModule -- cgit v1.2.3 From 2a20ced512038a930e79fc14bb30782fbd910ac1 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Sun, 11 Oct 2015 18:58:43 +0200 Subject: Also mutate module *class*'s owner in ChangeOwnerTraverser Keep owner for module (symbol of the tree) and module class (holds the members) in synch while moving trees between owners (e.g., while duplicating them in specialization) --- src/reflect/scala/reflect/internal/Internals.scala | 16 ++-------------- src/reflect/scala/reflect/internal/Trees.scala | 4 +++- 2 files changed, 5 insertions(+), 15 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/reflect/scala/reflect/internal/Internals.scala b/src/reflect/scala/reflect/internal/Internals.scala index ad4cec5b4d..acf000ebc5 100644 --- a/src/reflect/scala/reflect/internal/Internals.scala +++ b/src/reflect/scala/reflect/internal/Internals.scala @@ -60,19 +60,7 @@ trait Internals extends api.Internals { def typeDef(sym: Symbol): TypeDef = self.TypeDef(sym) def labelDef(sym: Symbol, params: List[Symbol], rhs: Tree): LabelDef = self.LabelDef(sym, params, rhs) - def changeOwner(tree: Tree, prev: Symbol, next: Symbol): tree.type = { - object changeOwnerAndModuleClassTraverser extends ChangeOwnerTraverser(prev, next) { - override def traverse(tree: Tree) { - tree match { - case _: DefTree => change(tree.symbol.moduleClass) - case _ => // do nothing - } - super.traverse(tree) - } - } - changeOwnerAndModuleClassTraverser.traverse(tree) - tree - } + def changeOwner(tree: Tree, prev: Symbol, next: Symbol): tree.type = { new ChangeOwnerTraverser(prev, next).traverse(tree); tree } lazy val gen = self.treeBuild @@ -170,4 +158,4 @@ trait Internals extends api.Internals { def mkZero(tp: Type): Tree = self.gen.mkZero(tp) def mkCast(tree: Tree, pt: Type): Tree = self.gen.mkCast(tree, pt) } -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 49554d6d0f..d63c23b992 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -1468,8 +1468,10 @@ trait Trees extends api.Trees { class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser { final def change(sym: Symbol) = { - if (sym != NoSymbol && sym.owner == oldowner) + if (sym != NoSymbol && sym.owner == oldowner) { sym.owner = newowner + if (sym.isModule) sym.moduleClass.owner = newowner + } } override def traverse(tree: Tree) { tree match { -- cgit v1.2.3 From 57de5b8bd811014b446c7c344aa4504e828888e6 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 1 Oct 2015 14:51:48 -0700 Subject: Annotation filtering & derivation in one place. This logic was scattered all over the hierarchy, even though it's only needed in one spot, and is unlikely to evolve. --- .../tools/nsc/typechecker/MethodSynthesis.scala | 65 +++++++++++----------- .../scala/reflect/internal/AnnotationInfos.scala | 16 ++++++ 2 files changed, 47 insertions(+), 34 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index f655e4e1cb..05fe60f7b7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -22,17 +22,6 @@ trait MethodSynthesis { import definitions._ import CODE._ - /** The annotations amongst those found on the original symbol which - * should be propagated to this kind of accessor. - */ - def deriveAnnotations(initial: List[AnnotationInfo], category: Symbol, keepClean: Boolean): List[AnnotationInfo] = { - def annotationFilter(ann: AnnotationInfo) = ann.metaAnnotations match { - case Nil if ann.defaultTargets.isEmpty => keepClean // no meta-annotations or default targets - case Nil => ann.defaultTargets contains category // default targets exist for ann - case metas => metas exists (_ matches category) // meta-annotations attached to ann - } - initial filter annotationFilter - } class ClassMethodSynthesis(val clazz: Symbol, localTyper: Typer) { def mkThis = This(clazz) setPos clazz.pos.focus @@ -160,13 +149,15 @@ trait MethodSynthesis { enterBeans(tree) } + import AnnotationInfo.{mkFilter => annotationFilter} + /** This is called for those ValDefs which addDerivedTrees ignores, but * which might have a warnable annotation situation. */ private def warnForDroppedAnnotations(tree: Tree) { val annotations = tree.symbol.initialize.annotations val targetClass = defaultAnnotationTarget(tree) - val retained = deriveAnnotations(annotations, targetClass, keepClean = true) + val retained = annotations filter annotationFilter(targetClass, defaultRetention = true) annotations filterNot (retained contains _) foreach (ann => issueAnnotationWarning(tree, ann, targetClass)) } @@ -208,8 +199,8 @@ trait MethodSynthesis { context.unit.synthetics get meth match { case Some(mdef) => context.unit.synthetics -= meth - meth setAnnotations deriveAnnotations(annotations, MethodTargetClass, keepClean = false) - cd.symbol setAnnotations deriveAnnotations(annotations, ClassTargetClass, keepClean = true) + meth setAnnotations (annotations filter annotationFilter(MethodTargetClass, defaultRetention = false)) + cd.symbol setAnnotations (annotations filter annotationFilter(ClassTargetClass, defaultRetention = true)) List(cd, mdef) case _ => // Shouldn't happen, but let's give ourselves a reasonable error when it does @@ -293,10 +284,6 @@ trait MethodSynthesis { def tree: ValDef final def enclClass = basisSym.enclClass - /** Which meta-annotation is associated with this kind of entity. - * Presently one of: field, getter, setter, beanGetter, beanSetter, param. - */ - def category: Symbol /* Explicit isSetter required for bean setters (beanSetterSym.isSetter is false) */ final def completer(sym: Symbol) = namerOf(sym).accessorTypeCompleter(tree, isSetter) @@ -307,7 +294,6 @@ trait MethodSynthesis { def isSetter = false def isDeferred = mods.isDeferred - def keepClean = false // whether annotations whose definitions are not meta-annotated should be kept. def validate() { } def createAndEnterSymbol(): MethodSymbol = { val sym = owner.newMethod(name, tree.pos.focus, derivedMods.flags) @@ -323,7 +309,29 @@ trait MethodSynthesis { } final def derive(initial: List[AnnotationInfo]): Tree = { validate() - derivedSym setAnnotations deriveAnnotations(initial, category, keepClean) + + // see scala.annotation.meta's package class for more info + // Annotations on ValDefs can be targeted towards the following: field, getter, setter, beanGetter, beanSetter, param. + // The defaults are: + // - (`val`-, `var`- or plain) constructor parameter annotations end up on the parameter, not on any other entity. + // - val/var member annotations solely end up on the underlying field. + // + // TODO: these defaults can be surprising for annotations not meant for accessors/fields -- should we revisit? + // (In order to have `@foo val X` result in the X getter being annotated with `@foo`, foo needs to be meta-annotated with @getter) + val annotFilter: AnnotationInfo => Boolean = this match { + case _: Param => annotationFilter(ParamTargetClass, defaultRetention = true) + // By default annotations go to the field, except if the field is generated for a class parameter (PARAMACCESSOR). + case _: Field => annotationFilter(FieldTargetClass, defaultRetention = !mods.isParamAccessor) + case _: BaseGetter => annotationFilter(GetterTargetClass, defaultRetention = false) + case _: Setter => annotationFilter(SetterTargetClass, defaultRetention = false) + case _: BeanSetter => annotationFilter(BeanSetterTargetClass, defaultRetention = false) + case _: AnyBeanGetter => annotationFilter(BeanGetterTargetClass, defaultRetention = false) + } + + // The annotations amongst those found on the original symbol which + // should be propagated to this kind of accessor. + derivedSym setAnnotations (initial filter annotFilter) + logDerived(derivedTree) } } @@ -370,7 +378,6 @@ trait MethodSynthesis { sealed abstract class BaseGetter(tree: ValDef) extends DerivedGetter { def name = tree.name - def category = GetterTargetClass def flagsMask = GetterFlags def flagsExtra = ACCESSOR.toLong | ( if (tree.mods.isMutable) 0 else STABLE ) @@ -450,7 +457,6 @@ trait MethodSynthesis { } case class Setter(tree: ValDef) extends DerivedSetter { def name = tree.setterName - def category = SetterTargetClass def flagsMask = SetterFlags def flagsExtra = ACCESSOR @@ -470,18 +476,14 @@ trait MethodSynthesis { // NOTE: do not look at `vd.symbol` when called from `enterGetterSetter` (luckily, that call-site implies `!mods.isLazy`), // as the symbol info is in the process of being created then. // TODO: harmonize tree & symbol creation - // TODO: the `def field` call-site does not tollerate including `|| vd.symbol.owner.isTrait` --> tests break - def noFieldFor(vd: ValDef) = vd.mods.isDeferred || (vd.mods.isLazy && isUnitType(vd.symbol.info)) // || vd.symbol.owner.isTrait)) + // TODO: the `def field` call-site breaks when you add `|| vd.symbol.owner.isTrait` (detected in test suite) + def noFieldFor(vd: ValDef) = vd.mods.isDeferred || (vd.mods.isLazy && isUnitType(vd.symbol.info)) } case class Field(tree: ValDef) extends DerivedFromValDef { def name = tree.localName - def category = FieldTargetClass def flagsMask = FieldFlags def flagsExtra = PrivateLocal - // By default annotations go to the field, except if the field is - // generated for a class parameter (PARAMACCESSOR). - override def keepClean = !mods.isParamAccessor // handle lazy val first for now (we emit a Field even though we probably shouldn't...) override def derivedTree = @@ -492,10 +494,8 @@ trait MethodSynthesis { } case class Param(tree: ValDef) extends DerivedFromValDef { def name = tree.name - def category = ParamTargetClass def flagsMask = -1L def flagsExtra = 0L - override def keepClean = true override def derivedTree = EmptyTree } def validateParam(tree: ValDef) { @@ -509,7 +509,6 @@ trait MethodSynthesis { override def derivedSym = enclClass.info decl name } sealed trait AnyBeanGetter extends BeanAccessor with DerivedGetter { - def category = BeanGetterTargetClass override def validate() { if (derivedSym == NoSymbol) { // the namer decides whether to generate these symbols or not. at that point, we don't @@ -532,9 +531,7 @@ trait MethodSynthesis { } case class BooleanBeanGetter(tree: ValDef) extends BeanAccessor("is") with AnyBeanGetter { } case class BeanGetter(tree: ValDef) extends BeanAccessor("get") with AnyBeanGetter { } - case class BeanSetter(tree: ValDef) extends BeanAccessor("set") with DerivedSetter { - def category = BeanSetterTargetClass - } + case class BeanSetter(tree: ValDef) extends BeanAccessor("set") with DerivedSetter // No Symbols available. private def beanAccessorsFromNames(tree: ValDef) = { diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index 207a66e360..c0772c8cc0 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -169,6 +169,22 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => def unapply(info: AnnotationInfo): Option[(Type, List[Tree], List[(Name, ClassfileAnnotArg)])] = Some((info.atp, info.args, info.assocs)) + + def mkFilter(category: Symbol, defaultRetention: Boolean)(ann: AnnotationInfo) = + (ann.metaAnnotations, ann.defaultTargets) match { + case (Nil, Nil) => defaultRetention + case (Nil, defaults) => defaults contains category + case (metas, _) => metas exists (_ matches category) + } + + def mkFilter(categories: List[Symbol], defaultRetention: Boolean)(ann: AnnotationInfo) = + (ann.metaAnnotations, ann.defaultTargets) match { + case (Nil, Nil) => defaultRetention + case (Nil, defaults) => categories exists defaults.contains + case (metas, _) => + val metaSyms = metas collect { case ann if !ann.symbol.isInstanceOf[StubSymbol] => ann.symbol } + categories exists (category => metaSyms exists (_ isNonBottomSubClass category)) + } } class CompleteAnnotationInfo( -- cgit v1.2.3 From 9050aaf60fcbbe9465e63fe39963fa14f7af2776 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 11 Nov 2015 14:39:11 -0800 Subject: Sbt-compatible implementation of `isPastXXXPhase` sbt's [API extraction phase](https://github.com/sbt/sbt/blob/0.13/compile/interface/src/main/scala/xsbt/API.scala#L25) extends `scala.reflect.internal.Phase`, which implements a bunch of methods, such as `erasedTypes` as `false`, which are then overridden by scalac in `GlobalPhase` (nested in scala.tools.nsc.Global). (`erasedTypes` in particular is again overridden in the back-end -- for performance?) However, since sbt's compiler phases extend `reflect.internal.Phase`, the logic for detecting the current phase does not work, as the default implementation is called (simply returning `false`), when chasing the `prev` pointers hits an sbt-injected phase, as its implementation is `reflect.internal`'s constant `false`. --- src/compiler/scala/tools/nsc/Global.scala | 9 --------- src/reflect/scala/reflect/internal/Phase.scala | 12 ++++++++---- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 70582c82c8..26e2b75c2a 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -384,15 +384,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) def apply(unit: CompilationUnit): Unit - private val isErased = prev.name == "erasure" || prev.erasedTypes - override def erasedTypes: Boolean = isErased - private val isFlat = prev.name == "flatten" || prev.flatClasses - override def flatClasses: Boolean = isFlat - private val isSpecialized = prev.name == "specialize" || prev.specialized - override def specialized: Boolean = isSpecialized - private val isRefChecked = prev.name == "refchecks" || prev.refChecked - override def refChecked: Boolean = isRefChecked - /** Is current phase cancelled on this unit? */ def cancelled(unit: CompilationUnit) = { // run the typer only if in `createJavadoc` mode diff --git a/src/reflect/scala/reflect/internal/Phase.scala b/src/reflect/scala/reflect/internal/Phase.scala index 1ecc202a07..a761f686e6 100644 --- a/src/reflect/scala/reflect/internal/Phase.scala +++ b/src/reflect/scala/reflect/internal/Phase.scala @@ -39,10 +39,14 @@ abstract class Phase(val prev: Phase) { def description: String = name // Will running with -Ycheck:name work? def checkable: Boolean = true - def specialized: Boolean = false - def erasedTypes: Boolean = false - def flatClasses: Boolean = false - def refChecked: Boolean = false + + // NOTE: sbt injects its own phases which extend this class, and not GlobalPhase, so we must implement this logic here + private val _erasedTypes = ((prev ne null) && (prev ne NoPhase)) && (prev.name == "erasure" || prev.erasedTypes) + def erasedTypes: Boolean = _erasedTypes // overridden in back-end + final val flatClasses: Boolean = ((prev ne null) && (prev ne NoPhase)) && (prev.name == "flatten" || prev.flatClasses) + final val specialized: Boolean = ((prev ne null) && (prev ne NoPhase)) && (prev.name == "specialize" || prev.specialized) + final val refChecked: Boolean = ((prev ne null) && (prev ne NoPhase)) && (prev.name == "refchecks" || prev.refChecked) + /** This is used only in unsafeTypeParams, and at this writing is * overridden to false in parser, namer, typer, and erasure. (And NoPhase.) -- cgit v1.2.3 From 5160387dbd34e8f7d800244d0d6234a6f4540e73 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Wed, 11 Nov 2015 20:53:13 -0800 Subject: Clean up a bit more in Constructors. Comment about my poor naming choice in Types. NullaryMethodType sounds like the method has one empty argument list, whereas it really has no argument lists at all. --- .../scala/tools/nsc/transform/Constructors.scala | 24 +++++++++++----------- src/reflect/scala/reflect/internal/Types.scala | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 2f019c75c9..f5eca11c98 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -359,7 +359,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { } log("merging: " + originalStats.mkString("\n") + "\nwith\n" + specializedStats.mkString("\n")) - val res = for (s <- originalStats; stat = s.duplicate) yield { + for (s <- originalStats; stat = s.duplicate) yield { log("merge: looking at " + stat) val stat1 = stat match { case Assign(sel @ Select(This(_), field), _) => @@ -389,9 +389,8 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { } else stat1 } - if (specBuf.nonEmpty) - println("residual specialized constructor statements: " + specBuf) - res +// if (specBuf.nonEmpty) +// println("residual specialized constructor statements: " + specBuf) } /* Add an 'if' around the statements coming after the super constructor. This @@ -591,7 +590,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { case ValDef(mods, name, _, _) if mods hasFlag PRESUPER => // stat is the constructor-local definition of the field value val fields = presupers filter (_.getterName == name) - assert(fields.length == 1) + assert(fields.length == 1, s"expected exactly one field by name $name in $presupers of $clazz's early initializers") val to = fields.head.symbol if (memoizeValue(to)) constrStatBuf += mkAssign(to, Ident(stat.symbol)) @@ -607,9 +606,9 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { // it goes before the superclass constructor call, otherwise it goes after. // A lazy val's effect is not moved to the constructor, as it is delayed. // Returns `true` when a `ValDef` is needed. - def moveEffectToCtor(mods: Modifiers, rhs: Tree, memoized: Boolean): Unit = { + def moveEffectToCtor(mods: Modifiers, rhs: Tree, assignSym: Symbol): Unit = { val initializingRhs = - if (!memoized || statSym.isLazy) EmptyTree // not memoized, or effect delayed (for lazy val) + if ((assignSym eq NoSymbol) || statSym.isLazy) EmptyTree // not memoized, or effect delayed (for lazy val) else if (!mods.hasStaticFlag) intoConstructor(statSym, primaryConstr.symbol)(rhs) else rhs @@ -619,7 +618,7 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { else if (mods hasFlag PRESUPER | PARAMACCESSOR) constrPrefixBuf else constrStatBuf - initPhase += mkAssign(statSym, initializingRhs) + initPhase += mkAssign(assignSym, initializingRhs) } } @@ -640,10 +639,11 @@ abstract class Constructors extends Statics with Transform with ast.TreeDSL { // - the constructor, before the super call (early initialized or a parameter accessor), // - the constructor, after the super call (regular val). case ValDef(mods, _, _, rhs) => - val emitField = memoizeValue(statSym) - moveEffectToCtor(mods, rhs, emitField) - - if (emitField) defBuf += deriveValDef(stat)(_ => EmptyTree) + if (rhs ne EmptyTree) { + val emitField = memoizeValue(statSym) + moveEffectToCtor(mods, rhs, if (emitField) statSym else NoSymbol) + if (emitField) defBuf += deriveValDef(stat)(_ => EmptyTree) + } else defBuf += stat // all other statements go into the constructor case _ => constrStatBuf += intoConstructor(impl.symbol, primaryConstr.symbol)(stat) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 33592bbd86..b282026c36 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2496,6 +2496,8 @@ trait Types override def isJava = true } + // TODO: rename so it's more appropriate for the type that is for a method without argument lists + // ("nullary" erroneously implies it has an argument list with zero arguments, it actually has zero argument lists) case class NullaryMethodType(override val resultType: Type) extends Type with NullaryMethodTypeApi { override def isTrivial = resultType.isTrivial && (resultType eq resultType.withoutAnnotations) override def prefix: Type = resultType.prefix -- cgit v1.2.3 From 238b1fba3d5085457d05817c646d436542def5ea Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 29 Oct 2015 13:01:07 +1000 Subject: Attacking exponential complexity in TypeMaps - Don't normalize existentials during the `contain`-s type map; `ExistentialType#normalize' calls contains internally and an exponential blowup ensues. - Ensure that the type map used in variance validation never returns modified types in order to avoid needless cloning of symbols. The enclosed test case still gets stuck in Uncurry, thanks to the way that `TypeMap#mapOver(List[Symbol])` recurses through the type first to check whether the type map would be an no-op or not. If not, it repeats the type map with cloned symbols. Doing the work twice at each level of recursion blows up the complexity. Removing that "fast path" allows the enclosed test to compile completely. As at this commit, it gets stuck in uncurry, which dealiases `s.List` to `s.c.i.List` within the type. Some more background on the troublesome part of `TypeMap`: http://lrytz.github.io/scala-aladdin-bugtracker/displayItem.do%3Fid=1210.html https://github.com/scala/scala/commit/f8b2b21050e7a2ca0f537ef70e3e0c8eead43abc --- src/reflect/scala/reflect/internal/Variances.scala | 24 ++++++++++++++-------- .../scala/reflect/internal/tpe/TypeMaps.scala | 18 ++++++++++++---- test/files/pos/existental-slow-compile2.scala | 7 +++++++ test/files/pos/existential-slow-compile1.flags | 1 + test/files/pos/existential-slow-compile1.scala | 7 +++++++ 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 test/files/pos/existental-slow-compile2.scala create mode 100644 test/files/pos/existential-slow-compile1.flags create mode 100644 test/files/pos/existential-slow-compile1.scala (limited to 'src/reflect/scala') diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index ef22df3f2e..af04f47e0e 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -122,15 +122,21 @@ trait Variances { * same is true of the parameters (ValDefs) unless we are inside a * refinement, in which case they are checked from here. */ - def apply(tp: Type): Type = tp match { - case _ if isUncheckedVariance(tp) => tp - case _ if resultTypeOnly(tp) => this(tp.resultType) - case TypeRef(_, sym, _) if sym.isAliasType => this(tp.normalize) - case TypeRef(_, sym, _) if !sym.variance.isInvariant => checkVarianceOfSymbol(sym) ; mapOver(tp) - case RefinedType(_, _) => withinRefinement(mapOver(tp)) - case ClassInfoType(parents, _, _) => parents foreach this ; tp - case mt @ MethodType(_, result) => flipped(mt.paramTypes foreach this) ; this(result) - case _ => mapOver(tp) + def apply(tp: Type): Type = { + tp match { + case _ if isUncheckedVariance(tp) => + case _ if resultTypeOnly(tp) => this(tp.resultType) + case TypeRef(_, sym, _) if sym.isAliasType => this(tp.normalize) + case TypeRef(_, sym, _) if !sym.variance.isInvariant => checkVarianceOfSymbol(sym) ; mapOver(tp) + case RefinedType(_, _) => withinRefinement(mapOver(tp)) + case ClassInfoType(parents, _, _) => parents foreach this + case mt @ MethodType(_, result) => flipped(mt.paramTypes foreach this) ; this(result) + case _ => mapOver(tp) + } + // We're using TypeMap here for type traversal only. To avoid wasteful symbol + // cloning during the recursion, it is important to return the input `tp`, rather + // than the result of the pattern match above, which normalizes types. + tp } def validateDefinition(base: Symbol) { val saved = this.base diff --git a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala index b8d4050d7d..804360b677 100644 --- a/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala +++ b/src/reflect/scala/reflect/internal/tpe/TypeMaps.scala @@ -998,10 +998,20 @@ private[internal] trait TypeMaps { class ContainsCollector(sym: Symbol) extends TypeCollector(false) { def traverse(tp: Type) { if (!result) { - tp.normalize match { - case TypeRef(_, sym1, _) if (sym == sym1) => result = true - case SingleType(_, sym1) if (sym == sym1) => result = true - case _ => mapOver(tp) + tp match { + case _: ExistentialType => + // ExistentialType#normalize internally calls contains, which leads to exponential performance + // for types like: `A[_ <: B[_ <: ... ]]`. Example: pos/existential-contains.scala. + // + // We can just map over the components and wait until we see the underlying type before we call + // normalize. + mapOver(tp) + case _ => + tp.normalize match { + case TypeRef(_, sym1, _) if (sym == sym1) => result = true + case SingleType(_, sym1) if (sym == sym1) => result = true + case _ => mapOver(tp) + } } } } diff --git a/test/files/pos/existental-slow-compile2.scala b/test/files/pos/existental-slow-compile2.scala new file mode 100644 index 0000000000..907344982c --- /dev/null +++ b/test/files/pos/existental-slow-compile2.scala @@ -0,0 +1,7 @@ +class C { + class L[+A] + def test = { + val foo: + L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_]]]]]]]]]]]]]]]]]]]]]]]] + = ??? } } + diff --git a/test/files/pos/existential-slow-compile1.flags b/test/files/pos/existential-slow-compile1.flags new file mode 100644 index 0000000000..7f7581974d --- /dev/null +++ b/test/files/pos/existential-slow-compile1.flags @@ -0,0 +1 @@ +-Ystop-after:refchecks diff --git a/test/files/pos/existential-slow-compile1.scala b/test/files/pos/existential-slow-compile1.scala new file mode 100644 index 0000000000..8602afd9db --- /dev/null +++ b/test/files/pos/existential-slow-compile1.scala @@ -0,0 +1,7 @@ +class C { + type L[+A] = scala.collection.immutable.List[A] + def test = { + val foo: + L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: _ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_ <: L[_]]]]]]]]]]]]]]]]]]]]]]]] + = ??? } } + -- cgit v1.2.3 From eeeb92c3d59de611dec1782a969b86171454de40 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 22 Jan 2015 10:34:17 +1000 Subject: SI-9110 Pattern `O.C` must check `$outer eq O` for a top level O The outer check was not being generated when the prefix was a top level module. The enclosed test shows that we in fact must synthesize the outer check in that case. Perhaps the bug was introduced by neglecting to consider that a module can inherit member classes. --- src/reflect/scala/reflect/internal/Types.scala | 3 ++- test/files/run/t9110.scala | 27 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t9110.scala (limited to 'src/reflect/scala') diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index b282026c36..5b23bbf144 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -3940,7 +3940,8 @@ trait Types def maybeCreateDummyClone(pre: Type, sym: Symbol): Type = pre match { case SingleType(pre1, sym1) => if (sym1.isModule && sym1.isStatic) { - NoType + if (sym.owner == sym1 || sym.isJavaDefined || sym.owner.sourceModule.isStaticModule) NoType + else pre } else if (sym1.isModule && sym.owner == sym1.moduleClass) { val pre2 = maybeCreateDummyClone(pre1, sym1) if (pre2 eq NoType) pre2 diff --git a/test/files/run/t9110.scala b/test/files/run/t9110.scala new file mode 100644 index 0000000000..660291a4d1 --- /dev/null +++ b/test/files/run/t9110.scala @@ -0,0 +1,27 @@ +trait Event + +trait Domain { + case class Created(name: String) extends Event +} + +// declare three instances of Domain trait, one here and two +// in an inner scope + +object DomainC extends Domain + +object Test { + def main(args: Array[String]) { + object DomainA extends Domain + object DomainB extends Domain + + def lookingForAs(event: Event): Unit = { + event match { + case DomainB.Created(_) => throw null + case DomainC.Created(_) => throw null + case DomainA.Created(_) => // okay + } + } + + lookingForAs(DomainA.Created("I am an A")) + } +} -- cgit v1.2.3 From 9d6cdf0066716da71b3d668628a25859b353ee5e Mon Sep 17 00:00:00 2001 From: Janek Bogucki Date: Thu, 26 Nov 2015 22:27:19 +0000 Subject: Apply some static code analysis recommendations Fix a batch of code inspection recommendations generated by IntelliJ 14.1.5. Categories of fix, Unnecessary public modifier in interface Replace filter+size with count Replace filter+nonEmpty with exists Replace filter+headOption with find Replace `if (x != null) Some(x) else None` with Option(x) Replace getOrElse null with orNull Drop redundant semicolons Replace anon fun with PF Replace anon fun with method --- src/library/scala/reflect/ScalaLongSignature.java | 2 +- src/library/scala/reflect/ScalaSignature.java | 2 +- .../scala/reflect/internal/util/WeakHashSet.scala | 6 +++--- src/reflect/scala/reflect/macros/Attachments.scala | 2 +- src/reflect/scala/reflect/runtime/ReflectionUtils.scala | 4 ++-- src/reflect/scala/reflect/runtime/SynchronizedOps.scala | 4 ++-- .../scala/tools/nsc/interpreter/JLineCompletion.scala | 2 +- src/repl/scala/tools/nsc/interpreter/JavapClass.scala | 4 ++-- src/scalap/scala/tools/scalap/CodeWriter.scala | 2 +- src/scalap/scala/tools/scalap/Decode.scala | 2 +- src/scalap/scala/tools/scalap/JavaWriter.scala | 8 ++++---- src/scalap/scala/tools/scalap/MetaParser.scala | 16 ++++++++-------- src/scalap/scala/tools/scalap/scalax/rules/Result.scala | 2 +- .../scalap/scalax/rules/scalasig/ScalaSigPrinter.scala | 6 +++--- 14 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/library/scala/reflect/ScalaLongSignature.java b/src/library/scala/reflect/ScalaLongSignature.java index 5b6d78f446..94cf504aa4 100644 --- a/src/library/scala/reflect/ScalaLongSignature.java +++ b/src/library/scala/reflect/ScalaLongSignature.java @@ -8,5 +8,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface ScalaLongSignature { - public String[] bytes(); + String[] bytes(); } diff --git a/src/library/scala/reflect/ScalaSignature.java b/src/library/scala/reflect/ScalaSignature.java index a8af554d2b..217ae8e8f7 100644 --- a/src/library/scala/reflect/ScalaSignature.java +++ b/src/library/scala/reflect/ScalaSignature.java @@ -8,5 +8,5 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface ScalaSignature { - public String bytes(); + String bytes(); } diff --git a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala index 3a7a7626fb..83d2a3453b 100644 --- a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala +++ b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala @@ -41,7 +41,7 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D * power of two equal to or greater than the specified initial capacity */ private def computeCapacity = { - if (initialCapacity < 0) throw new IllegalArgumentException("initial capacity cannot be less than 0"); + if (initialCapacity < 0) throw new IllegalArgumentException("initial capacity cannot be less than 0") var candidate = 1 while (candidate < initialCapacity) { candidate *= 2 @@ -372,13 +372,13 @@ final class WeakHashSet[A <: AnyRef](val initialCapacity: Int, val loadFactor: D * Number of buckets that hold collisions. Useful for diagnosing performance issues. */ def collisionBucketsCount: Int = - (table filter (entry => entry != null && entry.tail != null)).size + (table count (entry => entry != null && entry.tail != null)) /** * Number of buckets that are occupied in this hash table. */ def fullBucketsCount: Int = - (table filter (entry => entry != null)).size + (table count (entry => entry != null)) /** * Number of buckets in the table diff --git a/src/reflect/scala/reflect/macros/Attachments.scala b/src/reflect/scala/reflect/macros/Attachments.scala index b5c340645a..0b5360c004 100644 --- a/src/reflect/scala/reflect/macros/Attachments.scala +++ b/src/reflect/scala/reflect/macros/Attachments.scala @@ -39,7 +39,7 @@ abstract class Attachments { self => /** An underlying payload of the given class type `T`. */ def get[T: ClassTag]: Option[T] = - (all filter matchesTag[T]).headOption.asInstanceOf[Option[T]] + (all find matchesTag[T]).asInstanceOf[Option[T]] /** Check underlying payload contains an instance of type `T`. */ def contains[T: ClassTag]: Boolean = diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index a4bd698068..a278ed3fd7 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -72,7 +72,7 @@ object ReflectionUtils { def singletonAccessor(clazz: Class[_]): Option[Method] = if (clazz == null) None else { - val declaredAccessor = clazz.getDeclaredMethods.filter(_.getName == accessorName).headOption + val declaredAccessor = clazz.getDeclaredMethods.find(_.getName == accessorName) declaredAccessor orElse singletonAccessor(clazz.getSuperclass) } @@ -92,7 +92,7 @@ object ReflectionUtils { } class EnclosedIn[T](enclosure: jClass[_] => T) { - def unapply(jclazz: jClass[_]): Option[T] = if (enclosure(jclazz) != null) Some(enclosure(jclazz)) else None + def unapply(jclazz: jClass[_]): Option[T] = Option(enclosure(jclazz)) } object EnclosedInMethod extends EnclosedIn(_.getEnclosingMethod) diff --git a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala index 4a8585d616..f0d96e0fd6 100644 --- a/src/reflect/scala/reflect/runtime/SynchronizedOps.scala +++ b/src/reflect/scala/reflect/runtime/SynchronizedOps.scala @@ -15,7 +15,7 @@ private[reflect] trait SynchronizedOps extends internal.SymbolTable override protected def newBaseTypeSeq(parents: List[Type], elems: Array[Type]) = // only need to synchronize BaseTypeSeqs if they contain refined types - if (elems.filter(_.isInstanceOf[RefinedType]).nonEmpty) new BaseTypeSeq(parents, elems) with SynchronizedBaseTypeSeq + if (elems.exists(_.isInstanceOf[RefinedType])) new BaseTypeSeq(parents, elems) with SynchronizedBaseTypeSeq else new BaseTypeSeq(parents, elems) trait SynchronizedBaseTypeSeq extends BaseTypeSeq { @@ -31,7 +31,7 @@ private[reflect] trait SynchronizedOps extends internal.SymbolTable override def lateMap(f: Type => Type): BaseTypeSeq = // only need to synchronize BaseTypeSeqs if they contain refined types - if (map(f).toList.filter(_.isInstanceOf[RefinedType]).nonEmpty) new MappedBaseTypeSeq(this, f) with SynchronizedBaseTypeSeq + if (map(f).toList.exists(_.isInstanceOf[RefinedType])) new MappedBaseTypeSeq(this, f) with SynchronizedBaseTypeSeq else new MappedBaseTypeSeq(this, f) } diff --git a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala index e9b0234a4f..c2ccfc8064 100644 --- a/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala +++ b/src/repl/scala/tools/nsc/interpreter/JLineCompletion.scala @@ -175,7 +175,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput case Some((clazz, runtimeType)) => val sym = intp.symbolOfTerm(id) if (sym.isStable) { - val param = new NamedParam.Untyped(id, intp valueOfTerm id getOrElse null) + val param = new NamedParam.Untyped(id, intp valueOfTerm id orNull) Some(TypeMemberCompletion(tpe, runtimeType, param)) } else default diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala index c240ab027a..9ad9479d05 100644 --- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala +++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala @@ -600,11 +600,11 @@ object JavapClass { def parents: List[ClassLoader] = parentsOf(loader) /* all file locations */ def locations = { - def alldirs = parents flatMap (_ match { + def alldirs = parents flatMap { case ucl: ScalaClassLoader.URLClassLoader => ucl.classPathURLs case jcl: java.net.URLClassLoader => jcl.getURLs case _ => Nil - }) + } val dirs = for (d <- alldirs; if d.getProtocol == "file") yield Path(new JFile(d.toURI)) dirs } diff --git a/src/scalap/scala/tools/scalap/CodeWriter.scala b/src/scalap/scala/tools/scalap/CodeWriter.scala index 168050096d..07aba0b632 100644 --- a/src/scalap/scala/tools/scalap/CodeWriter.scala +++ b/src/scalap/scala/tools/scalap/CodeWriter.scala @@ -35,7 +35,7 @@ class CodeWriter(writer: Writer) { def setIndentWidth(width: Int): CodeWriter = setIndentString(List.fill(width)(' ').mkString) - def getIndentString = step; + def getIndentString = step def setIndentString(step: String): CodeWriter = { this.step = step diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala index 76ce3f4173..310d6117e6 100644 --- a/src/scalap/scala/tools/scalap/Decode.scala +++ b/src/scalap/scala/tools/scalap/Decode.scala @@ -49,7 +49,7 @@ object Decode { import classFile._ classFile annotation SCALA_SIG_ANNOTATION map { case Annotation(_, els) => - val bytesElem = els find (x => constant(x.elementNameIndex) == BYTES_VALUE) getOrElse null + val bytesElem = els find (x => constant(x.elementNameIndex) == BYTES_VALUE) orNull val _bytes = bytesElem.elementValue match { case ConstValueIndex(x) => constantWrapped(x) } val bytes = _bytes.asInstanceOf[StringBytesPair].bytes val length = ByteCodecs.decode(bytes) diff --git a/src/scalap/scala/tools/scalap/JavaWriter.scala b/src/scalap/scala/tools/scalap/JavaWriter.scala index 772cf6eacd..75e2637d56 100644 --- a/src/scalap/scala/tools/scalap/JavaWriter.scala +++ b/src/scalap/scala/tools/scalap/JavaWriter.scala @@ -164,7 +164,7 @@ class JavaWriter(classfile: Classfile, writer: Writer) extends CodeWriter(writer } def printClass() { - val pck = getPackage(cf.classname); + val pck = getPackage(cf.classname) if (pck.length() > 0) println("package " + pck + ";") print(flagsToStr(true, cf.flags)) @@ -175,14 +175,14 @@ class JavaWriter(classfile: Classfile, writer: Writer) extends CodeWriter(writer printClassHeader; case Some(cf.Attribute(_, data)) => val mp = new MetaParser(getName( - ((data(0) & 0xff) << 8) + (data(1) & 0xff)).trim()); + ((data(0) & 0xff) << 8) + (data(1) & 0xff)).trim()) mp.parse match { case None => printClassHeader; case Some(str) => if (isInterface(cf.flags)) - print("trait " + getSimpleClassName(cf.classname) + str); + print("trait " + getSimpleClassName(cf.classname) + str) else - print("class " + getSimpleClassName(cf.classname) + str); + print("class " + getSimpleClassName(cf.classname) + str) } } var statics: List[cf.Member] = Nil diff --git a/src/scalap/scala/tools/scalap/MetaParser.scala b/src/scalap/scala/tools/scalap/MetaParser.scala index 1ebf86268a..b9dab0ad01 100644 --- a/src/scalap/scala/tools/scalap/MetaParser.scala +++ b/src/scalap/scala/tools/scalap/MetaParser.scala @@ -64,7 +64,7 @@ class MetaParser(meta: String) { case _: Exception => None } } else - None; + None protected def parseMetaClass: String = { nextToken @@ -100,7 +100,7 @@ class MetaParser(meta: String) { parseType } while (token == "with") } - res.toString(); + res.toString() } protected def parseMetaMethod: String = { @@ -113,10 +113,10 @@ class MetaParser(meta: String) { var loop = true res.append("[") while (loop) { - res.append(token.substring(1)); - nextToken; + res.append(token.substring(1)) + nextToken if (token == "<") { - nextToken; + nextToken res.append(" <: ") parseType } @@ -133,16 +133,16 @@ class MetaParser(meta: String) { if (token == "(") { do { if (token == ",") { - nextToken; + nextToken if (token != ")") res.append(", ") } else { - nextToken; + nextToken res.append("(") } if (token != ")") { if (token == "def") { - nextToken; + nextToken res.append("def ") } parseType diff --git a/src/scalap/scala/tools/scalap/scalax/rules/Result.scala b/src/scalap/scala/tools/scalap/scalax/rules/Result.scala index f37340e7b7..b6f650b899 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/Result.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/Result.scala @@ -12,7 +12,7 @@ package scala.tools.scalap package scalax -package rules; +package rules /** Represents the combined value of two rules applied in sequence. * diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala index dd17c39d84..3bfb82a639 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala @@ -91,7 +91,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { def printWithIndent(level: Int, s: String) { def indent() {for (i <- 1 to level) print(" ")} - indent; + indent print(s) } @@ -208,7 +208,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { mt.resultType match { case mt: MethodType => printMethodType(mt, printResult)({}) case x => if (printResult) { - print(": "); + print(": ") printType(x) } } @@ -374,7 +374,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) { } case AnnotatedWithSelfType(typeRef, symbol, attribTreeRefs) => toString(typeRef, sep) case ExistentialType(typeRef, symbols) => { - val refs = symbols.map(toString _).filter(!_.startsWith("_")).map("type " + _) + val refs = symbols.map(toString).filter(!_.startsWith("_")).map("type " + _) toString(typeRef, sep) + (if (refs.size > 0) refs.mkString(" forSome {", "; ", "}") else "") } case _ => sep + t.toString -- cgit v1.2.3 From 92affd3e76d1a3019f1c35ac20af32360d914641 Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Sun, 25 Oct 2015 23:20:04 +0100 Subject: Remove unused imports and other minor cleanups - Language imports are preceding other imports - Deleted empty file: InlineErasure - Removed some unused private[parallel] methods in scala/collection/parallel/package.scala This removes hundreds of warnings when compiling with "-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import". --- .../macros/compiler/DefaultMacroCompiler.scala | 3 +- src/compiler/scala/reflect/quasiquotes/Holes.scala | 3 +- .../scala/reflect/quasiquotes/Parsers.scala | 3 - .../scala/reflect/quasiquotes/Placeholders.scala | 2 +- src/compiler/scala/tools/ant/FastScalac.scala | 2 +- src/compiler/scala/tools/ant/Pack200Task.scala | 8 +- .../scala/tools/ant/ScalaMatchingTask.scala | 6 +- src/compiler/scala/tools/ant/ScalaTool.scala | 3 +- src/compiler/scala/tools/ant/Scalac.scala | 8 +- .../scala/tools/ant/sabbus/ScalacFork.scala | 2 +- src/compiler/scala/tools/ant/sabbus/Use.scala | 1 - src/compiler/scala/tools/cmd/FromString.scala | 2 +- src/compiler/scala/tools/cmd/Spec.scala | 2 +- src/compiler/scala/tools/nsc/CompileServer.scala | 8 +- src/compiler/scala/tools/nsc/CompileSocket.scala | 12 +-- src/compiler/scala/tools/nsc/Reporting.scala | 2 +- src/compiler/scala/tools/nsc/ast/Printers.scala | 2 +- .../scala/tools/nsc/ast/TreeBrowsers.scala | 5 +- src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 1 - src/compiler/scala/tools/nsc/ast/Trees.scala | 7 -- .../scala/tools/nsc/ast/parser/MarkupParsers.scala | 4 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 5 +- .../scala/tools/nsc/ast/parser/Scanners.scala | 2 +- .../tools/nsc/ast/parser/SymbolicXMLBuilder.scala | 2 +- .../scala/tools/nsc/ast/parser/TreeBuilder.scala | 1 - .../tools/nsc/classpath/FlatClassPathFactory.scala | 1 - src/compiler/scala/tools/nsc/io/Jar.scala | 5 +- src/compiler/scala/tools/nsc/io/Socket.scala | 2 +- src/compiler/scala/tools/nsc/io/SourceReader.scala | 2 +- src/compiler/scala/tools/nsc/plugins/Plugin.scala | 4 +- .../tools/nsc/reporters/ConsoleReporter.scala | 2 +- .../scala/tools/nsc/transform/Delambdafy.scala | 2 - .../scala/tools/nsc/transform/ExplicitOuter.scala | 2 - .../tools/nsc/transform/ExtensionMethods.scala | 2 +- .../scala/tools/nsc/transform/InlineErasure.scala | 11 --- .../scala/tools/nsc/transform/LambdaLift.scala | 2 +- .../scala/tools/nsc/transform/LazyVals.scala | 4 +- src/compiler/scala/tools/nsc/transform/Mixin.scala | 2 +- .../nsc/transform/TypeAdaptingTransformer.scala | 1 - .../scala/tools/nsc/transform/UnCurry.scala | 9 +- .../scala/tools/nsc/transform/patmat/Logic.scala | 4 +- .../tools/nsc/transform/patmat/MatchAnalysis.scala | 8 +- .../tools/nsc/transform/patmat/MatchCodeGen.scala | 4 +- .../nsc/transform/patmat/MatchOptimization.scala | 4 +- .../nsc/transform/patmat/MatchTranslation.scala | 5 +- .../nsc/transform/patmat/MatchTreeMaking.scala | 4 +- .../tools/nsc/transform/patmat/MatchWarnings.scala | 4 +- .../tools/nsc/typechecker/ContextErrors.scala | 1 - .../scala/tools/nsc/typechecker/Duplicators.scala | 2 +- .../scala/tools/nsc/typechecker/Implicits.scala | 2 +- .../scala/tools/nsc/typechecker/Macros.scala | 3 - .../tools/nsc/typechecker/MethodSynthesis.scala | 7 +- .../scala/tools/nsc/typechecker/Namers.scala | 1 - .../scala/tools/nsc/typechecker/RefChecks.scala | 14 +-- .../tools/nsc/typechecker/SyntheticMethods.scala | 8 +- .../scala/tools/nsc/typechecker/TreeCheckers.scala | 4 +- .../scala/tools/nsc/typechecker/Typers.scala | 4 +- .../tools/nsc/typechecker/TypersTracking.scala | 3 - src/compiler/scala/tools/reflect/FastTrack.scala | 1 - .../scala/tools/reflect/FormatInterpolator.scala | 6 +- .../scala/tools/reflect/ToolBoxFactory.scala | 3 +- src/compiler/scala/tools/util/PathResolver.scala | 5 +- .../tools/nsc/interactive/CompilerControl.scala | 4 +- .../scala/tools/nsc/interactive/Global.scala | 6 +- .../scala/tools/nsc/interactive/Pickler.scala | 4 +- .../scala/tools/nsc/interactive/REPL.scala | 1 - .../nsc/interactive/RichCompilationUnits.scala | 2 +- src/library/scala/Enumeration.scala | 14 +-- src/library/scala/Predef.scala | 3 +- src/library/scala/annotation/elidable.scala | 4 +- .../scala/annotation/implicitAmbiguous.scala | 4 +- src/library/scala/collection/IndexedSeqLike.scala | 3 - .../scala/collection/IndexedSeqOptimized.scala | 1 - src/library/scala/collection/IterableLike.scala | 11 +-- .../scala/collection/IterableProxyLike.scala | 1 - src/library/scala/collection/Iterator.scala | 16 ++-- .../scala/collection/LinearSeqOptimized.scala | 2 - src/library/scala/collection/MapLike.scala | 6 +- src/library/scala/collection/SeqLike.scala | 5 +- src/library/scala/collection/SetLike.scala | 4 +- src/library/scala/collection/TraversableLike.scala | 2 +- src/library/scala/collection/TraversableOnce.scala | 2 +- .../scala/collection/concurrent/TrieMap.scala | 2 - .../collection/generic/GenericParTemplate.scala | 1 - .../scala/collection/generic/MapFactory.scala | 2 - .../scala/collection/generic/ParFactory.scala | 1 - .../scala/collection/generic/ParSetFactory.scala | 1 - .../scala/collection/generic/SetFactory.scala | 1 - src/library/scala/collection/generic/package.scala | 1 - .../scala/collection/immutable/BitSet.scala | 2 +- src/library/scala/collection/immutable/List.scala | 10 +- .../scala/collection/immutable/ListMap.scala | 14 +-- .../scala/collection/immutable/ListSet.scala | 6 +- .../scala/collection/immutable/NumericRange.scala | 4 +- .../scala/collection/immutable/PagedSeq.scala | 1 - src/library/scala/collection/immutable/Queue.scala | 1 - .../scala/collection/immutable/SortedMap.scala | 1 - .../scala/collection/immutable/SortedSet.scala | 1 - .../scala/collection/immutable/Stream.scala | 12 +-- .../scala/collection/immutable/StringLike.scala | 32 +++---- .../scala/collection/mutable/ArrayBuilder.scala | 1 - .../scala/collection/mutable/ArrayOps.scala | 11 +-- src/library/scala/collection/mutable/BitSet.scala | 6 +- .../scala/collection/mutable/BufferLike.scala | 2 +- .../scala/collection/mutable/ListBuffer.scala | 1 - .../scala/collection/mutable/MutableList.scala | 2 +- .../collection/mutable/SynchronizedStack.scala | 1 - .../collection/parallel/ParIterableLike.scala | 18 ++-- src/library/scala/collection/parallel/ParMap.scala | 1 - .../scala/collection/parallel/ParMapLike.scala | 4 +- .../scala/collection/parallel/ParSeqLike.scala | 15 ++- .../collection/parallel/RemainsIterator.scala | 3 - .../collection/parallel/immutable/ParMap.scala | 1 - .../collection/parallel/immutable/ParRange.scala | 1 - .../collection/parallel/mutable/ParArray.scala | 1 - .../mutable/ResizableParArrayCombiner.scala | 8 -- .../mutable/UnrolledParArrayCombiner.scala | 6 +- .../scala/collection/parallel/package.scala | 12 +-- .../scala/concurrent/ExecutionContext.scala | 3 +- src/library/scala/concurrent/Future.scala | 15 ++- .../concurrent/impl/ExecutionContextImpl.scala | 4 +- src/library/scala/concurrent/impl/Promise.scala | 8 +- src/library/scala/io/BufferedSource.scala | 2 - src/library/scala/math/BigDecimal.scala | 103 ++++++++++----------- .../scala/runtime/AbstractPartialFunction.scala | 2 - src/library/scala/runtime/ScalaNumberProxy.scala | 4 +- src/library/scala/runtime/ScalaRunTime.scala | 8 +- src/library/scala/runtime/SeqCharSequence.scala | 2 - src/library/scala/util/Sorting.scala | 18 ++-- src/library/scala/util/Try.scala | 5 +- src/library/scala/util/control/Exception.scala | 2 - .../scala/tools/partest/BytecodeTest.scala | 2 +- .../scala/tools/partest/JavapTest.scala | 1 - .../scala/tools/partest/ReplTest.scala | 2 - .../scala/tools/partest/SigTest.scala | 2 - src/reflect/scala/reflect/api/TypeTags.scala | 2 - .../scala/reflect/internal/AnnotationInfos.scala | 1 - .../scala/reflect/internal/BaseTypeSeqs.scala | 3 +- src/reflect/scala/reflect/internal/Chars.scala | 5 +- .../scala/reflect/internal/Definitions.scala | 9 +- .../reflect/internal/ExistentialsAndSkolems.scala | 1 - src/reflect/scala/reflect/internal/Flags.scala | 2 - src/reflect/scala/reflect/internal/Internals.scala | 5 +- .../reflect/internal/JMethodOrConstructor.scala | 2 +- src/reflect/scala/reflect/internal/Kinds.scala | 1 - src/reflect/scala/reflect/internal/Names.scala | 4 +- src/reflect/scala/reflect/internal/Printers.scala | 26 +++--- .../reflect/internal/ReificationSupport.scala | 8 +- src/reflect/scala/reflect/internal/StdNames.scala | 4 +- .../scala/reflect/internal/SymbolTable.scala | 2 +- src/reflect/scala/reflect/internal/Symbols.scala | 3 +- src/reflect/scala/reflect/internal/TreeInfo.scala | 2 +- src/reflect/scala/reflect/internal/Trees.scala | 2 +- src/reflect/scala/reflect/internal/Types.scala | 2 +- src/reflect/scala/reflect/internal/Variances.scala | 2 +- .../reflect/internal/pickling/UnPickler.scala | 2 +- .../scala/reflect/internal/transform/Erasure.scala | 2 - .../internal/util/AbstractFileClassLoader.scala | 4 +- .../reflect/internal/util/FreshNameCreator.scala | 1 - .../scala/reflect/internal/util/Origins.scala | 2 +- .../reflect/internal/util/ScalaClassLoader.scala | 8 +- .../internal/util/TraceSymbolActivity.scala | 3 +- .../scala/reflect/internal/util/WeakHashSet.scala | 3 +- .../scala/reflect/internal/util/package.scala | 1 - src/reflect/scala/reflect/io/AbstractFile.scala | 3 +- src/reflect/scala/reflect/io/File.scala | 8 +- src/reflect/scala/reflect/io/Path.scala | 7 +- src/reflect/scala/reflect/io/PlainFile.scala | 2 - src/reflect/scala/reflect/io/Streamable.scala | 4 +- src/reflect/scala/reflect/io/ZipArchive.scala | 2 +- .../scala/reflect/runtime/JavaMirrors.scala | 10 +- .../scala/reflect/runtime/ReflectionUtils.scala | 1 - .../scala/reflect/runtime/SymbolLoaders.scala | 2 - .../tools/nsc/interpreter/jline/JLineReader.scala | 2 +- src/repl/scala/tools/nsc/MainGenericRunner.scala | 4 +- .../scala/tools/nsc/interpreter/ExprTyper.scala | 2 - src/repl/scala/tools/nsc/interpreter/ILoop.scala | 14 ++- src/repl/scala/tools/nsc/interpreter/IMain.scala | 5 - src/repl/scala/tools/nsc/interpreter/Imports.scala | 4 +- .../scala/tools/nsc/interpreter/JavapClass.scala | 13 +-- .../scala/tools/nsc/interpreter/LoopCommands.scala | 4 +- .../tools/nsc/interpreter/MemberHandlers.scala | 3 +- .../scala/tools/nsc/interpreter/NamedParam.scala | 5 +- src/repl/scala/tools/nsc/interpreter/Phased.scala | 1 - src/repl/scala/tools/nsc/interpreter/Power.scala | 13 ++- .../PresentationCompilerCompleter.scala | 1 - .../scala/tools/nsc/interpreter/RichClass.scala | 2 +- .../nsc/interpreter/session/SimpleHistory.scala | 1 - src/scaladoc/scala/tools/ant/Scaladoc.scala | 4 +- src/scaladoc/scala/tools/nsc/ScalaDoc.scala | 1 - .../scala/tools/nsc/doc/ScaladocGlobal.scala | 4 - .../scala/tools/nsc/doc/html/HtmlPage.scala | 8 +- .../scala/tools/nsc/doc/html/page/Template.scala | 2 +- .../doc/html/page/diagram/DiagramGenerator.scala | 2 +- .../html/page/diagram/DotDiagramGenerator.scala | 2 +- .../scala/tools/nsc/doc/model/ModelFactory.scala | 6 +- .../doc/model/ModelFactoryImplicitSupport.scala | 1 - .../nsc/doc/model/ModelFactoryTypeSupport.scala | 2 +- .../scala/tools/nsc/doc/model/TreeFactory.scala | 2 +- .../doc/model/diagram/DiagramDirectiveParser.scala | 2 +- .../scala/tools/partest/ScaladocModelTest.scala | 1 - src/scalap/scala/tools/scalap/Decode.scala | 6 +- .../parallel-collections/ParallelRangeCheck.scala | 2 +- 203 files changed, 389 insertions(+), 590 deletions(-) delete mode 100644 src/compiler/scala/tools/nsc/transform/InlineErasure.scala (limited to 'src/reflect/scala') diff --git a/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala b/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala index b8384851da..a3bf894b25 100644 --- a/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala +++ b/src/compiler/scala/reflect/macros/compiler/DefaultMacroCompiler.scala @@ -12,7 +12,6 @@ abstract class DefaultMacroCompiler extends Resolvers import treeInfo._ import definitions._ val runDefinitions = currentRun.runDefinitions - import runDefinitions.Predef_??? val typer: global.analyzer.Typer val context = typer.context @@ -92,4 +91,4 @@ abstract class DefaultMacroCompiler extends Resolvers EmptyTree } } -} \ No newline at end of file +} diff --git a/src/compiler/scala/reflect/quasiquotes/Holes.scala b/src/compiler/scala/reflect/quasiquotes/Holes.scala index 47084fc317..63be500061 100644 --- a/src/compiler/scala/reflect/quasiquotes/Holes.scala +++ b/src/compiler/scala/reflect/quasiquotes/Holes.scala @@ -1,7 +1,6 @@ package scala.reflect package quasiquotes -import scala.collection.{immutable, mutable} import scala.reflect.internal.Flags._ import scala.reflect.macros.TypecheckException @@ -222,7 +221,7 @@ trait Holes { self: Quasiquotes => else if (rank == NoDot) Some(unlifter) else { val idx = records.indexWhere { p => p._1 =:= tpe && p._2 == rank } - val resIdx = if (idx != -1) idx else { records +:= (tpe, rank); records.length - 1} + val resIdx = if (idx != -1) idx else { records +:= ((tpe, rank)); records.length - 1} Some(Ident(TermName(nme.QUASIQUOTE_UNLIFT_HELPER + resIdx))) } } diff --git a/src/compiler/scala/reflect/quasiquotes/Parsers.scala b/src/compiler/scala/reflect/quasiquotes/Parsers.scala index 97ec7dbfc3..6972c4070c 100644 --- a/src/compiler/scala/reflect/quasiquotes/Parsers.scala +++ b/src/compiler/scala/reflect/quasiquotes/Parsers.scala @@ -3,10 +3,7 @@ package quasiquotes import scala.tools.nsc.ast.parser.{Parsers => ScalaParser} import scala.tools.nsc.ast.parser.Tokens._ -import scala.compat.Platform.EOL import scala.reflect.internal.util.{BatchSourceFile, SourceFile, FreshNameCreator} -import scala.collection.mutable.ListBuffer -import scala.util.Try /** Builds upon the vanilla Scala parser and teams up together with Placeholders.scala to emulate holes. * A principled solution to splicing into Scala syntax would be a parser that natively supports holes. diff --git a/src/compiler/scala/reflect/quasiquotes/Placeholders.scala b/src/compiler/scala/reflect/quasiquotes/Placeholders.scala index a5b42f8a1f..bc4f954275 100644 --- a/src/compiler/scala/reflect/quasiquotes/Placeholders.scala +++ b/src/compiler/scala/reflect/quasiquotes/Placeholders.scala @@ -2,7 +2,7 @@ package scala.reflect package quasiquotes import java.util.UUID.randomUUID -import scala.collection.{immutable, mutable} +import scala.collection.mutable /** Emulates hole support (see Holes.scala) in the quasiquote parser (see Parsers.scala). * A principled solution to splicing into Scala syntax would be a parser that natively supports holes. diff --git a/src/compiler/scala/tools/ant/FastScalac.scala b/src/compiler/scala/tools/ant/FastScalac.scala index 6f0a30aa9d..e0b7be8004 100644 --- a/src/compiler/scala/tools/ant/FastScalac.scala +++ b/src/compiler/scala/tools/ant/FastScalac.scala @@ -8,7 +8,7 @@ package scala.tools.ant -import org.apache.tools.ant.{AntClassLoader, Project} +import org.apache.tools.ant.AntClassLoader import org.apache.tools.ant.taskdefs.Java import org.apache.tools.ant.types.Path diff --git a/src/compiler/scala/tools/ant/Pack200Task.scala b/src/compiler/scala/tools/ant/Pack200Task.scala index 3c1bc8cad9..df162d734a 100644 --- a/src/compiler/scala/tools/ant/Pack200Task.scala +++ b/src/compiler/scala/tools/ant/Pack200Task.scala @@ -8,14 +8,10 @@ package scala.tools.ant -import java.io.{BufferedOutputStream, File, FileInputStream, - FileOutputStream, PipedInputStream, PipedOutputStream} -import java.util.jar.{JarFile, JarInputStream, JarOutputStream, Pack200} +import java.io.{BufferedOutputStream, File, FileOutputStream} +import java.util.jar.{JarFile, JarOutputStream, Pack200} import java.util.jar.Pack200.Packer._ -import org.apache.tools.ant.{BuildException, DirectoryScanner} -import org.apache.tools.ant.types.FileSet - /** An [[http://ant.apache.org Ant]] task that applies the pack200 encoding * to a JAR file. * diff --git a/src/compiler/scala/tools/ant/ScalaMatchingTask.scala b/src/compiler/scala/tools/ant/ScalaMatchingTask.scala index 68a84bed0c..43b9010509 100644 --- a/src/compiler/scala/tools/ant/ScalaMatchingTask.scala +++ b/src/compiler/scala/tools/ant/ScalaMatchingTask.scala @@ -8,11 +8,8 @@ package scala.tools.ant -import java.io.{ File, InputStream, FileWriter } - import org.apache.tools.ant.{ Task, BuildException } import org.apache.tools.ant.taskdefs.MatchingTask -import org.apache.tools.ant.types.{ Path, Reference } trait ScalaTask { self: Task => @@ -27,5 +24,4 @@ trait ScalaTask { throw new BuildException(message, getLocation()) } -abstract class ScalaMatchingTask extends MatchingTask with ScalaTask { -} +abstract class ScalaMatchingTask extends MatchingTask with ScalaTask diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala index bb6a933d3f..67879d6de3 100644 --- a/src/compiler/scala/tools/ant/ScalaTool.scala +++ b/src/compiler/scala/tools/ant/ScalaTool.scala @@ -8,8 +8,7 @@ package scala.tools.ant -import java.io.{File, InputStream, FileWriter} -import org.apache.tools.ant.BuildException +import java.io.{File, FileWriter} import org.apache.tools.ant.types.{Path, Reference} /** An Ant task that generates a shell or batch script to execute a diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index 4554a648b4..fe9815be20 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -10,13 +10,11 @@ package scala.tools.ant import java.io.{File, PrintWriter, BufferedWriter, FileWriter} -import org.apache.tools.ant.{ BuildException, Project, AntClassLoader } +import org.apache.tools.ant.{ Project, AntClassLoader} import org.apache.tools.ant.taskdefs.Java import org.apache.tools.ant.types.{Path, Reference} -import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper, - SourceFileScanner, facade} -import org.apache.tools.ant.util.facade.{FacadeTaskHelper, - ImplementationSpecificArgument} +import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper, SourceFileScanner} +import org.apache.tools.ant.util.facade.{FacadeTaskHelper, ImplementationSpecificArgument} import scala.tools.nsc.{Global, Settings, CompilerCommand} import scala.tools.nsc.io.{Path => SPath} diff --git a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala index cde827ba54..c31f55c9b6 100644 --- a/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala +++ b/src/compiler/scala/tools/ant/sabbus/ScalacFork.scala @@ -10,7 +10,7 @@ package scala package tools.ant package sabbus -import java.io.{ File, FileWriter } +import java.io.File import org.apache.tools.ant.Project import org.apache.tools.ant.taskdefs.Java import org.apache.tools.ant.util.{ GlobPatternMapper, SourceFileScanner } diff --git a/src/compiler/scala/tools/ant/sabbus/Use.scala b/src/compiler/scala/tools/ant/sabbus/Use.scala index a8736f228b..cb514e35b3 100644 --- a/src/compiler/scala/tools/ant/sabbus/Use.scala +++ b/src/compiler/scala/tools/ant/sabbus/Use.scala @@ -13,7 +13,6 @@ package sabbus import java.io.File -import org.apache.tools.ant.types.{Path, Reference} import org.apache.tools.ant.util.{GlobPatternMapper, SourceFileScanner} class Use extends ScalaMatchingTask { diff --git a/src/compiler/scala/tools/cmd/FromString.scala b/src/compiler/scala/tools/cmd/FromString.scala index 0b074efc0f..ab49c7507c 100644 --- a/src/compiler/scala/tools/cmd/FromString.scala +++ b/src/compiler/scala/tools/cmd/FromString.scala @@ -6,7 +6,7 @@ package scala.tools package cmd -import nsc.io.{ Path, File, Directory } +import nsc.io.Directory import scala.reflect.OptManifest /** A general mechanism for defining how a command line argument diff --git a/src/compiler/scala/tools/cmd/Spec.scala b/src/compiler/scala/tools/cmd/Spec.scala index a1cb31f911..069a7a89a1 100644 --- a/src/compiler/scala/tools/cmd/Spec.scala +++ b/src/compiler/scala/tools/cmd/Spec.scala @@ -47,6 +47,6 @@ object Spec { } class EnvironmentVar(val name: String) { - override def toString = "${%s}" format name + override def toString = s"$${$name}" } } diff --git a/src/compiler/scala/tools/nsc/CompileServer.scala b/src/compiler/scala/tools/nsc/CompileServer.scala index aa02957a6c..9cac497a85 100644 --- a/src/compiler/scala/tools/nsc/CompileServer.scala +++ b/src/compiler/scala/tools/nsc/CompileServer.scala @@ -8,7 +8,7 @@ package scala.tools.nsc import java.io.PrintStream import io.Directory import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} -import scala.reflect.internal.util.{FakePos, Position} +import scala.reflect.internal.util.FakePos import scala.tools.util.SocketServer import settings.FscSettings @@ -193,14 +193,14 @@ object CompileServer { val i = args.indexOf("-p") if (i >= 0 && args.length > i + 1) { scala.util.control.Exception.ignoring(classOf[NumberFormatException]) { - port = args(i + 1).toInt + port = args(i + 1).toInt } } - + // Create instance rather than extend to pass a port parameter. val server = new StandardCompileServer(port) val redirectDir = (server.compileSocket.tmpDir / "output-redirects").createDirectory() - + if (debug) { server.echo("Starting CompileServer on port " + server.port) server.echo("Redirect dir is " + redirectDir) diff --git a/src/compiler/scala/tools/nsc/CompileSocket.scala b/src/compiler/scala/tools/nsc/CompileSocket.scala index 27a14141fa..01c7d72d4f 100644 --- a/src/compiler/scala/tools/nsc/CompileSocket.scala +++ b/src/compiler/scala/tools/nsc/CompileSocket.scala @@ -5,9 +5,9 @@ package scala.tools.nsc -import java.io.{ FileNotFoundException, PrintWriter, FileOutputStream } +import java.io.FileNotFoundException import java.security.SecureRandom -import io.{ File, Path, Directory, Socket } +import io.{ File, Path, Socket } import scala.tools.util.CompileOutputCommon import scala.reflect.internal.util.StringOps.splitWhere import scala.sys.process._ @@ -46,7 +46,7 @@ trait HasCompileSocket { class CompileSocket extends CompileOutputCommon { protected lazy val compileClient: StandardCompileClient = CompileClient def verbose = compileClient.verbose - + /* Fixes the port where to start the server, 0 yields some free port */ var fixPort = 0 @@ -67,7 +67,7 @@ class CompileSocket extends CompileOutputCommon { /** The class name of the scala compile server */ protected val serverClass = "scala.tools.nsc.CompileServer" - protected def serverClassArgs = (if (verbose) List("-v") else Nil) ::: (if (fixPort > 0) List("-p", fixPort.toString) else Nil) + protected def serverClassArgs = (if (verbose) List("-v") else Nil) ::: (if (fixPort > 0) List("-p", fixPort.toString) else Nil) /** A temporary directory to use */ val tmpDir = { @@ -196,7 +196,7 @@ class CompileSocket extends CompileOutputCommon { catch { case _: NumberFormatException => None } def getSocket(serverAdr: String): Option[Socket] = ( - for ((name, portStr) <- splitWhere(serverAdr, _ == ':', doDropIndex = true) ; port <- parseInt(portStr)) yield + for ((name, portStr) <- splitWhere(serverAdr, _ == ':', doDropIndex = true) ; port <- parseInt(portStr)) yield getSocket(name, port) ) getOrElse fatal("Malformed server address: %s; exiting" format serverAdr) @@ -205,7 +205,7 @@ class CompileSocket extends CompileOutputCommon { if (sock.isEmpty) warn("Unable to establish connection to server %s:%d".format(hostName, port)) sock } - + def getPassword(port: Int): String = { val ff = portFile(port) val f = ff.bufferedReader() diff --git a/src/compiler/scala/tools/nsc/Reporting.scala b/src/compiler/scala/tools/nsc/Reporting.scala index e01c536ad1..e11cba466e 100644 --- a/src/compiler/scala/tools/nsc/Reporting.scala +++ b/src/compiler/scala/tools/nsc/Reporting.scala @@ -7,7 +7,7 @@ package scala package tools package nsc -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import scala.reflect.internal.util.StringOps.countElementsAsString /** Provides delegates to the reporter doing the actual work. diff --git a/src/compiler/scala/tools/nsc/ast/Printers.scala b/src/compiler/scala/tools/nsc/ast/Printers.scala index f3def3c80c..8b37948e9b 100644 --- a/src/compiler/scala/tools/nsc/ast/Printers.scala +++ b/src/compiler/scala/tools/nsc/ast/Printers.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package ast -import java.io.{ OutputStream, PrintWriter, StringWriter, Writer } +import java.io.{ OutputStream, PrintWriter } trait Printers extends scala.reflect.internal.Printers { this: Global => diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index eafecf9462..105bdee256 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -7,7 +7,9 @@ package scala package tools.nsc package ast -import java.awt.{List => awtList, _} +import scala.language.implicitConversions + +import java.awt.{List => _, _} import java.awt.event._ import java.io.StringWriter @@ -17,7 +19,6 @@ import javax.swing.tree._ import scala.concurrent.Lock import scala.text._ -import scala.language.implicitConversions /** * Tree browsers can show the AST in a graphical and interactive diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 6dda30b5e7..9e1498cf3e 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package ast -import symtab.Flags import scala.language.implicitConversions /** A DSL for generating scala code. The goal is that the diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 934257092f..2d47e254e5 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -7,13 +7,6 @@ package scala.tools.nsc package ast import scala.reflect.ClassTag -import scala.reflect.internal.Flags.BYNAMEPARAM -import scala.reflect.internal.Flags.DEFAULTPARAM -import scala.reflect.internal.Flags.IMPLICIT -import scala.reflect.internal.Flags.PARAM -import scala.reflect.internal.Flags.PARAMACCESSOR -import scala.reflect.internal.Flags.PRESUPER -import scala.reflect.internal.Flags.TRAIT import scala.compat.Platform.EOL trait Trees extends scala.reflect.internal.Trees { self: Global => diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index 52b8a51a79..46d533b037 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -12,7 +12,7 @@ import mutable.{ Buffer, ArrayBuffer, ListBuffer } import scala.util.control.ControlThrowable import scala.tools.nsc.util.CharArrayReader import scala.tools.nsc.ast.parser.xml.{MarkupParserCommon, Utility} -import scala.reflect.internal.Chars.{ SU, LF } +import scala.reflect.internal.Chars.SU // XXX/Note: many/most of the functions in here are almost direct cut and pastes // from another file - scala.xml.parsing.MarkupParser, it looks like. @@ -261,7 +261,7 @@ trait MarkupParsers { def coalesce(): ArrayBuffer[Tree] = { def copy() = { val buf = new ArrayBuffer[Tree] - var acc = new StringBuilder + val acc = new StringBuilder var pos: Position = NoPosition def emit() = if (acc.nonEmpty) { appendText(pos, buf, acc.toString) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index dac3c7a285..1d96b940ae 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -9,10 +9,9 @@ package scala.tools.nsc package ast.parser -import scala.collection.{ mutable, immutable } -import mutable.{ ListBuffer, StringBuilder } +import scala.collection.mutable +import mutable.ListBuffer import scala.reflect.internal.{ Precedence, ModifierFlags => Flags } -import scala.reflect.internal.Chars.{ isScalaLetter } import scala.reflect.internal.util.{ SourceFile, Position, FreshNameCreator, ListOfNil } import Tokens._ diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 51bb0d3c5b..3d8f5a2dd3 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -10,7 +10,7 @@ import scala.reflect.internal.util._ import scala.reflect.internal.Chars._ import Tokens._ import scala.annotation.{ switch, tailrec } -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import mutable.{ ListBuffer, ArrayBuffer } import scala.tools.nsc.ast.parser.xml.Utility.isNameStart import scala.language.postfixOps diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index 67241ef639..c3c3ee9d47 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package ast.parser -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import symtab.Flags.MUTABLE import scala.reflect.internal.util.ListOfNil import scala.reflect.internal.util.StringOps.splitWhere diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index 6e5a3f6ef7..6b564197a1 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package ast.parser import symtab.Flags._ -import scala.collection.mutable.ListBuffer import scala.reflect.internal.util.{Position, SourceFile, FreshNameCreator} /** Methods for building trees, used in the parser. All the trees diff --git a/src/compiler/scala/tools/nsc/classpath/FlatClassPathFactory.scala b/src/compiler/scala/tools/nsc/classpath/FlatClassPathFactory.scala index 7f67381d4d..d8ca325885 100644 --- a/src/compiler/scala/tools/nsc/classpath/FlatClassPathFactory.scala +++ b/src/compiler/scala/tools/nsc/classpath/FlatClassPathFactory.scala @@ -5,7 +5,6 @@ package scala.tools.nsc.classpath import scala.tools.nsc.Settings import scala.tools.nsc.io.AbstractFile -import scala.tools.nsc.util.ClassPath import FileUtils.AbstractFileOps /** diff --git a/src/compiler/scala/tools/nsc/io/Jar.scala b/src/compiler/scala/tools/nsc/io/Jar.scala index efb026cdff..779f546f69 100644 --- a/src/compiler/scala/tools/nsc/io/Jar.scala +++ b/src/compiler/scala/tools/nsc/io/Jar.scala @@ -6,11 +6,12 @@ package scala.tools.nsc package io -import java.io.{ InputStream, OutputStream, IOException, FileNotFoundException, FileInputStream, DataOutputStream } +import scala.language.postfixOps + +import java.io.{ InputStream, OutputStream, DataOutputStream } import java.util.jar._ import scala.collection.JavaConverters._ import Attributes.Name -import scala.language.{ implicitConversions, postfixOps } // Attributes.Name instances: // diff --git a/src/compiler/scala/tools/nsc/io/Socket.scala b/src/compiler/scala/tools/nsc/io/Socket.scala index a803e4121a..a17517da2e 100644 --- a/src/compiler/scala/tools/nsc/io/Socket.scala +++ b/src/compiler/scala/tools/nsc/io/Socket.scala @@ -8,7 +8,7 @@ package io import java.io.{ IOException, InputStreamReader, BufferedReader, PrintWriter, Closeable } import java.io.{ BufferedOutputStream, BufferedReader } -import java.net.{ ServerSocket, SocketException, SocketTimeoutException, InetAddress, Socket => JSocket } +import java.net.{ InetAddress, Socket => JSocket } import scala.io.Codec /** A skeletal only-as-much-as-I-need Socket wrapper. diff --git a/src/compiler/scala/tools/nsc/io/SourceReader.scala b/src/compiler/scala/tools/nsc/io/SourceReader.scala index 3220c2e2b2..b84c509a32 100644 --- a/src/compiler/scala/tools/nsc/io/SourceReader.scala +++ b/src/compiler/scala/tools/nsc/io/SourceReader.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package io -import java.io.{ FileInputStream, InputStream, IOException } +import java.io.{ FileInputStream, IOException } import java.nio.{ByteBuffer, CharBuffer} import java.nio.channels.{ ReadableByteChannel, Channels } import java.nio.charset.{CharsetDecoder, CoderResult} diff --git a/src/compiler/scala/tools/nsc/plugins/Plugin.scala b/src/compiler/scala/tools/nsc/plugins/Plugin.scala index dd17750cd4..5caf7e41bf 100644 --- a/src/compiler/scala/tools/nsc/plugins/Plugin.scala +++ b/src/compiler/scala/tools/nsc/plugins/Plugin.scala @@ -6,14 +6,12 @@ package scala.tools.nsc package plugins -import scala.tools.nsc.io.{ Jar } +import scala.tools.nsc.io.Jar import scala.reflect.internal.util.ScalaClassLoader import scala.reflect.io.{ Directory, File, Path } import java.io.InputStream -import java.util.zip.ZipException import scala.collection.mutable -import mutable.ListBuffer import scala.util.{ Try, Success, Failure } /** Information about a plugin loaded from a jar file. diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index 4bf92fd1fb..9b9d94bb0f 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -7,7 +7,7 @@ package scala package tools.nsc package reporters -import java.io.{ BufferedReader, IOException, PrintWriter } +import java.io.{ BufferedReader, PrintWriter } import scala.reflect.internal.util._ import StringOps._ diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala index 072a0bc68d..f15d05f7df 100644 --- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala +++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala @@ -4,8 +4,6 @@ package transform import symtab._ import Flags._ import scala.collection._ -import scala.language.postfixOps -import scala.reflect.internal.Symbols import scala.collection.mutable.LinkedHashMap /** diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 854acd63c0..1a0b4cdec0 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -9,9 +9,7 @@ package transform import symtab._ import Flags.{ CASE => _, _ } -import scala.collection.mutable import scala.collection.mutable.ListBuffer -import scala.tools.nsc.settings.ScalaVersion /** This class ... * diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index 6349fc3fb9..d83cf68b38 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -7,7 +7,7 @@ package transform import symtab._ import Flags._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable /** * Perform Step 1 in the inline classes SIP: Creates extension methods for all diff --git a/src/compiler/scala/tools/nsc/transform/InlineErasure.scala b/src/compiler/scala/tools/nsc/transform/InlineErasure.scala deleted file mode 100644 index 1bbe1b8410..0000000000 --- a/src/compiler/scala/tools/nsc/transform/InlineErasure.scala +++ /dev/null @@ -1,11 +0,0 @@ -package scala.tools.nsc -package transform - -trait InlineErasure { - self: Erasure => - -/* - import global._ - import definitions._ - */ -} diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index a943b53bf7..facb6ed263 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -8,7 +8,7 @@ package transform import symtab._ import Flags._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import scala.collection.mutable.{ LinkedHashMap, LinkedHashSet, TreeSet } abstract class LambdaLift extends InfoTransform { diff --git a/src/compiler/scala/tools/nsc/transform/LazyVals.scala b/src/compiler/scala/tools/nsc/transform/LazyVals.scala index ae2a9184b4..8a0086dbdd 100644 --- a/src/compiler/scala/tools/nsc/transform/LazyVals.scala +++ b/src/compiler/scala/tools/nsc/transform/LazyVals.scala @@ -1,14 +1,14 @@ package scala.tools.nsc package transform -import scala.collection.{ mutable, immutable } +import scala.collection.mutable abstract class LazyVals extends Transform with TypingTransformers with ast.TreeDSL { // inherits abstract value `global` and class `Phase` from Transform import global._ // the global environment import definitions._ // standard classes and methods - import typer.{typed, atOwner} // methods to type trees + import typer.typed // methods to type trees import CODE._ val phaseName: String = "lazyvals" diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala index 1cea9c159a..d13e11e9ec 100644 --- a/src/compiler/scala/tools/nsc/transform/Mixin.scala +++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala @@ -8,7 +8,7 @@ package transform import symtab._ import Flags._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable abstract class Mixin extends InfoTransform with ast.TreeDSL { import global._ diff --git a/src/compiler/scala/tools/nsc/transform/TypeAdaptingTransformer.scala b/src/compiler/scala/tools/nsc/transform/TypeAdaptingTransformer.scala index 3b23306386..1ed728247b 100644 --- a/src/compiler/scala/tools/nsc/transform/TypeAdaptingTransformer.scala +++ b/src/compiler/scala/tools/nsc/transform/TypeAdaptingTransformer.scala @@ -2,7 +2,6 @@ package scala.tools.nsc package transform import scala.tools.nsc.ast.TreeDSL -import scala.tools.nsc.Global /** * A trait usable by transforms that need to adapt trees of one type to another type diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 9d61dbbcae..f7a1f462b7 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -7,9 +7,10 @@ package scala package tools.nsc package transform -import symtab.Flags._ -import scala.collection.{ mutable, immutable } import scala.language.postfixOps + +import symtab.Flags._ +import scala.collection.mutable import scala.reflect.internal.util.ListOfNil /* */ @@ -696,7 +697,7 @@ abstract class UnCurry extends InfoTransform // declared type and assign this to a synthetic val. Later, we'll patch // the method body to refer to this, rather than the parameter. val tempVal: ValDef = { - // SI-9442: using the "uncurry-erased" type (the one after the uncurry phase) can lead to incorrect + // SI-9442: using the "uncurry-erased" type (the one after the uncurry phase) can lead to incorrect // tree transformations. For example, compiling: // ``` // def foo(c: Ctx)(l: c.Tree): Unit = { @@ -725,7 +726,7 @@ abstract class UnCurry extends InfoTransform // to redo this desugaring manually here // 2. the type needs to be normalized, since `gen.mkCast` checks this (no HK here, just aliases have // to be expanded before handing the type to `gen.mkAttributedCast`, which calls `gen.mkCast`) - val info0 = + val info0 = enteringUncurry(p.symbol.info) match { case DesugaredParameterType(desugaredTpe) => desugaredTpe diff --git a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala index 62d9c497ba..1a4df9973e 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/Logic.scala @@ -8,9 +8,9 @@ package scala package tools.nsc.transform.patmat import scala.language.postfixOps + import scala.collection.mutable import scala.reflect.internal.util.{NoPosition, Position, Statistics, HashSet} -import scala.tools.nsc.Global trait Logic extends Debugging { import PatternMatchingStats._ @@ -646,7 +646,7 @@ trait ScalaLogic extends Interface with Logic with TreeAndTypeAnalysis { } - import global.{ConstantType, Constant, EmptyScope, SingletonType, Literal, Ident, refinedType, singleType, TypeBounds, NoSymbol} + import global.{ConstantType, SingletonType, Literal, Ident, singleType, TypeBounds, NoSymbol} import global.definitions._ diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala index f259283e48..affbcf9ec8 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchAnalysis.scala @@ -6,9 +6,8 @@ package scala.tools.nsc.transform.patmat -import scala.annotation.tailrec -import scala.collection.immutable.{IndexedSeq, Iterable} import scala.language.postfixOps + import scala.collection.mutable import scala.reflect.internal.util.Statistics @@ -707,9 +706,8 @@ trait MatchAnalysis extends MatchApproximation { val (equal, notEqual) = varAssignment.getOrElse(variable, Nil -> Nil) - def addVarAssignment(equalTo: List[Const], notEqualTo: List[Const]) = { - Map(variable ->(equal ++ equalTo, notEqual ++ notEqualTo)) - } + def addVarAssignment(equalTo: List[Const], notEqualTo: List[Const]) = + Map(variable ->((equal ++ equalTo, notEqual ++ notEqualTo))) // this assignment is needed in case that // there exists already an assign diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchCodeGen.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchCodeGen.scala index af536cb2d3..03d0a28fb1 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchCodeGen.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchCodeGen.scala @@ -6,9 +6,9 @@ package scala.tools.nsc.transform.patmat -import scala.tools.nsc.symtab.Flags.SYNTHETIC import scala.language.postfixOps -import scala.reflect.internal.util.Statistics + +import scala.tools.nsc.symtab.Flags.SYNTHETIC import scala.reflect.internal.util.Position /** Factory methods used by TreeMakers to make the actual trees. diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala index cca8d2dbb8..6fdaa79c10 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchOptimization.scala @@ -6,10 +6,10 @@ package scala.tools.nsc.transform.patmat -import scala.tools.nsc.symtab.Flags.MUTABLE import scala.language.postfixOps + +import scala.tools.nsc.symtab.Flags.MUTABLE import scala.collection.mutable -import scala.reflect.internal.util.Statistics import scala.reflect.internal.util.Position /** Optimize and analyze matches based on their TreeMaker-representation. diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 451b72d498..96a20ea631 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -7,7 +7,7 @@ package scala.tools.nsc.transform.patmat import scala.language.postfixOps -import scala.collection.mutable + import scala.reflect.internal.util.Statistics /** Translate typed Trees that represent pattern matches into the patternmatching IR, defined by TreeMakers. @@ -18,8 +18,7 @@ trait MatchTranslation { import PatternMatchingStats._ import global._ import definitions._ - import global.analyzer.{ErrorUtils, formalTypes} - import treeInfo.{ WildcardStarArg, Unapplied, isStar, unbind } + import treeInfo.{ Unapplied, unbind } import CODE._ // Always map repeated params to sequences diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala index e0fcc05de2..18a63a6e53 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTreeMaking.scala @@ -6,10 +6,10 @@ package scala.tools.nsc.transform.patmat -import scala.tools.nsc.symtab.Flags.{SYNTHETIC, ARTIFACT} import scala.language.postfixOps + +import scala.tools.nsc.symtab.Flags.{SYNTHETIC, ARTIFACT} import scala.collection.mutable -import scala.reflect.internal.util.Statistics import scala.reflect.internal.util.Position /** Translate our IR (TreeMakers) into actual Scala Trees using the factory methods in MatchCodeGen. diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala index 8beb1837ad..27d674762f 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchWarnings.scala @@ -7,8 +7,6 @@ package scala.tools.nsc.transform.patmat import scala.language.postfixOps -import scala.collection.mutable -import scala.reflect.internal.util.Statistics trait MatchWarnings { self: PatternMatching => @@ -83,4 +81,4 @@ trait MatchWarnings { } } } -} \ No newline at end of file +} diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 4161900502..ccdff5c9a1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package typechecker import scala.reflect.internal.util.StringOps.{ countElementsAsString, countAsString } -import symtab.Flags.IS_ERROR import scala.compat.Platform.EOL import scala.reflect.runtime.ReflectionUtils import scala.reflect.macros.runtime.AbortMacroException diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala index 69ae6ec0c8..0c10242950 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package typechecker import scala.tools.nsc.symtab.Flags -import scala.collection.{ mutable, immutable } +import scala.collection.mutable /** Duplicate trees and re-type check them, taking care to replace * and create fresh symbols for new local definitions. diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index eacac5cc86..a34e97b6cb 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -13,7 +13,7 @@ package tools.nsc package typechecker import scala.annotation.tailrec -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import mutable.{ LinkedHashMap, ListBuffer } import scala.util.matching.Regex import symtab.Flags._ diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 3ed128cbc5..bcf9e018e2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -5,14 +5,11 @@ import java.lang.Math.min import symtab.Flags._ import scala.reflect.internal.util.ScalaClassLoader import scala.reflect.runtime.ReflectionUtils -import scala.collection.mutable.ListBuffer -import scala.reflect.ClassTag import scala.reflect.internal.util.Statistics import scala.reflect.macros.util._ import scala.util.control.ControlThrowable import scala.reflect.internal.util.ListOfNil import scala.reflect.macros.runtime.{AbortMacroException, MacroRuntimes} -import scala.reflect.runtime.{universe => ru} import scala.reflect.macros.compiler.DefaultMacroCompiler import scala.tools.reflect.FastTrack import scala.runtime.ScalaRunTime diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 05fe60f7b7..abc3e91ed2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -5,12 +5,11 @@ package scala.tools.nsc package typechecker +import scala.language.higherKinds + import symtab.Flags._ -import scala.reflect.internal.util.StringOps.{ ojoin } -import scala.reflect.ClassTag +import scala.reflect.internal.util.StringOps.ojoin import scala.reflect.internal.util.ListOfNil -import scala.reflect.runtime.{ universe => ru } -import scala.language.higherKinds /** Logic related to method synthesis which involves cooperation between * Namer and Typer. diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index ba095c808e..e01edd196e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -7,7 +7,6 @@ package scala.tools.nsc package typechecker import scala.collection.mutable -import scala.annotation.tailrec import symtab.Flags._ import scala.language.postfixOps import scala.reflect.internal.util.ListOfNil diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 915ffcc7d0..3860cc252d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -6,15 +6,17 @@ package scala.tools.nsc package typechecker -import symtab.Flags._ -import scala.collection.{ mutable, immutable } -import transform.InfoTransform -import scala.collection.mutable.ListBuffer import scala.language.postfixOps + +import scala.collection.mutable +import scala.collection.mutable.ListBuffer import scala.tools.nsc.settings.ScalaVersion -import scala.tools.nsc.settings.AnyScalaVersion import scala.tools.nsc.settings.NoScalaVersion +import symtab.Flags._ +import transform.InfoTransform + + /**

* Post-attribution checking and transformation. *

@@ -48,7 +50,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans import global._ import definitions._ - import typer.{typed, typedOperator, atOwner} + import typer.typed /** the following two members override abstract members in Transform */ val phaseName: String = "refchecks" diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 4ccc183334..243a706745 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -6,11 +6,13 @@ package scala.tools.nsc package typechecker -import scala.collection.{ mutable, immutable } -import symtab.Flags._ -import scala.collection.mutable.ListBuffer import scala.language.postfixOps +import scala.collection.mutable +import scala.collection.mutable.ListBuffer + +import symtab.Flags._ + /** Synthetic method implementations for case classes and case objects. * * Added to all case classes/objects: diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index e8db8309f1..f6ee0c47a5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -7,8 +7,6 @@ package scala.tools.nsc package typechecker import scala.collection.mutable -import mutable.ListBuffer -import util.returning import scala.reflect.internal.util.shortClassOfInstance import scala.reflect.internal.util.StringOps._ @@ -94,7 +92,7 @@ abstract class TreeCheckers extends Analyzer { def latest = maps.head._2 val defSyms = symbolTreeMap[DefTree]() val newSyms = mutable.HashSet[Symbol]() - val movedMsgs = new ListBuffer[String] + val movedMsgs = mutable.ListBuffer[String]() def sortedNewSyms = newSyms.toList.distinct sortBy (_.name.toString) def record(tree: Tree) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 3889d48213..84af9233e1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -14,7 +14,7 @@ package tools.nsc package typechecker import scala.collection.{mutable, immutable} -import scala.reflect.internal.util.{ BatchSourceFile, Statistics, shortClassOfInstance, ListOfNil } +import scala.reflect.internal.util.{ Statistics, ListOfNil } import mutable.ListBuffer import symtab.Flags._ import Mode._ @@ -110,7 +110,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper abstract class Typer(context0: Context) extends TyperDiagnostics with Adaptation with Tag with PatternTyper with TyperContextErrors { import context0.unit - import typeDebug.{ ptTree, ptBlock, ptLine, inGreen, inRed } + import typeDebug.ptTree import TyperErrorGen._ val runDefinitions = currentRun.runDefinitions import runDefinitions._ diff --git a/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala b/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala index 37fbb73b85..f2911fb98b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypersTracking.scala @@ -6,9 +6,6 @@ package scala.tools.nsc package typechecker -import scala.collection.mutable -import scala.reflect.internal.util.{ BatchSourceFile, Statistics } -import mutable.ListBuffer import Mode._ trait TypersTracking { diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala index 8fed53c89f..dc26c93066 100644 --- a/src/compiler/scala/tools/reflect/FastTrack.scala +++ b/src/compiler/scala/tools/reflect/FastTrack.scala @@ -4,7 +4,6 @@ package reflect import scala.reflect.reify.Taggers import scala.tools.nsc.typechecker.{ Analyzer, Macros } import scala.reflect.runtime.Macros.currentMirror -import scala.reflect.api.Universe import scala.reflect.quasiquotes.{ Quasiquotes => QuasiquoteImpls } /** Optimizes system macro expansions by hardwiring them directly to their implementations diff --git a/src/compiler/scala/tools/reflect/FormatInterpolator.scala b/src/compiler/scala/tools/reflect/FormatInterpolator.scala index b445f1e2bb..cbdb01a10a 100644 --- a/src/compiler/scala/tools/reflect/FormatInterpolator.scala +++ b/src/compiler/scala/tools/reflect/FormatInterpolator.scala @@ -6,7 +6,7 @@ import scala.reflect.internal.util.Position import scala.PartialFunction.cond import scala.util.matching.Regex.Match -import java.util.{ Formatter, Formattable, IllegalFormatException } +import java.util.Formattable abstract class FormatInterpolator { val c: Context @@ -262,7 +262,7 @@ abstract class FormatInterpolator { def goodFlags = { val badFlags = flags map (_ filterNot (okFlags contains _)) for (bf <- badFlags; f <- bf) badFlag(f, s"Illegal flag '$f'") - badFlags.getOrElse("").isEmpty + badFlags.getOrElse("").isEmpty } def goodIndex = { if (index.nonEmpty && hasFlag('<')) @@ -281,7 +281,7 @@ abstract class FormatInterpolator { ) orElse Some(variants(0)) } object Conversion { - import SpecifierGroups.{ Spec, CC, Width } + import SpecifierGroups.{ Spec, CC } def apply(m: Match, p: Position, n: Int): Option[Conversion] = { def badCC(msg: String) = { val dk = new ErrorXn(m, p) diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 47c88f2c00..ae6a9e22b6 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -3,13 +3,12 @@ package tools package reflect import scala.tools.cmd.CommandLineParser -import scala.tools.nsc.Global import scala.tools.nsc.reporters._ import scala.tools.nsc.CompilerCommand import scala.tools.nsc.io.{AbstractFile, VirtualDirectory} import scala.reflect.internal.util.AbstractFileClassLoader import scala.reflect.internal.Flags._ -import scala.reflect.internal.util.{BatchSourceFile, NoSourceFile, NoFile} +import scala.reflect.internal.util.NoSourceFile import java.lang.{Class => jClass} import scala.compat.Platform.EOL import scala.reflect.NameTransformer diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala index 09c6c9d744..42b939f18b 100644 --- a/src/compiler/scala/tools/util/PathResolver.scala +++ b/src/compiler/scala/tools/util/PathResolver.scala @@ -7,15 +7,16 @@ package scala package tools package util +import scala.language.postfixOps + import java.net.URL import scala.tools.reflect.WrappedProperties.AccessControl import scala.tools.nsc.Settings import scala.tools.nsc.util.{ ClassFileLookup, ClassPath, JavaClassPath } import scala.reflect.io.{ File, Directory, Path, AbstractFile } import scala.reflect.runtime.ReflectionUtils -import ClassPath.{ JavaContext, DefaultJavaContext, join, split } +import ClassPath.{ JavaContext, DefaultJavaContext, split } import PartialFunction.condOpt -import scala.language.postfixOps import scala.tools.nsc.classpath.{ AggregateFlatClassPath, ClassPathFactory, FlatClassPath, FlatClassPathFactory } import scala.tools.nsc.settings.ClassPathRepresentationType diff --git a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala index 586f011429..cb12cebc49 100644 --- a/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/interactive/scala/tools/nsc/interactive/CompilerControl.scala @@ -10,7 +10,7 @@ import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.util.FailedInterrupt import scala.tools.nsc.util.EmptyAction import scala.tools.nsc.util.WorkScheduler -import scala.reflect.internal.util.{SourceFile, Position} +import scala.reflect.internal.util.SourceFile import scala.tools.nsc.util.InterruptReq /** Interface of interactive compiler to a client such as an IDE @@ -189,7 +189,7 @@ trait CompilerControl { self: Global => * continues with current pass. * Waits until source is fully type checked and returns body in response. * @param source The source file that needs to be fully typed. - * @param keepLoaded Whether to keep that file in the PC if it was not loaded before. If + * @param keepLoaded Whether to keep that file in the PC if it was not loaded before. If the file is already loaded, this flag is ignored. * @param response The response, which is set to the fully attributed tree of `source`. * If the unit corresponding to `source` has been removed in the meantime diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala index 306a750de6..64535a749f 100644 --- a/src/interactive/scala/tools/nsc/interactive/Global.scala +++ b/src/interactive/scala/tools/nsc/interactive/Global.scala @@ -5,12 +5,12 @@ package scala.tools.nsc package interactive -import java.io.{ PrintWriter, StringWriter, FileReader, FileWriter } +import java.io.{ FileReader, FileWriter } import scala.collection.mutable -import mutable.{LinkedHashMap, SynchronizedMap, HashSet, SynchronizedSet} +import mutable.{LinkedHashMap, HashSet, SynchronizedSet} import scala.util.control.ControlThrowable import scala.tools.nsc.io.AbstractFile -import scala.reflect.internal.util.{ SourceFile, BatchSourceFile, Position, NoPosition } +import scala.reflect.internal.util.SourceFile import scala.tools.nsc.reporters._ import scala.tools.nsc.symtab._ import scala.tools.nsc.typechecker.Analyzer diff --git a/src/interactive/scala/tools/nsc/interactive/Pickler.scala b/src/interactive/scala/tools/nsc/interactive/Pickler.scala index ddc0c8a068..c0446b0402 100644 --- a/src/interactive/scala/tools/nsc/interactive/Pickler.scala +++ b/src/interactive/scala/tools/nsc/interactive/Pickler.scala @@ -1,9 +1,9 @@ package scala.tools.nsc.interactive +import scala.language.implicitConversions + import Lexer._ import java.io.Writer -import scala.language.implicitConversions -import scala.reflect.ClassTag /** An abstract class for writing and reading Scala objects to and * from a legible representation. The representation follows the following grammar: diff --git a/src/interactive/scala/tools/nsc/interactive/REPL.scala b/src/interactive/scala/tools/nsc/interactive/REPL.scala index ffa61b0524..e9cec31975 100644 --- a/src/interactive/scala/tools/nsc/interactive/REPL.scala +++ b/src/interactive/scala/tools/nsc/interactive/REPL.scala @@ -9,7 +9,6 @@ package interactive import scala.reflect.internal.util._ import scala.tools.nsc.reporters._ import scala.tools.nsc.io._ -import java.io.FileWriter /** Interface of interactive compiler to a client such as an IDE */ diff --git a/src/interactive/scala/tools/nsc/interactive/RichCompilationUnits.scala b/src/interactive/scala/tools/nsc/interactive/RichCompilationUnits.scala index b83c2cd095..b82888b2aa 100644 --- a/src/interactive/scala/tools/nsc/interactive/RichCompilationUnits.scala +++ b/src/interactive/scala/tools/nsc/interactive/RichCompilationUnits.scala @@ -5,7 +5,7 @@ package scala.tools.nsc package interactive -import scala.reflect.internal.util.{SourceFile, Position, NoPosition} +import scala.reflect.internal.util.SourceFile import scala.collection.mutable.ArrayBuffer trait RichCompilationUnits { self: Global => diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala index c4aa511cd7..9d9a3f849b 100644 --- a/src/library/scala/Enumeration.scala +++ b/src/library/scala/Enumeration.scala @@ -9,7 +9,7 @@ package scala import scala.collection.{ mutable, immutable, generic, SortedSetLike, AbstractSet } -import java.lang.reflect.{ Modifier, Method => JMethod, Field => JField } +import java.lang.reflect.{ Method => JMethod, Field => JField } import scala.reflect.NameTransformer._ import scala.util.matching.Regex @@ -154,14 +154,14 @@ abstract class Enumeration (initial: Int) extends Serializable { protected final def Value(i: Int, name: String): Value = new Val(i, name) private def populateNameMap() { - val fields = getClass.getDeclaredFields - def isValDef(m: JMethod) = fields exists (fd => fd.getName == m.getName && fd.getType == m.getReturnType) + val fields: Array[JField] = getClass.getDeclaredFields + def isValDef(m: JMethod): Boolean = fields exists (fd => fd.getName == m.getName && fd.getType == m.getReturnType) // The list of possible Value methods: 0-args which return a conforming type - val methods = getClass.getMethods filter (m => m.getParameterTypes.isEmpty && - classOf[Value].isAssignableFrom(m.getReturnType) && - m.getDeclaringClass != classOf[Enumeration] && - isValDef(m)) + val methods: Array[JMethod] = getClass.getMethods filter (m => m.getParameterTypes.isEmpty && + classOf[Value].isAssignableFrom(m.getReturnType) && + m.getDeclaringClass != classOf[Enumeration] && + isValDef(m)) methods foreach { m => val name = m.getName // invoke method to obtain actual `Value` instance diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index a6f0fa9e78..50a53732f1 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -8,13 +8,14 @@ package scala +import scala.language.implicitConversions + import scala.collection.{ mutable, immutable, generic } import immutable.StringOps import mutable.ArrayOps import generic.CanBuildFrom import scala.annotation.{ elidable, implicitNotFound } import scala.annotation.elidable.ASSERTION -import scala.language.{implicitConversions, existentials} import scala.io.StdIn /** The `Predef` object provides definitions that are accessible in all Scala diff --git a/src/library/scala/annotation/elidable.scala b/src/library/scala/annotation/elidable.scala index f9c5e8a744..dd0d9b511c 100644 --- a/src/library/scala/annotation/elidable.scala +++ b/src/library/scala/annotation/elidable.scala @@ -8,8 +8,6 @@ package scala.annotation -import java.util.logging.Level - /** An annotation for methods whose bodies may be excluded * from compiler-generated bytecode. * @@ -62,7 +60,7 @@ import java.util.logging.Level * @author Paul Phillips * @since 2.8 */ -final class elidable(final val level: Int) extends scala.annotation.StaticAnnotation {} +final class elidable(final val level: Int) extends scala.annotation.StaticAnnotation /** This useless appearing code was necessary to allow people to use * named constants for the elidable annotation. This is what it takes diff --git a/src/library/scala/annotation/implicitAmbiguous.scala b/src/library/scala/annotation/implicitAmbiguous.scala index f190865623..44e8d23085 100644 --- a/src/library/scala/annotation/implicitAmbiguous.scala +++ b/src/library/scala/annotation/implicitAmbiguous.scala @@ -1,7 +1,5 @@ package scala.annotation -import scala.annotation.meta._ - /** * To customize the error message that's emitted when an implicit search finds * multiple ambiguous values, annotate at least one of the implicit values @@ -31,4 +29,4 @@ import scala.annotation.meta._ * @author Brian McKenna * @since 2.12.0 */ -final class implicitAmbiguous(msg: String) extends scala.annotation.StaticAnnotation {} +final class implicitAmbiguous(msg: String) extends scala.annotation.StaticAnnotation diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala index 18c9175ee1..f4bf58ffe3 100644 --- a/src/library/scala/collection/IndexedSeqLike.scala +++ b/src/library/scala/collection/IndexedSeqLike.scala @@ -9,9 +9,6 @@ package scala package collection -import mutable.ArrayBuffer -import scala.annotation.tailrec - /** A template trait for indexed sequences of type `IndexedSeq[A]`. * * $indexedSeqInfo diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala index a7e06b4d1a..3765b2fff0 100644 --- a/src/library/scala/collection/IndexedSeqOptimized.scala +++ b/src/library/scala/collection/IndexedSeqOptimized.scala @@ -10,7 +10,6 @@ package scala package collection import generic._ -import mutable.ArrayBuffer import scala.annotation.tailrec /** A template trait for indexed sequences of type `IndexedSeq[A]` which optimizes diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala index ecf64624e8..b89720da78 100644 --- a/src/library/scala/collection/IterableLike.scala +++ b/src/library/scala/collection/IterableLike.scala @@ -10,8 +10,7 @@ package scala package collection import generic._ -import immutable.{ List, Stream } -import scala.annotation.unchecked.uncheckedVariance +import immutable.Stream /** A template trait for iterable collections of type `Iterable[A]`. * $iterableInfo @@ -83,8 +82,8 @@ self => iterator.foldRight(z)(op) override /*TraversableLike*/ def reduceRight[B >: A](op: (A, B) => B): B = iterator.reduceRight(op) - - + + /** Returns this $coll as an iterable collection. * * A new collection will not be built; lazy collections will stay lazy. @@ -94,7 +93,7 @@ self => */ override /*TraversableLike*/ def toIterable: Iterable[A] = thisCollection - + /** Returns an Iterator over the elements in this $coll. Produces the same * result as `iterator`. * $willNotTerminateInf @@ -102,7 +101,7 @@ self => */ @deprecatedOverriding("toIterator should stay consistent with iterator for all Iterables: override iterator instead.", "2.11.0") override def toIterator: Iterator[A] = iterator - + override /*TraversableLike*/ def head: A = iterator.next() diff --git a/src/library/scala/collection/IterableProxyLike.scala b/src/library/scala/collection/IterableProxyLike.scala index 90e630ee28..334b511fb9 100644 --- a/src/library/scala/collection/IterableProxyLike.scala +++ b/src/library/scala/collection/IterableProxyLike.scala @@ -12,7 +12,6 @@ package scala package collection import generic._ -import mutable.Buffer // Methods could be printed by cat IterableLike.scala | egrep '^ (override )?def' diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index 922bb2b5e0..17bb83e52e 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -12,8 +12,6 @@ package collection import mutable.ArrayBuffer import scala.annotation.migration import immutable.Stream -import scala.collection.generic.CanBuildFrom -import scala.annotation.unchecked.{ uncheckedVariance => uV } /** The `Iterator` object provides various functions for creating specialized iterators. * @@ -521,13 +519,13 @@ trait Iterator[+A] extends TraversableOnce[A] { def collect[B](pf: PartialFunction[A, B]): Iterator[B] = new AbstractIterator[B] { // Manually buffer to avoid extra layer of wrapping with buffered private[this] var hd: A = _ - + // Little state machine to keep track of where we are // Seek = 0; Found = 1; Empty = -1 // Not in vals because scalac won't make them static (@inline def only works with -optimize) // BE REALLY CAREFUL TO KEEP COMMENTS AND NUMBERS IN SYNC! private[this] var status = 0/*Seek*/ - + def hasNext = { while (status == 0/*Seek*/) { if (self.hasNext) { @@ -700,9 +698,9 @@ trait Iterator[+A] extends TraversableOnce[A] { } } } - + val leading = new Leading - + val trailing = new AbstractIterator[A] { private[this] var myLeading = leading /* Status flags meanings: @@ -738,7 +736,7 @@ trait Iterator[+A] extends TraversableOnce[A] { } else Iterator.empty.next() } - + override def toString = "unknown-if-empty iterator" } @@ -772,7 +770,7 @@ trait Iterator[+A] extends TraversableOnce[A] { status = 1 false } - def next() = + def next() = if (hasNext) { if (status == 1) self.next() else { @@ -1325,7 +1323,7 @@ trait Iterator[+A] extends TraversableOnce[A] { */ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = { var i = start - val end = start + math.min(len, xs.length - start) + val end = start + math.min(len, xs.length - start) while (i < end && hasNext) { xs(i) = next() i += 1 diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index 978f1c9075..a3860f10a4 100644 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -9,8 +9,6 @@ package scala package collection -import mutable.ListBuffer -import immutable.List import scala.annotation.tailrec /** A template trait for linear sequences of type `LinearSeq[A]` which optimizes diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala index 183279d093..4ac87b29a9 100644 --- a/src/library/scala/collection/MapLike.scala +++ b/src/library/scala/collection/MapLike.scala @@ -11,7 +11,7 @@ package collection import generic._ import mutable.{ Builder, MapBuilder } -import scala.annotation.{migration, bridge} +import scala.annotation.migration import parallel.ParMap /** A template trait for maps, which associate keys with values. @@ -331,8 +331,8 @@ self => foreach(vb += _) vb.result } - } - + } + override def toBuffer[C >: (A, B)]: mutable.Buffer[C] = { val result = new mutable.ArrayBuffer[C](size) // Faster to let the map iterate itself than to defer through copyToBuffer diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index b775480532..a26765027c 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -9,11 +9,10 @@ package scala package collection -import mutable.{ ListBuffer, ArraySeq } import immutable.{ List, Range } import generic._ import parallel.ParSeq -import scala.math.{ min, max, Ordering } +import scala.math.Ordering /** A template trait for sequences of type `Seq[A]` * $seqInfo @@ -146,7 +145,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * more than one way to generate the same subsequence, only one will be returned. * * For example, `"xyyy"` has three different ways to generate `"xy"` depending on - * whether the first, second, or third `"y"` is selected. However, since all are + * whether the first, second, or third `"y"` is selected. However, since all are * identical, only one will be chosen. Which of the three will be taken is an * implementation detail that is not defined. * diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala index d03c808c2c..9143c40870 100644 --- a/src/library/scala/collection/SetLike.scala +++ b/src/library/scala/collection/SetLike.scala @@ -11,7 +11,7 @@ package collection import generic._ import mutable.{ Builder, SetBuilder } -import scala.annotation.{migration, bridge} +import scala.annotation.migration import parallel.ParSet /** A template trait for sets. @@ -86,7 +86,7 @@ self => vb.result } } - + override def toBuffer[A1 >: A]: mutable.Buffer[A1] = { val result = new mutable.ArrayBuffer[A1](size) // Faster to let the map iterate itself than to defer through copyToBuffer diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index 32718ddf03..fa9a3a7482 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -11,7 +11,7 @@ package collection import generic._ import mutable.{ Builder } -import scala.annotation.{tailrec, migration, bridge} +import scala.annotation.migration import scala.annotation.unchecked.{ uncheckedVariance => uV } import parallel.ParIterable import scala.language.higherKinds diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 910c59b179..41362e8dd7 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -9,7 +9,7 @@ package scala package collection -import mutable.{ Buffer, Builder, ListBuffer, ArrayBuffer } +import mutable.{ Buffer, Builder, ArrayBuffer } import generic.CanBuildFrom import scala.annotation.unchecked.{ uncheckedVariance => uV } import scala.language.{implicitConversions, higherKinds} diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala index 426f9bf864..d113cbfcdf 100644 --- a/src/library/scala/collection/concurrent/TrieMap.scala +++ b/src/library/scala/collection/concurrent/TrieMap.scala @@ -11,13 +11,11 @@ package collection package concurrent import java.util.concurrent.atomic._ -import scala.collection.immutable.{ ListMap => ImmutableListMap } import scala.collection.parallel.mutable.ParTrieMap import scala.util.hashing.Hashing import scala.util.control.ControlThrowable import generic._ import scala.annotation.tailrec -import scala.annotation.switch private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends INodeBase[K, V](g) { import INodeBase._ diff --git a/src/library/scala/collection/generic/GenericParTemplate.scala b/src/library/scala/collection/generic/GenericParTemplate.scala index b9b7043270..44a778a953 100644 --- a/src/library/scala/collection/generic/GenericParTemplate.scala +++ b/src/library/scala/collection/generic/GenericParTemplate.scala @@ -13,7 +13,6 @@ package generic import scala.collection.parallel.Combiner import scala.collection.parallel.ParIterable import scala.collection.parallel.ParMap -import scala.collection.parallel.TaskSupport import scala.annotation.unchecked.uncheckedVariance import scala.language.higherKinds diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala index b9f3d4b010..255d695303 100644 --- a/src/library/scala/collection/generic/MapFactory.scala +++ b/src/library/scala/collection/generic/MapFactory.scala @@ -10,8 +10,6 @@ package scala package collection package generic - -import mutable.{Builder, MapBuilder} import scala.language.higherKinds /** A template for companion objects of `Map` and subclasses thereof. diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala index 4486cea419..901e9fc239 100644 --- a/src/library/scala/collection/generic/ParFactory.scala +++ b/src/library/scala/collection/generic/ParFactory.scala @@ -11,7 +11,6 @@ package collection package generic import scala.collection.parallel.ParIterable -import scala.collection.parallel.Combiner import scala.language.higherKinds /** A template class for companion objects of `ParIterable` and subclasses diff --git a/src/library/scala/collection/generic/ParSetFactory.scala b/src/library/scala/collection/generic/ParSetFactory.scala index 4320635ae6..1341ddcb38 100644 --- a/src/library/scala/collection/generic/ParSetFactory.scala +++ b/src/library/scala/collection/generic/ParSetFactory.scala @@ -10,7 +10,6 @@ package scala package collection package generic -import scala.collection.mutable.Builder import scala.collection.parallel.Combiner import scala.collection.parallel.ParSet import scala.collection.parallel.ParSetLike diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala index fcd8d00c18..5e50844cc9 100644 --- a/src/library/scala/collection/generic/SetFactory.scala +++ b/src/library/scala/collection/generic/SetFactory.scala @@ -12,7 +12,6 @@ package scala package collection package generic -import mutable.Builder import scala.language.higherKinds abstract class SetFactory[CC[X] <: Set[X] with SetLike[X, CC[X]]] diff --git a/src/library/scala/collection/generic/package.scala b/src/library/scala/collection/generic/package.scala index 1beb4a8599..015c3455db 100644 --- a/src/library/scala/collection/generic/package.scala +++ b/src/library/scala/collection/generic/package.scala @@ -1,6 +1,5 @@ package scala package collection -import generic.CanBuildFrom import scala.language.higherKinds diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala index 70543aa3a6..846bc22182 100644 --- a/src/library/scala/collection/immutable/BitSet.scala +++ b/src/library/scala/collection/immutable/BitSet.scala @@ -14,7 +14,7 @@ package immutable import generic._ import BitSetLike.{LogWL, updateArray} -import mutable.{ Builder, SetBuilder } +import mutable.Builder /** A class for immutable bitsets. * $bitsetinfo diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index 3ad567375c..c09328cae6 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -89,8 +89,6 @@ sealed abstract class List[+A] extends AbstractSeq[A] with scala.Serializable { override def companion: GenericCompanion[List] = List - import scala.collection.{Iterable, Traversable, Seq, IndexedSeq} - def isEmpty: Boolean def head: A def tail: List[A] @@ -265,7 +263,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] } (b.toList, these) } - + final override def map[B, That](f: A => B)(implicit bf: CanBuildFrom[List[A], B, That]): That = { if (bf eq List.ReusableCBF) { if (this eq Nil) Nil.asInstanceOf[That] else { @@ -283,7 +281,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] } else super.map(f) } - + final override def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[List[A], B, That]): That = { if (bf eq List.ReusableCBF) { if (this eq Nil) Nil.asInstanceOf[That] else { @@ -312,7 +310,7 @@ sealed abstract class List[+A] extends AbstractSeq[A] } else super.collect(pf) } - + final override def flatMap[B, That](f: A => GenTraversableOnce[B])(implicit bf: CanBuildFrom[List[A], B, That]): That = { if (bf eq List.ReusableCBF) { if (this eq Nil) Nil.asInstanceOf[That] else { @@ -452,7 +450,7 @@ object List extends SeqFactory[List] { override def empty[A]: List[A] = Nil override def apply[A](xs: A*): List[A] = xs.toList - + private[collection] val partialNotApplied = new Function1[Any, Any] { def apply(x: Any): Any = this } @SerialVersionUID(1L) diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index c59f4f7436..f30c0cbf8e 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -13,7 +13,7 @@ package collection package immutable import generic._ -import scala.annotation.{tailrec, bridge} +import scala.annotation.tailrec /** $factoryInfo * @since 1 @@ -30,7 +30,7 @@ object ListMap extends ImmutableMapFactory[ListMap] { def empty[A, B]: ListMap[A, B] = EmptyListMap.asInstanceOf[ListMap[A, B]] @SerialVersionUID(-8256686706655863282L) - private object EmptyListMap extends ListMap[Any, Nothing] { + private object EmptyListMap extends ListMap[Any, Nothing] { override def apply(key: Any) = throw new NoSuchElementException("key not found: " + key) override def contains(key: Any) = false } @@ -179,16 +179,16 @@ extends AbstractMap[A, B] @tailrec private def get0(cur: ListMap[A, B1], k: A): Option[B1] = if (k == cur.key) Some(cur.value) else if (cur.next.nonEmpty) get0(cur.next, k) else None - - + + override def contains(key: A): Boolean = contains0(this, key) - + @tailrec private def contains0(cur: ListMap[A, B1], k: A): Boolean = if (k == cur.key) true else if (cur.next.nonEmpty) contains0(cur.next, k) else false - + /** This method allows one to create a new map with an additional mapping * from `key` to `value`. If the map contains already a mapping for `key`, * it will be overridden by this function. @@ -198,7 +198,7 @@ extends AbstractMap[A, B] new m.Node[B2](k, v) } - + /** Creates a new mapping without the given `key`. * If the map does not contain a mapping for the given key, the * method returns the same map. diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala index adc975479a..a65e25ed6e 100644 --- a/src/library/scala/collection/immutable/ListSet.scala +++ b/src/library/scala/collection/immutable/ListSet.scala @@ -11,8 +11,8 @@ package collection package immutable import generic._ -import scala.annotation.{tailrec, bridge} -import mutable.{ ListBuffer, Builder } +import scala.annotation.tailrec +import mutable.Builder /** $factoryInfo * @define Coll immutable.ListSet @@ -179,6 +179,6 @@ class ListSet[A] extends AbstractSet[A] override def tail: ListSet[A] = self } - + override def toSet[B >: A]: Set[B] = this.asInstanceOf[ListSet[B]] } diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala index 11603a118b..c8d7519254 100644 --- a/src/library/scala/collection/immutable/NumericRange.scala +++ b/src/library/scala/collection/immutable/NumericRange.scala @@ -10,8 +10,6 @@ package scala package collection package immutable -import mutable.{ Builder, ListBuffer } - // TODO: Now the specialization exists there is no clear reason to have // separate classes for Range/NumericRange. Investigate and consolidate. @@ -193,7 +191,7 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable { // Either numRangeElements or (head + last) must be even, so divide the even one before multiplying val a = head.toLong val b = last.toLong - val ans = + val ans = if ((numRangeElements & 1) == 0) (numRangeElements / 2) * (a + b) else numRangeElements * { // Sum is even, but we might overflow it, so divide in pieces and add back remainder diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index d3dc65f834..fab5ad47eb 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -13,7 +13,6 @@ package collection package immutable import java.io.{File, FileReader, Reader} -import scala.util.matching.Regex import scala.reflect.ClassTag /** The `PagedSeq` object defines a lazy implementations of diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala index 53af3ce158..70b51f8251 100644 --- a/src/library/scala/collection/immutable/Queue.scala +++ b/src/library/scala/collection/immutable/Queue.scala @@ -12,7 +12,6 @@ package immutable import generic._ import mutable.{ Builder, ListBuffer } -import scala.annotation.tailrec /** `Queue` objects implement data structures that allow to * insert and retrieve elements in a first-in-first-out (FIFO) manner. diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala index 682788e18e..0f3bd2e195 100644 --- a/src/library/scala/collection/immutable/SortedMap.scala +++ b/src/library/scala/collection/immutable/SortedMap.scala @@ -14,7 +14,6 @@ package immutable import generic._ import mutable.Builder -import scala.annotation.unchecked.uncheckedVariance /** A map whose keys are sorted. * diff --git a/src/library/scala/collection/immutable/SortedSet.scala b/src/library/scala/collection/immutable/SortedSet.scala index 4a8859a7ab..107f77f287 100644 --- a/src/library/scala/collection/immutable/SortedSet.scala +++ b/src/library/scala/collection/immutable/SortedSet.scala @@ -13,7 +13,6 @@ package collection package immutable import generic._ -import mutable.Builder /** A subtrait of `collection.SortedSet` which represents sorted sets * which cannot be mutated. diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index aa98b810d4..d92b159f3b 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -11,7 +11,7 @@ package collection package immutable import generic._ -import mutable.{Builder, StringBuilder, LazyBuilder, ListBuffer} +import mutable.{Builder, StringBuilder, LazyBuilder} import scala.annotation.tailrec import Stream.cons import scala.language.implicitConversions @@ -203,11 +203,9 @@ abstract class Stream[+A] extends AbstractSeq[A] with LinearSeq[A] with GenericTraversableTemplate[A, Stream] with LinearSeqOptimized[A, Stream[A]] - with Serializable { -self => - override def companion: GenericCompanion[Stream] = Stream + with Serializable { self => - import scala.collection.{Traversable, Iterable, Seq, IndexedSeq} + override def companion: GenericCompanion[Stream] = Stream /** Indicates whether or not the `Stream` is empty. * @@ -1091,14 +1089,12 @@ object Stream extends SeqFactory[Stream] { /** Creates a new builder for a stream */ def newBuilder[A]: Builder[A, Stream[A]] = new StreamBuilder[A] - import scala.collection.{Iterable, Seq, IndexedSeq} - /** A builder for streams * @note This builder is lazy only in the sense that it does not go downs the spine * of traversables that are added as a whole. If more laziness can be achieved, * this builder should be bypassed. */ - class StreamBuilder[A] extends scala.collection.mutable.LazyBuilder[A, Stream[A]] { + class StreamBuilder[A] extends LazyBuilder[A, Stream[A]] { def result: Stream[A] = parts.toStream flatMap (_.toStream) } diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala index 7b3da1e2ea..d92db68912 100644 --- a/src/library/scala/collection/immutable/StringLike.scala +++ b/src/library/scala/collection/immutable/StringLike.scala @@ -10,7 +10,7 @@ package scala package collection package immutable -import mutable.{ ArrayBuilder, Builder } +import mutable.Builder import scala.util.matching.Regex import scala.math.ScalaNumber import scala.reflect.ClassTag @@ -208,32 +208,32 @@ self => else "\\" + ch /** Split this string around the separator character - * + * * If this string is the empty string, returns an array of strings * that contains a single empty string. - * + * * If this string is not the empty string, returns an array containing * the substrings terminated by the start of the string, the end of the * string or the separator character, excluding empty trailing substrings - * - * If the separator character is a surrogate character, only split on + * + * If the separator character is a surrogate character, only split on * matching surrogate characters if they are not part of a surrogate pair - * + * * The behaviour follows, and is implemented in terms of String.split(re: String) - * - * + * + * * @example {{{ * "a.b".split('.') //returns Array("a", "b") - * + * * //splitting the empty string always returns the array with a single * //empty string - * "".split('.') //returns Array("") - * + * "".split('.') //returns Array("") + * * //only trailing empty substrings are removed * "a.".split('.') //returns Array("a") * ".a.".split('.') //returns Array("", "a") * "..a..".split('.') //returns Array("", "", "a") - * + * * //all parts are empty and trailing * ".".split('.') //returns Array() * "..".split('.') //returns Array() @@ -247,16 +247,16 @@ self => * //well-formed surrogate pairs are not split * val highlow = highstring + lowstring * highlow.split(high) //returns Array(highlow) - * + * * //bare surrogate characters are split * val bare = "_" + highstring + "_" * bare.split(high) //returns Array("_", "_") - * + * * }}} - * + * * @param separator the character used as a delimiter */ - def split(separator: Char): Array[String] = + def split(separator: Char): Array[String] = toString.split(escape(separator)) diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala index 6e53824cbe..ac78ab823b 100644 --- a/src/library/scala/collection/mutable/ArrayBuilder.scala +++ b/src/library/scala/collection/mutable/ArrayBuilder.scala @@ -11,7 +11,6 @@ package collection package mutable import scala.reflect.ClassTag -import scala.runtime.ScalaRunTime /** A builder class for arrays. * diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala index 2bc41b5802..5144db7de3 100644 --- a/src/library/scala/collection/mutable/ArrayOps.scala +++ b/src/library/scala/collection/mutable/ArrayOps.scala @@ -10,7 +10,6 @@ package scala package collection package mutable -import scala.compat.Platform.arraycopy import scala.reflect.ClassTag import scala.runtime.ScalaRunTime._ import parallel.mutable.ParArray @@ -106,9 +105,9 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza bb.result() } } - + /** Converts an array of pairs into an array of first elements and an array of second elements. - * + * * @tparam T1 the type of the first half of the element pairs * @tparam T2 the type of the second half of the element pairs * @param asPair an implicit conversion which asserts that the element type @@ -134,9 +133,9 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza } (a1, a2) } - + /** Converts an array of triples into three arrays, one containing the elements from each position of the triple. - * + * * @tparam T1 the type of the first of three elements in the triple * @tparam T2 the type of the second of three elements in the triple * @tparam T3 the type of the third of three elements in the triple @@ -168,7 +167,7 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza } (a1, a2, a3) } - + def seq = thisCollection diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala index e92d48cfeb..feef694e01 100644 --- a/src/library/scala/collection/mutable/BitSet.scala +++ b/src/library/scala/collection/mutable/BitSet.scala @@ -13,7 +13,7 @@ package collection package mutable import generic._ -import BitSetLike.{LogWL, MaxSize, updateArray} +import BitSetLike.{LogWL, MaxSize} /** A class for mutable bitsets. * @@ -56,7 +56,7 @@ class BitSet(protected final var elems: Array[Long]) extends AbstractSet[Int] @deprecatedOverriding("Internal implementation does not admit sensible overriding of this method.", "2.11.0") protected def nwords = elems.length - + @deprecatedOverriding("Internal implementation does not admit sensible overriding of this method.", "2.11.0") protected def word(idx: Int): Long = if (idx < nwords) elems(idx) else 0L @@ -100,7 +100,7 @@ class BitSet(protected final var elems: Array[Long]) extends AbstractSet[Int] @deprecatedOverriding("Override add to prevent += and add from exhibiting different behavior.", "2.11.0") def += (elem: Int): this.type = { add(elem); this } - + @deprecatedOverriding("Override add to prevent += and add from exhibiting different behavior.", "2.11.0") def -= (elem: Int): this.type = { remove(elem); this } diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala index bd9c61ae6a..98c9771a05 100644 --- a/src/library/scala/collection/mutable/BufferLike.scala +++ b/src/library/scala/collection/mutable/BufferLike.scala @@ -14,7 +14,7 @@ package mutable import generic._ import script._ -import scala.annotation.{migration, bridge} +import scala.annotation.migration /** A template trait for buffers of type `Buffer[A]`. * diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index eece557fe8..0a483ceb86 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -13,7 +13,6 @@ package mutable import generic._ import immutable.{List, Nil, ::} import java.io.{ObjectOutputStream, ObjectInputStream} -import scala.annotation.migration /** A `Buffer` implementation backed by a list. It provides constant time * prepend and append. Most other operations are linear. diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala index 646023f469..a333eedb1a 100644 --- a/src/library/scala/collection/mutable/MutableList.scala +++ b/src/library/scala/collection/mutable/MutableList.scala @@ -11,7 +11,7 @@ package collection package mutable import generic._ -import immutable.{List, Nil} +import immutable.List /** * This class is used internally to represent mutable lists. It is the diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala index bbb6f5a9bb..c77a6fad62 100644 --- a/src/library/scala/collection/mutable/SynchronizedStack.scala +++ b/src/library/scala/collection/mutable/SynchronizedStack.scala @@ -27,7 +27,6 @@ package mutable */ @deprecated("Synchronization via selective overriding of methods is inherently unreliable. Consider java.util.concurrent.LinkedBlockingDequeue instead.", "2.11.0") class SynchronizedStack[A] extends Stack[A] { - import scala.collection.Traversable /** Checks if the stack is empty. * diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 44df7f7260..2ed7bc075e 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -9,6 +9,8 @@ package scala package collection.parallel +import scala.language.{ higherKinds, implicitConversions } + import scala.collection.mutable.Builder import scala.collection.mutable.ArrayBuffer import scala.collection.IterableLike @@ -21,13 +23,9 @@ import scala.collection.GenIterable import scala.collection.GenTraversableOnce import scala.collection.GenTraversable import immutable.HashMapCombiner -import scala.reflect.{ClassTag, classTag} - -import java.util.concurrent.atomic.AtomicBoolean +import scala.reflect.ClassTag import scala.annotation.unchecked.uncheckedVariance -import scala.annotation.unchecked.uncheckedStable -import scala.language.{ higherKinds, implicitConversions } import scala.collection.parallel.ParallelCollectionImplicits._ @@ -1284,7 +1282,7 @@ self: ParIterableLike[T, Repr, Sequential] => extends Transformer[Combiner[(U, S), That], Zip[U, S, That]] { @volatile var result: Result = null def leaf(prev: Option[Result]) = result = pit.zip2combiner[U, S, That](othpit, pbf()) - protected[this] def newSubtask(p: IterableSplitter[T]) = unsupported + protected[this] def newSubtask(p: IterableSplitter[T]) = throw new UnsupportedOperationException override def split = { val pits = pit.splitWithSignalling val sizes = pits.map(_.remaining) @@ -1300,7 +1298,7 @@ self: ParIterableLike[T, Repr, Sequential] => extends Transformer[Combiner[(U, S), That], ZipAll[U, S, That]] { @volatile var result: Result = null def leaf(prev: Option[Result]) = result = pit.zipAll2combiner[U, S, That](othpit, thiselem, thatelem, pbf()) - protected[this] def newSubtask(p: IterableSplitter[T]) = unsupported + protected[this] def newSubtask(p: IterableSplitter[T]) = throw new UnsupportedOperationException override def split = if (pit.remaining <= len) { val pits = pit.splitWithSignalling val sizes = pits.map(_.remaining) @@ -1322,7 +1320,7 @@ self: ParIterableLike[T, Repr, Sequential] => extends Accessor[Unit, CopyToArray[U, This]] { @volatile var result: Unit = () def leaf(prev: Option[Unit]) = pit.copyToArray(array, from, len) - protected[this] def newSubtask(p: IterableSplitter[T]) = unsupported + protected[this] def newSubtask(p: IterableSplitter[T]) = throw new UnsupportedOperationException override def split = { val pits = pit.splitWithSignalling for ((p, untilp) <- pits zip pits.scanLeft(0)(_ + _.remaining); if untilp < len) yield { @@ -1379,7 +1377,7 @@ self: ParIterableLike[T, Repr, Sequential] => val half = howmany / 2 ScanNode(mergeTrees(trees, from, half), mergeTrees(trees, from + half, howmany - half)) } else trees(from) - protected[this] def newSubtask(pit: IterableSplitter[T]) = unsupported + protected[this] def newSubtask(pit: IterableSplitter[T]) = throw new UnsupportedOperationException override def split = { val pits = pit.splitWithSignalling for ((p, untilp) <- pits zip pits.scanLeft(from)(_ + _.remaining)) yield { @@ -1416,7 +1414,7 @@ self: ParIterableLike[T, Repr, Sequential] => new FromScanTree(left, z, op, cbf), new FromScanTree(right, z, op, cbf) ) - case _ => unsupportedop("Cannot be split further") + case _ => throw new UnsupportedOperationException("Cannot be split further") } def shouldSplitFurther = tree match { case ScanNode(_, _) => true diff --git a/src/library/scala/collection/parallel/ParMap.scala b/src/library/scala/collection/parallel/ParMap.scala index 9f92e6c1e8..70afe5174b 100644 --- a/src/library/scala/collection/parallel/ParMap.scala +++ b/src/library/scala/collection/parallel/ParMap.scala @@ -11,7 +11,6 @@ package collection.parallel import scala.collection.Map import scala.collection.GenMap -import scala.collection.mutable.Builder import scala.collection.generic.ParMapFactory import scala.collection.generic.GenericParMapTemplate import scala.collection.generic.GenericParMapCompanion diff --git a/src/library/scala/collection/parallel/ParMapLike.scala b/src/library/scala/collection/parallel/ParMapLike.scala index 0a671fb085..a3ac388587 100644 --- a/src/library/scala/collection/parallel/ParMapLike.scala +++ b/src/library/scala/collection/parallel/ParMapLike.scala @@ -12,10 +12,8 @@ package collection.parallel import scala.collection.MapLike import scala.collection.GenMapLike import scala.collection.Map -import scala.collection.mutable.Builder + import scala.annotation.unchecked.uncheckedVariance -import scala.collection.generic.IdleSignalling -import scala.collection.generic.Signalling /** A template trait for mutable parallel maps. This trait is to be mixed in * with concrete parallel maps to override the representation type. diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala index 0b6fec364e..60fa1858e7 100644 --- a/src/library/scala/collection/parallel/ParSeqLike.scala +++ b/src/library/scala/collection/parallel/ParSeqLike.scala @@ -9,11 +9,10 @@ package scala package collection.parallel -import scala.collection.{ Parallel, SeqLike, GenSeqLike, GenSeq, GenIterable, Iterator } +import scala.collection.{ SeqLike, GenSeq, GenIterable, Iterator } import scala.collection.generic.DefaultSignalling import scala.collection.generic.AtomicIndexFlag import scala.collection.generic.CanBuildFrom -import scala.collection.generic.CanCombineFrom import scala.collection.generic.VolatileAbort import scala.collection.parallel.ParallelCollectionImplicits._ @@ -365,7 +364,7 @@ self => pit.setIndexFlagIfLesser(from) } } - protected[this] def newSubtask(p: SuperParIterator) = unsupported + protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException override def split = { val pits = pit.splitWithSignalling for ((p, untilp) <- pits zip pits.scanLeft(from)(_ + _.remaining)) yield new IndexWhere(pred, untilp, p) @@ -386,7 +385,7 @@ self => pit.setIndexFlagIfGreater(pos) } } - protected[this] def newSubtask(p: SuperParIterator) = unsupported + protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException override def split = { val pits = pit.splitWithSignalling for ((p, untilp) <- pits zip pits.scanLeft(pos)(_ + _.remaining)) yield new LastIndexWhere(pred, untilp, p) @@ -420,7 +419,7 @@ self => result = pit.sameElements(otherpit) if (!result) pit.abort() } - protected[this] def newSubtask(p: SuperParIterator) = unsupported + protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException override def split = { val fp = pit.remaining / 2 val sp = pit.remaining - fp @@ -434,7 +433,7 @@ self => extends Transformer[Combiner[U, That], Updated[U, That]] { @volatile var result: Combiner[U, That] = null def leaf(prev: Option[Combiner[U, That]]) = result = pit.updated2combiner(pos, elem, pbf()) - protected[this] def newSubtask(p: SuperParIterator) = unsupported + protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException override def split = { val pits = pit.splitWithSignalling for ((p, untilp) <- pits zip pits.scanLeft(0)(_ + _.remaining)) yield new Updated(pos - untilp, elem, pbf, p) @@ -447,7 +446,7 @@ self => extends Transformer[Combiner[(U, S), That], Zip[U, S, That]] { @volatile var result: Result = null def leaf(prev: Option[Result]) = result = pit.zip2combiner[U, S, That](otherpit, cf()) - protected[this] def newSubtask(p: SuperParIterator) = unsupported + protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException override def split = { val fp = len / 2 val sp = len - len / 2 @@ -468,7 +467,7 @@ self => result = pit.corresponds(corr)(otherpit) if (!result) pit.abort() } - protected[this] def newSubtask(p: SuperParIterator) = unsupported + protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException override def split = { val fp = pit.remaining / 2 val sp = pit.remaining - fp diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala index 7bb278b038..63d63d9ef3 100644 --- a/src/library/scala/collection/parallel/RemainsIterator.scala +++ b/src/library/scala/collection/parallel/RemainsIterator.scala @@ -9,13 +9,10 @@ package scala package collection.parallel -import scala.collection.Parallel import scala.collection.generic.Signalling import scala.collection.generic.DelegatedSignalling import scala.collection.generic.IdleSignalling -import scala.collection.generic.CanCombineFrom import scala.collection.mutable.Builder -import scala.collection.Iterator.empty import scala.collection.GenTraversableOnce import scala.collection.parallel.immutable.repetition diff --git a/src/library/scala/collection/parallel/immutable/ParMap.scala b/src/library/scala/collection/parallel/immutable/ParMap.scala index 2956c2a883..65bb2e12c5 100644 --- a/src/library/scala/collection/parallel/immutable/ParMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParMap.scala @@ -16,7 +16,6 @@ import scala.collection.generic.GenericParMapCompanion import scala.collection.generic.CanCombineFrom import scala.collection.parallel.ParMapLike import scala.collection.parallel.Combiner -import scala.collection.GenMapLike /** A template trait for immutable parallel maps. * diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala index ec90de3a7d..8fd5382ce9 100644 --- a/src/library/scala/collection/parallel/immutable/ParRange.scala +++ b/src/library/scala/collection/parallel/immutable/ParRange.scala @@ -12,7 +12,6 @@ package collection.parallel.immutable import scala.collection.immutable.Range import scala.collection.parallel.Combiner import scala.collection.parallel.SeqSplitter -import scala.collection.generic.CanCombineFrom import scala.collection.Iterator /** Parallel ranges. diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala index d0d022db4b..8a2cf2716a 100644 --- a/src/library/scala/collection/parallel/mutable/ParArray.scala +++ b/src/library/scala/collection/parallel/mutable/ParArray.scala @@ -18,7 +18,6 @@ import scala.collection.generic.GenericParCompanion import scala.collection.generic.CanCombineFrom import scala.collection.generic.CanBuildFrom import scala.collection.generic.ParFactory -import scala.collection.generic.Sizing import scala.collection.parallel.Combiner import scala.collection.parallel.SeqSplitter import scala.collection.parallel.ParSeqLike diff --git a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala index 79322c85b1..6883457fef 100644 --- a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala @@ -9,18 +9,10 @@ package scala package collection.parallel.mutable - - -import scala.collection.generic.Sizing import scala.collection.mutable.ArraySeq import scala.collection.mutable.ArrayBuffer -import scala.collection.parallel.TaskSupport -import scala.collection.parallel.unsupportedop -import scala.collection.parallel.Combiner import scala.collection.parallel.Task - - /** An array combiner that uses a chain of arraybuffers to store elements. */ trait ResizableParArrayCombiner[T] extends LazyCombiner[T, ParArray[T], ExposedArrayBuffer[T]] { diff --git a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala index d1379cde11..5e4572da60 100644 --- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala +++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala @@ -9,13 +9,9 @@ package scala package collection.parallel.mutable -import scala.collection.generic.Sizing import scala.collection.mutable.ArraySeq -import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.UnrolledBuffer import scala.collection.mutable.UnrolledBuffer.Unrolled -import scala.collection.parallel.TaskSupport -import scala.collection.parallel.unsupportedop import scala.collection.parallel.Combiner import scala.collection.parallel.Task import scala.reflect.ClassTag @@ -62,7 +58,7 @@ extends Combiner[T, ParArray[T]] { case that: UnrolledParArrayCombiner[t] => buff concat that.buff this - case _ => unsupportedop("Cannot combine with combiner of different type.") + case _ => throw new UnsupportedOperationException("Cannot combine with combiner of different type.") } def size = buff.size diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala index d77dcb0658..ba64ca505b 100644 --- a/src/library/scala/collection/parallel/package.scala +++ b/src/library/scala/collection/parallel/package.scala @@ -35,15 +35,7 @@ package object parallel { else sz } - private[parallel] def unsupported = throw new UnsupportedOperationException - - private[parallel] def unsupportedop(msg: String) = throw new UnsupportedOperationException(msg) - - private[parallel] def outofbounds(idx: Int) = throw new IndexOutOfBoundsException(idx.toString) - - private[parallel] def getTaskSupport: TaskSupport = new ExecutionContextTaskSupport - - val defaultTaskSupport: TaskSupport = getTaskSupport + val defaultTaskSupport: TaskSupport = new ExecutionContextTaskSupport def setTaskSupport[Coll](c: Coll, t: TaskSupport): Coll = { c match { @@ -98,7 +90,7 @@ package parallel { } } } - + trait FactoryOps[From, Elem, To] { trait Otherwise[R] { def otherwise(notbody: => R): R diff --git a/src/library/scala/concurrent/ExecutionContext.scala b/src/library/scala/concurrent/ExecutionContext.scala index df2d68c9c6..e022b94ea8 100644 --- a/src/library/scala/concurrent/ExecutionContext.scala +++ b/src/library/scala/concurrent/ExecutionContext.scala @@ -11,7 +11,6 @@ package scala.concurrent import java.util.concurrent.{ ExecutorService, Executor } import scala.annotation.implicitNotFound -import scala.util.Try /** * An `ExecutionContext` can execute program logic asynchronously, @@ -75,7 +74,7 @@ trait ExecutionContext { /** Prepares for the execution of a task. Returns the prepared * execution context. The recommended implementation of * `prepare` is to return `this`. - * + * * This method should no longer be overridden or called. It was * originally expected that `prepare` would be called by * all libraries that consume ExecutionContexts, in order to diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index c8ababbcab..f49536d351 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -10,15 +10,12 @@ package scala.concurrent import scala.language.higherKinds -import java.util.concurrent.{ CountDownLatch, TimeUnit, Callable } -import java.util.concurrent.TimeUnit.{ NANOSECONDS => NANOS, MILLISECONDS ⇒ MILLIS } +import java.util.concurrent.{CountDownLatch, TimeUnit} import java.util.concurrent.atomic.AtomicInteger import scala.util.control.NonFatal import scala.util.{Try, Success, Failure} import scala.concurrent.duration._ -import scala.annotation.tailrec -import scala.collection.mutable.Builder import scala.collection.generic.CanBuildFrom import scala.reflect.ClassTag @@ -215,7 +212,7 @@ trait Future[+T] extends Awaitable[T] { * @param f function that transforms a failure of the receiver into a failure of the returned future * @return a `Future` that will be completed with the transformed value */ - def transform[S](s: T => S, f: Throwable => Throwable)(implicit executor: ExecutionContext): Future[S] = + def transform[S](s: T => S, f: Throwable => Throwable)(implicit executor: ExecutionContext): Future[S] = transform { case Success(r) => Try(s(r)) case Failure(t) => Try(throw f(t)) // will throw fatal errors! @@ -348,7 +345,7 @@ trait Future[+T] extends Awaitable[T] { * @param pf the `PartialFunction` to apply if this `Future` fails * @return a `Future` with the successful value of this `Future` or the result of the `PartialFunction` */ - def recover[U >: T](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U] = + def recover[U >: T](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Future[U] = transform { _ recover pf } /** Creates a new future that will handle any matching throwable that this @@ -429,7 +426,7 @@ trait Future[+T] extends Awaitable[T] { * @return a `Future` with the successful result of this or that `Future` or the failure of this `Future` if both fail */ def fallbackTo[U >: T](that: Future[U]): Future[U] = - if (this eq that) this + if (this eq that) this else { implicit val ec = internalExecutor recoverWith { case _ => that } recoverWith { case _ => this } @@ -532,7 +529,7 @@ object Future { ready(atMost) throw new TimeoutException(s"Future timed out after [$atMost]") } - + override def onSuccess[U](pf: PartialFunction[Nothing, U])(implicit executor: ExecutionContext): Unit = () override def onFailure[U](pf: PartialFunction[Throwable, U])(implicit executor: ExecutionContext): Unit = () override def onComplete[U](f: Try[Nothing] => U)(implicit executor: ExecutionContext): Unit = () @@ -597,7 +594,7 @@ object Future { * @return the `Future` holding the result of the computation */ def apply[T](body: =>T)(implicit @deprecatedName('execctx) executor: ExecutionContext): Future[T] = - unit.map(_ => body) + unit.map(_ => body) /** Simple version of `Future.traverse`. Asynchronously and non-blockingly transforms a `TraversableOnce[Future[A]]` * into a `Future[TraversableOnce[A]]`. Useful for reducing many `Future`s into a single `Future`. diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index 4cb5f51e62..7bf5cc5729 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -8,10 +8,10 @@ package scala.concurrent.impl -import java.util.concurrent.{ ForkJoinPool, ForkJoinWorkerThread, ForkJoinTask, Callable, Executor, ExecutorService, Executors, ThreadFactory, TimeUnit } +import java.util.concurrent.{ ForkJoinPool, ForkJoinWorkerThread, ForkJoinTask, Callable, Executor, ExecutorService, ThreadFactory, TimeUnit } import java.util.concurrent.atomic.AtomicInteger import java.util.Collection -import scala.concurrent.{ BlockContext, ExecutionContext, Awaitable, CanAwait, ExecutionContextExecutor, ExecutionContextExecutorService } +import scala.concurrent.{ BlockContext, ExecutionContext, CanAwait, ExecutionContextExecutor, ExecutionContextExecutorService } import scala.annotation.tailrec diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index 3538ac6b94..178cd6d912 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -8,13 +8,13 @@ package scala.concurrent.impl -import scala.concurrent.{ ExecutionContext, CanAwait, OnCompleteRunnable, TimeoutException, ExecutionException, blocking } +import scala.concurrent.{ ExecutionContext, CanAwait, OnCompleteRunnable, TimeoutException, ExecutionException } import scala.concurrent.Future.InternalCallbackExecutor -import scala.concurrent.duration.{ Duration, Deadline, FiniteDuration, NANOSECONDS } +import scala.concurrent.duration.{ Duration, FiniteDuration } import scala.annotation.tailrec import scala.util.control.NonFatal import scala.util.{ Try, Success, Failure } -import java.io.ObjectInputStream + import java.util.concurrent.locks.AbstractQueuedSynchronizer import java.util.concurrent.atomic.AtomicReference @@ -393,7 +393,7 @@ private[concurrent] object Promise { override def collect[S](pf: PartialFunction[T, S])(implicit executor: ExecutionContext): Future[S] = thisAs[S] override def zip[U](that: Future[U]): Future[(T, U)] = thisAs[(T,U)] override def zipWith[U, R](that: Future[U])(f: (T, U) => R)(implicit executor: ExecutionContext): Future[R] = thisAs[R] - override def fallbackTo[U >: T](that: Future[U]): Future[U] = + override def fallbackTo[U >: T](that: Future[U]): Future[U] = if (this eq that) this else that.recoverWith({ case _ => this })(InternalCallbackExecutor) override def mapTo[S](implicit tag: ClassTag[S]): Future[S] = thisAs[S] } diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala index 52fa525b24..33b5a1468e 100644 --- a/src/library/scala/io/BufferedSource.scala +++ b/src/library/scala/io/BufferedSource.scala @@ -8,11 +8,9 @@ package scala.io -import java.util.Arrays import java.io.{ InputStream, BufferedReader, InputStreamReader, PushbackReader } import Source.DefaultBufSize import scala.collection.{ Iterator, AbstractIterator } -import scala.collection.mutable.ArrayBuffer /** This object provides convenience methods to create an iterable * representation of a source file. diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala index bb337e7a1d..371fd59a93 100644 --- a/src/library/scala/math/BigDecimal.scala +++ b/src/library/scala/math/BigDecimal.scala @@ -10,13 +10,12 @@ package scala package math -import java.{ lang => jl } -import java.math.{ MathContext, BigDecimal => BigDec } -import scala.collection.immutable.NumericRange import scala.language.implicitConversions +import java.math.{ MathContext, BigDecimal => BigDec } +import scala.collection.immutable.NumericRange -/** +/** * @author Stephane Micheloud * @author Rex Kerr * @version 1.1 @@ -44,17 +43,17 @@ object BigDecimal { val HALF_UP = Value(RM.HALF_UP.ordinal) val HALF_DOWN = Value(RM.HALF_DOWN.ordinal) val HALF_EVEN = Value(RM.HALF_EVEN.ordinal) - val UNNECESSARY = Value(RM.UNNECESSARY.ordinal) + val UNNECESSARY = Value(RM.UNNECESSARY.ordinal) } - + /** Constructs a `BigDecimal` using the decimal text representation of `Double` value `d`, rounding if necessary. */ def decimal(d: Double, mc: MathContext): BigDecimal = new BigDecimal(new BigDec(java.lang.Double.toString(d), mc), mc) /** Constructs a `BigDecimal` using the decimal text representation of `Double` value `d`. */ def decimal(d: Double): BigDecimal = decimal(d, defaultMathContext) - - /** Constructs a `BigDecimal` using the decimal text representation of `Float` value `f`, rounding if necessary. + + /** Constructs a `BigDecimal` using the decimal text representation of `Float` value `f`, rounding if necessary. * Note that `BigDecimal.decimal(0.1f) != 0.1f` since equality agrees with the `Double` representation, and * `0.1 != 0.1f`. */ @@ -66,18 +65,18 @@ object BigDecimal { * `0.1 != 0.1f`. */ def decimal(f: Float): BigDecimal = decimal(f, defaultMathContext) - + // This exists solely to avoid conversion from Int/Long to Float, screwing everything up. /** Constructs a `BigDecimal` from a `Long`, rounding if necessary. This is identical to `BigDecimal(l, mc)`. */ def decimal(l: Long, mc: MathContext): BigDecimal = apply(l, mc) - + // This exists solely to avoid conversion from Int/Long to Float, screwing everything up. /** Constructs a `BigDecimal` from a `Long`. This is identical to `BigDecimal(l)`. */ def decimal(l: Long): BigDecimal = apply(l) - + /** Constructs a `BigDecimal` using a `java.math.BigDecimal`, rounding if necessary. */ def decimal(bd: BigDec, mc: MathContext): BigDecimal = new BigDecimal(bd.round(mc), mc) - + /** Constructs a `BigDecimal` by expanding the binary fraction * contained by `Double` value `d` into a decimal representation, * rounding if necessary. When a `Float` is converted to a @@ -85,50 +84,50 @@ object BigDecimal { * also works for converted `Float`s. */ def binary(d: Double, mc: MathContext): BigDecimal = new BigDecimal(new BigDec(d, mc), mc) - + /** Constructs a `BigDecimal` by expanding the binary fraction * contained by `Double` value `d` into a decimal representation. * Note: this also works correctly on converted `Float`s. */ def binary(d: Double): BigDecimal = binary(d, defaultMathContext) - + /** Constructs a `BigDecimal` from a `java.math.BigDecimal`. The * precision is the default for `BigDecimal` or enough to represent * the `java.math.BigDecimal` exactly, whichever is greater. */ def exact(repr: BigDec): BigDecimal = { - val mc = + val mc = if (repr.precision <= defaultMathContext.getPrecision) defaultMathContext else new MathContext(repr.precision, java.math.RoundingMode.HALF_EVEN) new BigDecimal(repr, mc) } - + /** Constructs a `BigDecimal` by fully expanding the binary fraction * contained by `Double` value `d`, adjusting the precision as * necessary. Note: this works correctly on converted `Float`s also. */ def exact(d: Double): BigDecimal = exact(new BigDec(d)) - + /** Constructs a `BigDecimal` that exactly represents a `BigInt`. */ def exact(bi: BigInt): BigDecimal = exact(new BigDec(bi.bigInteger)) - + /** Constructs a `BigDecimal` that exactly represents a `Long`. Note that * all creation methods for `BigDecimal` that do not take a `MathContext` * represent a `Long`; this is equivalent to `apply`, `valueOf`, etc.. */ def exact(l: Long): BigDecimal = apply(l) - + /** Constructs a `BigDecimal` that exactly represents the number * specified in a `String`. */ def exact(s: String): BigDecimal = exact(new BigDec(s)) - + /** Constructs a `BigDecimal` that exactly represents the number * specified in base 10 in a character array. */ def exact(cs: Array[Char]): BigDecimal = exact(new BigDec(cs)) - + /** Constructs a `BigDecimal` using the java BigDecimal static * valueOf constructor. Equivalent to `BigDecimal.decimal`. @@ -137,7 +136,7 @@ object BigDecimal { * @return the constructed `BigDecimal` */ def valueOf(d: Double): BigDecimal = apply(BigDec valueOf d) - + /** Constructs a `BigDecimal` using the java BigDecimal static * valueOf constructor, specifying a `MathContext` that is * used for computations but isn't used for rounding. Use @@ -151,7 +150,7 @@ object BigDecimal { */ @deprecated("MathContext is not applied to Doubles in valueOf. Use BigDecimal.decimal to use rounding, or java.math.BigDecimal.valueOf to avoid it.","2.11") def valueOf(d: Double, mc: MathContext): BigDecimal = apply(BigDec valueOf d, mc) - + /** Constructs a `BigDecimal` using the java BigDecimal static * valueOf constructor. * @@ -159,14 +158,14 @@ object BigDecimal { * @return the constructed `BigDecimal` */ def valueOf(x: Long): BigDecimal = apply(x) - + /** Constructs a `BigDecimal` using the java BigDecimal static * valueOf constructor. This is unlikely to do what you want; * use `valueOf(f.toDouble)` or `decimal(f)` instead. */ @deprecated("Float arguments to valueOf may not do what you wish. Use decimal or valueOf(f.toDouble).","2.11") def valueOf(f: Float): BigDecimal = valueOf(f.toDouble) - + /** Constructs a `BigDecimal` using the java BigDecimal static * valueOf constructor. This is unlikely to do what you want; * use `valueOf(f.toDouble)` or `decimal(f)` instead. @@ -174,7 +173,7 @@ object BigDecimal { @deprecated("Float arguments to valueOf may not do what you wish. Use decimal or valueOf(f.toDouble).","2.11") def valueOf(f: Float, mc: MathContext): BigDecimal = valueOf(f.toDouble, mc) - + /** Constructs a `BigDecimal` whose value is equal to that of the * specified `Integer` value. * @@ -247,7 +246,7 @@ object BigDecimal { * @return the constructed `BigDecimal` */ def apply(d: Double): BigDecimal = decimal(d, defaultMathContext) - + // note we don't use the static valueOf because it doesn't let us supply // a MathContext, but we should be duplicating its logic, modulo caching. /** Constructs a `BigDecimal` whose value is equal to that of the @@ -281,7 +280,7 @@ object BigDecimal { * into a `BigDecimal`. */ def apply(x: String): BigDecimal = exact(x) - + /** Translates the decimal String representation of a `BigDecimal` * into a `BigDecimal`, rounding if necessary. */ @@ -295,12 +294,12 @@ object BigDecimal { * @return the constructed `BigDecimal` */ def apply(x: BigInt): BigDecimal = exact(x) - + /** Constructs a `BigDecimal` whose value is equal to that of the * specified `BigInt` value, rounding if necessary. * * @param x the specified `BigInt` value - * @param mc the precision and rounding mode for creation of this value and future operations on it + * @param mc the precision and rounding mode for creation of this value and future operations on it * @return the constructed `BigDecimal` */ def apply(x: BigInt, mc: MathContext): BigDecimal = @@ -315,13 +314,13 @@ object BigDecimal { */ def apply(unscaledVal: BigInt, scale: Int): BigDecimal = exact(new BigDec(unscaledVal.bigInteger, scale)) - + /** Constructs a `BigDecimal` whose unscaled value is equal to that * of the specified `BigInt` value. * * @param unscaledVal the specified `BigInt` value * @param scale the scale - * @param mc the precision and rounding mode for creation of this value and future operations on it + * @param mc the precision and rounding mode for creation of this value and future operations on it * @return the constructed `BigDecimal` */ def apply(unscaledVal: BigInt, scale: Int, mc: MathContext): BigDecimal = @@ -329,7 +328,7 @@ object BigDecimal { /** Constructs a `BigDecimal` from a `java.math.BigDecimal`. */ def apply(bd: BigDec): BigDecimal = apply(bd, defaultMathContext) - + @deprecated("This method appears to round a java.math.BigDecimal but actually doesn't. Use new BigDecimal(bd, mc) instead for no rounding, or BigDecimal.decimal(bd, mc) for rounding.", "2.11") def apply(bd: BigDec, mc: MathContext): BigDecimal = new BigDecimal(bd, mc) @@ -402,7 +401,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { def this(bigDecimal: BigDec) = this(bigDecimal, BigDecimal.defaultMathContext) import BigDecimal.RoundingMode._ import BigDecimal.{decimal, binary, exact} - + if (bigDecimal eq null) throw new IllegalArgumentException("null value for BigDecimal") if (mc eq null) throw new IllegalArgumentException("null MathContext for BigDecimal") @@ -423,7 +422,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { scala.util.hashing.MurmurHash3.mixLast( temp.scaleByPowerOfTen(temp.scale).toBigInteger.hashCode, temp.scale ) } } - + /** Returns the hash code for this BigDecimal. * Note that this does not merely use the underlying java object's * `hashCode` because we compare `BigDecimal`s with `compareTo` @@ -444,15 +443,15 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { */ override def equals (that: Any): Boolean = that match { case that: BigDecimal => this equals that - case that: BigInt => - that.bitLength > (precision-scale-2)*BigDecimal.deci2binary && + case that: BigInt => + that.bitLength > (precision-scale-2)*BigDecimal.deci2binary && this.toBigIntExact.exists(that equals _) - case that: Double => + case that: Double => !that.isInfinity && { val d = toDouble !d.isInfinity && d == that && equals(decimal(d)) } - case that: Float => + case that: Float => !that.isInfinity && { val f = toFloat !f.isInfinity && f == that && equals(decimal(f.toDouble)) @@ -482,43 +481,43 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { val d = toDouble !d.isInfinity && bigDecimal.compareTo(new BigDec(d)) == 0 } - + /** Tests whether this `BigDecimal` holds the decimal representation of a `Double`. */ def isDecimalDouble = { val d = toDouble !d.isInfinity && equals(decimal(d)) } - + /** Tests whether this `BigDecimal` holds the decimal representation of a `Float`. */ def isDecimalFloat = { val f = toFloat !f.isInfinity && equals(decimal(f)) } - + /** Tests whether this `BigDecimal` holds, to within precision, the binary representation of a `Double`. */ def isBinaryDouble = { val d = toDouble !d.isInfinity && equals(binary(d,mc)) } - + /** Tests whether this `BigDecimal` holds, to within precision, the binary representation of a `Float`. */ def isBinaryFloat = { val f = toFloat !f.isInfinity && equals(binary(f,mc)) } - + /** Tests whether this `BigDecimal` holds the exact expansion of a `Double`'s binary fractional form into base 10. */ def isExactDouble = { val d = toDouble !d.isInfinity && equals(exact(d)) } - + /** Tests whether this `BigDecimal` holds the exact expansion of a `Float`'s binary fractional form into base 10. */ def isExactFloat = { val f = toFloat !f.isInfinity && equals(exact(f.toDouble)) } - + private def noArithmeticException(body: => Unit): Boolean = { try { body ; true } @@ -526,9 +525,9 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { } def isWhole() = scale <= 0 || bigDecimal.stripTrailingZeros.scale <= 0 - + def underlying = bigDecimal - + /** Compares this BigDecimal with the specified BigDecimal for equality. */ @@ -589,14 +588,14 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { case x if x <= 0 => this case _ => that } - + /** Returns the maximum of this and that, or this if the two are equal */ def max (that: BigDecimal): BigDecimal = (this compare that) match { case x if x >= 0 => this case _ => that } - + /** Remainder after dividing this by that. */ def remainder (that: BigDecimal): BigDecimal = new BigDecimal(this.bigDecimal remainder that.bigDecimal, mc) @@ -635,7 +634,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { val r = this.bigDecimal round mc if (r eq bigDecimal) this else new BigDecimal(r, this.mc) } - + /** Returns a `BigDecimal` rounded according to its own `MathContext` */ def rounded: BigDecimal = { val r = bigDecimal round mc @@ -657,7 +656,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable { /** Returns a `BigDecimal` whose scale is the specified value, and whose value is * numerically equal to this BigDecimal's. */ - def setScale(scale: Int): BigDecimal = + def setScale(scale: Int): BigDecimal = if (this.scale == scale) this else new BigDecimal(this.bigDecimal setScale scale, mc) diff --git a/src/library/scala/runtime/AbstractPartialFunction.scala b/src/library/scala/runtime/AbstractPartialFunction.scala index 986cd0390f..630966d0d4 100644 --- a/src/library/scala/runtime/AbstractPartialFunction.scala +++ b/src/library/scala/runtime/AbstractPartialFunction.scala @@ -9,8 +9,6 @@ package scala package runtime -import scala.annotation.unspecialized - /** `AbstractPartialFunction` reformulates all operations of its supertrait `PartialFunction` * in terms of `isDefinedAt` and `applyOrElse`. * diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala index 5e4da24c0d..9b4899aef6 100644 --- a/src/library/scala/runtime/ScalaNumberProxy.scala +++ b/src/library/scala/runtime/ScalaNumberProxy.scala @@ -9,8 +9,8 @@ package scala package runtime -import scala.collection.{ mutable, immutable } -import scala.math.{ ScalaNumericConversions, ScalaNumericAnyConversions } +import scala.collection.immutable +import scala.math.ScalaNumericAnyConversions import immutable.NumericRange import Proxy.Typed diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 026d5edd29..1195f95093 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -9,16 +9,14 @@ package scala package runtime -import scala.collection.{ Seq, IndexedSeq, TraversableView, AbstractIterator, GenIterable } +import scala.collection.{ TraversableView, AbstractIterator, GenIterable } import scala.collection.mutable.WrappedArray -import scala.collection.immutable.{ StringLike, NumericRange, List, Stream, Nil, :: } +import scala.collection.immutable.{ StringLike, NumericRange } import scala.collection.generic.{ Sorted, IsTraversableLike } import scala.reflect.{ ClassTag, classTag } -import scala.util.control.ControlThrowable import java.lang.{ Class => jClass } -import java.lang.Double.doubleToLongBits -import java.lang.reflect.{ Modifier, Method => JMethod } +import java.lang.reflect.{ Method => JMethod } /** The object ScalaRunTime provides support methods required by * the scala runtime. All these methods should be considered diff --git a/src/library/scala/runtime/SeqCharSequence.scala b/src/library/scala/runtime/SeqCharSequence.scala index 74e67bb9e7..293bf950db 100644 --- a/src/library/scala/runtime/SeqCharSequence.scala +++ b/src/library/scala/runtime/SeqCharSequence.scala @@ -9,8 +9,6 @@ package scala package runtime -import java.util.Arrays.copyOfRange - @deprecated("Use Predef.SeqCharSequence", "2.11.0") final class SeqCharSequence(val xs: scala.collection.IndexedSeq[Char]) extends CharSequence { def length: Int = xs.length diff --git a/src/library/scala/util/Sorting.scala b/src/library/scala/util/Sorting.scala index b4f965f69b..3bda7c0d39 100644 --- a/src/library/scala/util/Sorting.scala +++ b/src/library/scala/util/Sorting.scala @@ -45,7 +45,7 @@ object Sorting { /** Sort an array of Floats using `java.util.Arrays.sort`. */ def quickSort(a: Array[Float]): Unit = java.util.Arrays.sort(a) - + private final val qsortThreshold = 16 /** Sort array `a` with quicksort, using the Ordering on its elements. @@ -57,9 +57,9 @@ object Sorting { def inner(a: Array[K], i0: Int, iN: Int, ord: Ordering[K]): Unit = { if (iN - i0 < qsortThreshold) insertionSort(a, i0, iN, ord) else { - var iK = (i0 + iN) >>> 1 // Unsigned div by 2 + val iK = (i0 + iN) >>> 1 // Unsigned div by 2 // Find index of median of first, central, and last elements - var pL = + var pL = if (ord.compare(a(i0), a(iN - 1)) <= 0) if (ord.compare(a(i0), a(iK)) < 0) if (ord.compare(a(iN - 1), a(iK)) < 0) iN - 1 else iK @@ -140,9 +140,9 @@ object Sorting { } inner(a, 0, a.length, implicitly[Ordering[K]]) } - + private final val mergeThreshold = 32 - + // Ordering[T] might be slow especially for boxed primitives, so use binary search variant of insertion sort // Caller must pass iN >= i0 or math will fail. Also, i0 >= 0. private def insertionSort[@specialized T](a: Array[T], i0: Int, iN: Int, ord: Ordering[T]): Unit = { @@ -176,7 +176,7 @@ object Sorting { m += 1 } } - + // Caller is required to pass iN >= i0, else math will fail. Also, i0 >= 0. private def mergeSort[@specialized T: ClassTag](a: Array[T], i0: Int, iN: Int, ord: Ordering[T], scratch: Array[T] = null): Unit = { if (iN - i0 < mergeThreshold) insertionSort(a, i0, iN, ord) @@ -188,7 +188,7 @@ object Sorting { mergeSorted(a, i0, iK, iN, ord, sc) } } - + // Must have 0 <= i0 < iK < iN private def mergeSorted[@specialized T](a: Array[T], i0: Int, iK: Int, iN: Int, ord: Ordering[T], scratch: Array[T]): Unit = { // Check to make sure we're not already in order @@ -212,7 +212,7 @@ object Sorting { // Don't need to finish a(i) because it's already in place, k = i } } - + // Why would you even do this? private def booleanSort(a: Array[Boolean]): Unit = { var i = 0 @@ -235,7 +235,7 @@ object Sorting { // TODO: add upper bound: T <: AnyRef, propagate to callers below (not binary compatible) // Maybe also rename all these methods to `sort`. @inline private def sort[T](a: Array[T], ord: Ordering[T]): Unit = a match { - case _: Array[AnyRef] => + case _: Array[AnyRef] => // Note that runtime matches are covariant, so could actually be any Array[T] s.t. T is not primitive (even boxed value classes) if (a.length > 1 && (ord eq null)) throw new NullPointerException("Ordering") java.util.Arrays.sort(a, ord) diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala index b1b9965614..84d170249d 100644 --- a/src/library/scala/util/Try.scala +++ b/src/library/scala/util/Try.scala @@ -9,7 +9,6 @@ package scala package util -import scala.collection.Seq import scala.util.control.NonFatal import scala.language.implicitConversions @@ -218,12 +217,12 @@ final case class Failure[+T](exception: Throwable) extends Try[T] { override def isSuccess: Boolean = false override def get: T = throw exception override def getOrElse[U >: T](default: => U): U = default - override def orElse[U >: T](default: => Try[U]): Try[U] = + override def orElse[U >: T](default: => Try[U]): Try[U] = try default catch { case NonFatal(e) => Failure(e) } override def flatMap[U](f: T => Try[U]): Try[U] = this.asInstanceOf[Try[U]] override def flatten[U](implicit ev: T <:< Try[U]): Try[U] = this.asInstanceOf[Try[U]] override def foreach[U](f: T => U): Unit = () - override def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U] = + override def transform[U](s: T => Try[U], f: Throwable => Try[U]): Try[U] = try f(exception) catch { case NonFatal(e) => Failure(e) } override def map[U](f: T => U): Try[U] = this.asInstanceOf[Try[U]] override def collect[U](pf: PartialFunction[T, U]): Try[U] = this.asInstanceOf[Try[U]] diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index 24c297a2fc..702d3b5e5e 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -10,9 +10,7 @@ package scala package util package control -import scala.collection.immutable.List import scala.reflect.{ ClassTag, classTag } -import java.lang.reflect.InvocationTargetException import scala.language.implicitConversions diff --git a/src/partest-extras/scala/tools/partest/BytecodeTest.scala b/src/partest-extras/scala/tools/partest/BytecodeTest.scala index 8459419fa5..290b7b434e 100644 --- a/src/partest-extras/scala/tools/partest/BytecodeTest.scala +++ b/src/partest-extras/scala/tools/partest/BytecodeTest.scala @@ -4,7 +4,7 @@ import scala.tools.nsc.util.JavaClassPath import scala.collection.JavaConverters._ import scala.tools.asm.{ClassWriter, ClassReader} import scala.tools.asm.tree._ -import java.io.{FileOutputStream, FileInputStream, File => JFile, InputStream} +import java.io.{File => JFile, InputStream} import AsmNode._ /** diff --git a/src/partest-extras/scala/tools/partest/JavapTest.scala b/src/partest-extras/scala/tools/partest/JavapTest.scala index 3cb3dc6ca8..27017b1585 100644 --- a/src/partest-extras/scala/tools/partest/JavapTest.scala +++ b/src/partest-extras/scala/tools/partest/JavapTest.scala @@ -1,7 +1,6 @@ package scala.tools.partest -import scala.util.{Try,Success,Failure} import java.lang.System.{out => sysout} /** A trait for testing repl's javap command diff --git a/src/partest-extras/scala/tools/partest/ReplTest.scala b/src/partest-extras/scala/tools/partest/ReplTest.scala index 20dfe0eb16..608ac73b61 100644 --- a/src/partest-extras/scala/tools/partest/ReplTest.scala +++ b/src/partest-extras/scala/tools/partest/ReplTest.scala @@ -7,8 +7,6 @@ package scala.tools.partest import scala.tools.nsc.Settings import scala.tools.nsc.interpreter.{ ILoop, replProps } -import java.lang.reflect.{ Method => JMethod, Field => JField } -import scala.util.matching.Regex import scala.util.matching.Regex.Match /** A class for testing repl code. diff --git a/src/partest-extras/scala/tools/partest/SigTest.scala b/src/partest-extras/scala/tools/partest/SigTest.scala index fe233a4fb5..a516daa629 100644 --- a/src/partest-extras/scala/tools/partest/SigTest.scala +++ b/src/partest-extras/scala/tools/partest/SigTest.scala @@ -5,8 +5,6 @@ package scala.tools.partest -import scala.tools.nsc.Settings -import scala.tools.nsc.interpreter.ILoop import java.lang.reflect.{ Method => JMethod, Field => JField } import scala.reflect.{ClassTag, classTag} diff --git a/src/reflect/scala/reflect/api/TypeTags.scala b/src/reflect/scala/reflect/api/TypeTags.scala index bc239ca870..cad318dbed 100644 --- a/src/reflect/scala/reflect/api/TypeTags.scala +++ b/src/reflect/scala/reflect/api/TypeTags.scala @@ -7,8 +7,6 @@ package scala package reflect package api -import java.lang.{ Class => jClass } -import scala.language.implicitConversions import java.io.ObjectStreamException /** diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index c0772c8cc0..fa19103d0c 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -7,7 +7,6 @@ package scala package reflect package internal -import pickling.ByteCodecs import scala.annotation.tailrec import scala.collection.immutable.ListMap import scala.language.postfixOps diff --git a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala index 54f64153c1..81281b5eb4 100644 --- a/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala +++ b/src/reflect/scala/reflect/internal/BaseTypeSeqs.scala @@ -7,8 +7,7 @@ package reflect package internal // todo implement in terms of BitSet -import scala.collection.{ mutable, immutable } -import scala.math.max +import scala.collection.mutable import util.Statistics /** A base type sequence (BaseTypeSeq) is an ordered sequence spanning all the base types diff --git a/src/reflect/scala/reflect/internal/Chars.scala b/src/reflect/scala/reflect/internal/Chars.scala index 74413fdaba..daee8a49ee 100644 --- a/src/reflect/scala/reflect/internal/Chars.scala +++ b/src/reflect/scala/reflect/internal/Chars.scala @@ -6,10 +6,11 @@ package scala package reflect package internal -import scala.annotation.{ tailrec, switch } -import java.lang.{ Character => JCharacter } import scala.language.postfixOps +import scala.annotation.switch +import java.lang.{ Character => JCharacter } + /** Contains constants and classifier methods for characters */ trait Chars { // Be very careful touching these. diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 35b08e72c4..d167f1485d 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -8,8 +8,9 @@ package reflect package internal import scala.language.postfixOps -import scala.annotation.{ switch, meta } -import scala.collection.{ mutable, immutable } + +import scala.annotation.meta +import scala.collection.mutable import Flags._ import scala.reflect.api.{Universe => ApiUniverse} @@ -1397,8 +1398,8 @@ trait Definitions extends api.StandardDefinitions { if (isInitialized) return ObjectClass.initialize ScalaPackageClass.initialize - val forced1 = symbolsNotPresentInBytecode - val forced2 = NoSymbol + symbolsNotPresentInBytecode + NoSymbol isInitialized = true } //init diff --git a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala index 3e18f88f80..cc9f379cfe 100644 --- a/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala +++ b/src/reflect/scala/reflect/internal/ExistentialsAndSkolems.scala @@ -7,7 +7,6 @@ package scala package reflect package internal -import scala.collection.{ mutable, immutable } /** The name of this trait defines the eventual intent better than * it does the initial contents. diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index 754b96a9dd..b022ba2981 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -7,8 +7,6 @@ package scala package reflect package internal -import scala.collection.{ mutable, immutable } - // Flags at each index of a flags Long. Those marked with /M are used in // Parsers/JavaParsers and therefore definitely appear on Modifiers; but the // absence of /M on the other flags does not imply they aren't. diff --git a/src/reflect/scala/reflect/internal/Internals.scala b/src/reflect/scala/reflect/internal/Internals.scala index acf000ebc5..cfacad24b4 100644 --- a/src/reflect/scala/reflect/internal/Internals.scala +++ b/src/reflect/scala/reflect/internal/Internals.scala @@ -4,12 +4,9 @@ package internal import scala.language.implicitConversions import scala.language.higherKinds -import scala.collection.mutable.WeakHashMap -import scala.ref.WeakReference + import scala.reflect.api.Universe import scala.reflect.macros.Attachments -import scala.reflect.internal.util.FreshNameCreator -import scala.reflect.internal.util.ListOfNil trait Internals extends api.Internals { self: SymbolTable => diff --git a/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala b/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala index fb1cdb34e1..b9cc167933 100644 --- a/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala +++ b/src/reflect/scala/reflect/internal/JMethodOrConstructor.scala @@ -7,7 +7,7 @@ package reflect package internal import scala.language.implicitConversions -import java.lang.{ Class => jClass } + import java.lang.annotation.{ Annotation => jAnnotation } import java.lang.reflect.{ Member => jMember, Constructor => jConstructor, Method => jMethod, diff --git a/src/reflect/scala/reflect/internal/Kinds.scala b/src/reflect/scala/reflect/internal/Kinds.scala index 902ba9fa80..a7e462d8de 100644 --- a/src/reflect/scala/reflect/internal/Kinds.scala +++ b/src/reflect/scala/reflect/internal/Kinds.scala @@ -7,7 +7,6 @@ package scala package reflect package internal -import scala.collection.{ mutable, immutable } import scala.reflect.internal.util.StringOps.{ countAsString, countElementsAsString } trait Kinds { diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index 32d12d305e..97f51149ba 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -7,10 +7,10 @@ package scala package reflect package internal -import scala.io.Codec -import java.security.MessageDigest import scala.language.implicitConversions +import scala.io.Codec + trait Names extends api.Names { private final val HASH_SIZE = 0x8000 private final val HASH_MASK = 0x7FFF diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index b44c4022f6..8fb7a0c1d0 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -9,7 +9,7 @@ package scala package reflect package internal -import java.io.{ OutputStream, PrintWriter, StringWriter, Writer } +import java.io.{ OutputStream, PrintWriter, Writer } import Flags._ import scala.compat.Platform.EOL @@ -73,10 +73,10 @@ trait Printers extends api.Printers { self: SymbolTable => def indent() = indentMargin += indentStep def undent() = indentMargin -= indentStep - def printPosition(tree: Tree) = + def printPosition(tree: Tree) = if (printPositions) comment(print(tree.pos.show)) - - protected def printTypesInfo(tree: Tree) = + + protected def printTypesInfo(tree: Tree) = if (printTypes && tree.isTerm && tree.canHaveAttrs) comment{ print("{", if (tree.tpe eq null) "" else tree.tpe.toString, "}") @@ -313,7 +313,7 @@ trait Printers extends api.Printers { self: SymbolTable => protected def printBlock(stats: List[Tree], expr: Tree) = printColumn(stats ::: List(expr), "{", ";", "}") - + def printTree(tree: Tree) = { tree match { case EmptyTree => @@ -639,14 +639,14 @@ trait Printers extends api.Printers { self: SymbolTable => case _ => true } - protected def syntheticToRemove(tree: Tree) = + protected def syntheticToRemove(tree: Tree) = tree match { case _: ValDef | _: TypeDef => false // don't remove ValDef and TypeDef case md: MemberDef if md.mods.isSynthetic => true case _ => false } - override def printOpt(prefix: String, tree: Tree) = + override def printOpt(prefix: String, tree: Tree) = if (!isEmptyTree(tree)) super.printOpt(prefix, tree) override def printColumn(ts: List[Tree], start: String, sep: String, end: String) = { @@ -959,13 +959,13 @@ trait Printers extends api.Printers { self: SymbolTable => printFunction(f)(printValueParams(vparams, inParentheses = printParentheses)) case Typed(expr, tp) => - def printTp = print("(", tp, ")") + def printTp() = print("(", tp, ")") tp match { - case EmptyTree | EmptyTypeTree() => printTp + case EmptyTree | EmptyTypeTree() => printTp() // case for untypechecked trees - case Annotated(annot, arg) if (expr ne null) && (arg ne null) && expr.equalsStructure(arg) => printTp // remove double arg - 5: 5: @unchecked - case tt: TypeTree if tt.original.isInstanceOf[Annotated] => printTp + case Annotated(annot, arg) if (expr ne null) && (arg ne null) && expr.equalsStructure(arg) => printTp() // remove double arg - 5: 5: @unchecked + case tt: TypeTree if tt.original.isInstanceOf[Annotated] => printTp() case Function(List(), EmptyTree) => print("(", expr, " _)") //func _ // parentheses required when (a match {}) : Type case _ => print("((", expr, "): ", tp, ")") @@ -1000,7 +1000,7 @@ trait Printers extends api.Printers { self: SymbolTable => } case _ => print(fun) } - printRow(args, "(", ", ", ")") + printRow(args, "(", ", ", ")") case st @ Super(This(qual), mix) => printSuper(st, printedName(qual), checkSymbol = false) @@ -1016,7 +1016,7 @@ trait Printers extends api.Printers { self: SymbolTable => print(qual) case Select(qual, name) => - def checkRootPackage(tr: Tree): Boolean = + def checkRootPackage(tr: Tree): Boolean = (currentParent match { //check that Select is not for package def name case Some(_: PackageDef) => false case _ => true diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala index d393a841b7..c58cb71e97 100644 --- a/src/reflect/scala/reflect/internal/ReificationSupport.scala +++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala @@ -726,7 +726,7 @@ trait ReificationSupport { self: SymbolTable => protected object FilterCall { def unapply(tree: Tree): Option[(Tree,Tree)] = tree match { case Apply(Select(obj, nme.withFilter | nme.filter), arg :: Nil) => - Some(obj, arg) + Some((obj, arg)) case _ => None } } @@ -760,10 +760,10 @@ trait ReificationSupport { self: SymbolTable => def unapply(tree: Tree) = tree match { case SyntacticApplied(SyntacticTypeApplied(sel @ Select(lhs, meth), _), (f :: Nil) :: Nil) if name == meth && sel.hasAttachment[ForAttachment.type] => - Some(lhs, f) + Some((lhs, f)) case SyntacticApplied(SyntacticTypeApplied(sel @ Select(lhs, meth), _), (f :: Nil) :: _ :: Nil) if name == meth && sel.hasAttachment[ForAttachment.type] => - Some(lhs, f) + Some((lhs, f)) case _ => None } } @@ -1132,7 +1132,7 @@ trait ReificationSupport { self: SymbolTable => def apply(tpt: Tree, where: List[Tree]): ExistentialTypeTree = ExistentialTypeTree(tpt, where.map { case md: MemberDef => md - case tree => throw new IllegalArgumentException("$tree is not legal forSome definition") + case tree => throw new IllegalArgumentException(s"$tree is not legal forSome definition") }) def unapply(tree: Tree): Option[(Tree, List[MemberDef])] = tree match { case MaybeTypeTreeOriginal(ExistentialTypeTree(tpt, where)) => diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 9a31634751..d16d431f6e 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -7,11 +7,11 @@ package scala package reflect package internal +import scala.language.implicitConversions + import java.security.MessageDigest -import java.util.UUID.randomUUID import Chars.isOperatorPart import scala.annotation.switch -import scala.language.implicitConversions import scala.collection.immutable import scala.io.Codec diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index b0145f8a89..88a94ab530 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -8,7 +8,7 @@ package reflect package internal import scala.annotation.elidable -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import util._ import java.util.concurrent.TimeUnit import scala.reflect.internal.{TreeGen => InternalTreeGen} diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 14afd0d42d..65740e87f1 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -7,7 +7,7 @@ package scala package reflect package internal -import scala.collection.{ mutable, immutable } +import scala.collection.immutable import scala.collection.mutable.ListBuffer import util.{ Statistics, shortClassOfInstance } import Flags._ @@ -3441,7 +3441,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => extends ClassSymbol(owner0, pos0, tpnme.REFINE_CLASS_NAME) { override def name_=(name: Name) { abort("Cannot set name of RefinementClassSymbol to " + name) - super.name_=(name) } override def isRefinementClass = true override def isAnonOrRefinementClass = true diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala index 7ad5fdf096..86b70643c9 100644 --- a/src/reflect/scala/reflect/internal/TreeInfo.scala +++ b/src/reflect/scala/reflect/internal/TreeInfo.scala @@ -18,7 +18,7 @@ abstract class TreeInfo { val global: SymbolTable import global._ - import definitions.{ isTupleSymbol, isVarArgsList, isCastSymbol, ThrowableClass, TupleClass, uncheckedStableClass, isBlackboxMacroBundleType, isWhiteboxContextType } + import definitions.{ isVarArgsList, isCastSymbol, ThrowableClass, uncheckedStableClass, isBlackboxMacroBundleType, isWhiteboxContextType } /* Does not seem to be used. Not sure what it does anyway. def isOwnerDefinition(tree: Tree): Boolean = tree match { diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index d63c23b992..b43ea640d9 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -8,7 +8,7 @@ package reflect package internal import Flags._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import scala.reflect.macros.Attachments import util.Statistics diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index 5b23bbf144..2e6cd819b4 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -7,7 +7,7 @@ package scala package reflect package internal -import scala.collection.{ mutable, immutable, generic } +import scala.collection.{ mutable, immutable } import scala.ref.WeakReference import mutable.ListBuffer import Flags._ diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index af04f47e0e..8d74065207 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -8,7 +8,7 @@ package reflect package internal import Variance._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import scala.annotation.tailrec /** See comments at scala.reflect.internal.Variance. diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala index 277e89d656..4bc804445c 100644 --- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala +++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala @@ -14,7 +14,7 @@ import java.lang.Double.longBitsToDouble import Flags._ import PickleFormat._ -import scala.collection.{ mutable, immutable } +import scala.collection.mutable import scala.collection.mutable.ListBuffer import scala.annotation.switch diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index f661978fcd..32af6529ca 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -3,8 +3,6 @@ package reflect package internal package transform -import Flags.{PARAMACCESSOR, METHOD} - trait Erasure { val global: SymbolTable diff --git a/src/reflect/scala/reflect/internal/util/AbstractFileClassLoader.scala b/src/reflect/scala/reflect/internal/util/AbstractFileClassLoader.scala index 5cbdb92664..b5030460b8 100644 --- a/src/reflect/scala/reflect/internal/util/AbstractFileClassLoader.scala +++ b/src/reflect/scala/reflect/internal/util/AbstractFileClassLoader.scala @@ -5,8 +5,8 @@ package scala package reflect.internal.util -import scala.collection.{ mutable, immutable } -import scala.reflect.io.{ AbstractFile, Streamable } +import scala.collection.mutable +import scala.reflect.io.AbstractFile import java.net.{ URL, URLConnection, URLStreamHandler } import java.security.cert.Certificate import java.security.{ ProtectionDomain, CodeSource } diff --git a/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala b/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala index 8442c1015f..c69dd23c40 100644 --- a/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala +++ b/src/reflect/scala/reflect/internal/util/FreshNameCreator.scala @@ -8,7 +8,6 @@ package util import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.atomic.AtomicLong -import scala.collection.mutable import scala.reflect.NameTransformer class FreshNameCreator(creatorPrefix: String = "") { diff --git a/src/reflect/scala/reflect/internal/util/Origins.scala b/src/reflect/scala/reflect/internal/util/Origins.scala index 2eb4fa29d5..4c425457a7 100644 --- a/src/reflect/scala/reflect/internal/util/Origins.scala +++ b/src/reflect/scala/reflect/internal/util/Origins.scala @@ -7,7 +7,7 @@ package scala package reflect package internal.util -import scala.collection.{ mutable, immutable } +import scala.collection.mutable /** A debugging class for logging from whence a method is being called. * Say you wanted to discover who was calling phase_= in SymbolTable. diff --git a/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala b/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala index 296934e253..cc5be92489 100644 --- a/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala +++ b/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala @@ -6,16 +6,16 @@ package scala package reflect.internal.util +import scala.language.implicitConversions + import java.lang.{ ClassLoader => JClassLoader } -import java.lang.reflect.{ Constructor, Modifier, Method } -import java.io.{ File => JFile } +import java.lang.reflect.Modifier import java.net.{ URLClassLoader => JURLClassLoader } import java.net.URL -import scala.reflect.internal.FatalError + import scala.reflect.runtime.ReflectionUtils.{ show, unwrapHandler } import ScalaClassLoader._ import scala.util.control.Exception.{ catching } -import scala.language.implicitConversions import scala.reflect.{ ClassTag, classTag } trait HasClassPath { diff --git a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala index e4a6503184..e48c35908f 100644 --- a/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala +++ b/src/reflect/scala/reflect/internal/util/TraceSymbolActivity.scala @@ -2,8 +2,7 @@ package scala package reflect.internal package util -import scala.collection.{ mutable, immutable } -import scala.language.postfixOps +import scala.collection.mutable trait TraceSymbolActivity { val global: SymbolTable diff --git a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala index 83d2a3453b..f8dfa720d5 100644 --- a/src/reflect/scala/reflect/internal/util/WeakHashSet.scala +++ b/src/reflect/scala/reflect/internal/util/WeakHashSet.scala @@ -3,7 +3,6 @@ package reflect.internal.util import java.lang.ref.{WeakReference, ReferenceQueue} import scala.annotation.tailrec -import scala.collection.generic.Clearable import scala.collection.mutable.{Set => MSet} /** @@ -403,4 +402,4 @@ object WeakHashSet { val defaultLoadFactor = .75 def apply[A <: AnyRef](initialCapacity: Int = WeakHashSet.defaultInitialCapacity, loadFactor: Double = WeakHashSet.defaultLoadFactor) = new WeakHashSet[A](initialCapacity, defaultLoadFactor) -} \ No newline at end of file +} diff --git a/src/reflect/scala/reflect/internal/util/package.scala b/src/reflect/scala/reflect/internal/util/package.scala index 3618c150ca..ec5938b902 100644 --- a/src/reflect/scala/reflect/internal/util/package.scala +++ b/src/reflect/scala/reflect/internal/util/package.scala @@ -5,7 +5,6 @@ package internal import scala.language.existentials // SI-6541 package object util { - import StringOps.longestCommonPrefix // An allocation-avoiding reusable instance of the so-common List(Nil). val ListOfNil: List[List[Nothing]] = Nil :: Nil diff --git a/src/reflect/scala/reflect/io/AbstractFile.scala b/src/reflect/scala/reflect/io/AbstractFile.scala index bcefcc471f..ee0bc129f8 100644 --- a/src/reflect/scala/reflect/io/AbstractFile.scala +++ b/src/reflect/scala/reflect/io/AbstractFile.scala @@ -8,10 +8,9 @@ package scala package reflect package io -import java.io.{ FileOutputStream, IOException, InputStream, OutputStream, BufferedOutputStream, ByteArrayOutputStream } +import java.io.{ IOException, InputStream, OutputStream, BufferedOutputStream, ByteArrayOutputStream } import java.io.{ File => JFile } import java.net.URL -import scala.collection.mutable.ArrayBuffer import scala.reflect.internal.util.Statistics /** diff --git a/src/reflect/scala/reflect/io/File.scala b/src/reflect/scala/reflect/io/File.scala index a9c6807e88..206861adb3 100644 --- a/src/reflect/scala/reflect/io/File.scala +++ b/src/reflect/scala/reflect/io/File.scala @@ -6,20 +6,16 @@ ** |/ ** \* */ - package scala package reflect package io import java.io.{ - FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter, - BufferedInputStream, BufferedOutputStream, IOException, PrintStream, PrintWriter, Closeable => JCloseable, - File => JFile + FileInputStream, FileOutputStream, BufferedWriter, OutputStreamWriter, + BufferedOutputStream, IOException, PrintWriter, File => JFile } -import java.nio.channels.{ Channel, FileChannel } import scala.io.Codec -import scala.language.{reflectiveCalls, implicitConversions} /** * ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */ diff --git a/src/reflect/scala/reflect/io/Path.scala b/src/reflect/scala/reflect/io/Path.scala index 15fce953f2..5f93506015 100644 --- a/src/reflect/scala/reflect/io/Path.scala +++ b/src/reflect/scala/reflect/io/Path.scala @@ -7,12 +7,11 @@ package scala package reflect package io -import java.io.{ - FileInputStream, FileOutputStream, BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter, - BufferedInputStream, BufferedOutputStream, RandomAccessFile, File => JFile } +import scala.language.implicitConversions + +import java.io.{ RandomAccessFile, File => JFile } import java.net.{ URI, URL } import scala.util.Random.alphanumeric -import scala.language.implicitConversions import scala.reflect.internal.util.Statistics /** An abstraction for filesystem paths. The differences between diff --git a/src/reflect/scala/reflect/io/PlainFile.scala b/src/reflect/scala/reflect/io/PlainFile.scala index 8f24d84488..eb0940e703 100644 --- a/src/reflect/scala/reflect/io/PlainFile.scala +++ b/src/reflect/scala/reflect/io/PlainFile.scala @@ -7,8 +7,6 @@ package scala package reflect package io -import java.io.{ FileInputStream, FileOutputStream, IOException } - /** ''Note: This library is considered experimental and should not be used unless you know what you are doing.'' */ class PlainDirectory(givenPath: Directory) extends PlainFile(givenPath) { override def isDirectory = true diff --git a/src/reflect/scala/reflect/io/Streamable.scala b/src/reflect/scala/reflect/io/Streamable.scala index 99a14d1fb0..bc4031ca9b 100644 --- a/src/reflect/scala/reflect/io/Streamable.scala +++ b/src/reflect/scala/reflect/io/Streamable.scala @@ -7,8 +7,8 @@ package scala package reflect package io -import java.net.{ URI, URL } -import java.io.{ BufferedInputStream, InputStream, PrintStream } +import java.net.URL +import java.io.{ BufferedInputStream, InputStream } import java.io.{ BufferedReader, InputStreamReader, Closeable => JCloseable } import scala.io.{ Codec, BufferedSource, Source } import scala.collection.mutable.ArrayBuffer diff --git a/src/reflect/scala/reflect/io/ZipArchive.scala b/src/reflect/scala/reflect/io/ZipArchive.scala index 0c63acb86c..42e22fda6f 100644 --- a/src/reflect/scala/reflect/io/ZipArchive.scala +++ b/src/reflect/scala/reflect/io/ZipArchive.scala @@ -12,7 +12,7 @@ import java.io.{ IOException, InputStream, ByteArrayInputStream, FilterInputStre import java.io.{ File => JFile } import java.util.zip.{ ZipEntry, ZipFile, ZipInputStream } import java.util.jar.Manifest -import scala.collection.{ immutable, mutable } +import scala.collection.mutable import scala.collection.convert.WrapAsScala.asScalaIterator import scala.annotation.tailrec diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 50442519f2..40f2a1ef90 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -2,24 +2,24 @@ package scala package reflect package runtime +import scala.language.existentials + import scala.ref.WeakReference import scala.collection.mutable.WeakHashMap import java.lang.{Class => jClass, Package => jPackage} import java.lang.reflect.{ Method => jMethod, Constructor => jConstructor, Field => jField, - Member => jMember, Type => jType, TypeVariable => jTypeVariable, Array => jArray, - AccessibleObject => jAccessibleObject, + Member => jMember, Type => jType, TypeVariable => jTypeVariable, GenericDeclaration, GenericArrayType, ParameterizedType, WildcardType, AnnotatedElement } import java.lang.annotation.{Annotation => jAnnotation} import java.io.IOException -import scala.reflect.internal.{ MissingRequirementError, JavaAccFlags, JMethodOrConstructor } +import scala.reflect.internal.{ MissingRequirementError, JavaAccFlags } import internal.pickling.ByteCodecs import internal.pickling.UnPickler -import scala.collection.mutable.{ HashMap, ListBuffer, ArrayBuffer } +import scala.collection.mutable.ListBuffer import internal.Flags._ import ReflectionUtils._ -import scala.language.existentials import scala.runtime.{ScalaRunTime, BoxesRunTime} private[scala] trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse with TwoWayCaches { thisUniverse: SymbolTable => diff --git a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala index a278ed3fd7..d92e37953f 100644 --- a/src/reflect/scala/reflect/runtime/ReflectionUtils.scala +++ b/src/reflect/scala/reflect/runtime/ReflectionUtils.scala @@ -10,7 +10,6 @@ import java.lang.{Class => jClass} import java.lang.reflect.{ Method, InvocationTargetException, UndeclaredThrowableException } import scala.reflect.internal.util.AbstractFileClassLoader import scala.reflect.io._ -import java.io.{File => JFile} /** A few java-reflection oriented utility functions useful during reflection bootstrapping. */ diff --git a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala index 9ce6331e33..43ab41f541 100644 --- a/src/reflect/scala/reflect/runtime/SymbolLoaders.scala +++ b/src/reflect/scala/reflect/runtime/SymbolLoaders.scala @@ -2,8 +2,6 @@ package scala package reflect package runtime -import internal.Flags -import java.lang.{Class => jClass, Package => jPackage} import scala.collection.mutable import scala.reflect.runtime.ReflectionUtils.scalacShouldntLoadClass import scala.reflect.internal.Flags._ diff --git a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala index dc33223f4b..1f2b0952e7 100644 --- a/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala +++ b/src/repl-jline/scala/tools/nsc/interpreter/jline/JLineReader.scala @@ -11,7 +11,7 @@ import java.util.{Collection => JCollection, List => JList} import _root_.jline.{console => jconsole} import jline.console.ConsoleReader -import jline.console.completer.{CompletionHandler, Completer, ArgumentCompleter} +import jline.console.completer.{CompletionHandler, Completer} import jconsole.history.{History => JHistory} diff --git a/src/repl/scala/tools/nsc/MainGenericRunner.scala b/src/repl/scala/tools/nsc/MainGenericRunner.scala index 34057ed341..747b684293 100644 --- a/src/repl/scala/tools/nsc/MainGenericRunner.scala +++ b/src/repl/scala/tools/nsc/MainGenericRunner.scala @@ -6,8 +6,8 @@ package scala package tools.nsc -import io.{ File } -import util.{ ClassPath, ScalaClassLoader } +import io.File +import util.ClassPath import GenericRunnerCommand._ object JarRunner extends CommonRunner { diff --git a/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala b/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala index 8a6a405810..01e3a90950 100644 --- a/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/repl/scala/tools/nsc/interpreter/ExprTyper.scala @@ -6,8 +6,6 @@ package scala.tools.nsc package interpreter -import scala.tools.nsc.ast.parser.Tokens.EOF - trait ExprTyper { val repl: IMain diff --git a/src/repl/scala/tools/nsc/interpreter/ILoop.scala b/src/repl/scala/tools/nsc/interpreter/ILoop.scala index 57ba15e33b..459450a94e 100644 --- a/src/repl/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/repl/scala/tools/nsc/interpreter/ILoop.scala @@ -12,18 +12,17 @@ import Predef.{ println => _, _ } import interpreter.session._ import StdReplTags._ import scala.tools.asm.ClassReader -import scala.util.Properties.{ jdkHome, javaVersion, versionString, javaVmName } -import scala.tools.nsc.util.{ ClassPath, Exceptional, stringFromWriter, stringFromStream } +import scala.util.Properties.jdkHome +import scala.tools.nsc.util.{ ClassPath, stringFromStream } import scala.reflect.classTag import scala.reflect.internal.util.{ BatchSourceFile, ScalaClassLoader } import ScalaClassLoader._ -import scala.reflect.io.{ File, Directory } +import scala.reflect.io.File import scala.tools.util._ import io.AbstractFile -import scala.collection.generic.Clearable -import scala.concurrent.{ ExecutionContext, Await, Future, future } +import scala.concurrent.{ ExecutionContext, Await, Future } import ExecutionContext.Implicits._ -import java.io.{ BufferedReader, FileReader, StringReader } +import java.io.BufferedReader import scala.util.{ Try, Success, Failure } @@ -543,7 +542,6 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) case i => val n = s.take(i).toInt ; (n, s.drop(i+1).toInt - n) } } - import scala.collection.JavaConverters._ val index = (start - 1) max 0 val text = history.asStrings(index, index + len) mkString "\n" edit(text) @@ -906,7 +904,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) // sets in to some kind of reader depending on environmental cues in = in0.fold(chooseReader(settings))(r => SimpleReader(r, out, interactive = true)) - globalFuture = future { + globalFuture = Future { intp.initializeSynchronous() loopPostInit() !intp.reporter.hasErrors diff --git a/src/repl/scala/tools/nsc/interpreter/IMain.scala b/src/repl/scala/tools/nsc/interpreter/IMain.scala index ef6ab4063a..893bde42ab 100644 --- a/src/repl/scala/tools/nsc/interpreter/IMain.scala +++ b/src/repl/scala/tools/nsc/interpreter/IMain.scala @@ -15,19 +15,14 @@ import scala.concurrent.{ Future, ExecutionContext } import scala.reflect.runtime.{ universe => ru } import scala.reflect.{ ClassTag, classTag } import scala.reflect.internal.util.{ BatchSourceFile, SourceFile } -import scala.tools.nsc.interactive -import scala.tools.nsc.reporters.StoreReporter -import scala.tools.nsc.util.ClassPath.DefaultJavaContext import scala.tools.util.PathResolverFactory import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.typechecker.{ TypeStrings, StructuredTypeStrings } import scala.tools.nsc.util._ import ScalaClassLoader.URLClassLoader import scala.tools.nsc.util.Exceptional.unwrap -import scala.tools.nsc.backend.JavaPlatform import javax.script.{AbstractScriptEngine, Bindings, ScriptContext, ScriptEngine, ScriptEngineFactory, ScriptException, CompiledScript, Compilable} import java.net.URL -import java.io.File /** An interpreter for Scala code. * diff --git a/src/repl/scala/tools/nsc/interpreter/Imports.scala b/src/repl/scala/tools/nsc/interpreter/Imports.scala index 5742c1d0d8..6a75432ac6 100644 --- a/src/repl/scala/tools/nsc/interpreter/Imports.scala +++ b/src/repl/scala/tools/nsc/interpreter/Imports.scala @@ -6,13 +6,13 @@ package scala.tools.nsc package interpreter -import scala.collection.{ mutable, immutable } +import scala.collection.mutable trait Imports { self: IMain => import global._ - import definitions.{ ObjectClass, ScalaPackage, JavaLangPackage, PredefModule } + import definitions.{ ScalaPackage, JavaLangPackage, PredefModule } import memberHandlers._ /** Synthetic import handlers for the language defined imports. */ diff --git a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala index 04f4512717..034437fe5c 100644 --- a/src/repl/scala/tools/nsc/interpreter/JavapClass.scala +++ b/src/repl/scala/tools/nsc/interpreter/JavapClass.scala @@ -6,23 +6,23 @@ package scala package tools.nsc package interpreter +import scala.language.reflectiveCalls + import java.lang.{ Iterable => JIterable } -import scala.tools.nsc.util.ScalaClassLoader +import scala.reflect.internal.util.ScalaClassLoader import java.io.{ ByteArrayInputStream, CharArrayWriter, FileNotFoundException, PrintWriter, StringWriter, Writer } import java.util.{ Locale } import java.util.concurrent.ConcurrentLinkedQueue -import javax.tools.{ Diagnostic, DiagnosticCollector, DiagnosticListener, +import javax.tools.{ Diagnostic, DiagnosticListener, ForwardingJavaFileManager, JavaFileManager, JavaFileObject, SimpleJavaFileObject, StandardLocation } -import scala.reflect.io.{ AbstractFile, Directory, File, Path } +import scala.reflect.io.File import scala.io.Source import scala.util.{ Try, Success, Failure } import scala.util.Properties.{ lineSeparator => EOL } -import scala.util.matching.Regex import scala.collection.JavaConverters._ import scala.collection.generic.Clearable import java.net.URL -import scala.language.reflectiveCalls import Javap.{ JpResult, JpError, Showable, helper, toolArgs, DefaultOptions } /** Javap command implementation. @@ -214,7 +214,6 @@ class JavapClass( ) orFailed null class JavaReporter extends DiagnosticListener[JavaFileObject] with Clearable { - import scala.collection.mutable.{ ArrayBuffer, SynchronizedBuffer } type D = Diagnostic[_ <: JavaFileObject] val diagnostics = new ConcurrentLinkedQueue[D] override def report(d: Diagnostic[_ <: JavaFileObject]) { @@ -342,8 +341,6 @@ class JavapClass( } object JavapClass { - import scala.tools.asm.ClassReader - import scala.tools.asm.tree.{ ClassNode, MethodNode } def apply( loader: ScalaClassLoader = ScalaClassLoader.appLoader, diff --git a/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala b/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala index 9f555aee14..8c3b174513 100644 --- a/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala +++ b/src/repl/scala/tools/nsc/interpreter/LoopCommands.scala @@ -8,10 +8,10 @@ package tools package nsc package interpreter -import scala.collection.{ mutable, immutable } -import mutable.ListBuffer import scala.language.implicitConversions +import scala.collection.mutable.ListBuffer + class ProcessResult(val line: String) { import scala.sys.process._ private val buffer = new ListBuffer[String] diff --git a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala index 4e45f6d615..d6c0dafaf2 100644 --- a/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/repl/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -6,9 +6,10 @@ package scala.tools.nsc package interpreter -import scala.collection.{ mutable, immutable } import scala.language.implicitConversions +import scala.collection.mutable + trait MemberHandlers { val intp: IMain diff --git a/src/repl/scala/tools/nsc/interpreter/NamedParam.scala b/src/repl/scala/tools/nsc/interpreter/NamedParam.scala index a0af72940a..d59b07a452 100644 --- a/src/repl/scala/tools/nsc/interpreter/NamedParam.scala +++ b/src/repl/scala/tools/nsc/interpreter/NamedParam.scala @@ -6,10 +6,11 @@ package scala.tools.nsc package interpreter -import NamedParam._ import scala.language.implicitConversions + +import NamedParam._ import scala.reflect.runtime.{universe => ru} -import scala.reflect.{ClassTag, classTag} +import scala.reflect.{ClassTag} import scala.tools.nsc.typechecker.{ TypeStrings } trait NamedParamCreator { diff --git a/src/repl/scala/tools/nsc/interpreter/Phased.scala b/src/repl/scala/tools/nsc/interpreter/Phased.scala index 3dda323762..d1d422ce3e 100644 --- a/src/repl/scala/tools/nsc/interpreter/Phased.scala +++ b/src/repl/scala/tools/nsc/interpreter/Phased.scala @@ -6,7 +6,6 @@ package scala.tools.nsc package interpreter -import scala.collection.immutable import scala.language.implicitConversions /** Mix this into an object and use it as a phasing diff --git a/src/repl/scala/tools/nsc/interpreter/Power.scala b/src/repl/scala/tools/nsc/interpreter/Power.scala index a14a60d216..3c08a03c94 100644 --- a/src/repl/scala/tools/nsc/interpreter/Power.scala +++ b/src/repl/scala/tools/nsc/interpreter/Power.scala @@ -6,14 +6,13 @@ package scala.tools.nsc package interpreter -import scala.collection.{ mutable, immutable } -import scala.util.matching.Regex -import scala.io.Codec -import java.net.{ URL, MalformedURLException } -import io.{ Path } import scala.language.implicitConversions + +import scala.collection.mutable +import scala.io.Codec +import java.net.URL import scala.reflect.runtime.{universe => ru} -import scala.reflect.{ClassTag, classTag} +import scala.reflect.ClassTag /** Collecting some power mode examples. @@ -43,7 +42,7 @@ Lost after 18/flatten { /** A class for methods to be injected into the intp in power mode. */ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, replVals: ReplValsImpl) { - import intp.{ beQuietDuring, typeOfExpression, interpret, parse } + import intp.{ beQuietDuring, parse } import intp.global._ import definitions.{ compilerTypeFromTag, compilerSymbolFromTag} diff --git a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala index 62e12f8703..a912ec9749 100644 --- a/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala +++ b/src/repl/scala/tools/nsc/interpreter/PresentationCompilerCompleter.scala @@ -4,7 +4,6 @@ */ package scala.tools.nsc.interpreter -import scala.reflect.internal.Flags import scala.reflect.internal.util.StringOps import scala.tools.nsc.interpreter.Completion.Candidates import scala.util.control.NonFatal diff --git a/src/repl/scala/tools/nsc/interpreter/RichClass.scala b/src/repl/scala/tools/nsc/interpreter/RichClass.scala index 36cdf65510..df900d1436 100644 --- a/src/repl/scala/tools/nsc/interpreter/RichClass.scala +++ b/src/repl/scala/tools/nsc/interpreter/RichClass.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package interpreter -import scala.reflect.{ ClassTag, classTag } +import scala.reflect.ClassTag class RichClass[T](val clazz: Class[T]) { def toTag: ClassTag[T] = ClassTag[T](clazz) diff --git a/src/repl/scala/tools/nsc/interpreter/session/SimpleHistory.scala b/src/repl/scala/tools/nsc/interpreter/session/SimpleHistory.scala index 504d0d30ee..92bf9d1df4 100644 --- a/src/repl/scala/tools/nsc/interpreter/session/SimpleHistory.scala +++ b/src/repl/scala/tools/nsc/interpreter/session/SimpleHistory.scala @@ -8,7 +8,6 @@ package interpreter package session import scala.collection.mutable.{ Buffer, ListBuffer } -import scala.collection.JavaConverters._ class SimpleHistory extends History { private var _index: Int = 0 diff --git a/src/scaladoc/scala/tools/ant/Scaladoc.scala b/src/scaladoc/scala/tools/ant/Scaladoc.scala index 034416e844..b38aadd328 100644 --- a/src/scaladoc/scala/tools/ant/Scaladoc.scala +++ b/src/scaladoc/scala/tools/ant/Scaladoc.scala @@ -6,7 +6,6 @@ ** |/ ** \* */ - package scala.tools.ant import java.io.File @@ -15,9 +14,8 @@ import org.apache.tools.ant.Project import org.apache.tools.ant.types.{Path, Reference} import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper} -import scala.tools.nsc.Global import scala.tools.nsc.doc.Settings -import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} +import scala.tools.nsc.reporters.ConsoleReporter /** An Ant task to document Scala code. * diff --git a/src/scaladoc/scala/tools/nsc/ScalaDoc.scala b/src/scaladoc/scala/tools/nsc/ScalaDoc.scala index 32a6ba0ce3..bd00c27f7b 100644 --- a/src/scaladoc/scala/tools/nsc/ScalaDoc.scala +++ b/src/scaladoc/scala/tools/nsc/ScalaDoc.scala @@ -6,7 +6,6 @@ package scala.tools.nsc -import java.io.File.pathSeparator import scala.tools.nsc.doc.DocFactory import scala.tools.nsc.reporters.ConsoleReporter import scala.reflect.internal.util.FakePos diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala index 4b40d25c17..10bfe6f94b 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocGlobal.scala @@ -6,11 +6,7 @@ package scala.tools.nsc package doc -import scala.tools.nsc.ast.parser.{ SyntaxAnalyzer, BracePatch } import reporters.Reporter -import typechecker.Analyzer -import scala.reflect.internal.util.{ BatchSourceFile, RangePosition } - trait ScaladocGlobalTrait extends Global { outer => diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala index 6cdd99c9ee..c177251dd9 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala @@ -15,7 +15,7 @@ import model._ import scala.xml.NodeSeq import scala.xml.Elem -import scala.xml.dtd.{DocType, PublicID} +import scala.xml.dtd.DocType import scala.collection._ import java.io.Writer @@ -245,10 +245,10 @@ abstract class HtmlPage extends Page { thisPage => Permalink - - def docEntityKindToCompanionTitle(ety: DocTemplateEntity, baseString: String = "See companion") = + + def docEntityKindToCompanionTitle(ety: DocTemplateEntity, baseString: String = "See companion") = ety.companion match{ - case Some(companion) => + case Some(companion) => s"$baseString${ if(companion.isObject) " object" else if(companion.isTrait) " trait" diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala index 0353e58e67..e4f5a1e775 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Template.scala @@ -15,7 +15,7 @@ import base.comment._ import model._ import model.diagram._ -import scala.xml.{Elem, NodeSeq, Text, UnprefixedAttribute} +import scala.xml.{NodeSeq, Text, UnprefixedAttribute} import scala.language.postfixOps import scala.collection.mutable. { Set, HashSet } diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala index cf65de4151..829bba3f32 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DiagramGenerator.scala @@ -23,5 +23,5 @@ trait DiagramGenerator { * @param p The page the diagram will be embedded in (needed for link generation) * @return The HTML to be embedded in the Scaladoc page */ - def generate(d: Diagram, t: DocTemplateEntity, p: HtmlPage):NodeSeq + def generate(d: Diagram, t: DocTemplateEntity, p: HtmlPage): NodeSeq } diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala index 4c0ba32856..41cb812378 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/diagram/DotDiagramGenerator.scala @@ -10,7 +10,7 @@ package html package page package diagram -import scala.xml.{NodeSeq, XML, PrefixedAttribute, Elem, MetaData, Null, UnprefixedAttribute} +import scala.xml.{NodeSeq, PrefixedAttribute, Elem, Null, UnprefixedAttribute} import scala.collection.immutable._ import model._ import model.diagram._ diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala index 3432e5e150..bccb65aa5f 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala @@ -9,11 +9,9 @@ import base.comment._ import diagram._ import scala.collection._ -import scala.tools.nsc.doc.html.HtmlPage import scala.tools.nsc.doc.html.page.diagram.{DotRunner} import scala.util.matching.Regex import scala.reflect.macros.internal.macroImpl -import scala.xml.NodeSeq import symtab.Flags import io._ @@ -30,8 +28,8 @@ class ModelFactory(val global: Global, val settings: doc.Settings) { with MemberLookup => import global._ - import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass, ListClass } - import rootMirror.{ RootPackage, RootClass, EmptyPackage } + import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass } + import rootMirror.{ RootPackage, EmptyPackage } // Defaults for member grouping, that may be overridden by the template val defaultGroup = "Ungrouped" diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index db39d059d7..0264f2f99f 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -11,7 +11,6 @@ package doc package model import scala.collection._ -import symtab.Flags /** * This trait finds implicit conversions for a class in the default scope and creates scaladoc entries for each of them. diff --git a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala index 45745b5f55..9b04125cc5 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/ModelFactoryTypeSupport.scala @@ -20,7 +20,7 @@ trait ModelFactoryTypeSupport { with MemberLookup => import global._ - import definitions.{ ObjectClass, NothingClass, AnyClass, AnyValClass, AnyRefClass } + import definitions.{ ObjectClass, AnyClass, AnyRefClass } protected val typeCache = new mutable.LinkedHashMap[Type, TypeEntity] diff --git a/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala index c1228e8735..27668a6040 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/TreeFactory.scala @@ -3,7 +3,7 @@ package doc package model import scala.collection._ -import scala.reflect.internal.util.{RangePosition, OffsetPosition, SourceFile} +import scala.reflect.internal.util.{RangePosition, SourceFile} /** The goal of this trait is , using makeTree, * to browse a tree to diff --git a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala index b300752a34..3b7eb4e947 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramDirectiveParser.scala @@ -3,7 +3,7 @@ package model package diagram import model._ -import java.util.regex.{Pattern, Matcher} +import java.util.regex.Pattern import scala.util.matching.Regex /** diff --git a/src/scaladoc/scala/tools/partest/ScaladocModelTest.scala b/src/scaladoc/scala/tools/partest/ScaladocModelTest.scala index fa3e8ff5cb..1ad3b3ff2b 100644 --- a/src/scaladoc/scala/tools/partest/ScaladocModelTest.scala +++ b/src/scaladoc/scala/tools/partest/ScaladocModelTest.scala @@ -5,7 +5,6 @@ package scala.tools.partest -import scala.tools.nsc import scala.tools.nsc._ import scala.tools.cmd.CommandLineParser import scala.tools.nsc.doc.{ DocFactory, Universe } diff --git a/src/scalap/scala/tools/scalap/Decode.scala b/src/scalap/scala/tools/scalap/Decode.scala index 310d6117e6..8e63c7f47f 100644 --- a/src/scalap/scala/tools/scalap/Decode.scala +++ b/src/scalap/scala/tools/scalap/Decode.scala @@ -10,12 +10,12 @@ package scala.tools.scalap import scala.tools.scalap.scalax.rules.scalasig._ -import scala.tools.nsc.util.ScalaClassLoader -import scala.tools.nsc.util.ScalaClassLoader.appLoader +import scala.reflect.internal.util.ScalaClassLoader +import scala.reflect.internal.util.ScalaClassLoader.appLoader import scala.reflect.internal.pickling.ByteCodecs import ClassFileParser.{ ConstValueIndex, Annotation } -import Main.{ SCALA_SIG, SCALA_SIG_ANNOTATION, BYTES_VALUE } +import Main.{ SCALA_SIG_ANNOTATION, BYTES_VALUE } /** Temporary decoder. This would be better off in the scala.tools.nsc * but right now the compiler won't acknowledge scala.tools.scalap diff --git a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala index f490d9490a..a80d1a27a1 100644 --- a/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala +++ b/test/files/scalacheck/parallel-collections/ParallelRangeCheck.scala @@ -27,7 +27,7 @@ class ParallelRangeCheck(val tasksupport: TaskSupport) extends ParallelSeqCheck[ def isCheckingViews = false - def ofSize(vals: Seq[Gen[Int]], sz: Int) = unsupported + def ofSize(vals: Seq[Gen[Int]], sz: Int) = throw new UnsupportedOperationException override def instances(vals: Seq[Gen[Int]]): Gen[Seq[Int]] = sized { start => sized { end => -- cgit v1.2.3 From a3e62cc194699254aa689030b155a29af8356619 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 19 Jan 2016 15:30:51 +0100 Subject: SD-70 Don't share footnotes across multiple calls to universe.showRaw Before this commit, multiple invocations of universe.showRaw used a shared weak map that caches footnotes. If the two printed objects have equal components printed as footnotes, e.g., an equal TypeRef, the result of the second invocation depends on whether the object has been collected (and removed from the weak map) or not. See https://github.com/scala/scala-dev/issues/70#issuecomment-171701671 --- src/reflect/scala/reflect/api/Printers.scala | 2 +- src/reflect/scala/reflect/internal/Printers.scala | 48 +++++++++++------------ test/files/run/showraw_tree_types_ids.check | 8 ++-- test/files/run/showraw_tree_types_typed.check | 8 ++-- test/files/run/showraw_tree_ultimate.check | 8 ++-- 5 files changed, 36 insertions(+), 38 deletions(-) (limited to 'src/reflect/scala') diff --git a/src/reflect/scala/reflect/api/Printers.scala b/src/reflect/scala/reflect/api/Printers.scala index c0abc5120c..257dd6c43e 100644 --- a/src/reflect/scala/reflect/api/Printers.scala +++ b/src/reflect/scala/reflect/api/Printers.scala @@ -232,7 +232,7 @@ trait Printers { self: Universe => * @group Printers */ def showRaw(any: Any, printTypes: BooleanFlag = None, printIds: BooleanFlag = None, printOwners: BooleanFlag = None, printKinds: BooleanFlag = None, printMirrors: BooleanFlag = None, printPositions: BooleanFlag = None): String = - render(any, newRawTreePrinter(_), printTypes, printIds, printOwners, printKinds, printMirrors, printPositions) + render(any, newRawTreePrinter, printTypes, printIds, printOwners, printKinds, printMirrors, printPositions) /** Hook to define what `showRaw(...)` means. * @group Printers diff --git a/src/reflect/scala/reflect/internal/Printers.scala b/src/reflect/scala/reflect/internal/Printers.scala index 8fb7a0c1d0..37b99c4345 100644 --- a/src/reflect/scala/reflect/internal/Printers.scala +++ b/src/reflect/scala/reflect/internal/Printers.scala @@ -1134,11 +1134,12 @@ trait Printers extends api.Printers { self: SymbolTable => def newRawTreePrinter(writer: PrintWriter): RawTreePrinter = new RawTreePrinter(writer) // provides footnotes for types and mirrors - import scala.collection.mutable.{Map, WeakHashMap, SortedSet} - private val footnoteIndex = new FootnoteIndex - private class FootnoteIndex { + private class Footnotes { + import scala.collection.mutable.{Map, WeakHashMap, SortedSet} + private val index = Map[Class[_], WeakHashMap[Any, Int]]() private def classIndex[T: ClassTag] = index.getOrElseUpdate(classTag[T].runtimeClass, WeakHashMap[Any, Int]()) + private val counters = Map[Class[_], Int]() private def nextCounter[T: ClassTag] = { val clazz = classTag[T].runtimeClass @@ -1147,29 +1148,26 @@ trait Printers extends api.Printers { self: SymbolTable => counters(clazz) } - def mkFootnotes() = new Footnotes - class Footnotes { - private val footnotes = Map[Class[_], SortedSet[Int]]() - private def classFootnotes[T: ClassTag] = footnotes.getOrElseUpdate(classTag[T].runtimeClass, SortedSet[Int]()) + private val footnotes = Map[Class[_], SortedSet[Int]]() + private def classFootnotes[T: ClassTag] = footnotes.getOrElseUpdate(classTag[T].runtimeClass, SortedSet[Int]()) - def put[T: ClassTag](any: T): Int = { - val index = classIndex[T].getOrElseUpdate(any, nextCounter[T]) - classFootnotes[T] += index - index - } + def put[T: ClassTag](any: T): Int = { + val index = classIndex[T].getOrElseUpdate(any, nextCounter[T]) + classFootnotes[T] += index + index + } - def get[T: ClassTag]: List[(Int, Any)] = - classFootnotes[T].toList map (fi => (fi, classIndex[T].find{ case (any, ii) => ii == fi }.get._1)) - - def print[T: ClassTag](printer: Printers.super.TreePrinter): Unit = { - val footnotes = get[T] - if (footnotes.nonEmpty) { - printer.print(EOL) - footnotes.zipWithIndex foreach { - case ((fi, any), ii) => - printer.print("[", fi, "] ", any) - if (ii < footnotes.length - 1) printer.print(EOL) - } + def get[T: ClassTag]: List[(Int, Any)] = + classFootnotes[T].toList map (fi => (fi, classIndex[T].find{ case (any, ii) => ii == fi }.get._1)) + + def print[T: ClassTag](printer: Printers.super.TreePrinter): Unit = { + val footnotes = get[T] + if (footnotes.nonEmpty) { + printer.print(EOL) + footnotes.zipWithIndex foreach { + case ((fi, any), ii) => + printer.print("[", fi, "] ", any) + if (ii < footnotes.length - 1) printer.print(EOL) } } } @@ -1180,7 +1178,7 @@ trait Printers extends api.Printers { self: SymbolTable => private var depth = 0 private var printTypesInFootnotes = true private var printingFootnotes = false - private val footnotes = footnoteIndex.mkFootnotes() + private val footnotes = new Footnotes() def print(args: Any*): Unit = { // don't print type footnotes if the argument is a mere type diff --git a/test/files/run/showraw_tree_types_ids.check b/test/files/run/showraw_tree_types_ids.check index 75347463cb..e122148040 100644 --- a/test/files/run/showraw_tree_types_ids.check +++ b/test/files/run/showraw_tree_types_ids.check @@ -4,9 +4,9 @@ Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](sca [3] TypeRef(ThisType(scala.collection.immutable#), scala.collection.immutable.HashMap#, List()) [4] TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()) [5] SingleType(ThisType(scala#), scala.Predef#) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap#), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#), TypeName("String")#)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#), TypeName("String")#)))))), termNames.CONSTRUCTOR#), List()) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.mutable.HashMap#), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#), TypeName("String")#)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef#), TypeName("String")#)))))), termNames.CONSTRUCTOR#), List()) +[1] TypeRef(ThisType(scala.collection.mutable#), scala.collection.mutable.HashMap#, List(TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()), TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#), scala.collection.mutable.HashMap#, List(TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()), TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List())))) +[3] TypeRef(ThisType(scala.collection.mutable#), scala.collection.mutable.HashMap#, List()) [4] TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()) [5] SingleType(ThisType(scala#), scala.Predef#) -[6] TypeRef(ThisType(scala.collection.mutable#), scala.collection.mutable.HashMap#, List(TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()), TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable#), scala.collection.mutable.HashMap#, List(TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List()), TypeRef(SingleType(ThisType(scala#), scala.Predef#), TypeName("String")#, List())))) -[8] TypeRef(ThisType(scala.collection.mutable#), scala.collection.mutable.HashMap#, List()) diff --git a/test/files/run/showraw_tree_types_typed.check b/test/files/run/showraw_tree_types_typed.check index de691e369e..4934ed41dc 100644 --- a/test/files/run/showraw_tree_types_typed.check +++ b/test/files/run/showraw_tree_types_typed.check @@ -4,9 +4,9 @@ Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](sca [3] TypeRef(ThisType(scala.collection.immutable), scala.collection.immutable.HashMap, List()) [4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) [5] SingleType(ThisType(scala), scala.Predef) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), termNames.CONSTRUCTOR), List()) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.mutable.HashMap), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef), TypeName("String"))))))), termNames.CONSTRUCTOR), List()) +[1] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) +[3] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) [4] TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()) [5] SingleType(ThisType(scala), scala.Predef) -[6] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List(TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List()), TypeRef(SingleType(ThisType(scala), scala.Predef), TypeName("String"), List())))) -[8] TypeRef(ThisType(scala.collection.mutable), scala.collection.mutable.HashMap, List()) diff --git a/test/files/run/showraw_tree_ultimate.check b/test/files/run/showraw_tree_ultimate.check index 81efcc05ab..b94d568a75 100644 --- a/test/files/run/showraw_tree_ultimate.check +++ b/test/files/run/showraw_tree_ultimate.check @@ -4,9 +4,9 @@ Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](sca [3] TypeRef(ThisType(scala.collection.immutable##PKC), scala.collection.immutable.HashMap##CLS, List()) [4] TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()) [5] SingleType(ThisType(scala##PKC), scala.Predef##MOD) -Apply[6](Select[7](New[6](TypeTree[6]().setOriginal(AppliedTypeTree(Ident[8](scala.collection.mutable.HashMap##CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef##MOD), TypeName("String")##TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef##MOD), TypeName("String")##TPE)))))), termNames.CONSTRUCTOR##CTOR), List()) +Apply[1](Select[2](New[1](TypeTree[1]().setOriginal(AppliedTypeTree(Ident[3](scala.collection.mutable.HashMap##CLS), List(TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef##MOD), TypeName("String")##TPE)), TypeTree[4]().setOriginal(Select[4](Ident[5](scala.Predef##MOD), TypeName("String")##TPE)))))), termNames.CONSTRUCTOR##CTOR), List()) +[1] TypeRef(ThisType(scala.collection.mutable##PKC), scala.collection.mutable.HashMap##CLS, List(TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()), TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()))) +[2] MethodType(List(), TypeRef(ThisType(scala.collection.mutable##PKC), scala.collection.mutable.HashMap##CLS, List(TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()), TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List())))) +[3] TypeRef(ThisType(scala.collection.mutable##PKC), scala.collection.mutable.HashMap##CLS, List()) [4] TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()) [5] SingleType(ThisType(scala##PKC), scala.Predef##MOD) -[6] TypeRef(ThisType(scala.collection.mutable##PKC), scala.collection.mutable.HashMap##CLS, List(TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()), TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()))) -[7] MethodType(List(), TypeRef(ThisType(scala.collection.mutable##PKC), scala.collection.mutable.HashMap##CLS, List(TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List()), TypeRef(SingleType(ThisType(scala##PKC), scala.Predef##MOD), TypeName("String")##TPE, List())))) -[8] TypeRef(ThisType(scala.collection.mutable##PKC), scala.collection.mutable.HashMap##CLS, List()) -- cgit v1.2.3