diff --git a/compiler/sjs/backend/sjs/JSCodeGen.scala b/compiler/sjs/backend/sjs/JSCodeGen.scala index 09f6d07b563e..1d6c538e6fdc 100644 --- a/compiler/sjs/backend/sjs/JSCodeGen.scala +++ b/compiler/sjs/backend/sjs/JSCodeGen.scala @@ -1704,7 +1704,7 @@ class JSCodeGen()(implicit ctx: Context) { nme.UNARY_! -> js.JSUnaryOp.! ) - def unapply(name: Names.TermName): Option[js.JSUnaryOp.Code] = + def unapply(name: TermName): Option[js.JSUnaryOp.Code] = map.get(name) } @@ -1732,7 +1732,7 @@ class JSCodeGen()(implicit ctx: Context) { nme.ZOR -> js.JSBinaryOp.|| ) - def unapply(name: Names.TermName): Option[js.JSBinaryOp.Code] = + def unapply(name: TermName): Option[js.JSBinaryOp.Code] = map.get(name) } diff --git a/compiler/sjs/backend/sjs/JSEncoding.scala b/compiler/sjs/backend/sjs/JSEncoding.scala index e8ea3258bfa2..8644cdaf5760 100644 --- a/compiler/sjs/backend/sjs/JSEncoding.scala +++ b/compiler/sjs/backend/sjs/JSEncoding.scala @@ -39,11 +39,11 @@ object JSEncoding { private final val ScalaJSEnvironmentName = "ScalaJS" implicit class SymOps(val self: Symbol) extends AnyVal { - def unexpandedName(implicit ctx: Context): Names.Name = + def unexpandedName(implicit ctx: Context): Name = self.name.unexpandedName } - implicit class MyNameOps(val self: Names.Name) extends AnyVal { + implicit class MyNameOps(val self: Name) extends AnyVal { def decoded: String = self.decode.toString } diff --git a/compiler/sjs/backend/sjs/JSPositions.scala b/compiler/sjs/backend/sjs/JSPositions.scala index 10570da00129..019b87f32818 100644 --- a/compiler/sjs/backend/sjs/JSPositions.scala +++ b/compiler/sjs/backend/sjs/JSPositions.scala @@ -11,7 +11,7 @@ import org.scalajs.core.ir class JSPositions()(implicit ctx: Context) { /** Implicit conversion from dotty Position to ir.Position. */ - implicit def pos2irPos(pos: Positions.Position): ir.Position = { + implicit def pos2irPos(pos: Position): ir.Position = { if (!pos.exists) ir.Position.NoPosition else { val source = pos2irPosCache.toIRSource(ctx.compilationUnit.source) @@ -23,7 +23,7 @@ class JSPositions()(implicit ctx: Context) { /** Implicitly materializes an ir.Position from an implicit dotty Position. */ implicit def implicitPos2irPos( - implicit pos: Positions.Position): ir.Position = { + implicit pos: Position): ir.Position = { pos2irPos(pos) } diff --git a/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala b/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala index 8e7cfc688724..a2d178e70c49 100644 --- a/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala +++ b/compiler/src/dotty/tools/backend/jvm/CollectEntryPoints.scala @@ -5,30 +5,15 @@ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Types import dotty.tools.dotc.transform.MegaPhase._ import dotty.tools.dotc.ast.tpd -import dotty.tools.dotc -import dotty.tools.dotc.core.Flags.FlagSet -import dotty.tools.dotc.transform.Erasure -import dotty.tools.dotc.transform.SymUtils._ -import java.io.{File => JFile} +import java.io.{File => _} -import scala.collection.generic.Clearable -import scala.collection.mutable -import scala.reflect.ClassTag -import dotty.tools.io.{Directory, PlainDirectory, AbstractFile} -import scala.tools.asm.{ClassVisitor, FieldVisitor, MethodVisitor} -import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface} import dotty.tools.dotc.core._ -import Periods._ import SymDenotations._ import Contexts._ import Types._ import Symbols._ -import Denotations._ -import Phases._ -import java.lang.AssertionError import dotty.tools.dotc.util.Positions.Position import Decorators._ -import tpd._ import StdNames.nme /** @@ -46,7 +31,7 @@ class CollectEntryPoints extends MiniPhase { } object CollectEntryPoints{ - def isJavaMainMethod(sym: Symbol)(implicit ctx: Context) = { + def isJavaMainMethod(sym: Symbol)(implicit ctx: Context): Boolean = { (sym.name == nme.main) && (sym.info match { case r@MethodTpe(_, List(defn.ArrayOf(t)), _) => (t.widenDealias =:= defn.StringType) && ( @@ -56,7 +41,6 @@ object CollectEntryPoints{ } def isJavaEntryPoint(sym: Symbol)(implicit ctx: Context): Boolean = { - import Types.MethodType val d = ctx.definitions val StringType = d.StringType // The given class has a main method. diff --git a/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala b/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala index cabc51c394bf..8e646b5b7d81 100644 --- a/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala +++ b/compiler/src/dotty/tools/backend/jvm/CollectSuperCalls.scala @@ -1,7 +1,6 @@ package dotty.tools.backend.jvm import dotty.tools.dotc.ast.tpd -import dotty.tools.dotc.ast.Trees._ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.core.Flags.Trait diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala index 8114a00f80a9..d1b4f2d52f68 100644 --- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala +++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala @@ -6,37 +6,29 @@ import dotty.tools.dotc import dotty.tools.dotc.core.Flags.FlagSet import dotty.tools.dotc.transform.{Erasure, GenericSignatures} import dotty.tools.dotc.transform.SymUtils._ -import java.io.{File => JFile} +import java.io.{File => _} import scala.collection.generic.Clearable import scala.collection.mutable import scala.reflect.ClassTag import scala.reflect.internal.util.WeakHashSet -import dotty.tools.io.{AbstractFile, Directory, PlainDirectory} -import scala.tools.asm.{AnnotationVisitor, ClassVisitor, FieldVisitor, MethodVisitor} +import dotty.tools.io.AbstractFile +import scala.tools.asm.AnnotationVisitor import scala.tools.nsc.backend.jvm.{BCodeHelpers, BackendInterface} import dotty.tools.dotc.core._ -import Periods._ -import SymDenotations._ import Contexts._ import Types._ import Symbols._ -import Denotations._ import Phases._ -import java.lang.AssertionError -import dotty.tools.dotc.util.{DotClass, Positions} +import dotty.tools.dotc.util.Positions import Decorators._ import tpd._ import scala.tools.asm import StdNames.{nme, str} -import NameOps._ import NameKinds.{DefaultGetterName, ExpandedName} -import dotty.tools.dotc.core -import dotty.tools.dotc.core.Names.TypeName - -import scala.annotation.tailrec +import Names.TermName class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Map[Symbol, Set[ClassSymbol]])(implicit ctx: Context) extends BackendInterface{ import Symbols.{toDenot, toClassDenot} @@ -84,7 +76,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma type LabelDef = tpd.DefDef type Closure = tpd.Closure - val NoSymbol = Symbols.NoSymbol + val NoSymbol: Symbol = Symbols.NoSymbol val NoPosition: Position = Positions.NoPosition val EmptyTree: Tree = tpd.EmptyTree @@ -112,11 +104,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma val nme_EQEQ_LOCAL_VAR: Name = StdNames.nme.EQEQ_LOCAL_VAR // require LambdaMetafactory: scalac uses getClassIfDefined, but we need those always. - override lazy val LambdaMetaFactory = ctx.requiredClass("java.lang.invoke.LambdaMetafactory") - override lazy val MethodHandle = ctx.requiredClass("java.lang.invoke.MethodHandle") + override lazy val LambdaMetaFactory: ClassSymbol = ctx.requiredClass("java.lang.invoke.LambdaMetafactory") + override lazy val MethodHandle: ClassSymbol = ctx.requiredClass("java.lang.invoke.MethodHandle") val nme_valueOf: Name = StdNames.nme.valueOf - val nme_apply = StdNames.nme.apply + val nme_apply: TermName = StdNames.nme.apply val NothingClass: Symbol = defn.NothingClass val NullClass: Symbol = defn.NullClass val ObjectClass: Symbol = defn.ObjectClass @@ -136,7 +128,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma val LongClass: Symbol = defn.LongClass val FloatClass: Symbol = defn.FloatClass val DoubleClass: Symbol = defn.DoubleClass - def isArrayClone(tree: Tree) = tree match { + def isArrayClone(tree: Tree): Boolean = tree match { case Select(qual, StdNames.nme.clone_) if qual.tpe.widen.isInstanceOf[JavaArrayType] => true case _ => false } @@ -154,11 +146,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma val String_valueOf: Symbol = defn.String_valueOf_Object lazy val Predef_classOf: Symbol = defn.ScalaPredefModule.requiredMethod(nme.classOf) - lazy val AnnotationRetentionAttr = ctx.requiredClass("java.lang.annotation.Retention") - lazy val AnnotationRetentionSourceAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("SOURCE") - lazy val AnnotationRetentionClassAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("CLASS") - lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("RUNTIME") - lazy val JavaAnnotationClass = ctx.requiredClass("java.lang.annotation.Annotation") + lazy val AnnotationRetentionAttr: ClassSymbol = ctx.requiredClass("java.lang.annotation.Retention") + lazy val AnnotationRetentionSourceAttr: TermSymbol = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("SOURCE") + lazy val AnnotationRetentionClassAttr: TermSymbol = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("CLASS") + lazy val AnnotationRetentionRuntimeAttr: TermSymbol = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("RUNTIME") + lazy val JavaAnnotationClass: ClassSymbol = ctx.requiredClass("java.lang.annotation.Annotation") def boxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses().map{x => // @darkdimius Are you sure this should be a def? (x, Erasure.Boxing.boxMethod(x.asClass)) @@ -166,7 +158,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma def unboxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses().map(x => (x, Erasure.Boxing.unboxMethod(x.asClass))).toMap - override def isSyntheticArrayConstructor(s: Symbol) = { + override def isSyntheticArrayConstructor(s: Symbol): Boolean = { s eq defn.newArrayMethod } @@ -317,7 +309,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } override def emitAnnotations(cw: asm.ClassVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers) - (innerClasesStore: bcodeStore.BCInnerClassGen) = { + (innerClasesStore: bcodeStore.BCInnerClassGen): Unit = { for(annot <- annotations; if shouldEmitAnnotation(annot)) { val typ = annot.atp val assocs = annot.assocs @@ -334,7 +326,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } override def emitAnnotations(mw: asm.MethodVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers) - (innerClasesStore: bcodeStore.BCInnerClassGen) = { + (innerClasesStore: bcodeStore.BCInnerClassGen): Unit = { for(annot <- annotations; if shouldEmitAnnotation(annot)) { val typ = annot.atp val assocs = annot.assocs @@ -344,7 +336,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } override def emitAnnotations(fw: asm.FieldVisitor, annotations: List[Annotation], bcodeStore: BCodeHelpers) - (innerClasesStore: bcodeStore.BCInnerClassGen) = { + (innerClasesStore: bcodeStore.BCInnerClassGen): Unit = { for(annot <- annotations; if shouldEmitAnnotation(annot)) { val typ = annot.atp val assocs = annot.assocs @@ -400,7 +392,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma def emitAsmp: Option[String] = None - def shouldEmitJumpAfterLabels = true + def shouldEmitJumpAfterLabels: Boolean = true def dumpClasses: Option[String] = if (ctx.settings.Ydumpclasses.isDefault) None @@ -428,7 +420,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma val MODULE_INSTANCE_FIELD: String = str.MODULE_INSTANCE_FIELD - def dropModule(str: String) = + def dropModule(str: String): String = if (!str.isEmpty && str.last == '$') str.take(str.length - 1) else str def newTermName(prefix: String): Name = prefix.toTermName @@ -479,7 +471,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } // todo: remove - def isMaybeBoxed(sym: Symbol) = { + def isMaybeBoxed(sym: Symbol): Boolean = { (sym == ObjectClass) || (sym == JavaSerializableClass) || (sym == defn.ComparableClass) || @@ -1055,13 +1047,13 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma // todo: this product1s should also eventually become name-based pattn matching object Literal extends LiteralDeconstructor { - def get = field.const + def get: Constant = field.const } object Throw extends ThrowDeconstructor { - def get = field.args.head + def get: Tree = field.args.head - override def unapply(s: Throw): DottyBackendInterface.this.Throw.type = { + override def unapply(s: Throw): Throw.type = { if (s.fun.symbol eq defn.throwMethod) { field = s } else { @@ -1072,11 +1064,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } object New extends NewDeconstructor { - def get = field.tpt.tpe + def get: Type = field.tpt.tpe } object This extends ThisDeconstructor { - def get = field.qual.name + def get: Name = field.qual.name def apply(s: Symbol): This = tpd.This(s.asClass) } @@ -1096,15 +1088,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } object Ident extends IdentDeconstructor { - def get = field.name + def get: Name = field.name } object Alternative extends AlternativeDeconstructor { - def get = field.trees + def get: List[Tree] = field.trees } object Constant extends ConstantDeconstructor { - def get = field.value + def get: Any = field.value } object ThrownException extends ThrownException { def unapply(a: Annotation): Option[Symbol] = None // todo @@ -1121,7 +1113,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma def _2: List[Symbol] = field.vparamss.flatMap(_.map(_.symbol)) def _3: Tree = field.rhs - override def unapply(s: LabelDef): DottyBackendInterface.this.LabelDef.type = { + override def unapply(s: LabelDef): LabelDef.type = { if (s.symbol is Flags.Label) this.field = s else this.field = null this @@ -1199,9 +1191,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } object Closure extends ClosureDeconstructor { - def _1 = field.env - def _2 = field.meth - def _3 = { + def _1: List[Tree] = field.env + def _2: Tree = field.meth + def _3: Symbol = { val t = field.tpt.tpe.typeSymbol if (t.exists) t else { @@ -1214,5 +1206,5 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma } } - def currentUnit = ctx.compilationUnit + def currentUnit: CompilationUnit = ctx.compilationUnit } diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala index ffae0c29ff7f..fe5d3c08aa8a 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala @@ -10,6 +10,7 @@ import scala.tools.asm.CustomAttr import scala.tools.nsc.backend.jvm._ import dotty.tools.dotc.transform.SymUtils._ import dotty.tools.dotc.interfaces +import dotty.tools.dotc.util.SourceFile import java.util.Optional import dotty.tools.dotc.core._ @@ -20,22 +21,21 @@ import Decorators._ import java.io.DataOutputStream -import dotty.tools.io.Directory import scala.tools.asm import scala.tools.asm.tree._ import tpd._ import StdNames._ -import dotty.tools.dotc.core.tasty.{TastyBuffer, TastyHeaderUnpickler, TastyPickler} +import dotty.tools.dotc.core.tasty.{TastyBuffer, TastyHeaderUnpickler} import dotty.tools.io._ class GenBCode extends Phase { def phaseName: String = GenBCode.name private val entryPoints = new mutable.HashSet[Symbol]() - def registerEntryPoint(sym: Symbol) = entryPoints += sym + def registerEntryPoint(sym: Symbol): Unit = entryPoints += sym private val superCallsMap = newMutableSymbolMap[Set[ClassSymbol]] - def registerSuperCall(sym: Symbol, calls: ClassSymbol) = { + def registerSuperCall(sym: Symbol, calls: ClassSymbol): Unit = { val old = superCallsMap.getOrElse(sym, Set.empty) superCallsMap.update(sym, old + calls) } @@ -54,7 +54,7 @@ class GenBCode extends Phase { entryPoints.clear() } - override def runOn(units: List[CompilationUnit])(implicit ctx: Context) = { + override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = { try super.runOn(units) finally myOutput match { case jar: JarArchive => @@ -70,9 +70,9 @@ object GenBCode { class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInterface)(implicit val ctx: Context) extends BCodeSyncAndTry { - var tree: Tree = _ + private[this] var tree: Tree = _ - val sourceFile = ctx.compilationUnit.source + private[this] val sourceFile: SourceFile = ctx.compilationUnit.source /** Convert a `dotty.tools.io.AbstractFile` into a * `dotty.tools.dotc.interfaces.AbstractFile`. @@ -95,7 +95,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter /* ---------------- q1 ---------------- */ case class Item1(arrivalPos: Int, cd: TypeDef, cunit: CompilationUnit) { - def isPoison = { arrivalPos == Int.MaxValue } + def isPoison: Boolean = { arrivalPos == Int.MaxValue } } private val poison1 = Item1(Int.MaxValue, null, ctx.compilationUnit) private val q1 = new java.util.LinkedList[Item1] @@ -108,7 +108,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter case class Item2(arrivalPos: Int, mirror: SubItem2, plain: SubItem2) { - def isPoison = { arrivalPos == Int.MaxValue } + def isPoison: Boolean = { arrivalPos == Int.MaxValue } } private val poison2 = Item2(Int.MaxValue, null, null) @@ -133,7 +133,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter mirror: SubItem3, plain: SubItem3) { - def isPoison = { arrivalPos == Int.MaxValue } + def isPoison: Boolean = { arrivalPos == Int.MaxValue } } private val i3comparator = new java.util.Comparator[Item3] { override def compare(a: Item3, b: Item3) = { @@ -192,7 +192,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter * enqueues them in queue-2. * */ - def visit(item: Item1) = { + def visit(item: Item1): Boolean = { val Item1(arrivalPos, cd, cunit) = item val claszSymbol = cd.symbol @@ -351,7 +351,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter } // end of class BCodePhase.Worker2 - var arrivalPos = 0 + var arrivalPos: Int = 0 /* * A run of the BCodePhase phase comprises: @@ -364,7 +364,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter * (c) tear down (closing the classfile-writer and clearing maps) * */ - def run(t: Tree) = { + def run(t: Tree): Unit = { this.tree = t // val bcodeStart = Statistics.startTimer(BackendStats.bcodeTimer) diff --git a/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala b/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala index b898e9496fe9..451ef95c288a 100644 --- a/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala +++ b/compiler/src/dotty/tools/backend/jvm/LabelDefs.scala @@ -6,7 +6,6 @@ import dotty.tools.dotc.core.Flags._ import dotty.tools.dotc.core.Symbols._ import dotty.tools.dotc.transform.MegaPhase._ -import scala.collection.mutable /** * Verifies that each Label DefDef has only a single address to jump back and diff --git a/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala b/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala index fed7aeb81f63..66c247167ed8 100644 --- a/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala +++ b/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala @@ -14,7 +14,7 @@ import Names.TermName, StdNames._ import Types.{JavaArrayType, UnspecifiedErrorType, Type} import Symbols.{Symbol, NoSymbol} -import scala.collection.{ mutable, immutable } +import scala.collection.immutable /** Scala primitive operations are represented as methods in `Any` and diff --git a/compiler/src/dotty/tools/dotc/CompilationUnit.scala b/compiler/src/dotty/tools/dotc/CompilationUnit.scala index 210894277f92..4cbd228c02a2 100644 --- a/compiler/src/dotty/tools/dotc/CompilationUnit.scala +++ b/compiler/src/dotty/tools/dotc/CompilationUnit.scala @@ -12,13 +12,13 @@ import dotty.tools.dotc.transform.SymUtils._ class CompilationUnit(val source: SourceFile) { - override def toString = source.toString + override def toString: String = source.toString var untpdTree: untpd.Tree = untpd.EmptyTree var tpdTree: tpd.Tree = tpd.EmptyTree - def isJava = source.file.name.endsWith(".java") + def isJava: Boolean = source.file.name.endsWith(".java") /** Pickled TASTY binaries, indexed by class. */ var pickled: Map[ClassSymbol, Array[Byte]] = Map() @@ -29,7 +29,7 @@ class CompilationUnit(val source: SourceFile) { var containsQuotesOrSplices: Boolean = false /** A structure containing a temporary map for generating inline accessors */ - val inlineAccessors = new InlineAccessors + val inlineAccessors: InlineAccessors = new InlineAccessors } object CompilationUnit { diff --git a/compiler/src/dotty/tools/dotc/Compiler.scala b/compiler/src/dotty/tools/dotc/Compiler.scala index 564646b446c7..17bf78e54a50 100644 --- a/compiler/src/dotty/tools/dotc/Compiler.scala +++ b/compiler/src/dotty/tools/dotc/Compiler.scala @@ -3,17 +3,9 @@ package dotc import core._ import Contexts._ -import Periods._ -import Symbols._ -import Types._ -import Scopes._ -import typer.{FrontEnd, ImportInfo, RefChecks, Typer} -import reporting.{ConsoleReporter, Reporter} +import typer.{FrontEnd, RefChecks} import Phases.Phase import transform._ -import util.FreshNameCreator -import core.DenotTransformers.DenotTransformer -import core.Denotations.SingleDenotation import dotty.tools.backend.jvm.{CollectSuperCalls, GenBCode, LabelDefs} import dotty.tools.dotc.transform.localopt.StringInterpolatorOpt @@ -126,8 +118,8 @@ class Compiler { List(new GenBCode) :: // Generate JVM bytecode Nil - var runId = 1 - def nextRunId = { + var runId: Int = 1 + def nextRunId: Int = { runId += 1; runId } diff --git a/compiler/src/dotty/tools/dotc/Driver.scala b/compiler/src/dotty/tools/dotc/Driver.scala index 804f5379e8f0..e3d303807619 100644 --- a/compiler/src/dotty/tools/dotc/Driver.scala +++ b/compiler/src/dotty/tools/dotc/Driver.scala @@ -5,7 +5,6 @@ import config.CompilerCommand import core.Comments.{ContextDoc, ContextDocstrings} import core.Contexts.{Context, ContextBase} import core.Mode -import util.DotClass import reporting._ import scala.util.control.NonFatal import fromtasty.TASTYCompiler @@ -38,9 +37,9 @@ class Driver { } else ctx.reporter - protected def initCtx = (new ContextBase).initialCtx + protected def initCtx: Context = (new ContextBase).initialCtx - protected def sourcesRequired = true + protected def sourcesRequired: Boolean = true def setup(args: Array[String], rootCtx: Context): (List[String], Context) = { val ctx = rootCtx.fresh diff --git a/compiler/src/dotty/tools/dotc/Resident.scala b/compiler/src/dotty/tools/dotc/Resident.scala index 7f6c288cc892..0b971dd05953 100644 --- a/compiler/src/dotty/tools/dotc/Resident.scala +++ b/compiler/src/dotty/tools/dotc/Resident.scala @@ -27,7 +27,7 @@ class Resident extends Driver { object residentCompiler extends Compiler - override def sourcesRequired = false + override def sourcesRequired: Boolean = false private val quit = ":q" private val reset = ":reset" diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 52694c0e5662..f7e88c124b57 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -5,17 +5,15 @@ import core._ import Contexts._ import Periods._ import Symbols._ -import Phases._ import Types._ import Scopes._ -import typer.{FrontEnd, ImportInfo, RefChecks, Typer} +import typer.{ImportInfo, Typer} import Decorators._ import io.{AbstractFile, PlainFile} import scala.io.Codec import util.{Set => _, _} import reporting.Reporter -import transform.TreeChecker import rewrites.Rewrites import java.io.{BufferedWriter, OutputStreamWriter} @@ -26,7 +24,6 @@ import parsing.JavaParsers.JavaParser import typer.ImplicitRunInfo import collection.mutable -import scala.annotation.tailrec import dotty.tools.io.VirtualFile import scala.util.control.NonFatal @@ -67,7 +64,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint private[this] var myCtx = rootContext(ictx) /** The context created for this run */ - def runContext = myCtx + def runContext: Context = myCtx protected[this] implicit def ctx: Context = myCtx assert(ctx.runId <= Periods.MaxPossibleRunId) @@ -131,7 +128,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint * or we need to assemble phases on each run, and take -Yskip, -Ystop into * account. I think the latter would be preferable. */ - def compileSources(sources: List[SourceFile]) = + def compileSources(sources: List[SourceFile]): Unit = if (sources forall (_.exists)) { units = sources map (new CompilationUnit(_)) compileUnits() @@ -267,7 +264,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint r } - override def reset() = { + override def reset(): Unit = { super[ImplicitRunInfo].reset() super[ConstraintRunInfo].reset() myCtx = null diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index b22e31492156..60360a268993 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -4,10 +4,9 @@ package ast import core._ import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._ -import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._ +import Symbols._, StdNames._, Trees._ import Decorators._, transform.SymUtils._ import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName} -import language.higherKinds import typer.FrontEnd import collection.mutable.ListBuffer import reporting.diagnostic.messages._ @@ -38,15 +37,15 @@ object desugar { // ----- DerivedTypeTrees ----------------------------------- class SetterParamTree extends DerivedTypeTree { - def derivedTree(sym: Symbol)(implicit ctx: Context) = tpd.TypeTree(sym.info.resultType) + def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = tpd.TypeTree(sym.info.resultType) } class TypeRefTree extends DerivedTypeTree { - def derivedTree(sym: Symbol)(implicit ctx: Context) = tpd.TypeTree(sym.typeRef) + def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = tpd.TypeTree(sym.typeRef) } class TermRefTree extends DerivedTypeTree { - def derivedTree(sym: Symbol)(implicit ctx: Context) = tpd.ref(sym) + def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.Tree = tpd.ref(sym) } /** A type tree that computes its type from an existing parameter. @@ -60,7 +59,7 @@ object desugar { * be completed so that OriginalSymbol attachments are pushed to DerivedTypeTrees * in apply/unapply methods. */ - override def ensureCompletions(implicit ctx: Context) = + override def ensureCompletions(implicit ctx: Context): Unit = if (!(ctx.owner is Package)) if (ctx.owner.isClass) { ctx.owner.ensureCompleted() @@ -82,7 +81,7 @@ object desugar { * * parameter name == reference name ++ suffix */ - def derivedTree(sym: Symbol)(implicit ctx: Context) = { + def derivedTree(sym: Symbol)(implicit ctx: Context): tpd.TypeTree = { val relocate = new TypeMap { val originalOwner = sym.owner def apply(tp: Type) = tp match { @@ -115,7 +114,7 @@ object desugar { TypeDef(sym.name, new DerivedFromParamTree("").watching(sym)).withFlags(TypeParam) /** A value definition copied from `vdef` with a tpt typetree derived from it */ - def derivedTermParam(vdef: ValDef) = + def derivedTermParam(vdef: ValDef): ValDef = cpy.ValDef(vdef)( tpt = new DerivedFromParamTree("") withPos vdef.tpt.pos watching vdef) @@ -151,7 +150,7 @@ object desugar { else vdef } - def makeImplicitParameters(tpts: List[Tree], forPrimaryConstructor: Boolean = false)(implicit ctx: Context) = + def makeImplicitParameters(tpts: List[Tree], forPrimaryConstructor: Boolean = false)(implicit ctx: Context): List[ValDef] = for (tpt <- tpts) yield { val paramFlags: FlagSet = if (forPrimaryConstructor) PrivateLocalParamAccessor else Param val epname = EvidenceParamName.fresh() @@ -622,10 +621,10 @@ object desugar { case _ => Nil } - cpy.TypeDef(cdef)( + cpy.TypeDef(cdef: TypeDef)( name = className, rhs = cpy.Template(impl)(constr, parents1, self1, - tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths)) + tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths)): TypeDef } // install the watch on classTycon @@ -637,7 +636,7 @@ object desugar { flatTree(cdef1 :: companions ::: implicitWrappers) } - val AccessOrSynthetic = AccessFlags | Synthetic + val AccessOrSynthetic: FlagSet = AccessFlags | Synthetic /** Expand * @@ -763,7 +762,7 @@ object desugar { } /** Expand variable identifier x to x @ _ */ - def patternVar(tree: Tree)(implicit ctx: Context) = { + def patternVar(tree: Tree)(implicit ctx: Context): Bind = { val Ident(name) = tree Bind(name, Ident(nme.WILDCARD)).withPos(tree.pos) } @@ -838,7 +837,7 @@ object desugar { * def $anonfun(params) = body * Closure($anonfun) */ - def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), isImplicit: Boolean)(implicit ctx: Context) = + def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), isImplicit: Boolean)(implicit ctx: Context): Block = Block( DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(synthetic | Artifact), Closure(Nil, Ident(nme.ANON_FUN), if (isImplicit) ImplicitEmptyTree else EmptyTree)) @@ -853,7 +852,7 @@ object desugar { * * (x$1, ..., x$n) => (x$0, ..., x${n-1} @unchecked) match { cases } */ - def makeCaseLambda(cases: List[CaseDef], nparams: Int = 1, unchecked: Boolean = true)(implicit ctx: Context) = { + def makeCaseLambda(cases: List[CaseDef], nparams: Int = 1, unchecked: Boolean = true)(implicit ctx: Context): Function = { val params = (1 to nparams).toList.map(makeSyntheticParameter(_)) val selector = makeTuple(params.map(p => Ident(p.name))) @@ -897,7 +896,7 @@ object desugar { * following `fullName`. This is necessary so that we avoid reading an annotation from * the classpath that is also compiled from source. */ - def makeAnnotated(fullName: String, tree: Tree)(implicit ctx: Context) = { + def makeAnnotated(fullName: String, tree: Tree)(implicit ctx: Context): Annotated = { val parts = fullName.split('.') val ttree = ctx.typerPhase match { case phase: FrontEnd if phase.stillToBeEntered(parts.last) => @@ -908,7 +907,7 @@ object desugar { case _ => TypeTree(ctx.requiredClass(fullName).typeRef) } - Annotated(tree, untpd.New(ttree, Nil)) + Annotated(tree, New(ttree, Nil)) } private def derivedValDef(original: Tree, named: NameTree, tpt: Tree, rhs: Tree, mods: Modifiers)(implicit ctx: Context) = { diff --git a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala index 77fe8dd97379..69b0bf780b75 100644 --- a/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala +++ b/compiler/src/dotty/tools/dotc/ast/DesugarEnums.scala @@ -4,9 +4,8 @@ package ast import core._ import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._ -import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._ +import Symbols._, StdNames._, Trees._ import Decorators._ -import collection.mutable.ListBuffer import util.Property import typer.ErrorReporting._ @@ -15,14 +14,13 @@ import scala.annotation.internal.sharable /** Helper methods to desugar enums */ object DesugarEnums { import untpd._ - import desugar.DerivedFromParamTree @sharable object CaseKind extends Enumeration { - val Simple, Object, Class = Value + val Simple, Object, Class: Value = Value } /** Attachment containing the number of enum cases and the smallest kind that was seen so far. */ - val EnumCaseCount = new Property.Key[(Int, CaseKind.Value)] + val EnumCaseCount: Property.Key[(Int, DesugarEnums.CaseKind.Value)] = new Property.Key /** The enumeration class that belongs to an enum case. This works no matter * whether the case is still in the enum class or it has been transferred to the @@ -66,11 +64,11 @@ object DesugarEnums { } /** A type tree referring to `enumClass` */ - def enumClassRef(implicit ctx: Context) = + def enumClassRef(implicit ctx: Context): Tree = if (enumClass.exists) TypeTree(enumClass.typeRef) else TypeTree() /** Add implied flags to an enum class or an enum case */ - def addEnumFlags(cdef: TypeDef)(implicit ctx: Context) = + def addEnumFlags(cdef: TypeDef)(implicit ctx: Context): TypeDef = if (cdef.mods.isEnumClass) cdef.withMods(cdef.mods.withFlags(cdef.mods.flags | Abstract | Sealed)) else if (isEnumCase(cdef)) cdef.withMods(cdef.mods.withFlags(cdef.mods.flags | Final)) else cdef diff --git a/compiler/src/dotty/tools/dotc/ast/Positioned.scala b/compiler/src/dotty/tools/dotc/ast/Positioned.scala index 87d46eb9a9bf..9db97de44590 100644 --- a/compiler/src/dotty/tools/dotc/ast/Positioned.scala +++ b/compiler/src/dotty/tools/dotc/ast/Positioned.scala @@ -2,7 +2,6 @@ package dotty.tools.dotc package ast import util.Positions._ -import util.DotClass import core.Contexts.Context import core.Decorators._ import core.Flags.JavaDefined @@ -51,7 +50,7 @@ abstract class Positioned extends Product { * any checks of consistency with - or updates of - other positions. * Called from Unpickler when entering positions. */ - private[dotc] def setPosUnchecked(pos: Position) = curPos = pos + private[dotc] def setPosUnchecked(pos: Position): Unit = curPos = pos /** If any children of this node do not have positions, * fit their positions between the positions of the known subtrees diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index 73c20430c841..4f59b51a9a53 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -4,15 +4,13 @@ package ast import core._ import Flags._, Trees._, Types._, Contexts._ -import Names._, StdNames._, NameOps._, Decorators._, Symbols._ -import util.HashSet +import Names._, StdNames._, NameOps._, Symbols._ import typer.ConstFold import reporting.trace import scala.annotation.tailrec trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => - import TreeInfo._ // Note: the <: Type constraint looks necessary (and is needed to make the file compile in dotc). // But Scalac accepts the program happily without it. Need to find out why. @@ -26,7 +24,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => case _ => false } - def isOpAssign(tree: Tree) = unsplice(tree) match { + def isOpAssign(tree: Tree): Boolean = unsplice(tree) match { case Apply(fn, _ :: _) => unsplice(fn) match { case Select(_, name) if name.isOpAssignmentName => true @@ -122,7 +120,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => case _ => false } - def isSuperSelection(tree: Tree) = unsplice(tree) match { + def isSuperSelection(tree: Tree): Boolean = unsplice(tree) match { case Select(Super(_, _), _) => true case _ => false } @@ -163,7 +161,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => } /** Is name a left-associative operator? */ - def isLeftAssoc(operator: Name) = !operator.isEmpty && (operator.toSimpleName.last != ':') + def isLeftAssoc(operator: Name): Boolean = !operator.isEmpty && (operator.toSimpleName.last != ':') /** can this type be a type pattern? */ def mayBeTypePat(tree: Tree): Boolean = unsplice(tree) match { @@ -196,7 +194,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => }*/ /** Does this argument list end with an argument of the form : _* ? */ - def isWildcardStarArgList(trees: List[Tree])(implicit ctx: Context) = + def isWildcardStarArgList(trees: List[Tree])(implicit ctx: Context): Boolean = trees.nonEmpty && isWildcardStarArg(trees.last) /** Is the argument a wildcard argument of the form `_` or `x @ _`? @@ -207,28 +205,28 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => } /** Does this list contain a named argument tree? */ - def hasNamedArg(args: List[Any]) = args exists isNamedArg - val isNamedArg = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[_]] + def hasNamedArg(args: List[Any]): Boolean = args exists isNamedArg + val isNamedArg: Any => Boolean = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[_]] /** Is this pattern node a catch-all (wildcard or variable) pattern? */ - def isDefaultCase(cdef: CaseDef) = cdef match { + def isDefaultCase(cdef: CaseDef): Boolean = cdef match { case CaseDef(pat, EmptyTree, _) => isWildcardArg(pat) case _ => false } /** Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know * whether the user provided cases are exhaustive. */ - def isSyntheticDefaultCase(cdef: CaseDef) = unsplice(cdef) match { + def isSyntheticDefaultCase(cdef: CaseDef): Boolean = unsplice(cdef) match { case CaseDef(Bind(nme.DEFAULT_CASE, _), EmptyTree, _) => true case _ => false } /** Does this CaseDef catch Throwable? */ - def catchesThrowable(cdef: CaseDef)(implicit ctx: Context) = + def catchesThrowable(cdef: CaseDef)(implicit ctx: Context): Boolean = catchesAllOf(cdef, defn.ThrowableType) /** Does this CaseDef catch everything of a certain Type? */ - def catchesAllOf(cdef: CaseDef, threshold: Type)(implicit ctx: Context) = + def catchesAllOf(cdef: CaseDef, threshold: Type)(implicit ctx: Context): Boolean = isDefaultCase(cdef) || cdef.guard.isEmpty && { unbind(cdef.pat) match { @@ -238,7 +236,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => } /** Is this case guarded? */ - def isGuardedCase(cdef: CaseDef) = cdef.guard ne EmptyTree + def isGuardedCase(cdef: CaseDef): Boolean = cdef.guard ne EmptyTree /** The underlying pattern ignoring any bindings */ def unbind(x: Tree): Tree = unsplice(x) match { @@ -287,7 +285,6 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => } trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] => - import TreeInfo._ import untpd._ /** The underlying tree when stripping any TypedSplice or Parens nodes */ @@ -300,7 +297,7 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped] /** True iff definition is a val or def with no right-hand-side, or it * is an abstract typoe declaration */ - def lacksDefinition(mdef: MemberDef)(implicit ctx: Context) = mdef match { + def lacksDefinition(mdef: MemberDef)(implicit ctx: Context): Boolean = mdef match { case mdef: ValOrDefDef => mdef.unforcedRhs == EmptyTree && !mdef.name.isConstructorName && !mdef.mods.is(TermParamOrAccessor) case mdef: TypeDef => @@ -422,11 +419,11 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => private def minOf(l0: PurityLevel, ls: List[PurityLevel]) = (l0 /: ls)(_ min _) - def isSimplyPure(tree: Tree)(implicit ctx: Context) = exprPurity(tree) == SimplyPure - def isPureExpr(tree: Tree)(implicit ctx: Context) = exprPurity(tree) >= Pure - def isIdempotentExpr(tree: Tree)(implicit ctx: Context) = exprPurity(tree) >= Idempotent + def isSimplyPure(tree: Tree)(implicit ctx: Context): Boolean = exprPurity(tree) == SimplyPure + def isPureExpr(tree: Tree)(implicit ctx: Context): Boolean = exprPurity(tree) >= Pure + def isIdempotentExpr(tree: Tree)(implicit ctx: Context): Boolean = exprPurity(tree) >= Idempotent - def isPureBinding(tree: Tree)(implicit ctx: Context) = statPurity(tree) >= Pure + def isPureBinding(tree: Tree)(implicit ctx: Context): Boolean = statPurity(tree) >= Pure /** The purity level of this reference. * @return @@ -447,9 +444,9 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => else SimplyPure } - def isPureRef(tree: Tree)(implicit ctx: Context) = + def isPureRef(tree: Tree)(implicit ctx: Context): Boolean = refPurity(tree) == SimplyPure - def isIdempotentRef(tree: Tree)(implicit ctx: Context) = + def isIdempotentRef(tree: Tree)(implicit ctx: Context): Boolean = refPurity(tree) >= Idempotent /** If `tree` is a constant expression, its value as a Literal, @@ -512,7 +509,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => /** Is tree a reference to a mutable variable, or to a potential getter * that has a setter in the same class? */ - def isVariableOrGetter(tree: Tree)(implicit ctx: Context) = { + def isVariableOrGetter(tree: Tree)(implicit ctx: Context): Boolean = { def sym = tree.symbol def isVar = sym is Mutable def isGetter = @@ -620,7 +617,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => } /** Is this pattern node a catch-all or type-test pattern? */ - def isCatchCase(cdef: CaseDef)(implicit ctx: Context) = cdef match { + def isCatchCase(cdef: CaseDef)(implicit ctx: Context): Boolean = cdef match { case CaseDef(Typed(Ident(nme.WILDCARD), tpt), EmptyTree, _) => isSimpleThrowable(tpt.tpe) case CaseDef(Bind(_, Typed(Ident(nme.WILDCARD), tpt)), EmptyTree, _) => @@ -734,7 +731,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => /** The qualifier part of a Select or Ident. * For an Ident, this is the `This` of the current class. */ - def qualifier(tree: Tree)(implicit ctx: Context) = tree match { + def qualifier(tree: Tree)(implicit ctx: Context): Tree = tree match { case Select(qual, _) => qual case tree: Ident => desugarIdentPrefix(tree) case _ => This(ctx.owner.enclosingClass.asClass) @@ -743,7 +740,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => /** Is this a selection of a member of a structural type that is not a member * of an underlying class or trait? */ - def isStructuralTermSelect(tree: Tree)(implicit ctx: Context) = tree match { + def isStructuralTermSelect(tree: Tree)(implicit ctx: Context): Boolean = tree match { case tree: Select => def hasRefinement(qualtpe: Type): Boolean = qualtpe.dealias match { case RefinedType(parent, rname, rinfo) => @@ -796,12 +793,12 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => object TreeInfo { class PurityLevel(val x: Int) extends AnyVal { - def >= (that: PurityLevel) = x >= that.x - def min(that: PurityLevel) = new PurityLevel(x min that.x) + def >= (that: PurityLevel): Boolean = x >= that.x + def min(that: PurityLevel): PurityLevel = new PurityLevel(x min that.x) } - val SimplyPure = new PurityLevel(3) - val Pure = new PurityLevel(2) - val Idempotent = new PurityLevel(1) - val Impure = new PurityLevel(0) + val SimplyPure: PurityLevel = new PurityLevel(3) + val Pure: PurityLevel = new PurityLevel(2) + val Idempotent: PurityLevel = new PurityLevel(1) + val Impure: PurityLevel = new PurityLevel(0) } diff --git a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala index 856597b4b7ff..25269c17e863 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeTypeMap.scala @@ -3,9 +3,9 @@ package dotc package ast import core._ -import Types._, Contexts._, Constants._, Names._, Flags._ -import SymDenotations._, Symbols._, Annotations._, Trees._, Symbols._ -import Denotations._, Decorators._ +import Types._, Contexts._ +import Symbols._, Annotations._, Trees._, Symbols._ +import Decorators._ import dotty.tools.dotc.transform.SymUtils._ import core.tasty.TreePickler.Hole @@ -42,7 +42,7 @@ class TreeTypeMap( import tpd._ /** If `sym` is one of `oldOwners`, replace by corresponding symbol in `newOwners` */ - def mapOwner(sym: Symbol) = sym.subst(oldOwners, newOwners) + def mapOwner(sym: Symbol): Symbol = sym.subst(oldOwners, newOwners) /** Replace occurrences of `This(oldOwner)` in some prefix of a type * by the corresponding `This(newOwner)`. @@ -59,7 +59,7 @@ class TreeTypeMap( } } - def mapType(tp: Type) = + def mapType(tp: Type): Type = mapOwnerThis(typeMap(tp).substSym(substFrom, substTo)) private def updateDecls(prevStats: List[Tree], newStats: List[Tree]): Unit = @@ -128,7 +128,7 @@ class TreeTypeMap( } } - override def transformStats(trees: List[tpd.Tree])(implicit ctx: Context) = + override def transformStats(trees: List[tpd.Tree])(implicit ctx: Context): List[Tree] = transformDefs(trees)._2 def transformDefs[TT <: tpd.Tree](trees: List[TT])(implicit ctx: Context): (TreeTypeMap, List[TT]) = { diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 7e6aaa86f25c..453516880ab9 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -5,18 +5,14 @@ package ast import core._ import Types._, Names._, NameOps._, Flags._, util.Positions._, Contexts._, Constants._ import SymDenotations._, Symbols._, Denotations._, StdNames._, Comments._ -import annotation.tailrec import language.higherKinds -import collection.IndexedSeqOptimized -import collection.immutable.IndexedSeq import collection.mutable.ListBuffer -import parsing.Tokens.Token import printing.Printer -import util.{Stats, Attachment, Property, DotClass} +import printing.Texts.Text +import util.{Stats, Attachment, Property} import config.Config import annotation.internal.sharable import annotation.unchecked.uncheckedVariance -import language.implicitConversions object Trees { @@ -29,10 +25,10 @@ object Trees { type Untyped = Null /** The total number of created tree nodes, maintained if Stats.enabled */ - @sharable var ntrees = 0 + @sharable var ntrees: Int = 0 /** Property key for trees with documentation strings attached */ - val DocComment = new Property.StickyKey[Comment] + val DocComment: Property.StickyKey[Comments.Comment] = new Property.StickyKey @sharable private[this] var nextId = 0 // for debugging @@ -74,7 +70,7 @@ object Trees { */ @sharable private var myUniqueId: Int = nxId - def uniqueId = myUniqueId + def uniqueId: Int = myUniqueId /** The type constructor at the root of the tree */ type ThisTree[T >: Untyped] <: Tree[T] @@ -86,7 +82,7 @@ object Trees { * which implements copy-on-write. Another use-case is in method interpolateAndAdapt in Typer, * where we overwrite with a simplified version of the type itself. */ - private[dotc] def overwriteType(tpe: T) = + private[dotc] def overwriteType(tpe: T): Unit = myTpe = tpe /** The type of the tree. In case of an untyped tree, @@ -212,7 +208,7 @@ object Trees { */ def foreachInThicket(op: Tree[T] => Unit): Unit = op(this) - override def toText(printer: Printer) = printer.toText(this) + override def toText(printer: Printer): Text = printer.toText(this) def sameTree(that: Tree[_]): Boolean = { def isSame(x: Any, y: Any): Boolean = @@ -240,7 +236,7 @@ object Trees { } override def hashCode(): Int = uniqueId // for debugging; was: System.identityHashCode(this) - override def equals(that: Any) = this eq that.asInstanceOf[AnyRef] + override def equals(that: Any): Boolean = this eq that.asInstanceOf[AnyRef] override def clone: Tree[T] = { val tree = super.clone.asInstanceOf[Tree[T]] @@ -260,7 +256,7 @@ object Trees { */ trait TypTree[-T >: Untyped] extends Tree[T] { type ThisTree[-T >: Untyped] <: TypTree[T] - override def isType = true + override def isType: Boolean = true } /** Instances of this class are trees for which isTerm is definitely true. @@ -268,7 +264,7 @@ object Trees { */ trait TermTree[-T >: Untyped] extends Tree[T] { type ThisTree[-T >: Untyped] <: TermTree[T] - override def isTerm = true + override def isTerm: Boolean = true } /** Instances of this class are trees which are not terms but are legal @@ -276,13 +272,13 @@ object Trees { */ trait PatternTree[-T >: Untyped] extends Tree[T] { type ThisTree[-T >: Untyped] <: PatternTree[T] - override def isPattern = true + override def isPattern: Boolean = true } /** Tree's denotation can be derived from its type */ abstract class DenotingTree[-T >: Untyped] extends Tree[T] { type ThisTree[-T >: Untyped] <: DenotingTree[T] - override def denot(implicit ctx: Context) = typeOpt match { + override def denot(implicit ctx: Context): Denotation = typeOpt match { case tpe: NamedType => tpe.denot case tpe: ThisType => tpe.cls.denot case tpe: AnnotatedType => tpe.stripAnnots match { @@ -301,8 +297,8 @@ object Trees { type ThisTree[-T >: Untyped] <: ProxyTree[T] def forwardTo: Tree[T] override def denot(implicit ctx: Context): Denotation = forwardTo.denot - override def isTerm = forwardTo.isTerm - override def isType = forwardTo.isType + override def isTerm: Boolean = forwardTo.isTerm + override def isType: Boolean = forwardTo.isType } /** Tree has a name */ @@ -315,15 +311,15 @@ object Trees { abstract class RefTree[-T >: Untyped] extends NameTree[T] { type ThisTree[-T >: Untyped] <: RefTree[T] def qualifier: Tree[T] - override def isType = name.isTypeName - override def isTerm = name.isTermName + override def isType: Boolean = name.isTypeName + override def isTerm: Boolean = name.isTermName } /** Tree defines a new symbol */ trait DefTree[-T >: Untyped] extends DenotingTree[T] { type ThisTree[-T >: Untyped] <: DefTree[T] - override def isDef = true - def namedType = tpe.asInstanceOf[NamedType] + override def isDef: Boolean = true + def namedType: NamedType = tpe.asInstanceOf[NamedType] } /** Tree defines a new symbol and carries modifiers. @@ -354,7 +350,7 @@ object Trees { asInstanceOf[ThisTree[Untyped]] } - protected def setMods(mods: untpd.Modifiers) = myMods = mods + protected def setMods(mods: untpd.Modifiers): Unit = myMods = mods /** The position of the name defined by this definition. * This is a point position if the definition is synthetic, or a range position @@ -362,7 +358,7 @@ object Trees { * It might also be that the definition does not have a position (for instance when synthesized by * a calling chain from `viewExists`), in that case the return position is NoPosition. */ - def namePos = + def namePos: Position = if (pos.exists) { val point = pos.point if (rawMods.is(Synthetic) || name.toTermName == nme.ERROR) Position(point) @@ -395,12 +391,12 @@ object Trees { extends Ident[T](name) { override def isBackquoted: Boolean = true - override def toString = s"BackquotedIdent($name)" + override def toString: String = s"BackquotedIdent($name)" } class SearchFailureIdent[-T >: Untyped] private[ast] (name: Name) extends Ident[T](name) { - override def toString = s"SearchFailureIdent($name)" + override def toString: String = s"SearchFailureIdent($name)" } /** qualifier.name, or qualifier#name, if qualifier is a type */ @@ -411,7 +407,7 @@ object Trees { class SelectWithSig[-T >: Untyped] private[ast] (qualifier: Tree[T], name: Name, val sig: Signature) extends Select[T](qualifier, name) { - override def toString = s"SelectWithSig($qualifier, $name, $sig)" + override def toString: String = s"SelectWithSig($qualifier, $name, $sig)" } /** qual.this */ @@ -433,14 +429,14 @@ object Trees { case class Super[-T >: Untyped] private[ast] (qual: Tree[T], mix: untpd.Ident) extends ProxyTree[T] with TermTree[T] { type ThisTree[-T >: Untyped] = Super[T] - def forwardTo = qual + def forwardTo: Tree[T] = qual } abstract class GenericApply[-T >: Untyped] extends ProxyTree[T] with TermTree[T] { type ThisTree[-T >: Untyped] <: GenericApply[T] val fun: Tree[T] val args: List[Tree[T]] - def forwardTo = fun + def forwardTo: Tree[T] = fun } /** fun(args) */ @@ -471,7 +467,7 @@ object Trees { case class Typed[-T >: Untyped] private[ast] (expr: Tree[T], tpt: Tree[T]) extends ProxyTree[T] with TermTree[T] { type ThisTree[-T >: Untyped] = Typed[T] - def forwardTo = expr + def forwardTo: Tree[T] = expr } /** name = arg, in a parameter list */ @@ -582,7 +578,7 @@ object Trees { /** Array(elems) */ class JavaSeqLiteral[T >: Untyped] private[ast] (elems: List[Tree[T]], elemtpt: Tree[T]) extends SeqLiteral(elems, elemtpt) { - override def toString = s"JavaSeqLiteral($elems, $elemtpt)" + override def toString: String = s"JavaSeqLiteral($elems, $elemtpt)" } /** A tree representing inlined code. @@ -604,15 +600,15 @@ object Trees { case class Inlined[-T >: Untyped] private[ast] (call: tpd.Tree, bindings: List[MemberDef[T]], expansion: Tree[T]) extends Tree[T] { type ThisTree[-T >: Untyped] = Inlined[T] - override def initialPos = call.pos + override def initialPos: Position = call.pos } /** A type tree that represents an existing or inferred type */ case class TypeTree[-T >: Untyped] () extends DenotingTree[T] with TypTree[T] { type ThisTree[-T >: Untyped] = TypeTree[T] - override def isEmpty = !hasType - override def toString = + override def isEmpty: Boolean = !hasType + override def toString: String = s"TypeTree${if (hasType) s"[$typeOpt]" else ""}" } @@ -643,14 +639,14 @@ object Trees { case class RefinedTypeTree[-T >: Untyped] private[ast] (tpt: Tree[T], refinements: List[Tree[T]]) extends ProxyTree[T] with TypTree[T] { type ThisTree[-T >: Untyped] = RefinedTypeTree[T] - def forwardTo = tpt + def forwardTo: Tree[T] = tpt } /** tpt[args] */ case class AppliedTypeTree[-T >: Untyped] private[ast] (tpt: Tree[T], args: List[Tree[T]]) extends ProxyTree[T] with TypTree[T] { type ThisTree[-T >: Untyped] = AppliedTypeTree[T] - def forwardTo = tpt + def forwardTo: Tree[T] = tpt } /** [typeparams] -> tpt */ @@ -681,8 +677,8 @@ object Trees { case class Bind[-T >: Untyped] private[ast] (name: Name, body: Tree[T]) extends NameTree[T] with DefTree[T] with PatternTree[T] { type ThisTree[-T >: Untyped] = Bind[T] - override def isType = name.isTypeName - override def isTerm = name.isTermName + override def isType: Boolean = name.isTypeName + override def isTerm: Boolean = name.isTermName } /** tree_1 | ... | tree_n */ @@ -715,8 +711,8 @@ object Trees { extends ValOrDefDef[T] { type ThisTree[-T >: Untyped] = ValDef[T] assert(isEmpty || tpt != genericEmptyTree) - def unforced = preRhs - protected def force(x: AnyRef) = preRhs = x + def unforced: LazyTree = preRhs + protected def force(x: AnyRef): Unit = preRhs = x } /** mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs */ @@ -725,8 +721,8 @@ object Trees { extends ValOrDefDef[T] { type ThisTree[-T >: Untyped] = DefDef[T] assert(tpt != genericEmptyTree) - def unforced = preRhs - protected def force(x: AnyRef) = preRhs = x + def unforced: LazyTree = preRhs + protected def force(x: AnyRef): Unit = preRhs = x } /** mods class name template or @@ -739,16 +735,16 @@ object Trees { type ThisTree[-T >: Untyped] = TypeDef[T] /** Is this a definition of a class? */ - def isClassDef = rhs.isInstanceOf[Template[_]] + def isClassDef: Boolean = rhs.isInstanceOf[Template[_]] } /** extends parents { self => body } */ case class Template[-T >: Untyped] private[ast] (constr: DefDef[T], parents: List[Tree[T]], self: ValDef[T], private var preBody: LazyTreeList) extends DefTree[T] with WithLazyField[List[Tree[T]]] { type ThisTree[-T >: Untyped] = Template[T] - def unforcedBody = unforced - def unforced = preBody - protected def force(x: AnyRef) = preBody = x + def unforcedBody: LazyTreeList = unforced + def unforced: LazyTreeList = preBody + protected def force(x: AnyRef): Unit = preBody = x def body(implicit ctx: Context): List[Tree[T]] = forceIfLazy } @@ -765,20 +761,20 @@ object Trees { case class PackageDef[-T >: Untyped] private[ast] (pid: RefTree[T], stats: List[Tree[T]]) extends ProxyTree[T] { type ThisTree[-T >: Untyped] = PackageDef[T] - def forwardTo = pid + def forwardTo: RefTree[T] = pid } /** arg @annot */ case class Annotated[-T >: Untyped] private[ast] (arg: Tree[T], annot: Tree[T]) extends ProxyTree[T] { type ThisTree[-T >: Untyped] = Annotated[T] - def forwardTo = arg + def forwardTo: Tree[T] = arg } trait WithoutTypeOrPos[-T >: Untyped] extends Tree[T] { - override def withTypeUnchecked(tpe: Type) = this.asInstanceOf[ThisTree[Type]] - override def pos = NoPosition - override def setPos(pos: Position) = {} + override def withTypeUnchecked(tpe: Type): ThisTree[Type] = this.asInstanceOf[ThisTree[Type]] + override def pos: Position = NoPosition + override def setPos(pos: Position): Unit = {} } /** Temporary class that results from translation of ModuleDefs @@ -793,7 +789,7 @@ object Trees { type ThisTree[-T >: Untyped] = Thicket[T] override def isEmpty: Boolean = trees.isEmpty override def toList: List[Tree[T]] = flatten(trees) - override def toString = if (isEmpty) "EmptyTree" else "Thicket(" + trees.mkString(", ") + ")" + override def toString: String = if (isEmpty) "EmptyTree" else "Thicket(" + trees.mkString(", ") + ")" override def withPos(pos: Position): this.type = { val newTrees = trees.mapConserve(_.withPos(pos)) if (trees eq newTrees) @@ -801,7 +797,7 @@ object Trees { else new Thicket[T](newTrees).asInstanceOf[this.type] } - override def pos = (NoPosition /: trees) ((pos, t) => pos union t.pos) + override def pos: Position = (NoPosition /: trees) ((pos, t) => pos union t.pos) override def foreachInThicket(op: Tree[T] => Unit): Unit = trees foreach (_.foreachInThicket(op)) } @@ -814,7 +810,7 @@ object Trees { } @sharable val theEmptyTree: Thicket[Type] = Thicket(Nil) - @sharable val theEmptyValDef = new EmptyValDef[Type] + @sharable val theEmptyValDef: EmptyValDef[Type] = new EmptyValDef[Type] def genericEmptyValDef[T >: Untyped]: ValDef[T] = theEmptyValDef.asInstanceOf[ValDef[T]] def genericEmptyTree[T >: Untyped]: Thicket[T] = theEmptyTree.asInstanceOf[Thicket[T]] @@ -985,7 +981,7 @@ object Trees { case _ => finalize(tree, untpd.Select(qualifier, name)) } /** Copy Ident or Select trees */ - def Ref(tree: RefTree)(name: Name)(implicit ctx: Context) = tree match { + def Ref(tree: RefTree)(name: Name)(implicit ctx: Context): RefTree = tree match { case Ident(_) => Ident(tree)(name) case Select(qual, _) => Select(tree)(qual, name) } @@ -1428,8 +1424,8 @@ object Trees { abstract class TreeTraverser extends TreeAccumulator[Unit] { def traverse(tree: Tree)(implicit ctx: Context): Unit - def apply(x: Unit, tree: Tree)(implicit ctx: Context) = traverse(tree) - protected def traverseChildren(tree: Tree)(implicit ctx: Context) = foldOver((), tree) + def apply(x: Unit, tree: Tree)(implicit ctx: Context): Unit = traverse(tree) + protected def traverseChildren(tree: Tree)(implicit ctx: Context): Unit = foldOver((), tree) } /** Fold `f` over all tree nodes, in depth-first, prefix order */ diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 471350ba3d03..c7007294b7c8 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -8,11 +8,10 @@ import transform.SymUtils._ import transform.TypeUtils._ import core._ import util.Positions._, Types._, Contexts._, Constants._, Names._, Flags._, NameOps._ -import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Symbols._ -import Denotations._, Decorators._, DenotTransformers._ +import Symbols._, StdNames._, Annotations._, Trees._, Symbols._ +import Decorators._, DenotTransformers._ import collection.mutable import util.{Property, SourceFile, NoSource} -import typer.ErrorReporting._ import NameKinds.{TempResultName, OuterSelectName} import scala.annotation.tailrec @@ -335,7 +334,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { // ------ Making references ------------------------------------------------------ - def prefixIsElidable(tp: NamedType)(implicit ctx: Context) = { + def prefixIsElidable(tp: NamedType)(implicit ctx: Context): Boolean = { val typeIsElidable = tp.prefix match { case pre: ThisType => tp.isType || @@ -354,7 +353,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { tp.symbol.hasAnnotation(defn.ScalaStaticAnnot) } - def needsSelect(tp: Type)(implicit ctx: Context) = tp match { + def needsSelect(tp: Type)(implicit ctx: Context): Boolean = tp match { case tp: TermRef => !prefixIsElidable(tp) case _ => false } @@ -478,9 +477,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { } /** A `_' with given type */ - def Underscore(tp: Type)(implicit ctx: Context) = untpd.Ident(nme.WILDCARD).withType(tp) + def Underscore(tp: Type)(implicit ctx: Context): Ident = untpd.Ident(nme.WILDCARD).withType(tp) - def defaultValue(tpe: Types.Type)(implicit ctx: Context) = { + def defaultValue(tpe: Type)(implicit ctx: Context): Tree = { val tpw = tpe.widen if (tpw isRef defn.IntClass) Literal(Constant(0)) @@ -508,7 +507,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { override val cpy: TypedTreeCopier = // Type ascription needed to pick up any new members in TreeCopier (currently there are none) new TypedTreeCopier - val cpyBetweenPhases = new TimeTravellingTreeCopier + val cpyBetweenPhases: TimeTravellingTreeCopier = new TimeTravellingTreeCopier class TypedTreeCopier extends TreeCopier { def postProcess(tree: Tree, copied: untpd.Tree): copied.ThisTree[Type] = @@ -678,14 +677,14 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { Closure(tree: Tree)(env, meth, tpt) } - override def skipTransform(tree: Tree)(implicit ctx: Context) = tree.tpe.isError + override def skipTransform(tree: Tree)(implicit ctx: Context): Boolean = tree.tpe.isError implicit class TreeOps[ThisTree <: tpd.Tree](private val tree: ThisTree) extends AnyVal { def isValue(implicit ctx: Context): Boolean = tree.isTerm && tree.tpe.widen.isValueType - def isValueOrPattern(implicit ctx: Context) = + def isValueOrPattern(implicit ctx: Context): Boolean = tree.isValue || tree.isPattern def isValueType: Boolean = @@ -696,10 +695,10 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { case _ => false } - def shallowFold[T](z: T)(op: (T, tpd.Tree) => T)(implicit ctx: Context) = + def shallowFold[T](z: T)(op: (T, tpd.Tree) => T)(implicit ctx: Context): T = new ShallowFolder(op).apply(z, tree) - def deepFold[T](z: T)(op: (T, tpd.Tree) => T)(implicit ctx: Context) = + def deepFold[T](z: T)(op: (T, tpd.Tree) => T)(implicit ctx: Context): T = new DeepFolder(op).apply(z, tree) def find[T](pred: (tpd.Tree) => Boolean)(implicit ctx: Context): Option[tpd.Tree] = @@ -827,7 +826,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { if (tree.tpe.widen.isParameterless) tree else tree.appliedToNone /** `tree == that` */ - def equal(that: Tree)(implicit ctx: Context) = + def equal(that: Tree)(implicit ctx: Context): Tree = if (that.tpe.widen.isRef(defn.NothingClass)) Literal(Constant(false)) else @@ -867,7 +866,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { /** If inititializer tree is `_', the default value of its type, * otherwise the tree itself. */ - def wildcardToDefault(implicit ctx: Context) = + def wildcardToDefault(implicit ctx: Context): Tree = if (isWildcardArg(tree)) defaultValue(tree.tpe) else tree /** `this && that`, for boolean trees `this`, `that` */ @@ -978,7 +977,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { rootTrees.headOption.getOrElse(EmptyTree) /** Is it possible that the tree to load contains a definition of or reference to `id`? */ - def mightContain(id: String)(implicit ctx: Context) = true + def mightContain(id: String)(implicit ctx: Context): Boolean = true } // convert a numeric with a toXXX method @@ -1062,7 +1061,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { * * ~within('tree) */ - def letBindUnless(level: TreeInfo.PurityLevel, tree: Tree)(within: Tree => Tree)(implicit ctx: Context) = { + def letBindUnless(level: TreeInfo.PurityLevel, tree: Tree)(within: Tree => Tree)(implicit ctx: Context): Tree = { if (exprPurity(tree) >= level) within(tree) else { val vdef = SyntheticValDef(TempResultName.fresh(), tree) @@ -1071,7 +1070,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { } /** Let bind `tree` unless `tree` is at least idempotent */ - def evalOnce(tree: Tree)(within: Tree => Tree)(implicit ctx: Context) = + def evalOnce(tree: Tree)(within: Tree => Tree)(implicit ctx: Context): Tree = letBindUnless(TreeInfo.Idempotent, tree)(within) def runtimeCall(name: TermName, args: List[Tree])(implicit ctx: Context): Tree = { @@ -1113,7 +1112,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { /** The source file where the symbol of the `inline` method referred to by `call` * is defined */ - def sourceFile(call: Tree)(implicit ctx: Context) = { + def sourceFile(call: Tree)(implicit ctx: Context): SourceFile = { val file = call.symbol.sourceFile val encoding = ctx.settings.encoding.value if (file != null && file.exists) new SourceFile(file, Codec(encoding)) else NoSource diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala index 054e4e604749..7b0e6b41e23a 100644 --- a/compiler/src/dotty/tools/dotc/ast/untpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala @@ -3,13 +3,10 @@ package dotc package ast import core._ -import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._ -import Denotations._, SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._ -import Decorators._ +import Types._, Contexts._, Constants._, Names._, Flags._ +import Symbols._, StdNames._, Trees._ import util.Property import language.higherKinds -import collection.mutable.ListBuffer -import reflect.ClassTag import scala.annotation.internal.sharable @@ -19,15 +16,15 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { trait OpTree extends Tree { def op: Ident - override def isTerm = op.name.isTermName - override def isType = op.name.isTypeName + override def isTerm: Boolean = op.name.isTermName + override def isType: Boolean = op.name.isTypeName } /** A typed subtree of an untyped tree needs to be wrapped in a TypedSplice * @param owner The current owner at the time the tree was defined */ abstract case class TypedSplice(splice: tpd.Tree)(val owner: Symbol) extends ProxyTree { - def forwardTo = splice + def forwardTo: tpd.Tree = splice } object TypedSplice { @@ -39,7 +36,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class ModuleDef(name: TermName, impl: Template) extends MemberDef { type ThisTree[-T >: Untyped] <: Trees.NameTree[T] with Trees.MemberDef[T] with ModuleDef - def withName(name: Name)(implicit ctx: Context) = cpy.ModuleDef(this)(name.toTermName, impl) + def withName(name: Name)(implicit ctx: Context): ModuleDef = cpy.ModuleDef(this)(name.toTermName, impl) } case class ParsedTry(expr: Tree, handler: Tree, finalizer: Tree) extends TermTree @@ -54,8 +51,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { /** A function type */ case class Function(args: List[Tree], body: Tree) extends Tree { - override def isTerm = body.isTerm - override def isType = body.isType + override def isTerm: Boolean = body.isTerm + override def isType: Boolean = body.isType } /** A function type with `implicit` or `erased` modifiers */ @@ -73,15 +70,15 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class InfixOp(left: Tree, op: Ident, right: Tree) extends OpTree case class PostfixOp(od: Tree, op: Ident) extends OpTree case class PrefixOp(op: Ident, od: Tree) extends OpTree { - override def isType = op.isType - override def isTerm = op.isTerm + override def isType: Boolean = op.isType + override def isTerm: Boolean = op.isTerm } case class Parens(t: Tree) extends ProxyTree { - def forwardTo = t + def forwardTo: Tree = t } case class Tuple(trees: List[Tree]) extends Tree { - override def isTerm = trees.isEmpty || trees.head.isTerm - override def isType = !isTerm + override def isTerm: Boolean = trees.isEmpty || trees.head.isTerm + override def isType: Boolean = !isTerm } case class Throw(expr: Tree) extends TermTree case class Quote(expr: Tree) extends TermTree @@ -95,7 +92,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class DependentTypeTree(tp: List[Symbol] => Type) extends Tree @sharable object EmptyTypeIdent extends Ident(tpnme.EMPTY) with WithoutTypeOrPos[Untyped] { - override def isEmpty = true + override def isEmpty: Boolean = true } /** A block generated by the XML parser, only treated specially by @@ -160,7 +157,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def toTypeFlags: Modifiers = withFlags(flags.toTypeFlags) def toTermFlags: Modifiers = withFlags(flags.toTermFlags) - def withFlags(flags: FlagSet) = + def withFlags(flags: FlagSet): Modifiers = if (this.flags == flags) this else copy(flags = flags) @@ -191,18 +188,18 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { if (annots eq annotations) this else copy(annotations = annots) - def withPrivateWithin(pw: TypeName) = + def withPrivateWithin(pw: TypeName): Modifiers = if (pw.isEmpty) this else copy(privateWithin = pw) - def hasFlags = flags != EmptyFlags - def hasAnnotations = annotations.nonEmpty - def hasPrivateWithin = privateWithin != tpnme.EMPTY + def hasFlags: Boolean = flags != EmptyFlags + def hasAnnotations: Boolean = annotations.nonEmpty + def hasPrivateWithin: Boolean = privateWithin != tpnme.EMPTY private def isEnum = is(Enum, butNot = JavaDefined) - def isEnumCase = isEnum && is(Case) - def isEnumClass = isEnum && !is(Case) + def isEnumCase: Boolean = isEnum && is(Case) + def isEnumClass: Boolean = isEnum && !is(Case) } @sharable val EmptyModifiers: Modifiers = new Modifiers() @@ -246,13 +243,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { * from the symbol in this type. These type trees have marker trees * TypeRefOfSym or InfoOfSym as their originals. */ - val References = new Property.Key[List[DerivedTypeTree]] + val References: Property.Key[List[DerivedTypeTree]] = new Property.Key /** Property key for TypeTrees marked with TypeRefOfSym or InfoOfSym * which contains the symbol of the original tree from which this * TypeTree is derived. */ - val OriginalSymbol = new Property.Key[Symbol] + val OriginalSymbol: Property.Key[Symbol] = new Property.Key // ------ Creation methods for untyped only ----------------- @@ -282,7 +279,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def SeqLiteral(elems: List[Tree], elemtpt: Tree): SeqLiteral = new SeqLiteral(elems, elemtpt) def JavaSeqLiteral(elems: List[Tree], elemtpt: Tree): JavaSeqLiteral = new JavaSeqLiteral(elems, elemtpt) def Inlined(call: tpd.Tree, bindings: List[MemberDef], expansion: Tree): Inlined = new Inlined(call, bindings, expansion) - def TypeTree() = new TypeTree() + def TypeTree(): TypeTree = new TypeTree() def SingletonTypeTree(ref: Tree): SingletonTypeTree = new SingletonTypeTree(ref) def AndTypeTree(left: Tree, right: Tree): AndTypeTree = new AndTypeTree(left, right) def OrTypeTree(left: Tree, right: Tree): OrTypeTree = new OrTypeTree(left, right) @@ -299,7 +296,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def DefDef(name: TermName, tparams: List[TypeDef], vparamss: List[List[ValDef]], tpt: Tree, rhs: LazyTree): DefDef = new DefDef(name, tparams, vparamss, tpt, rhs) def TypeDef(name: TypeName, rhs: Tree): TypeDef = new TypeDef(name, rhs) def Template(constr: DefDef, parents: List[Tree], self: ValDef, body: LazyTreeList): Template = new Template(constr, parents, self, body) - def Import(expr: Tree, selectors: List[untpd.Tree]): Import = new Import(expr, selectors) + def Import(expr: Tree, selectors: List[Tree]): Import = new Import(expr, selectors) def PackageDef(pid: RefTree, stats: List[Tree]): PackageDef = new PackageDef(pid, stats) def Annotated(arg: Tree, annot: Tree): Annotated = new Annotated(arg, annot) @@ -336,7 +333,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def Apply(fn: Tree, arg: Tree): Apply = Apply(fn, arg :: Nil) - def ensureApplied(tpt: Tree) = tpt match { + def ensureApplied(tpt: Tree): Tree = tpt match { case _: Apply => tpt case _ => Apply(tpt, Nil) } @@ -346,15 +343,15 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def TypeTree(tpe: Type)(implicit ctx: Context): TypedSplice = TypedSplice(TypeTree().withTypeUnchecked(tpe)) - def unitLiteral = Literal(Constant(())) + def unitLiteral: Literal = Literal(Constant(())) def ref(tp: NamedType)(implicit ctx: Context): Tree = TypedSplice(tpd.ref(tp)) - def rootDot(name: Name) = Select(Ident(nme.ROOTPKG), name) - def scalaDot(name: Name) = Select(rootDot(nme.scala_), name) - def scalaUnit = scalaDot(tpnme.Unit) - def scalaAny = scalaDot(tpnme.Any) + def rootDot(name: Name): Select = Select(Ident(nme.ROOTPKG), name) + def scalaDot(name: Name): Select = Select(rootDot(nme.scala_), name) + def scalaUnit: Select = scalaDot(tpnme.Unit) + def scalaAny: Select = scalaDot(tpnme.Any) def makeConstructor(tparams: List[TypeDef], vparamss: List[List[ValDef]], rhs: Tree = EmptyTree)(implicit ctx: Context): DefDef = DefDef(nme.CONSTRUCTOR, tparams, vparamss, TypeTree(), rhs) @@ -362,15 +359,15 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def emptyConstructor(implicit ctx: Context): DefDef = makeConstructor(Nil, Nil) - def makeSelfDef(name: TermName, tpt: Tree)(implicit ctx: Context) = + def makeSelfDef(name: TermName, tpt: Tree)(implicit ctx: Context): ValDef = ValDef(name, tpt, EmptyTree).withFlags(PrivateLocal) - def makeTupleOrParens(ts: List[Tree])(implicit ctx: Context) = ts match { + def makeTupleOrParens(ts: List[Tree])(implicit ctx: Context): Tree = ts match { case t :: Nil => Parens(t) case _ => Tuple(ts) } - def makeTuple(ts: List[Tree])(implicit ctx: Context) = ts match { + def makeTuple(ts: List[Tree])(implicit ctx: Context): Tree = ts match { case t :: Nil => t case _ => Tuple(ts) } @@ -381,26 +378,26 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { def makeSyntheticParameter(n: Int = 1, tpt: Tree = TypeTree())(implicit ctx: Context): ValDef = ValDef(nme.syntheticParamName(n), tpt, EmptyTree).withFlags(SyntheticTermParam) - def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context) = + def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context): Tree = if (tparams.isEmpty) tpt else LambdaTypeTree(tparams, tpt) /** A reference to given definition. If definition is a repeated * parameter, the reference will be a repeated argument. */ - def refOfDef(tree: MemberDef)(implicit ctx: Context) = tree match { + def refOfDef(tree: MemberDef)(implicit ctx: Context): Tree = tree match { case ValDef(_, PostfixOp(_, Ident(tpnme.raw.STAR)), _) => repeated(Ident(tree.name)) case _ => Ident(tree.name) } /** A repeated argument such as `arg: _*` */ - def repeated(arg: Tree)(implicit ctx: Context) = Typed(arg, Ident(tpnme.WILDCARD_STAR)) + def repeated(arg: Tree)(implicit ctx: Context): Typed = Typed(arg, Ident(tpnme.WILDCARD_STAR)) // ----- Accessing modifiers ---------------------------------------------------- abstract class ModsDecorator { def mods: Modifiers } implicit class modsDeco(val mdef: MemberDef)(implicit ctx: Context) { - def mods = mdef.rawMods + def mods: Modifiers = mdef.rawMods } // --------- Copier/Transformer/Accumulator classes for untyped trees ----- @@ -419,84 +416,84 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { } }.asInstanceOf[copied.ThisTree[Untyped]] - def ModuleDef(tree: Tree)(name: TermName, impl: Template) = tree match { + def ModuleDef(tree: Tree)(name: TermName, impl: Template): ModuleDef = tree match { case tree: ModuleDef if (name eq tree.name) && (impl eq tree.impl) => tree case _ => finalize(tree, untpd.ModuleDef(name, impl)) } - def ParsedTry(tree: Tree)(expr: Tree, handler: Tree, finalizer: Tree) = tree match { + def ParsedTry(tree: Tree)(expr: Tree, handler: Tree, finalizer: Tree): TermTree = tree match { case tree: ParsedTry if (expr eq tree.expr) && (handler eq tree.handler) && (finalizer eq tree.finalizer) => tree case _ => finalize(tree, untpd.ParsedTry(expr, handler, finalizer)) } - def SymbolLit(tree: Tree)(str: String) = tree match { + def SymbolLit(tree: Tree)(str: String): TermTree = tree match { case tree: SymbolLit if str == tree.str => tree case _ => finalize(tree, untpd.SymbolLit(str)) } - def InterpolatedString(tree: Tree)(id: TermName, segments: List[Tree]) = tree match { + def InterpolatedString(tree: Tree)(id: TermName, segments: List[Tree]): TermTree = tree match { case tree: InterpolatedString if (id eq tree.id) && (segments eq tree.segments) => tree case _ => finalize(tree, untpd.InterpolatedString(id, segments)) } - def Function(tree: Tree)(args: List[Tree], body: Tree) = tree match { + def Function(tree: Tree)(args: List[Tree], body: Tree): Tree = tree match { case tree: Function if (args eq tree.args) && (body eq tree.body) => tree case _ => finalize(tree, untpd.Function(args, body)) } - def InfixOp(tree: Tree)(left: Tree, op: Ident, right: Tree) = tree match { + def InfixOp(tree: Tree)(left: Tree, op: Ident, right: Tree): Tree = tree match { case tree: InfixOp if (left eq tree.left) && (op eq tree.op) && (right eq tree.right) => tree case _ => finalize(tree, untpd.InfixOp(left, op, right)) } - def PostfixOp(tree: Tree)(od: Tree, op: Ident) = tree match { + def PostfixOp(tree: Tree)(od: Tree, op: Ident): Tree = tree match { case tree: PostfixOp if (od eq tree.od) && (op eq tree.op) => tree case _ => finalize(tree, untpd.PostfixOp(od, op)) } - def PrefixOp(tree: Tree)(op: Ident, od: Tree) = tree match { + def PrefixOp(tree: Tree)(op: Ident, od: Tree): Tree = tree match { case tree: PrefixOp if (op eq tree.op) && (od eq tree.od) => tree case _ => finalize(tree, untpd.PrefixOp(op, od)) } - def Parens(tree: Tree)(t: Tree) = tree match { + def Parens(tree: Tree)(t: Tree): ProxyTree = tree match { case tree: Parens if t eq tree.t => tree case _ => finalize(tree, untpd.Parens(t)) } - def Tuple(tree: Tree)(trees: List[Tree]) = tree match { + def Tuple(tree: Tree)(trees: List[Tree]): Tree = tree match { case tree: Tuple if trees eq tree.trees => tree case _ => finalize(tree, untpd.Tuple(trees)) } - def Throw(tree: Tree)(expr: Tree) = tree match { + def Throw(tree: Tree)(expr: Tree): TermTree = tree match { case tree: Throw if expr eq tree.expr => tree case _ => finalize(tree, untpd.Throw(expr)) } - def Quote(tree: Tree)(expr: Tree) = tree match { + def Quote(tree: Tree)(expr: Tree): TermTree = tree match { case tree: Quote if expr eq tree.expr => tree case _ => finalize(tree, untpd.Quote(expr)) } - def DoWhile(tree: Tree)(body: Tree, cond: Tree) = tree match { + def DoWhile(tree: Tree)(body: Tree, cond: Tree): TermTree = tree match { case tree: DoWhile if (body eq tree.body) && (cond eq tree.cond) => tree case _ => finalize(tree, untpd.DoWhile(body, cond)) } - def ForYield(tree: Tree)(enums: List[Tree], expr: Tree) = tree match { + def ForYield(tree: Tree)(enums: List[Tree], expr: Tree): TermTree = tree match { case tree: ForYield if (enums eq tree.enums) && (expr eq tree.expr) => tree case _ => finalize(tree, untpd.ForYield(enums, expr)) } - def ForDo(tree: Tree)(enums: List[Tree], body: Tree) = tree match { + def ForDo(tree: Tree)(enums: List[Tree], body: Tree): TermTree = tree match { case tree: ForDo if (enums eq tree.enums) && (body eq tree.body) => tree case _ => finalize(tree, untpd.ForDo(enums, body)) } - def GenFrom(tree: Tree)(pat: Tree, expr: Tree) = tree match { + def GenFrom(tree: Tree)(pat: Tree, expr: Tree): Tree = tree match { case tree: GenFrom if (pat eq tree.pat) && (expr eq tree.expr) => tree case _ => finalize(tree, untpd.GenFrom(pat, expr)) } - def GenAlias(tree: Tree)(pat: Tree, expr: Tree) = tree match { + def GenAlias(tree: Tree)(pat: Tree, expr: Tree): Tree = tree match { case tree: GenAlias if (pat eq tree.pat) && (expr eq tree.expr) => tree case _ => finalize(tree, untpd.GenAlias(pat, expr)) } - def ContextBounds(tree: Tree)(bounds: TypeBoundsTree, cxBounds: List[Tree]) = tree match { + def ContextBounds(tree: Tree)(bounds: TypeBoundsTree, cxBounds: List[Tree]): TypTree = tree match { case tree: ContextBounds if (bounds eq tree.bounds) && (cxBounds eq tree.cxBounds) => tree case _ => finalize(tree, untpd.ContextBounds(bounds, cxBounds)) } - def PatDef(tree: Tree)(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree) = tree match { + def PatDef(tree: Tree)(mods: Modifiers, pats: List[Tree], tpt: Tree, rhs: Tree): Tree = tree match { case tree: PatDef if (mods eq tree.mods) && (pats eq tree.pats) && (tpt eq tree.tpt) && (rhs eq tree.rhs) => tree case _ => finalize(tree, untpd.PatDef(mods, pats, tpt, rhs)) } - def TypedSplice(tree: Tree)(splice: tpd.Tree)(implicit ctx: Context) = tree match { + def TypedSplice(tree: Tree)(splice: tpd.Tree)(implicit ctx: Context): ProxyTree = tree match { case tree: TypedSplice if splice `eq` tree.splice => tree case _ => finalize(tree, untpd.TypedSplice(splice)) } @@ -598,8 +595,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { abstract class UntypedTreeTraverser extends UntypedTreeAccumulator[Unit] { def traverse(tree: Tree)(implicit ctx: Context): Unit - def apply(x: Unit, tree: Tree)(implicit ctx: Context) = traverse(tree) - protected def traverseChildren(tree: Tree)(implicit ctx: Context) = foldOver((), tree) + def apply(x: Unit, tree: Tree)(implicit ctx: Context): Unit = traverse(tree) + protected def traverseChildren(tree: Tree)(implicit ctx: Context): Unit = foldOver((), tree) } /** Fold `f` over all tree nodes, in depth-first, prefix order */ diff --git a/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala index 227282ff9ebd..24cd2e4d632b 100644 --- a/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/AggregateClassPath.scala @@ -5,7 +5,6 @@ package dotty.tools package dotc.classpath import java.net.URL -import scala.annotation.tailrec import scala.collection.mutable.ArrayBuffer import dotty.tools.io.{ AbstractFile, ClassPath, ClassRepresentation } @@ -66,7 +65,7 @@ case class AggregateClassPath(aggregates: Seq[ClassPath]) extends ClassPath { override private[dotty] def sources(inPackage: String): Seq[SourceFileEntry] = getDistinctEntries(_.sources(inPackage)) - override private[dotty] def hasPackage(pkg: String) = aggregates.exists(_.hasPackage(pkg)) + override private[dotty] def hasPackage(pkg: String): Boolean = aggregates.exists(_.hasPackage(pkg)) override private[dotty] def list(inPackage: String): ClassPathEntries = { val (packages, classesAndSources) = aggregates.map { cp => try { diff --git a/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala index 06a465530db3..6895897989d0 100644 --- a/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/ClassPath.scala @@ -7,7 +7,7 @@ import dotty.tools.io.AbstractFile import dotty.tools.io.ClassRepresentation case class ClassPathEntries(packages: Seq[PackageEntry], classesAndSources: Seq[ClassRepresentation]) { - def toTuple = (packages, classesAndSources) + def toTuple: (Seq[PackageEntry], Seq[ClassRepresentation]) = (packages, classesAndSources) } trait ClassFileEntry extends ClassRepresentation { @@ -23,21 +23,21 @@ trait PackageEntry { } private[dotty] case class ClassFileEntryImpl(file: AbstractFile) extends ClassFileEntry { - override def name = FileUtils.stripClassExtension(file.name) // class name + override def name: String = FileUtils.stripClassExtension(file.name) // class name override def binary: Option[AbstractFile] = Some(file) override def source: Option[AbstractFile] = None } private[dotty] case class SourceFileEntryImpl(file: AbstractFile) extends SourceFileEntry { - override def name = FileUtils.stripSourceExtension(file.name) + override def name: String = FileUtils.stripSourceExtension(file.name) override def binary: Option[AbstractFile] = None override def source: Option[AbstractFile] = Some(file) } private[dotty] case class ClassAndSourceFilesEntry(classFile: AbstractFile, srcFile: AbstractFile) extends ClassRepresentation { - override def name = FileUtils.stripClassExtension(classFile.name) + override def name: String = FileUtils.stripClassExtension(classFile.name) override def binary: Option[AbstractFile] = Some(classFile) override def source: Option[AbstractFile] = Some(srcFile) diff --git a/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala b/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala index fffbeac83116..3ade2fcf2f13 100644 --- a/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala +++ b/compiler/src/dotty/tools/dotc/classpath/ClassPathFactory.scala @@ -4,7 +4,6 @@ package dotty.tools.dotc.classpath import dotty.tools.io.{AbstractFile, VirtualDirectory} -import dotty.tools.dotc.config.Settings import FileUtils.AbstractFileOps import dotty.tools.io.ClassPath import dotty.tools.dotc.core.Contexts.Context @@ -43,14 +42,14 @@ class ClassPathFactory { def classesInExpandedPath(path: String)(implicit ctx: Context): IndexedSeq[ClassPath] = classesInPathImpl(path, expand = true).toIndexedSeq - def classesInPath(path: String)(implicit ctx: Context) = classesInPathImpl(path, expand = false) + def classesInPath(path: String)(implicit ctx: Context): List[ClassPath] = classesInPathImpl(path, expand = false) - def classesInManifest(useManifestClassPath: Boolean)(implicit ctx: Context) = + def classesInManifest(useManifestClassPath: Boolean)(implicit ctx: Context): List[ClassPath] = if (useManifestClassPath) dotty.tools.io.ClassPath.manifests.map(url => newClassPath(AbstractFile getResources url)) else Nil // Internal - protected def classesInPathImpl(path: String, expand: Boolean)(implicit ctx: Context) = + protected def classesInPathImpl(path: String, expand: Boolean)(implicit ctx: Context): List[ClassPath] = for { file <- expandPath(path, expand) dir <- { diff --git a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala index 5e18859bae8d..a761d746efdd 100644 --- a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala @@ -4,11 +4,8 @@ package dotty.tools.dotc.classpath import java.io.{File => JFile} -import java.net.{URI, URL} -import java.nio.file.{FileSystems, Files, SimpleFileVisitor} -import java.util.function.IntFunction -import java.util -import java.util.Comparator +import java.net.URL +import java.nio.file.{FileSystems, Files} import dotty.tools.io.{AbstractFile, PlainFile, ClassPath, ClassRepresentation} import FileUtils._ @@ -45,7 +42,7 @@ trait DirectoryLookup[FileEntryType <: ClassRepresentation] extends ClassPath { } } - override private[dotty] def hasPackage(pkg: String) = getDirectory(pkg).isDefined + override private[dotty] def hasPackage(pkg: String): Boolean = getDirectory(pkg).isDefined private[dotty] def packages(inPackage: String): Seq[PackageEntry] = { val dirForPackage = getDirectory(inPackage) @@ -164,7 +161,7 @@ final class JrtClassPath(fs: java.nio.file.FileSystem) extends ClassPath with No } /** Empty string represents root package */ - override private[dotty] def hasPackage(pkg: String) = packageToModuleBases.contains(pkg) + override private[dotty] def hasPackage(pkg: String): Boolean = packageToModuleBases.contains(pkg) override private[dotty] def packages(inPackage: String): Seq[PackageEntry] = { def matches(packageDottedName: String) = diff --git a/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala b/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala index ef571dbbf4b5..684fc7a58239 100644 --- a/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala +++ b/compiler/src/dotty/tools/dotc/classpath/FileUtils.scala @@ -43,7 +43,7 @@ object FileUtils { else throw new FatalError("Unexpected source file ending: " + fileName) } - def dirPath(forPackage: String) = forPackage.replace('.', '/') + def dirPath(forPackage: String): String = forPackage.replace('.', '/') def endsClass(fileName: String): Boolean = fileName.length > 6 && fileName.substring(fileName.length - 6) == ".class" @@ -68,7 +68,7 @@ object FileUtils { def mayBeValidPackage(dirName: String): Boolean = (dirName != "META-INF") && (dirName != "") && (dirName.charAt(0) != '.') - def mkFileFilter(f: JFile => Boolean) = new FileFilter { + def mkFileFilter(f: JFile => Boolean): FileFilter = new FileFilter { def accept(pathname: JFile): Boolean = f(pathname) } } diff --git a/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala index 51a97ef7ac14..1579e70afc55 100644 --- a/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/VirtualDirectoryClassPath.scala @@ -1,7 +1,7 @@ package dotty.tools.dotc.classpath import dotty.tools.io.ClassRepresentation -import dotty.tools.io.{AbstractFile, Path, PlainFile, VirtualDirectory} +import dotty.tools.io.{AbstractFile, VirtualDirectory} import FileUtils._ import java.net.URL diff --git a/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala b/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala index 77f628c673d4..256956fdb54b 100644 --- a/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala +++ b/compiler/src/dotty/tools/dotc/classpath/ZipArchiveFileLookup.scala @@ -46,7 +46,7 @@ trait ZipArchiveFileLookup[FileEntryType <: ClassRepresentation] extends ClassPa if isRequiredFileType(entry) } yield createFileEntry(entry) - override private[dotty] def hasPackage(pkg: String) = findDirEntry(pkg).isDefined + override private[dotty] def hasPackage(pkg: String): Boolean = findDirEntry(pkg).isDefined override private[dotty] def list(inPackage: String): ClassPathEntries = { val foundDirEntry = findDirEntry(inPackage) diff --git a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala index 81b4bdade5bf..c99724b4d024 100644 --- a/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala +++ b/compiler/src/dotty/tools/dotc/config/CompilerCommand.scala @@ -5,7 +5,6 @@ import java.nio.file.{Files, Paths} import Settings._ import core.Contexts._ -import util.DotClass import Properties._ import scala.collection.JavaConverters._ @@ -13,7 +12,7 @@ import scala.collection.JavaConverters._ object CompilerCommand { /** The name of the command */ - def cmdName = "dotc" + def cmdName: String = "dotc" private def explainAdvanced = """ |-- Notes on option parsing -- @@ -30,9 +29,9 @@ object CompilerCommand { | already are in phase X + 1. """ - def shortUsage = s"Usage: $cmdName " + def shortUsage: String = s"Usage: $cmdName " - def versionMsg = s"Dotty compiler $versionString -- $copyrightString" + def versionMsg: String = s"Dotty compiler $versionString -- $copyrightString" /** Distill arguments into summary detailing settings, errors and files to compiler */ def distill(args: Array[String])(implicit ctx: Context): ArgsSummary = { diff --git a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala b/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala index f0db0deafb6d..cbcf3c703f1d 100644 --- a/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala +++ b/compiler/src/dotty/tools/dotc/config/JavaPlatform.scala @@ -5,8 +5,8 @@ package config import io._ import classpath.AggregateClassPath import core._ -import Symbols._, Types._, Contexts._, Denotations._, SymDenotations._, StdNames._, Names._ -import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._ +import Symbols._, Types._, Contexts._, SymDenotations._, StdNames._ +import Flags._ import transform.ExplicitOuter, transform.SymUtils._ class JavaPlatform extends Platform { @@ -21,7 +21,7 @@ class JavaPlatform extends Platform { } // The given symbol is a method with the right name and signature to be a runnable java program. - def isMainMethod(sym: SymDenotation)(implicit ctx: Context) = + def isMainMethod(sym: SymDenotation)(implicit ctx: Context): Boolean = (sym.name == nme.main) && (sym.info match { case MethodTpe(_, defn.ArrayOf(el) :: Nil, restpe) => el =:= defn.StringType && (restpe isRef defn.UnitClass) case _ => false @@ -50,7 +50,7 @@ class JavaPlatform extends Platform { * to anything but other booleans, but it should be present in * case this is put to other uses. */ - def isMaybeBoxed(sym: ClassSymbol)(implicit ctx: Context) = { + def isMaybeBoxed(sym: ClassSymbol)(implicit ctx: Context): Boolean = { val d = defn import d._ (sym == ObjectClass) || diff --git a/compiler/src/dotty/tools/dotc/config/PathResolver.scala b/compiler/src/dotty/tools/dotc/config/PathResolver.scala index cb9abd70d236..943431566aa8 100644 --- a/compiler/src/dotty/tools/dotc/config/PathResolver.scala +++ b/compiler/src/dotty/tools/dotc/config/PathResolver.scala @@ -2,15 +2,15 @@ package dotty.tools package dotc package config -import java.net.{ URL, MalformedURLException } import WrappedProperties.AccessControl -import io.{ ClassPath, File, Directory, Path, AbstractFile } +import io.{ ClassPath, Directory, Path } import classpath.{AggregateClassPath, ClassPathFactory, JrtClassPath } -import ClassPath.{ JavaContext, join, split } +import ClassPath.split import PartialFunction.condOpt import scala.language.postfixOps import core.Contexts._ import Settings._ +import dotty.tools.io.File // Loosely based on the draft specification at: // https://wiki.scala-lang.org/display/SW/Classpath @@ -21,14 +21,14 @@ object PathResolver { // security exceptions. import AccessControl._ - def firstNonEmpty(xs: String*) = xs find (_ != "") getOrElse "" + def firstNonEmpty(xs: String*): String = xs find (_ != "") getOrElse "" /** Map all classpath elements to absolute paths and reconstruct the classpath. */ - def makeAbsolute(cp: String) = ClassPath.map(cp, x => Path(x).toAbsolute.path) + def makeAbsolute(cp: String): String = ClassPath.map(cp, x => Path(x).toAbsolute.path) /** pretty print class path */ - def ppcp(s: String) = split(s) match { + def ppcp(s: String): String = split(s) match { case Nil => "" case Seq(x) => x case xs => xs map ("\n" + _) mkString @@ -44,20 +44,20 @@ object PathResolver { /** Environment variables which java pays attention to so it * seems we do as well. */ - def classPathEnv = envOrElse("CLASSPATH", "") - def sourcePathEnv = envOrElse("SOURCEPATH", "") + def classPathEnv: String = envOrElse("CLASSPATH", "") + def sourcePathEnv: String = envOrElse("SOURCEPATH", "") - def javaBootClassPath = propOrElse("sun.boot.class.path", searchForBootClasspath) + def javaBootClassPath: String = propOrElse("sun.boot.class.path", searchForBootClasspath) - def javaExtDirs = propOrEmpty("java.ext.dirs") - def scalaHome = propOrEmpty("scala.home") - def scalaExtDirs = propOrEmpty("scala.ext.dirs") + def javaExtDirs: String = propOrEmpty("java.ext.dirs") + def scalaHome: String = propOrEmpty("scala.home") + def scalaExtDirs: String = propOrEmpty("scala.ext.dirs") /** The java classpath and whether to use it. */ - def javaUserClassPath = propOrElse("java.class.path", "") - def useJavaClassPath = propOrFalse("scala.usejavacp") + def javaUserClassPath: String = propOrElse("java.class.path", "") + def useJavaClassPath: Boolean = propOrFalse("scala.usejavacp") - override def toString = s""" + override def toString: String = s""" |object Environment { | scalaHome = $scalaHome (useJavaClassPath = $useJavaClassPath) | javaBootClassPath = <${javaBootClassPath.length} chars> @@ -71,27 +71,27 @@ object PathResolver { * to the path resolution specification. */ object Defaults { - def scalaSourcePath = Environment.sourcePathEnv - def javaBootClassPath = Environment.javaBootClassPath - def javaUserClassPath = Environment.javaUserClassPath - def javaExtDirs = Environment.javaExtDirs - def useJavaClassPath = Environment.useJavaClassPath + def scalaSourcePath: String = Environment.sourcePathEnv + def javaBootClassPath: String = Environment.javaBootClassPath + def javaUserClassPath: String = Environment.javaUserClassPath + def javaExtDirs: String = Environment.javaExtDirs + def useJavaClassPath: Boolean = Environment.useJavaClassPath - def scalaHome = Environment.scalaHome - def scalaHomeDir = Directory(scalaHome) - def scalaHomeExists = scalaHomeDir.isDirectory - def scalaLibDir = (scalaHomeDir / "lib").toDirectory - def scalaClassesDir = (scalaHomeDir / "classes").toDirectory + def scalaHome: String = Environment.scalaHome + def scalaHomeDir: Directory = Directory(scalaHome) + def scalaHomeExists: Boolean = scalaHomeDir.isDirectory + def scalaLibDir: Directory = (scalaHomeDir / "lib").toDirectory + def scalaClassesDir: Directory = (scalaHomeDir / "classes").toDirectory - def scalaLibAsJar = (scalaLibDir / "scala-library.jar").toFile - def scalaLibAsDir = (scalaClassesDir / "library").toDirectory + def scalaLibAsJar: File = (scalaLibDir / "scala-library.jar").toFile + def scalaLibAsDir: Directory = (scalaClassesDir / "library").toDirectory def scalaLibDirFound: Option[Directory] = if (scalaLibAsJar.isFile) Some(scalaLibDir) else if (scalaLibAsDir.isDirectory) Some(scalaClassesDir) else None - def scalaLibFound = + def scalaLibFound: String = if (scalaLibAsJar.isFile) scalaLibAsJar.path else if (scalaLibAsDir.isDirectory) scalaLibAsDir.path else "" @@ -101,7 +101,7 @@ object PathResolver { // the scala jars to end up on the classpath twice: one on the boot // classpath as set up by the runner (or regular classpath under -nobootcp) // and then again here. - def scalaBootClassPath = "" + def scalaBootClassPath: String = "" // scalaLibDirFound match { // case Some(dir) if scalaHomeExists => // val paths = ClassPath expandDir dir.path @@ -109,11 +109,11 @@ object PathResolver { // case _ => "" // } - def scalaExtDirs = Environment.scalaExtDirs + def scalaExtDirs: String = Environment.scalaExtDirs - def scalaPluginPath = (scalaHomeDir / "misc" / "scala-devel" / "plugins").path + def scalaPluginPath: String = (scalaHomeDir / "misc" / "scala-devel" / "plugins").path - override def toString = """ + override def toString: String = """ |object Defaults { | scalaHome = %s | javaBootClassPath = %s @@ -159,7 +159,7 @@ object PathResolver { } } } -import PathResolver.{ Defaults, Environment, firstNonEmpty, ppcp } +import PathResolver.{ Defaults, ppcp } class PathResolver(implicit ctx: Context) { import ctx.base.settings @@ -187,14 +187,14 @@ class PathResolver(implicit ctx: Context) { * those in Defaults. */ object Calculated { - def scalaHome = Defaults.scalaHome - def useJavaClassPath = settings.usejavacp.value || Defaults.useJavaClassPath - def javaBootClassPath = cmdLineOrElse("javabootclasspath", Defaults.javaBootClassPath) - def javaExtDirs = cmdLineOrElse("javaextdirs", Defaults.javaExtDirs) - def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else "" - def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath) - def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs) - def priorityClassPath = cmdLineOrElse("priorityclasspath", "") + def scalaHome: String = Defaults.scalaHome + def useJavaClassPath: Boolean = settings.usejavacp.value || Defaults.useJavaClassPath + def javaBootClassPath: String = cmdLineOrElse("javabootclasspath", Defaults.javaBootClassPath) + def javaExtDirs: String = cmdLineOrElse("javaextdirs", Defaults.javaExtDirs) + def javaUserClassPath: String = if (useJavaClassPath) Defaults.javaUserClassPath else "" + def scalaBootClassPath: String = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath) + def scalaExtDirs: String = cmdLineOrElse("extdirs", Defaults.scalaExtDirs) + def priorityClassPath: String = cmdLineOrElse("priorityclasspath", "") /** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as: * [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect * [scaladoc] case class ReificationException(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg) @@ -203,7 +203,7 @@ class PathResolver(implicit ctx: Context) { * and then when typing relative names, instead of picking .scala.relect, typedIdentifier will pick up the * .reflect package created by the bootstrapping. Thus, no bootstrapping for scaladoc! * TODO: we should refactor this as a separate -bootstrap option to have a clean implementation, no? */ - def sourcePath = cmdLineOrElse("sourcepath", Defaults.scalaSourcePath) + def sourcePath: String = cmdLineOrElse("sourcepath", Defaults.scalaSourcePath) /** Against my better judgment, giving in to martin here and allowing * CLASSPATH to be used automatically. So for the user-specified part @@ -213,7 +213,7 @@ class PathResolver(implicit ctx: Context) { * - Otherwise, if CLASSPATH is set, it is that * - If neither of those, then "." is used. */ - def userClassPath = { + def userClassPath: String = { if (!settings.classpath.isDefault) settings.classpath.value else sys.env.getOrElse("CLASSPATH", ".") @@ -223,7 +223,7 @@ class PathResolver(implicit ctx: Context) { // Assemble the elements! // priority class path takes precedence - def basis = List[Traversable[ClassPath]]( + def basis: List[Traversable[ClassPath]] = List( classesInExpandedPath(priorityClassPath), // 0. The priority class path (for testing). JrtClassPath.apply(), // 1. The Java 9 classpath (backed by the jrt:/ virtual system, if available) classesInPath(javaBootClassPath), // 2. The Java bootstrap class path. @@ -235,9 +235,9 @@ class PathResolver(implicit ctx: Context) { sourcesInPath(sourcePath) // 8. The Scala source path. ) - lazy val containers = basis.flatten.distinct + lazy val containers: List[ClassPath] = basis.flatten.distinct - override def toString = """ + override def toString: String = """ |object Calculated { | scalaHome = %s | priorityClassPath = %s @@ -258,7 +258,7 @@ class PathResolver(implicit ctx: Context) { ) } - def containers = Calculated.containers + def containers: List[ClassPath] = Calculated.containers lazy val result: ClassPath = { val cp = AggregateClassPath(containers.toIndexedSeq) @@ -275,6 +275,6 @@ class PathResolver(implicit ctx: Context) { cp } - def asURLs = result.asURLs + def asURLs: Seq[java.net.URL] = result.asURLs } diff --git a/compiler/src/dotty/tools/dotc/config/Properties.scala b/compiler/src/dotty/tools/dotc/config/Properties.scala index a4523f5d4633..c025685d1801 100644 --- a/compiler/src/dotty/tools/dotc/config/Properties.scala +++ b/compiler/src/dotty/tools/dotc/config/Properties.scala @@ -4,17 +4,17 @@ package config import scala.annotation.internal.sharable -import java.io.{ IOException, PrintWriter } +import java.io.IOException import java.util.jar.Attributes.{ Name => AttributeName } /** Loads `library.properties` from the jar. */ object Properties extends PropertiesTrait { - protected def propCategory = "compiler" - protected def pickJarBasedOn = classOf[Option[_]] + protected def propCategory: String = "compiler" + protected def pickJarBasedOn: Class[Option[_]] = classOf[Option[_]] /** Scala manifest attributes. */ - @sharable val ScalaCompilerVersion = new AttributeName("Scala-Compiler-Version") + @sharable val ScalaCompilerVersion: AttributeName = new AttributeName("Scala-Compiler-Version") } trait PropertiesTrait { @@ -22,7 +22,7 @@ trait PropertiesTrait { protected def pickJarBasedOn: Class[_] // props file comes from jar containing this /** The name of the properties file */ - protected val propFilename = "/" + propCategory + ".properties" + protected val propFilename: String = "/" + propCategory + ".properties" /** The loaded properties */ @sharable protected lazy val scalaProps: java.util.Properties = { @@ -41,18 +41,18 @@ trait PropertiesTrait { catch { case _: IOException => } } - def propIsSet(name: String) = System.getProperty(name) != null - def propIsSetTo(name: String, value: String) = propOrNull(name) == value - def propOrElse(name: String, alt: String) = System.getProperty(name, alt) - def propOrEmpty(name: String) = propOrElse(name, "") - def propOrNull(name: String) = propOrElse(name, null) - def propOrNone(name: String) = Option(propOrNull(name)) - def propOrFalse(name: String) = propOrNone(name) exists (x => List("yes", "on", "true") contains x.toLowerCase) - def setProp(name: String, value: String) = System.setProperty(name, value) - def clearProp(name: String) = System.clearProperty(name) + def propIsSet(name: String): Boolean = System.getProperty(name) != null + def propIsSetTo(name: String, value: String): Boolean = propOrNull(name) == value + def propOrElse(name: String, alt: String): String = System.getProperty(name, alt) + def propOrEmpty(name: String): String = propOrElse(name, "") + def propOrNull(name: String): String = propOrElse(name, null) + def propOrNone(name: String): Option[String] = Option(propOrNull(name)) + def propOrFalse(name: String): Boolean = propOrNone(name) exists (x => List("yes", "on", "true") contains x.toLowerCase) + def setProp(name: String, value: String): String = System.setProperty(name, value) + def clearProp(name: String): String = System.clearProperty(name) - def envOrElse(name: String, alt: String) = Option(System getenv name) getOrElse alt - def envOrNone(name: String) = Option(System getenv name) + def envOrElse(name: String, alt: String): String = Option(System getenv name) getOrElse alt + def envOrNone(name: String): Option[String] = Option(System getenv name) // for values based on propFilename def scalaPropOrElse(name: String, alt: String): String = scalaProps.getProperty(name, alt) @@ -62,12 +62,12 @@ trait PropertiesTrait { /** Either the development or release version if known, otherwise * the empty string. */ - def versionNumberString = scalaPropOrEmpty("version.number") + def versionNumberString: String = scalaPropOrEmpty("version.number") /** The version number of the jar this was loaded from plus "version " prefix, * or "version (unknown)" if it cannot be determined. */ - val versionString = { + val versionString: String = { val v = scalaPropOrElse("version.number", "(unknown)") "version " + scalaPropOrElse("version.number", "(unknown)") + { if (v.contains("SNAPSHOT") || v.contains("NIGHTLY")) { @@ -82,53 +82,53 @@ trait PropertiesTrait { * 2. Features supported by experimental versions of the compiler: * - research plugins */ - val experimental = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY") + val experimental: Boolean = versionString.contains("SNAPSHOT") || versionString.contains("NIGHTLY") - val copyrightString = scalaPropOrElse("copyright.string", "(c) 2002-2017 LAMP/EPFL") + val copyrightString: String = scalaPropOrElse("copyright.string", "(c) 2002-2017 LAMP/EPFL") /** This is the encoding to use reading in source files, overridden with -encoding * Note that it uses "prop" i.e. looks in the scala jar, not the system properties. */ - def sourceEncoding = scalaPropOrElse("file.encoding", "UTF-8") - def sourceReader = scalaPropOrElse("source.reader", "scala.tools.nsc.io.SourceReader") + def sourceEncoding: String = scalaPropOrElse("file.encoding", "UTF-8") + def sourceReader: String = scalaPropOrElse("source.reader", "scala.tools.nsc.io.SourceReader") /** This is the default text encoding, overridden (unreliably) with * `JAVA_OPTS="-Dfile.encoding=Foo"` */ - def encodingString = propOrElse("file.encoding", "UTF-8") + def encodingString: String = propOrElse("file.encoding", "UTF-8") /** The default end of line character. */ - def lineSeparator = propOrElse("line.separator", "\n") + def lineSeparator: String = propOrElse("line.separator", "\n") /** Various well-known properties. */ - def javaClassPath = propOrEmpty("java.class.path") - def javaHome = propOrEmpty("java.home") - def javaVendor = propOrEmpty("java.vendor") - def javaVersion = propOrEmpty("java.version") - def javaVmInfo = propOrEmpty("java.vm.info") - def javaVmName = propOrEmpty("java.vm.name") - def javaVmVendor = propOrEmpty("java.vm.vendor") - def javaVmVersion = propOrEmpty("java.vm.version") - def osName = propOrEmpty("os.name") - def scalaHome = propOrEmpty("scala.home") - def tmpDir = propOrEmpty("java.io.tmpdir") - def userDir = propOrEmpty("user.dir") - def userHome = propOrEmpty("user.home") - def userName = propOrEmpty("user.name") + def javaClassPath: String = propOrEmpty("java.class.path") + def javaHome: String = propOrEmpty("java.home") + def javaVendor: String = propOrEmpty("java.vendor") + def javaVersion: String = propOrEmpty("java.version") + def javaVmInfo: String = propOrEmpty("java.vm.info") + def javaVmName: String = propOrEmpty("java.vm.name") + def javaVmVendor: String = propOrEmpty("java.vm.vendor") + def javaVmVersion: String = propOrEmpty("java.vm.version") + def osName: String = propOrEmpty("os.name") + def scalaHome: String = propOrEmpty("scala.home") + def tmpDir: String = propOrEmpty("java.io.tmpdir") + def userDir: String = propOrEmpty("user.dir") + def userHome: String = propOrEmpty("user.home") + def userName: String = propOrEmpty("user.name") /** Some derived values. */ - def isWin = osName startsWith "Windows" - def isMac = javaVendor startsWith "Apple" + def isWin: Boolean = osName startsWith "Windows" + def isMac: Boolean = javaVendor startsWith "Apple" // This is looking for javac, tools.jar, etc. // Tries JDK_HOME first, then the more common but likely jre JAVA_HOME, // and finally the system property based javaHome. - def jdkHome = envOrElse("JDK_HOME", envOrElse("JAVA_HOME", javaHome)) + def jdkHome: String = envOrElse("JDK_HOME", envOrElse("JAVA_HOME", javaHome)) - def versionMsg = "Scala %s %s -- %s".format(propCategory, versionString, copyrightString) - def scalaCmd = if (isWin) "dotr.bat" else "dotr" - def scalacCmd = if (isWin) "dotc.bat" else "dotc" + def versionMsg: String = "Scala %s %s -- %s".format(propCategory, versionString, copyrightString) + def scalaCmd: String = if (isWin) "dotr.bat" else "dotr" + def scalacCmd: String = if (isWin) "dotc.bat" else "dotc" } diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 234553118300..07a52d32a778 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -1,153 +1,152 @@ package dotty.tools.dotc package config -import java.io.File -import dotty.tools.io.{ Directory, PlainDirectory } - +import dotty.tools.io.{ Directory, PlainDirectory, AbstractFile } import PathResolver.Defaults import rewrites.Rewrites +import Settings.Setting class ScalaSettings extends Settings.SettingGroup { - protected def defaultClasspath = sys.env.getOrElse("CLASSPATH", ".") + protected def defaultClasspath: String = sys.env.getOrElse("CLASSPATH", ".") /** Path related settings */ - val bootclasspath = PathSetting("-bootclasspath", "Override location of bootstrap class files.", Defaults.scalaBootClassPath) - val extdirs = PathSetting("-extdirs", "Override location of installed extensions.", Defaults.scalaExtDirs) - val javabootclasspath = PathSetting("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath) - val javaextdirs = PathSetting("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs) - val sourcepath = PathSetting("-sourcepath", "Specify location(s) of source files.", Defaults.scalaSourcePath) - val scansource = BooleanSetting("-scansource", "Scan source files to locate classes for which class-name != file-name") - - val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" - val outputDir = OutputSetting("-d", "directory|jar", "destination for generated classfiles.", + val bootclasspath: Setting[String] = PathSetting("-bootclasspath", "Override location of bootstrap class files.", Defaults.scalaBootClassPath) + val extdirs: Setting[String] = PathSetting("-extdirs", "Override location of installed extensions.", Defaults.scalaExtDirs) + val javabootclasspath: Setting[String] = PathSetting("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath) + val javaextdirs: Setting[String] = PathSetting("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs) + val sourcepath: Setting[String] = PathSetting("-sourcepath", "Specify location(s) of source files.", Defaults.scalaSourcePath) + val scansource: Setting[Boolean] = BooleanSetting("-scansource", "Scan source files to locate classes for which class-name != file-name") + + val classpath: Setting[String] = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp" + val outputDir: Setting[AbstractFile] = OutputSetting("-d", "directory|jar", "destination for generated classfiles.", new PlainDirectory(Directory("."))) - val priorityclasspath = PathSetting("-priorityclasspath", "class path that takes precedence over all other paths (or testing only)", "") + val priorityclasspath: Setting[String] = PathSetting("-priorityclasspath", "class path that takes precedence over all other paths (or testing only)", "") /** Other settings */ - val deprecation = BooleanSetting("-deprecation", "Emit warning and location for usages of deprecated APIs.") - val migration = BooleanSetting("-migration", "Emit warning and location for migration issues from Scala 2.") - val encoding = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding) - val explainTypes = BooleanSetting("-explain-types", "Explain type errors in more detail.") - val explain = BooleanSetting("-explain", "Explain errors in more detail.") - val feature = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.") - val help = BooleanSetting("-help", "Print a synopsis of standard options") - val color = ChoiceSetting("-color", "mode", "Colored output", List("always", "never"/*, "auto"*/), "always"/* "auto"*/) - val target = ChoiceSetting("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.", + val deprecation: Setting[Boolean] = BooleanSetting("-deprecation", "Emit warning and location for usages of deprecated APIs.") + val migration: Setting[Boolean] = BooleanSetting("-migration", "Emit warning and location for migration issues from Scala 2.") + val encoding: Setting[String] = StringSetting("-encoding", "encoding", "Specify character encoding used by source files.", Properties.sourceEncoding) + val explainTypes: Setting[Boolean] = BooleanSetting("-explain-types", "Explain type errors in more detail.") + val explain: Setting[Boolean] = BooleanSetting("-explain", "Explain errors in more detail.") + val feature: Setting[Boolean] = BooleanSetting("-feature", "Emit warning and location for usages of features that should be imported explicitly.") + val help: Setting[Boolean] = BooleanSetting("-help", "Print a synopsis of standard options") + val color: Setting[String] = ChoiceSetting("-color", "mode", "Colored output", List("always", "never"/*, "auto"*/), "always"/* "auto"*/) + val target: Setting[String] = ChoiceSetting("-target", "target", "Target platform for object files. All JVM 1.5 targets are deprecated.", List("jvm-1.5", "jvm-1.5-fjbg", "jvm-1.5-asm", "jvm-1.6", "jvm-1.7", "jvm-1.8", "msil"), "jvm-1.8") - val unchecked = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.") - val uniqid = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.") - val usejavacp = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.") - val verbose = BooleanSetting("-verbose", "Output messages about what the compiler is doing.") - val version = BooleanSetting("-version", "Print product version and exit.") - val pageWidth = IntSetting("-pagewidth", "Set page width", 80) - val strict = BooleanSetting("-strict", "Use strict type rules, which means some formerly legal code does not typecheck anymore.") - val language = MultiStringSetting("-language", "feature", "Enable one or more language features.") - val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax") - val silentWarnings = BooleanSetting("-nowarn", "Silence all warnings.") - val fromTasty = BooleanSetting("-from-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.") + val unchecked: Setting[Boolean] = BooleanSetting("-unchecked", "Enable additional warnings where generated code depends on assumptions.") + val uniqid: Setting[Boolean] = BooleanSetting("-uniqid", "Uniquely tag all identifiers in debugging output.") + val usejavacp: Setting[Boolean] = BooleanSetting("-usejavacp", "Utilize the java.class.path in classpath resolution.") + val verbose: Setting[Boolean] = BooleanSetting("-verbose", "Output messages about what the compiler is doing.") + val version: Setting[Boolean] = BooleanSetting("-version", "Print product version and exit.") + val pageWidth: Setting[Int] = IntSetting("-pagewidth", "Set page width", 80) + val strict: Setting[Boolean] = BooleanSetting("-strict", "Use strict type rules, which means some formerly legal code does not typecheck anymore.") + val language: Setting[List[String]] = MultiStringSetting("-language", "feature", "Enable one or more language features.") + val rewrite: Setting[Option[Rewrites]] = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax") + val silentWarnings: Setting[Boolean] = BooleanSetting("-nowarn", "Silence all warnings.") + val fromTasty: Setting[Boolean] = BooleanSetting("-from-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.") /** Decompiler settings */ - val printTasty = BooleanSetting("-print-tasty", "Prints the raw tasty.") - val printLines = BooleanSetting("-print-lines", "Show source code line numbers.") + val printTasty: Setting[Boolean] = BooleanSetting("-print-tasty", "Prints the raw tasty.") + val printLines: Setting[Boolean] = BooleanSetting("-print-lines", "Show source code line numbers.") /** Plugin-related setting */ - val plugin = MultiStringSetting ("-Xplugin", "paths", "Load a plugin from each classpath.") - val disable = MultiStringSetting ("-Xplugin-disable", "plugin", "Disable plugins by name.") - val require = MultiStringSetting ("-Xplugin-require", "plugin", "Abort if a named plugin is not loaded.") - val showPlugins = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins.") - val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search for plugin archives.", Defaults.scalaPluginPath) - val pluginOptions = MultiStringSetting ("-P", "plugin:opt", "Pass an option to a plugin, e.g. -P::") + val plugin: Setting[List[String]] = MultiStringSetting ("-Xplugin", "paths", "Load a plugin from each classpath.") + val disable: Setting[List[String]] = MultiStringSetting ("-Xplugin-disable", "plugin", "Disable plugins by name.") + val require: Setting[List[String]] = MultiStringSetting ("-Xplugin-require", "plugin", "Abort if a named plugin is not loaded.") + val showPlugins: Setting[Boolean] = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins.") + val pluginsDir: Setting[String] = StringSetting ("-Xpluginsdir", "path", "Path to search for plugin archives.", Defaults.scalaPluginPath) + val pluginOptions: Setting[List[String]] = MultiStringSetting ("-P", "plugin:opt", "Pass an option to a plugin, e.g. -P::") /** -X "Advanced" settings */ - val Xhelp = BooleanSetting("-X", "Print a synopsis of advanced options.") - val XnoForwarders = BooleanSetting("-Xno-forwarders", "Do not generate static forwarders in mirror classes.") - val XminImplicitSearchDepth = IntSetting("-Xmin-implicit-search-depth", "Set number of levels of implicit searches undertaken before checking for divergence.", 5) - val XmaxInlines = IntSetting("-Xmax-inlines", "Maximal number of successive inlines", 32) - val XmaxClassfileName = IntSetting("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, 72 to 255) - val Xmigration = VersionSetting("-Xmigration", "Warn about constructs whose behavior may have changed since version.") - val Xprint = PhasesSetting("-Xprint", "Print out program after") - val XprintTypes = BooleanSetting("-Xprint-types", "Print tree types (debugging option).") - val XprintDiff = BooleanSetting("-Xprint-diff", "Print changed parts of the tree since last print.") - val XprintDiffDel = BooleanSetting("-Xprint-diff-del", "Print changed parts of the tree since last print including deleted parts.") - val Xprompt = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).") - val XmainClass = StringSetting("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d )", "") - val XnoValueClasses = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") - val XreplLineWidth = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390) - val XfatalWarnings = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.") - val XverifySignatures = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.") + val Xhelp: Setting[Boolean] = BooleanSetting("-X", "Print a synopsis of advanced options.") + val XnoForwarders: Setting[Boolean] = BooleanSetting("-Xno-forwarders", "Do not generate static forwarders in mirror classes.") + val XminImplicitSearchDepth: Setting[Int] = IntSetting("-Xmin-implicit-search-depth", "Set number of levels of implicit searches undertaken before checking for divergence.", 5) + val XmaxInlines: Setting[Int] = IntSetting("-Xmax-inlines", "Maximal number of successive inlines", 32) + val XmaxClassfileName: Setting[Int] = IntSetting("-Xmax-classfile-name", "Maximum filename length for generated classes", 255, 72 to 255) + val Xmigration: Setting[ScalaVersion] = VersionSetting("-Xmigration", "Warn about constructs whose behavior may have changed since version.") + val Xprint: Setting[List[String]] = PhasesSetting("-Xprint", "Print out program after") + val XprintTypes: Setting[Boolean] = BooleanSetting("-Xprint-types", "Print tree types (debugging option).") + val XprintDiff: Setting[Boolean] = BooleanSetting("-Xprint-diff", "Print changed parts of the tree since last print.") + val XprintDiffDel: Setting[Boolean] = BooleanSetting("-Xprint-diff-del", "Print changed parts of the tree since last print including deleted parts.") + val Xprompt: Setting[Boolean] = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).") + val XmainClass: Setting[String] = StringSetting("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d )", "") + val XnoValueClasses: Setting[Boolean] = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.") + val XreplLineWidth: Setting[Int] = IntSetting("-Xrepl-line-width", "Maximal number of columns per line for REPL output", 390) + val XfatalWarnings: Setting[Boolean] = BooleanSetting("-Xfatal-warnings", "Fail the compilation if there are any warnings.") + val XverifySignatures: Setting[Boolean] = BooleanSetting("-Xverify-signatures", "Verify generic signatures in generated bytecode.") /** -Y "Private" settings */ - val YoverrideVars = BooleanSetting("-Yoverride-vars", "Allow vars to be overridden.") - val Yhelp = BooleanSetting("-Y", "Print a synopsis of private options.") - val Ycheck = PhasesSetting("-Ycheck", "Check the tree at the end of") - val YcheckMods = BooleanSetting("-Ycheck-mods", "Check that symbols and their defining trees have modifiers in sync") - val Ydebug = BooleanSetting("-Ydebug", "Increase the quantity of debugging output.") - val YdebugTrace = BooleanSetting("-Ydebug-trace", "Trace core operations") - val YdebugFlags = BooleanSetting("-Ydebug-flags", "Print all flags of definitions") - val YdebugMissingRefs = BooleanSetting("-Ydebug-missing-refs", "Print a stacktrace when a required symbol is missing") - val YdebugNames = BooleanSetting("-Ydebug-names", "Show internal representation of names") - val YtermConflict = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error") - val Ylog = PhasesSetting("-Ylog", "Log operations during") - val YemitTastyInClass = BooleanSetting("-Yemit-tasty-in-class", "Generate tasty in the .class file and add an empty *.hasTasty file.") - val YlogClasspath = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.") - val YdisableFlatCpCaching = BooleanSetting("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.") - - val Yscala2Unpickler = StringSetting("-Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always") - - val YnoImports = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.") - val YnoInline = BooleanSetting("-Yno-inline", "Suppress inlining.") - val YnoGenericSig = BooleanSetting("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.") - val YnoPredef = BooleanSetting("-Yno-predef", "Compile without importing Predef.") - val Yskip = PhasesSetting("-Yskip", "Skip") - val Ydumpclasses = StringSetting("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") - val YstopAfter = PhasesSetting("-Ystop-after", "Stop after") withAbbreviation ("-stop") // backward compat - val YstopBefore = PhasesSetting("-Ystop-before", "Stop before") // stop before erasure as long as we have not debugged it fully - val YtraceContextCreation = BooleanSetting("-Ytrace-context-creation", "Store stack trace of context creations.") - val YshowSuppressedErrors = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally suppressed.") - val YdetailedStats = BooleanSetting("-Ydetailed-stats", "show detailed internal compiler stats (needs Stats.enabled to be set to true).") - val Yheartbeat = BooleanSetting("-Ydetailed-stats", "show heartbeat stack trace of compiler operations (needs Stats.enabled to be set to true).") - val YprintPos = BooleanSetting("-Yprint-pos", "show tree positions.") - val YprintPosSyms = BooleanSetting("-Yprint-pos-syms", "show symbol definitions positions.") - val YnoDeepSubtypes = BooleanSetting("-Yno-deep-subtypes", "throw an exception on deep subtyping call stacks.") - val YnoPatmatOpt = BooleanSetting("-Yno-patmat-opt", "disable all pattern matching optimizations.") - val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.") - val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.") - val YprintDebug = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.") - val YprintDebugOwners = BooleanSetting("-Yprint-debug-owners", "when printing trees, print owners of definitions.") - val YshowPrintErrors = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.") - val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler") - val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.") - val YdropComments = BooleanSetting("-Ydrop-comments", "Drop comments when scanning source files.") - val YcookComments = BooleanSetting("-Ycook-comments", "Cook the comments (type check `@usecase`, etc.)") - val YforceSbtPhases = BooleanSetting("-Yforce-sbt-phases", "Run the phases used by sbt for incremental compilation (ExtractDependencies and ExtractAPI) even if the compiler is ran outside of sbt, for debugging.") - val YdumpSbtInc = BooleanSetting("-Ydump-sbt-inc", "For every compiled foo.scala, output the API representation and dependencies used for sbt incremental compilation in foo.inc, implies -Yforce-sbt-phases.") - val YcheckAllPatmat = BooleanSetting("-Ycheck-all-patmat", "Check exhaustivity and redundancy of all pattern matching (used for testing the algorithm)") - val YretainTrees = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree") - val YshowTreeIds = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.") - - val YprofileEnabled = BooleanSetting("-Yprofile-enabled", "Enable profiling.") - val YprofileDestination = StringSetting("-Yprofile-destination", "file", "where to send profiling output - specify a file, default is to the console.", "") + val YoverrideVars: Setting[Boolean] = BooleanSetting("-Yoverride-vars", "Allow vars to be overridden.") + val Yhelp: Setting[Boolean] = BooleanSetting("-Y", "Print a synopsis of private options.") + val Ycheck: Setting[List[String]] = PhasesSetting("-Ycheck", "Check the tree at the end of") + val YcheckMods: Setting[Boolean] = BooleanSetting("-Ycheck-mods", "Check that symbols and their defining trees have modifiers in sync") + val Ydebug: Setting[Boolean] = BooleanSetting("-Ydebug", "Increase the quantity of debugging output.") + val YdebugTrace: Setting[Boolean] = BooleanSetting("-Ydebug-trace", "Trace core operations") + val YdebugFlags: Setting[Boolean] = BooleanSetting("-Ydebug-flags", "Print all flags of definitions") + val YdebugMissingRefs: Setting[Boolean] = BooleanSetting("-Ydebug-missing-refs", "Print a stacktrace when a required symbol is missing") + val YdebugNames: Setting[Boolean] = BooleanSetting("-Ydebug-names", "Show internal representation of names") + val YtermConflict: Setting[String] = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error") + val Ylog: Setting[List[String]] = PhasesSetting("-Ylog", "Log operations during") + val YemitTastyInClass: Setting[Boolean] = BooleanSetting("-Yemit-tasty-in-class", "Generate tasty in the .class file and add an empty *.hasTasty file.") + val YlogClasspath: Setting[Boolean] = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.") + val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.") + + val Yscala2Unpickler: Setting[String] = StringSetting("-Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always") + + val YnoImports: Setting[Boolean] = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.") + val YnoInline: Setting[Boolean] = BooleanSetting("-Yno-inline", "Suppress inlining.") + val YnoGenericSig: Setting[Boolean] = BooleanSetting("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.") + val YnoPredef: Setting[Boolean] = BooleanSetting("-Yno-predef", "Compile without importing Predef.") + val Yskip: Setting[List[String]] = PhasesSetting("-Yskip", "Skip") + val Ydumpclasses: Setting[String] = StringSetting("-Ydump-classes", "dir", "Dump the generated bytecode to .class files (useful for reflective compilation that utilizes in-memory classloaders).", "") + val YstopAfter: Setting[List[String]] = PhasesSetting("-Ystop-after", "Stop after") withAbbreviation ("-stop") // backward compat + val YstopBefore: Setting[List[String]] = PhasesSetting("-Ystop-before", "Stop before") // stop before erasure as long as we have not debugged it fully + val YtraceContextCreation: Setting[Boolean] = BooleanSetting("-Ytrace-context-creation", "Store stack trace of context creations.") + val YshowSuppressedErrors: Setting[Boolean] = BooleanSetting("-Yshow-suppressed-errors", "Also show follow-on errors and warnings that are normally suppressed.") + val YdetailedStats: Setting[Boolean] = BooleanSetting("-Ydetailed-stats", "show detailed internal compiler stats (needs Stats.enabled to be set to true).") + val Yheartbeat: Setting[Boolean] = BooleanSetting("-Ydetailed-stats", "show heartbeat stack trace of compiler operations (needs Stats.enabled to be set to true).") + val YprintPos: Setting[Boolean] = BooleanSetting("-Yprint-pos", "show tree positions.") + val YprintPosSyms: Setting[Boolean] = BooleanSetting("-Yprint-pos-syms", "show symbol definitions positions.") + val YnoDeepSubtypes: Setting[Boolean] = BooleanSetting("-Yno-deep-subtypes", "throw an exception on deep subtyping call stacks.") + val YnoPatmatOpt: Setting[Boolean] = BooleanSetting("-Yno-patmat-opt", "disable all pattern matching optimizations.") + val YplainPrinter: Setting[Boolean] = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.") + val YprintSyms: Setting[Boolean] = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.") + val YprintDebug: Setting[Boolean] = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.") + val YprintDebugOwners: Setting[Boolean] = BooleanSetting("-Yprint-debug-owners", "when printing trees, print owners of definitions.") + val YshowPrintErrors: Setting[Boolean] = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.") + val YtestPickler: Setting[Boolean] = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler") + val YcheckReentrant: Setting[Boolean] = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.") + val YdropComments: Setting[Boolean] = BooleanSetting("-Ydrop-comments", "Drop comments when scanning source files.") + val YcookComments: Setting[Boolean] = BooleanSetting("-Ycook-comments", "Cook the comments (type check `@usecase`, etc.)") + val YforceSbtPhases: Setting[Boolean] = BooleanSetting("-Yforce-sbt-phases", "Run the phases used by sbt for incremental compilation (ExtractDependencies and ExtractAPI) even if the compiler is ran outside of sbt, for debugging.") + val YdumpSbtInc: Setting[Boolean] = BooleanSetting("-Ydump-sbt-inc", "For every compiled foo.scala, output the API representation and dependencies used for sbt incremental compilation in foo.inc, implies -Yforce-sbt-phases.") + val YcheckAllPatmat: Setting[Boolean] = BooleanSetting("-Ycheck-all-patmat", "Check exhaustivity and redundancy of all pattern matching (used for testing the algorithm)") + val YretainTrees: Setting[Boolean] = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree") + val YshowTreeIds: Setting[Boolean] = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.") + + val YprofileEnabled: Setting[Boolean] = BooleanSetting("-Yprofile-enabled", "Enable profiling.") + val YprofileDestination: Setting[String] = StringSetting("-Yprofile-destination", "file", "where to send profiling output - specify a file, default is to the console.", "") //.withPostSetHook( _ => YprofileEnabled.value = true ) - val YprofileExternalTool = PhasesSetting("-Yprofile-external-tool", "Enable profiling for a phase using an external tool hook. Generally only useful for a single phase", "typer") + val YprofileExternalTool: Setting[List[String]] = PhasesSetting("-Yprofile-external-tool", "Enable profiling for a phase using an external tool hook. Generally only useful for a single phase", "typer") //.withPostSetHook( _ => YprofileEnabled.value = true ) - val YprofileRunGcBetweenPhases = PhasesSetting("-Yprofile-run-gc", "Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or *", "_") + val YprofileRunGcBetweenPhases: Setting[List[String]] = PhasesSetting("-Yprofile-run-gc", "Run a GC between phases - this allows heap size to be accurate at the expense of more time. Specify a list of phases, or *", "_") //.withPostSetHook( _ => YprofileEnabled.value = true ) // Extremely experimental language features - val YkindPolymorphism = BooleanSetting("-Ykind-polymorphism", "Enable kind polymorphism (see http://dotty.epfl.ch/docs/reference/kind-polymorphism.html). Potentially unsound.") + val YkindPolymorphism: Setting[Boolean] = BooleanSetting("-Ykind-polymorphism", "Enable kind polymorphism (see http://dotty.epfl.ch/docs/reference/kind-polymorphism.html). Potentially unsound.") /** Area-specific debug output */ - val YexplainLowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.") - val YnoDoubleBindings = BooleanSetting("-Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).") - val YshowVarBounds = BooleanSetting("-Yshow-var-bounds", "Print type variables with their bounds") - val YshowNoInline = BooleanSetting("-Yshow-no-inline", "Show inlined code without the 'inlined from' info") + val YexplainLowlevel: Setting[Boolean] = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.") + val YnoDoubleBindings: Setting[Boolean] = BooleanSetting("-Yno-double-bindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).") + val YshowVarBounds: Setting[Boolean] = BooleanSetting("-Yshow-var-bounds", "Print type variables with their bounds") + val YshowNoInline: Setting[Boolean] = BooleanSetting("-Yshow-no-inline", "Show inlined code without the 'inlined from' info") - val YnoDecodeStacktraces = BooleanSetting("-Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.") + val YnoDecodeStacktraces: Setting[Boolean] = BooleanSetting("-Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.") /** Dottydoc specific settings */ - val siteRoot = StringSetting( + val siteRoot: Setting[String] = StringSetting( "-siteroot", "site root", "A directory containing static files from which to generate documentation", @@ -155,26 +154,26 @@ class ScalaSettings extends Settings.SettingGroup { ) - val projectName = StringSetting ( + val projectName: Setting[String] = StringSetting ( "-project", "project title", "The name of the project", "" ) - val projectVersion = StringSetting ( + val projectVersion: Setting[String] = StringSetting ( "-project-version", "project version", "The current version of your project", "" ) - val projectUrl = StringSetting ( + val projectUrl: Setting[String] = StringSetting ( "-project-url", "project repository homepage", "The source repository of your project", "" ) - val wikiSyntax = BooleanSetting("-Xwiki-syntax", "Retains the Scala2 behavior of using Wiki Syntax in Scaladoc") + val wikiSyntax: Setting[Boolean] = BooleanSetting("-Xwiki-syntax", "Retains the Scala2 behavior of using Wiki Syntax in Scaladoc") } diff --git a/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala b/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala index 9bb7431d5384..8ba3dce8306a 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaVersion.scala @@ -18,7 +18,7 @@ sealed abstract class ScalaVersion extends Ordered[ScalaVersion] { * A scala version that sorts higher than all actual versions */ @sharable case object NoScalaVersion extends ScalaVersion { - def unparse = "none" + def unparse: String = "none" def compare(that: ScalaVersion): Int = that match { case NoScalaVersion => 0 @@ -33,7 +33,7 @@ sealed abstract class ScalaVersion extends Ordered[ScalaVersion] { * to segregate builds */ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBuild) extends ScalaVersion { - def unparse = s"${major}.${minor}.${rev}.${build.unparse}" + def unparse: String = s"${major}.${minor}.${rev}.${build.unparse}" def compare(that: ScalaVersion): Int = that match { case SpecificScalaVersion(thatMajor, thatMinor, thatRev, thatBuild) => @@ -55,7 +55,7 @@ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBu * A Scala version that sorts lower than all actual versions */ @sharable case object AnyScalaVersion extends ScalaVersion { - def unparse = "any" + def unparse: String = "any" def compare(that: ScalaVersion): Int = that match { case AnyScalaVersion => 0 @@ -110,7 +110,7 @@ case class SpecificScalaVersion(major: Int, minor: Int, rev: Int, build: ScalaBu /** * The version of the compiler running now */ - val current = parse(util.Properties.versionNumberString).get + val current: ScalaVersion = parse(util.Properties.versionNumberString).get } /** @@ -129,9 +129,9 @@ object ScalaBuild { /** A development, test, nightly, snapshot or other "unofficial" build */ case class Development(id: String) extends ScalaBuild { - def unparse = s"-${id}" + def unparse: String = s"-${id}" - def compare(that: ScalaBuild) = that match { + def compare(that: ScalaBuild): Int = that match { // sorting two development builds based on id is reasonably valid for two versions created with the same schema // otherwise it's not correct, but since it's impossible to put a total ordering on development build versions // this is a pragmatic compromise @@ -145,9 +145,9 @@ object ScalaBuild { /** A final build */ case object Final extends ScalaBuild { - def unparse = "" + def unparse: String = "" - def compare(that: ScalaBuild) = that match { + def compare(that: ScalaBuild): Int = that match { case Final => 0 // a final is newer than anything other than a development build or another final case Development(_) => -1 @@ -158,9 +158,9 @@ object ScalaBuild { /** A candidate for final release */ case class RC(n: Int) extends ScalaBuild { - def unparse = s"-RC${n}" + def unparse: String = s"-RC${n}" - def compare(that: ScalaBuild) = that match { + def compare(that: ScalaBuild): Int = that match { // compare two rcs based on their RC numbers case RC(thatN) => n - thatN // an rc is older than anything other than a milestone or another rc @@ -172,9 +172,9 @@ object ScalaBuild { /** An intermediate release */ case class Milestone(n: Int) extends ScalaBuild { - def unparse = s"-M${n}" + def unparse: String = s"-M${n}" - def compare(that: ScalaBuild) = that match { + def compare(that: ScalaBuild): Int = that match { // compare two milestones based on their milestone numbers case Milestone(thatN) => n - thatN // a milestone is older than anything other than another milestone diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 35ed62aa6366..910cbe5da569 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -1,12 +1,12 @@ package dotty.tools.dotc package config -import collection.mutable.{ ArrayBuffer } -import scala.util.{ Try, Success, Failure } +import collection.mutable.ArrayBuffer +import scala.util.{ Success, Failure } import reflect.ClassTag import core.Contexts._ import scala.annotation.tailrec -import dotty.tools.io.{ AbstractFile, Directory, JarArchive, PlainDirectory, File, Path } +import dotty.tools.io.{ AbstractFile, Directory, JarArchive, PlainDirectory } // import annotation.unchecked // Dotty deviation: Imports take precedence over definitions in enclosing package @@ -16,19 +16,19 @@ import language.existentials object Settings { - val BooleanTag = ClassTag.Boolean - val IntTag = ClassTag.Int - val StringTag = ClassTag(classOf[String]) - val ListTag = ClassTag(classOf[List[_]]) - val VersionTag = ClassTag(classOf[ScalaVersion]) - val OptionTag = ClassTag(classOf[Option[_]]) - val OutputTag = ClassTag(classOf[AbstractFile]) + val BooleanTag: ClassTag[Boolean] = ClassTag.Boolean + val IntTag: ClassTag[Int] = ClassTag.Int + val StringTag: ClassTag[String] = ClassTag(classOf[String]) + val ListTag: ClassTag[List[_]] = ClassTag(classOf[List[_]]) + val VersionTag: ClassTag[ScalaVersion] = ClassTag(classOf[ScalaVersion]) + val OptionTag: ClassTag[Option[_]] = ClassTag(classOf[Option[_]]) + val OutputTag: ClassTag[AbstractFile] = ClassTag(classOf[AbstractFile]) class SettingsState(initialValues: Seq[Any]) { private[this] var values = ArrayBuffer(initialValues: _*) private[this] var _wasRead: Boolean = false - override def toString = s"SettingsState(values: ${values.toList})" + override def toString: String = s"SettingsState(values: ${values.toList})" def value(idx: Int): Any = { _wasRead = true @@ -50,10 +50,10 @@ object Settings { errors: List[String], warnings: List[String]) { - def fail(msg: String) = + def fail(msg: String): Settings.ArgsSummary = ArgsSummary(sstate, arguments.tail, errors :+ msg, warnings) - def warn(msg: String) = + def warn(msg: String): Settings.ArgsSummary = ArgsSummary(sstate, arguments.tail, errors, warnings :+ msg) } @@ -193,15 +193,15 @@ object Settings { class SettingGroup { - val _allSettings = new ArrayBuffer[Setting[_]] + private[this] val _allSettings: ArrayBuffer[Setting[_]] = new ArrayBuffer[Setting[_]] def allSettings: Seq[Setting[_]] = _allSettings - def defaultState = new SettingsState(allSettings map (_.default)) + def defaultState: SettingsState = new SettingsState(allSettings map (_.default)) - def userSetSettings(state: SettingsState) = + def userSetSettings(state: SettingsState): Seq[Setting[_]] = allSettings filterNot (_.isDefaultIn(state)) - def toConciseString(state: SettingsState) = + def toConciseString(state: SettingsState): String = userSetSettings(state).mkString("(", " ", ")") private def checkDependencies(state: ArgsSummary): ArgsSummary = diff --git a/compiler/src/dotty/tools/dotc/config/WrappedProperties.scala b/compiler/src/dotty/tools/dotc/config/WrappedProperties.scala index 07972b99b937..e80052872e7c 100644 --- a/compiler/src/dotty/tools/dotc/config/WrappedProperties.scala +++ b/compiler/src/dotty/tools/dotc/config/WrappedProperties.scala @@ -11,15 +11,15 @@ import java.security.AccessControlException trait WrappedProperties extends PropertiesTrait { def wrap[T](body: => T): Option[T] - protected def propCategory = "wrapped" - protected def pickJarBasedOn = this.getClass + protected def propCategory: String = "wrapped" + protected def pickJarBasedOn: Class[_] = this.getClass - override def propIsSet(name: String) = wrap(super.propIsSet(name)) exists (x => x) - override def propOrElse(name: String, alt: String) = wrap(super.propOrElse(name, alt)) getOrElse alt - override def setProp(name: String, value: String) = wrap(super.setProp(name, value)).orNull - override def clearProp(name: String) = wrap(super.clearProp(name)).orNull - override def envOrElse(name: String, alt: String) = wrap(super.envOrElse(name, alt)) getOrElse alt - override def envOrNone(name: String) = wrap(super.envOrNone(name)).flatten + override def propIsSet(name: String): Boolean = wrap(super.propIsSet(name)) exists (x => x) + override def propOrElse(name: String, alt: String): String = wrap(super.propOrElse(name, alt)) getOrElse alt + override def setProp(name: String, value: String): String = wrap(super.setProp(name, value)).orNull + override def clearProp(name: String): String = wrap(super.clearProp(name)).orNull + override def envOrElse(name: String, alt: String): String = wrap(super.envOrElse(name, alt)) getOrElse alt + override def envOrNone(name: String): Option[String] = wrap(super.envOrNone(name)).flatten def systemProperties: Iterator[(String, String)] = { import scala.collection.JavaConverters._ @@ -29,6 +29,6 @@ trait WrappedProperties extends PropertiesTrait { object WrappedProperties { object AccessControl extends WrappedProperties { - def wrap[T](body: => T) = try Some(body) catch { case _: AccessControlException => None } + def wrap[T](body: => T): Option[T] = try Some(body) catch { case _: AccessControlException => None } } } diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index d99db77c36ae..6a081898ed03 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -1,10 +1,11 @@ package dotty.tools.dotc package core -import Symbols._, Types._, util.Positions._, Contexts._, Constants._, ast.tpd._ +import Symbols._, Types._, Contexts._, Constants._, ast.tpd._ import config.ScalaVersion import StdNames._ -import dotty.tools.dotc.ast.{tpd, untpd} +import dotty.tools.dotc.ast.tpd +import scala.util.Try object Annotations { @@ -19,10 +20,10 @@ object Annotations { def appliesToModule: Boolean = true // for now; see remark in SymDenotations - def derivedAnnotation(tree: Tree)(implicit ctx: Context) = + def derivedAnnotation(tree: Tree)(implicit ctx: Context): Annotation = if (tree eq this.tree) this else Annotation(tree) - def arguments(implicit ctx: Context) = ast.tpd.arguments(tree) + def arguments(implicit ctx: Context): List[Tree] = ast.tpd.arguments(tree) def argument(i: Int)(implicit ctx: Context): Option[Tree] = { val args = arguments @@ -35,7 +36,7 @@ object Annotations { def ensureCompleted(implicit ctx: Context): Unit = tree - def sameAnnotation(that: Annotation)(implicit ctx: Context) = + def sameAnnotation(that: Annotation)(implicit ctx: Context): Boolean = symbol == that.symbol && tree.sameTree(that.tree) } @@ -48,12 +49,12 @@ object Annotations { def complete(implicit ctx: Context): Tree private[this] var myTree: Tree = null - def tree(implicit ctx: Context) = { + def tree(implicit ctx: Context): Tree = { if (myTree == null) myTree = complete(ctx) myTree } - override def isEvaluated = myTree != null + override def isEvaluated: Boolean = myTree != null } /** An annotation indicating the body of a right-hand side, @@ -61,21 +62,21 @@ object Annotations { * pickling/unpickling and TypeTreeMaps */ abstract class BodyAnnotation extends Annotation { - override def symbol(implicit ctx: Context) = defn.BodyAnnot - override def derivedAnnotation(tree: Tree)(implicit ctx: Context) = + override def symbol(implicit ctx: Context): ClassSymbol = defn.BodyAnnot + override def derivedAnnotation(tree: Tree)(implicit ctx: Context): Annotation = if (tree eq this.tree) this else ConcreteBodyAnnotation(tree) - override def arguments(implicit ctx: Context) = Nil - override def ensureCompleted(implicit ctx: Context) = () + override def arguments(implicit ctx: Context): List[Tree] = Nil + override def ensureCompleted(implicit ctx: Context): Unit = () } case class ConcreteBodyAnnotation(body: Tree) extends BodyAnnotation { - def tree(implicit ctx: Context) = body + def tree(implicit ctx: Context): Tree = body } case class LazyBodyAnnotation(private var bodyExpr: Context => Tree) extends BodyAnnotation { private[this] var evaluated = false private[this] var myBody: Tree = _ - def tree(implicit ctx: Context) = { + def tree(implicit ctx: Context): Tree = { if (evaluated) assert(myBody != null) else { evaluated = true @@ -84,12 +85,12 @@ object Annotations { } myBody } - override def isEvaluated = evaluated + override def isEvaluated: Boolean = evaluated } object Annotation { - def apply(tree: Tree) = ConcreteAnnotation(tree) + def apply(tree: Tree): ConcreteAnnotation = ConcreteAnnotation(tree) def apply(cls: ClassSymbol)(implicit ctx: Context): Annotation = apply(cls, Nil) @@ -149,7 +150,7 @@ object Annotations { def deferredResolve(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = deferred(atp.classSymbol, implicit ctx => resolveConstructor(atp, args)) - def makeAlias(sym: TermSymbol)(implicit ctx: Context) = + def makeAlias(sym: TermSymbol)(implicit ctx: Context): Annotation = apply(defn.AliasAnnot, List( ref(TermRef(sym.owner.thisType, sym.name, sym)))) @@ -176,11 +177,11 @@ object Annotations { else None } - def makeSourceFile(path: String)(implicit ctx: Context) = + def makeSourceFile(path: String)(implicit ctx: Context): Annotation = apply(defn.SourceFileAnnot, Literal(Constant(path))) } - def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context) = { + def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context): Annotation = { val tref = cls.typeRef Annotation(defn.ThrowsAnnotType.appliedTo(tref), Ident(tref)) } @@ -190,20 +191,20 @@ object Annotations { */ implicit class AnnotInfo(val sym: Symbol) extends AnyVal { - def isDeprecated(implicit ctx: Context) = + def isDeprecated(implicit ctx: Context): Boolean = sym.hasAnnotation(defn.DeprecatedAnnot) - def deprecationMessage(implicit ctx: Context) = + def deprecationMessage(implicit ctx: Context): Option[String] = for (annot <- sym.getAnnotation(defn.DeprecatedAnnot); arg <- annot.argumentConstant(0)) yield arg.stringValue - def migrationVersion(implicit ctx: Context) = + def migrationVersion(implicit ctx: Context): Option[Try[ScalaVersion]] = for (annot <- sym.getAnnotation(defn.MigrationAnnot); arg <- annot.argumentConstant(1)) yield ScalaVersion.parse(arg.stringValue) - def migrationMessage(implicit ctx: Context) = + def migrationMessage(implicit ctx: Context): Option[Try[ScalaVersion]] = for (annot <- sym.getAnnotation(defn.MigrationAnnot); arg <- annot.argumentConstant(0)) yield ScalaVersion.parse(arg.stringValue) diff --git a/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala b/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala index 48c842a284f5..bd4f77fae23a 100644 --- a/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala +++ b/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala @@ -2,22 +2,18 @@ package dotty.tools package dotc package core -import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._ -import SymDenotations._, Denotations.SingleDenotation -import util.Positions._ +import Contexts._, Types._, Symbols._, Names._, Flags._ +import Denotations.SingleDenotation import Decorators._ -import StdNames._ -import Annotations._ import collection.mutable -import ast.tpd._ /** Realizability status */ object CheckRealizable { abstract class Realizability(val msg: String) { - def andAlso(other: => Realizability) = + def andAlso(other: => Realizability): Realizability = if (this == Realizable) other else this - def mapError(f: Realizability => Realizability) = + def mapError(f: Realizability => Realizability): Realizability = if (this == Realizable) this else f(this) } @@ -47,10 +43,10 @@ object CheckRealizable { assert(problem != Realizable) } - def realizability(tp: Type)(implicit ctx: Context) = + def realizability(tp: Type)(implicit ctx: Context): Realizability = new CheckRealizable().realizability(tp) - def boundsRealizability(tp: Type)(implicit ctx: Context) = + def boundsRealizability(tp: Type)(implicit ctx: Context): Realizability = new CheckRealizable().boundsRealizability(tp) private val LateInitialized = Lazy | Erased, diff --git a/compiler/src/dotty/tools/dotc/core/Comments.scala b/compiler/src/dotty/tools/dotc/core/Comments.scala index d372423e9e66..6bb489550012 100644 --- a/compiler/src/dotty/tools/dotc/core/Comments.scala +++ b/compiler/src/dotty/tools/dotc/core/Comments.scala @@ -12,7 +12,7 @@ import parsing.Parsers.Parser import reporting.diagnostic.messages.ProperDefinitionNotFound object Comments { - val ContextDoc = new Key[ContextDocstrings] + val ContextDoc: Key[ContextDocstrings] = new Key[ContextDocstrings] /** Decorator for getting docbase out of context */ implicit class CommentsContext(val ctx: Context) extends AnyVal { @@ -26,7 +26,7 @@ object Comments { private[this] val _docstrings: MutableSymbolMap[Comment] = newMutableSymbolMap - val templateExpander = new CommentExpander + val templateExpander: CommentExpander = new CommentExpander def docstrings: Map[Symbol, Comment] = _docstrings.toMap @@ -54,7 +54,7 @@ object Comments { lazy val expandedBody: Option[String] = expanded.map(removeSections(_, "@usecase", "@define")) - val isDocComment = Comment.isDocComment(raw) + val isDocComment: Boolean = Comment.isDocComment(raw) /** * Expands this comment by giving its content to `f`, and then parsing the `@usecase` sections. @@ -398,7 +398,7 @@ object Comments { expandInternal(initialStr, 0).replaceAllLiterally("""\$""", "$") } - def defineVariables(sym: Symbol)(implicit ctx: Context) = { + def defineVariables(sym: Symbol)(implicit ctx: Context): Unit = { val Trim = "(?s)^[\\s&&[^\n\r]]*(.*?)\\s*$".r val raw = ctx.docCtx.flatMap(_.docstring(sym).map(_.raw)).getOrElse("") diff --git a/compiler/src/dotty/tools/dotc/core/Constants.scala b/compiler/src/dotty/tools/dotc/core/Constants.scala index 38cdac21d7fe..048fca394c95 100644 --- a/compiler/src/dotty/tools/dotc/core/Constants.scala +++ b/compiler/src/dotty/tools/dotc/core/Constants.scala @@ -3,6 +3,7 @@ package core import Types._, Symbols._, Contexts._ import printing.Printer +import printing.Texts.Text object Constants { @@ -27,15 +28,15 @@ object Constants { import java.lang.Double.doubleToRawLongBits import java.lang.Float.floatToRawIntBits - def isByteRange: Boolean = isIntRange && Byte.MinValue <= intValue && intValue <= Byte.MaxValue - def isShortRange: Boolean = isIntRange && Short.MinValue <= intValue && intValue <= Short.MaxValue - def isCharRange: Boolean = isIntRange && Char.MinValue <= intValue && intValue <= Char.MaxValue - def isIntRange: Boolean = ByteTag <= tag && tag <= IntTag - def isLongRange: Boolean = ByteTag <= tag && tag <= LongTag - def isFloatRange: Boolean = ByteTag <= tag && tag <= FloatTag - def isNumeric: Boolean = ByteTag <= tag && tag <= DoubleTag - def isNonUnitAnyVal = BooleanTag <= tag && tag <= DoubleTag - def isAnyVal = UnitTag <= tag && tag <= DoubleTag + def isByteRange: Boolean = isIntRange && Byte.MinValue <= intValue && intValue <= Byte.MaxValue + def isShortRange: Boolean = isIntRange && Short.MinValue <= intValue && intValue <= Short.MaxValue + def isCharRange: Boolean = isIntRange && Char.MinValue <= intValue && intValue <= Char.MaxValue + def isIntRange: Boolean = ByteTag <= tag && tag <= IntTag + def isLongRange: Boolean = ByteTag <= tag && tag <= LongTag + def isFloatRange: Boolean = ByteTag <= tag && tag <= FloatTag + def isNumeric: Boolean = ByteTag <= tag && tag <= DoubleTag + def isNonUnitAnyVal: Boolean = BooleanTag <= tag && tag <= DoubleTag + def isAnyVal: Boolean = UnitTag <= tag && tag <= DoubleTag def tpe(implicit ctx: Context): Type = tag match { case UnitTag => defn.UnitType @@ -62,7 +63,7 @@ object Constants { case _ => false } - def isNaN = value match { + def isNaN: Boolean = value match { case f: Float => f.isNaN case d: Double => d.isNaN case _ => false @@ -188,7 +189,7 @@ object Constants { def stringValue: String = value.toString - def toText(printer: Printer) = printer.toText(this) + def toText(printer: Printer): Text = printer.toText(this) def typeValue: Type = value.asInstanceOf[Type] def symbolValue: Symbol = value.asInstanceOf[Symbol] @@ -219,29 +220,29 @@ object Constants { finalizeHash(h, length = 2) } - override def toString = s"Constant($value)" - def canEqual(x: Any) = true - def get = value - def isEmpty = false - def _1 = value + override def toString: String = s"Constant($value)" + def canEqual(x: Any): Boolean = true + def get: Any = value + def isEmpty: Boolean = false + def _1: Any = value } object Constant { - def apply(x: Null) = new Constant(x, NullTag) - def apply(x: Unit) = new Constant(x, UnitTag) - def apply(x: Boolean) = new Constant(x, BooleanTag) - def apply(x: Byte) = new Constant(x, ByteTag) - def apply(x: Short) = new Constant(x, ShortTag) - def apply(x: Int) = new Constant(x, IntTag) - def apply(x: Long) = new Constant(x, LongTag) - def apply(x: Float) = new Constant(x, FloatTag) - def apply(x: Double) = new Constant(x, DoubleTag) - def apply(x: String) = new Constant(x, StringTag) - def apply(x: Char) = new Constant(x, CharTag) - def apply(x: Type) = new Constant(x, ClazzTag) - def apply(x: Symbol) = new Constant(x, EnumTag) - def apply(x: scala.Symbol) = new Constant(x, ScalaSymbolTag) - def apply(value: Any) = + def apply(x: Null): Constant = new Constant(x, NullTag) + def apply(x: Unit): Constant = new Constant(x, UnitTag) + def apply(x: Boolean): Constant = new Constant(x, BooleanTag) + def apply(x: Byte): Constant = new Constant(x, ByteTag) + def apply(x: Short): Constant = new Constant(x, ShortTag) + def apply(x: Int): Constant = new Constant(x, IntTag) + def apply(x: Long): Constant = new Constant(x, LongTag) + def apply(x: Float): Constant = new Constant(x, FloatTag) + def apply(x: Double): Constant = new Constant(x, DoubleTag) + def apply(x: String): Constant = new Constant(x, StringTag) + def apply(x: Char): Constant = new Constant(x, CharTag) + def apply(x: Type): Constant = new Constant(x, ClazzTag) + def apply(x: Symbol): Constant = new Constant(x, EnumTag) + def apply(x: scala.Symbol): Constant = new Constant(x, ScalaSymbolTag) + def apply(value: Any): Constant = new Constant(value, value match { case null => NullTag @@ -261,6 +262,6 @@ object Constants { } ) - def unapply(c: Constant) = c + def unapply(c: Constant): Constant = c } } diff --git a/compiler/src/dotty/tools/dotc/core/Constraint.scala b/compiler/src/dotty/tools/dotc/core/Constraint.scala index 02d4fc1dd5b9..946a19b24d30 100644 --- a/compiler/src/dotty/tools/dotc/core/Constraint.scala +++ b/compiler/src/dotty/tools/dotc/core/Constraint.scala @@ -2,12 +2,8 @@ package dotty.tools package dotc package core -import Types._, Contexts._, Symbols._ -import collection.mutable -import printing.{Printer, Showable} -import printing.Texts._ -import config.Config -import config.Printers.constr +import Types._, Contexts._ +import printing.Showable /** Constraint over undetermined type parameters. Constraints are built * over values of the following types: diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala index 87a168f26580..aff9883cf294 100644 --- a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala +++ b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala @@ -6,8 +6,6 @@ import Types._, Contexts._, Symbols._ import Decorators._ import config.Config import config.Printers.{constr, typr} -import TypeApplications.{EtaExpansion, TypeParamInfo} -import collection.mutable /** Methods for adding constraints and solving them. * @@ -33,7 +31,7 @@ trait ConstraintHandling { private[this] var addConstraintInvocations = 0 /** If the constraint is frozen we cannot add new bounds to the constraint. */ - protected var frozenConstraint = false + protected var frozenConstraint: Boolean = false /** Potentially a type lambda that is still instantiatable, even though the constraint * is generally frozen. @@ -45,7 +43,7 @@ trait ConstraintHandling { * Aligning means computing `S1 =:= S2` which may change the current constraint. * See note in TypeComparer#distributeAnd. */ - protected var homogenizeArgs = false + protected var homogenizeArgs: Boolean = false /** We are currently comparing type lambdas. Used as a flag for * optimization: when `false`, no need to do an expensive `pruneLambdaParams` diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala b/compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala index 73924d0cf19d..e6caae72bdde 100644 --- a/compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala +++ b/compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala @@ -7,14 +7,14 @@ import config.Printers.{default, typr} trait ConstraintRunInfo { self: Run => private[this] var maxSize = 0 private[this] var maxConstraint: Constraint = _ - def recordConstraintSize(c: Constraint, size: Int) = + def recordConstraintSize(c: Constraint, size: Int): Unit = if (size > maxSize) { maxSize = size maxConstraint = c } - def printMaxConstraint()(implicit ctx: Context) = { + def printMaxConstraint()(implicit ctx: Context): Unit = { val printer = if (ctx.settings.YdetailedStats.value) default else typr if (maxSize > 0) printer.println(s"max constraint = ${maxConstraint.show}") } - protected def reset() = maxConstraint = null + protected def reset(): Unit = maxConstraint = null } diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala index a80d25e16b04..7ea68b0ae816 100644 --- a/compiler/src/dotty/tools/dotc/core/Contexts.scala +++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala @@ -10,11 +10,7 @@ import Phases._ import Types._ import Symbols._ import Scopes._ -import NameOps._ import Uniques._ -import SymDenotations._ -import Comments._ -import util.Positions._ import ast.Trees._ import ast.untpd import util.{FreshNameCreator, NoSource, SimpleIdentityMap, SourceFile} @@ -25,13 +21,11 @@ import config.Config import reporting._ import reporting.diagnostic.Message import collection.mutable -import collection.immutable.BitSet import printing._ -import config.{JavaPlatform, Platform, ScalaSettings, Settings} +import config.{JavaPlatform, Platform, ScalaSettings} import scala.annotation.internal.sharable -import language.implicitConversions import DenotTransformers.DenotTransformer import dotty.tools.dotc.profile.Profiler import util.Property.Key @@ -87,7 +81,7 @@ object Contexts { val base: ContextBase /** All outer contexts, ending in `base.initialCtx` and then `NoContext` */ - def outersIterator = new Iterator[Context] { + def outersIterator: Iterator[Context] = new Iterator[Context] { var current = thiscontext def hasNext = current != NoContext def next = { val c = current; current = current.outer; c } @@ -95,12 +89,12 @@ object Contexts { /** The outer context */ private[this] var _outer: Context = _ - protected def outer_=(outer: Context) = _outer = outer + protected def outer_=(outer: Context): Unit = _outer = outer def outer: Context = _outer /** The current context */ private[this] var _period: Period = _ - protected def period_=(period: Period) = { + protected def period_=(period: Period): Unit = { assert(period.firstPhaseId == period.lastPhaseId, period) _period = period } @@ -108,54 +102,54 @@ object Contexts { /** The scope nesting level */ private[this] var _mode: Mode = _ - protected def mode_=(mode: Mode) = _mode = mode + protected def mode_=(mode: Mode): Unit = _mode = mode def mode: Mode = _mode /** The current owner symbol */ private[this] var _owner: Symbol = _ - protected def owner_=(owner: Symbol) = _owner = owner + protected def owner_=(owner: Symbol): Unit = _owner = owner def owner: Symbol = _owner /** The current tree */ private[this] var _tree: Tree[_ >: Untyped]= _ - protected def tree_=(tree: Tree[_ >: Untyped]) = _tree = tree + protected def tree_=(tree: Tree[_ >: Untyped]): Unit = _tree = tree def tree: Tree[_ >: Untyped] = _tree /** The current scope */ private[this] var _scope: Scope = _ - protected def scope_=(scope: Scope) = _scope = scope + protected def scope_=(scope: Scope): Unit = _scope = scope def scope: Scope = _scope /** The current type comparer */ private[this] var _typerState: TyperState = _ - protected def typerState_=(typerState: TyperState) = _typerState = typerState + protected def typerState_=(typerState: TyperState): Unit = _typerState = typerState def typerState: TyperState = _typerState /** The current type assigner or typer */ private[this] var _typeAssigner: TypeAssigner = _ - protected def typeAssigner_=(typeAssigner: TypeAssigner) = _typeAssigner = typeAssigner + protected def typeAssigner_=(typeAssigner: TypeAssigner): Unit = _typeAssigner = typeAssigner def typeAssigner: TypeAssigner = _typeAssigner /** The currently active import info */ private[this] var _importInfo: ImportInfo = _ - protected def importInfo_=(importInfo: ImportInfo) = _importInfo = importInfo + protected def importInfo_=(importInfo: ImportInfo): Unit = _importInfo = importInfo def importInfo: ImportInfo = _importInfo /** The current bounds in force for type parameters appearing in a GADT */ private[this] var _gadt: GADTMap = _ - protected def gadt_=(gadt: GADTMap) = _gadt = gadt + protected def gadt_=(gadt: GADTMap): Unit = _gadt = gadt def gadt: GADTMap = _gadt /** The history of implicit searches that are currently active */ private[this] var _searchHistory: SearchHistory = null - protected def searchHistory_= (searchHistory: SearchHistory) = _searchHistory = searchHistory + protected def searchHistory_= (searchHistory: SearchHistory): Unit = _searchHistory = searchHistory def searchHistory: SearchHistory = _searchHistory /** The current type comparer. This ones updates itself automatically for * each new context. */ private[this] var _typeComparer: TypeComparer = _ - protected def typeComparer_=(typeComparer: TypeComparer) = _typeComparer = typeComparer + protected def typeComparer_=(typeComparer: TypeComparer): Unit = _typeComparer = typeComparer def typeComparer: TypeComparer = { if (_typeComparer.ctx ne this) _typeComparer = _typeComparer.copyIn(this) @@ -166,7 +160,7 @@ object Contexts { * Typically used for attributes that are read and written only in special situations. */ private[this] var _moreProperties: Map[Key[Any], Any] = _ - protected def moreProperties_=(moreProperties: Map[Key[Any], Any]) = _moreProperties = moreProperties + protected def moreProperties_=(moreProperties: Map[Key[Any], Any]): Unit = _moreProperties = moreProperties def moreProperties: Map[Key[Any], Any] = _moreProperties def property[T](key: Key[T]): Option[T] = @@ -178,7 +172,7 @@ object Contexts { * slightly slower than a normal field access would be. */ private var _store: Store = _ - protected def store_=(store: Store) = _store = store + protected def store_=(store: Store): Unit = _store = store def store: Store = _store /** The compiler callback implementation, or null if no callback will be called. */ @@ -258,10 +252,10 @@ object Contexts { final def withPhase(phase: Phase): Context = withPhase(phase.id) - final def withPhaseNoLater(phase: Phase) = + final def withPhaseNoLater(phase: Phase): Context = if (phase.exists && ctx.phase.id > phase.id) withPhase(phase) else ctx - final def withPhaseNoEarlier(phase: Phase) = + final def withPhaseNoEarlier(phase: Phase): Context = if (phase.exists && ctx.phase.id < phase.id) withPhase(phase) else ctx // `creationTrace`-related code. To enable, uncomment the code below and the @@ -371,13 +365,13 @@ object Contexts { } /** The context of expression `expr` seen as a member of a statement sequence */ - def exprContext(stat: Tree[_ >: Untyped], exprOwner: Symbol) = + def exprContext(stat: Tree[_ >: Untyped], exprOwner: Symbol): Context = if (exprOwner == this.owner) this else if (untpd.isSuperConstrCall(stat) && this.owner.isClass) superCallContext else ctx.fresh.setOwner(exprOwner) /** A new context that summarizes an import statement */ - def importContext(imp: Import[_], sym: Symbol) = { + def importContext(imp: Import[_], sym: Symbol): FreshContext = { val impNameOpt = imp.expr match { case ref: RefTree[_] => Some(ref.name.asTermName) case _ => None @@ -427,37 +421,37 @@ object Contexts { case None => fresh.dropProperty(key) } - override def toString = { + override def toString: String = { def iinfo(implicit ctx: Context) = if (ctx.importInfo == null) "" else i"${ctx.importInfo.selectors}%, %" "Context(\n" + (outersIterator map ( ctx => s" owner = ${ctx.owner}, scope = ${ctx.scope}, import = ${iinfo(ctx)}") mkString "\n") } - def typerPhase = base.typerPhase - def sbtExtractDependenciesPhase = base.sbtExtractDependenciesPhase - def picklerPhase = base.picklerPhase - def refchecksPhase = base.refchecksPhase - def patmatPhase = base.patmatPhase - def elimRepeatedPhase = base.elimRepeatedPhase - def extensionMethodsPhase = base.extensionMethodsPhase - def explicitOuterPhase = base.explicitOuterPhase - def gettersPhase = base.gettersPhase - def erasurePhase = base.erasurePhase - def elimErasedValueTypePhase = base.elimErasedValueTypePhase - def lambdaLiftPhase = base.lambdaLiftPhase - def flattenPhase = base.flattenPhase - def genBCodePhase = base.genBCodePhase - def phases = base.phases - - def settings = base.settings - def definitions = base.definitions - def platform = base.platform - def pendingUnderlying = base.pendingUnderlying - def uniqueNamedTypes = base.uniqueNamedTypes - def uniques = base.uniques - def nextId = base.nextId - - def initialize()(implicit ctx: Context) = base.initialize()(ctx) + def typerPhase: Phase = base.typerPhase + def sbtExtractDependenciesPhase: Phase = base.sbtExtractDependenciesPhase + def picklerPhase: Phase = base.picklerPhase + def refchecksPhase: Phase = base.refchecksPhase + def patmatPhase: Phase = base.patmatPhase + def elimRepeatedPhase: Phase = base.elimRepeatedPhase + def extensionMethodsPhase: Phase = base.extensionMethodsPhase + def explicitOuterPhase: Phase = base.explicitOuterPhase + def gettersPhase: Phase = base.gettersPhase + def erasurePhase: Phase = base.erasurePhase + def elimErasedValueTypePhase: Phase = base.elimErasedValueTypePhase + def lambdaLiftPhase: Phase = base.lambdaLiftPhase + def flattenPhase: Phase = base.flattenPhase + def genBCodePhase: Phase = base.genBCodePhase + def phases: Array[Phase] = base.phases + + def settings: ScalaSettings = base.settings + def definitions: Definitions = base.definitions + def platform: Platform = base.platform + def pendingUnderlying: mutable.HashSet[Type] = base.pendingUnderlying + def uniqueNamedTypes: Uniques.NamedTypeUniques = base.uniqueNamedTypes + def uniques: util.HashSet[Type] = base.uniques + def nextId: Int = base.nextId + + def initialize()(implicit ctx: Context): Unit = base.initialize()(ctx) } /** A condensed context provides only a small memory footprint over @@ -529,7 +523,7 @@ object Contexts { def setSetting[T](setting: Setting[T], value: T): this.type = setSettings(setting.updateIn(settingsState, value)) - def setDebug = setSetting(base.settings.Ydebug, true) + def setDebug: this.type = setSetting(base.settings.Ydebug, true) } implicit class ModeChanges(val c: Context) extends AnyVal { @@ -566,7 +560,7 @@ object Contexts { } @sharable object NoContext extends Context { - val base = null + val base: ContextBase = null override val implicits: ContextualImplicits = new ContextualImplicits(Nil, null)(this) } @@ -578,7 +572,7 @@ object Contexts { with Phases.PhasesBase { /** The applicable settings */ - val settings = new ScalaSettings + val settings: ScalaSettings = new ScalaSettings /** The initial context */ val initialCtx: Context = new InitialContext(this, settings) @@ -605,7 +599,7 @@ object Contexts { usePhases(List(SomePhase)) /** The standard definitions */ - val definitions = new Definitions + val definitions: Definitions = new Definitions /** Initializes the `ContextBase` with a starting context. * This initializes the `platform` and the `definitions`. @@ -625,22 +619,22 @@ object Contexts { // Symbols state /** A counter for unique ids */ - private[core] var _nextId = 0 + private[core] var _nextId: Int = 0 - def nextId = { _nextId += 1; _nextId } + def nextId: Int = { _nextId += 1; _nextId } // Types state /** A table for hash consing unique types */ - private[core] val uniques = new util.HashSet[Type](Config.initialUniquesCapacity) { + private[core] val uniques: util.HashSet[Type] = new util.HashSet[Type](Config.initialUniquesCapacity) { override def hash(x: Type): Int = x.hash override def isEqual(x: Type, y: Type) = x.eql(y) } /** A table for hash consing unique applied types */ - private[dotc] val uniqueAppliedTypes = new AppliedUniques + private[dotc] val uniqueAppliedTypes: AppliedUniques = new AppliedUniques /** A table for hash consing unique named types */ - private[core] val uniqueNamedTypes = new NamedTypeUniques + private[core] val uniqueNamedTypes: NamedTypeUniques = new NamedTypeUniques private def uniqueSets = Map( "uniques" -> uniques, @@ -666,13 +660,13 @@ object Contexts { /** The set of named types on which a currently active invocation * of underlying during a controlled operation exists. */ - private[core] val pendingUnderlying = new mutable.HashSet[Type] + private[core] val pendingUnderlying: mutable.HashSet[Type] = new mutable.HashSet[Type] /** A map from ErrorType to associated message computation. We use this map * instead of storing message computations directly in ErrorTypes in order * to avoid space leaks - the message computation usually captures a context. */ - private[core] val errorTypeMsg = mutable.Map[ErrorType, () => Message]() + private[core] val errorTypeMsg: mutable.Map[Types.ErrorType, () => Message] = mutable.Map() // Phases state @@ -691,14 +685,14 @@ object Contexts { // Printers state /** Number of recursive invocations of a show method on current stack */ - private[dotc] var toTextRecursions = 0 + private[dotc] var toTextRecursions: Int = 0 // Reporters state - private[dotc] var indent = 0 + private[dotc] var indent: Int = 0 - protected[dotc] val indentTab = " " + protected[dotc] val indentTab: String = " " - def reset() = { + def reset(): Unit = { for ((_, set) <- uniqueSets) set.clear() errorTypeMsg.clear() } @@ -709,7 +703,7 @@ object Contexts { @sharable private[this] var thread: Thread = null /** Check that we are on the same thread as before */ - def checkSingleThreaded() = + def checkSingleThreaded(): Unit = if (thread == null) thread = Thread.currentThread() else assert(thread == Thread.currentThread(), "illegal multithreaded access to ContextBase") } @@ -718,10 +712,10 @@ object Contexts { private[this] var myBounds = initBounds def setBounds(sym: Symbol, b: TypeBounds): Unit = myBounds = myBounds.updated(sym, b) - def bounds = myBounds + def bounds: SimpleIdentityMap[Symbol, TypeBounds] = myBounds } @sharable object EmptyGADTMap extends GADTMap(SimpleIdentityMap.Empty) { - override def setBounds(sym: Symbol, b: TypeBounds) = unsupported("EmptyGADTMap.setBounds") + override def setBounds(sym: Symbol, b: TypeBounds): Unit = unsupported("EmptyGADTMap.setBounds") } } diff --git a/compiler/src/dotty/tools/dotc/core/Decorators.scala b/compiler/src/dotty/tools/dotc/core/Decorators.scala index 4343d2bb0ad9..95b55ac14632 100644 --- a/compiler/src/dotty/tools/dotc/core/Decorators.scala +++ b/compiler/src/dotty/tools/dotc/core/Decorators.scala @@ -3,7 +3,7 @@ package core import annotation.tailrec import Symbols._ -import Contexts._, Names._, Phases._, printing.Texts._, printing.Printer, printing.Showable +import Contexts._, Names._, Phases._, printing.Texts._, printing.Printer import util.Positions.Position, util.SourcePosition import collection.mutable.ListBuffer import dotty.tools.dotc.transform.MegaPhase @@ -143,7 +143,7 @@ object Decorators { } implicit class TextToString(val text: Text) extends AnyVal { - def show(implicit ctx: Context) = text.mkString(ctx.settings.pageWidth.value, ctx.settings.printLines.value) + def show(implicit ctx: Context): String = text.mkString(ctx.settings.pageWidth.value, ctx.settings.printLines.value) } /** Test whether a list of strings representing phases contains diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index d43611c53f52..05f599297e26 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -2,20 +2,19 @@ package dotty.tools package dotc package core -import Types._, Contexts._, Symbols._, Denotations._, SymDenotations._, StdNames._, Names._ -import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._, Periods._ +import Types._, Contexts._, Symbols._, SymDenotations._, StdNames._, Names._ +import Flags._, Scopes._, Decorators._, NameOps._, Periods._ import unpickleScala2.Scala2Unpickler.ensureConstructor -import scala.collection.{ mutable, immutable } -import PartialFunction._ +import scala.collection.mutable import collection.mutable -import util.common.alwaysZero +import Denotations.SingleDenotation object Definitions { /** The maximum number of elements in a tuple or product. * This should be removed once we go to hlists. */ - val MaxTupleArity = 22 + val MaxTupleArity: Int = 22 /** The maximum arity N of a function type that's implemented * as a trait `scala.FunctionN`. Functions of higher arity are possible, @@ -24,10 +23,10 @@ object Definitions { * The limit 22 is chosen for Scala2x interop. It could be something * else without affecting the set of programs that can be compiled. */ - val MaxImplementedFunctionArity = 22 + val MaxImplementedFunctionArity: Int = 22 /** The maximal arity of a function that can be accessed as member of a structural type */ - val MaxStructuralMethodArity = 7 + val MaxStructuralMethodArity: Int = 7 } /** A class defining symbols and types of standard definitions @@ -192,17 +191,17 @@ class Definitions { lazy val RootPackage: TermSymbol = ctx.newSymbol( NoSymbol, nme.ROOTPKG, PackageCreationFlags, TypeRef(NoPrefix, RootClass)) - lazy val EmptyPackageVal = ctx.newPackageSymbol( + lazy val EmptyPackageVal: TermSymbol = ctx.newPackageSymbol( RootClass, nme.EMPTY_PACKAGE, (emptypkg, emptycls) => ctx.base.rootLoader(emptypkg)).entered - lazy val EmptyPackageClass = EmptyPackageVal.moduleClass.asClass + lazy val EmptyPackageClass: ClassSymbol = EmptyPackageVal.moduleClass.asClass /** A package in which we can place all methods that are interpreted specially by the compiler */ - lazy val OpsPackageVal = ctx.newCompletePackageSymbol(RootClass, nme.OPS_PACKAGE).entered - lazy val OpsPackageClass = OpsPackageVal.moduleClass.asClass + lazy val OpsPackageVal: TermSymbol = ctx.newCompletePackageSymbol(RootClass, nme.OPS_PACKAGE).entered + lazy val OpsPackageClass: ClassSymbol = OpsPackageVal.moduleClass.asClass - lazy val ScalaPackageVal = ctx.requiredPackage(nme.scala_) - lazy val ScalaMathPackageVal = ctx.requiredPackage("scala.math") - lazy val ScalaPackageClass = { + lazy val ScalaPackageVal: TermSymbol = ctx.requiredPackage(nme.scala_) + lazy val ScalaMathPackageVal: TermSymbol = ctx.requiredPackage("scala.math") + lazy val ScalaPackageClass: ClassSymbol = { val cls = ScalaPackageVal.moduleClass.asClass cls.info.decls.openForMutations.useSynthesizer( name => ctx => @@ -210,22 +209,22 @@ class Definitions { else NoSymbol) cls } - lazy val ScalaPackageObjectRef = ctx.requiredModuleRef("scala.package") - lazy val JavaPackageVal = ctx.requiredPackage(nme.java) - lazy val JavaLangPackageVal = ctx.requiredPackage(jnme.JavaLang) + lazy val ScalaPackageObjectRef: TermRef = ctx.requiredModuleRef("scala.package") + lazy val JavaPackageVal: TermSymbol = ctx.requiredPackage(nme.java) + lazy val JavaLangPackageVal: TermSymbol = ctx.requiredPackage(jnme.JavaLang) // fundamental modules - lazy val SysPackage = ctx.requiredModule("scala.sys.package") - lazy val Sys_errorR = SysPackage.moduleClass.requiredMethodRef(nme.error) - def Sys_error(implicit ctx: Context) = Sys_errorR.symbol - - lazy val TypelevelPackageObjectRef = ctx.requiredModuleRef("scala.typelevel.package") - lazy val TypelevelPackageObject = TypelevelPackageObjectRef.symbol.moduleClass - lazy val Typelevel_errorR = TypelevelPackageObjectRef.symbol.requiredMethodRef(nme.error) - def Typelevel_error(implicit ctx: Context) = Typelevel_errorR.symbol - lazy val Typelevel_constValueR = TypelevelPackageObjectRef.symbol.requiredMethodRef("constValue") - def Typelevel_constValue(implicit ctx: Context) = Typelevel_constValueR.symbol - lazy val Typelevel_constValueOptR = TypelevelPackageObjectRef.symbol.requiredMethodRef("constValueOpt") - def Typelevel_constValueOpt(implicit ctx: Context) = Typelevel_constValueOptR.symbol + lazy val SysPackage: TermSymbol = ctx.requiredModule("scala.sys.package") + lazy val Sys_errorR: TermRef = SysPackage.moduleClass.requiredMethodRef(nme.error) + def Sys_error(implicit ctx: Context): Symbol = Sys_errorR.symbol + + lazy val TypelevelPackageObjectRef: TermRef = ctx.requiredModuleRef("scala.typelevel.package") + lazy val TypelevelPackageObject: Symbol = TypelevelPackageObjectRef.symbol.moduleClass + lazy val Typelevel_errorR: TermRef = TypelevelPackageObjectRef.symbol.requiredMethodRef(nme.error) + def Typelevel_error(implicit ctx: Context): Symbol = Typelevel_errorR.symbol + lazy val Typelevel_constValueR: TermRef = TypelevelPackageObjectRef.symbol.requiredMethodRef("constValue") + def Typelevel_constValue(implicit ctx: Context): Symbol = Typelevel_constValueR.symbol + lazy val Typelevel_constValueOptR: TermRef = TypelevelPackageObjectRef.symbol.requiredMethodRef("constValueOpt") + def Typelevel_constValueOpt(implicit ctx: Context): Symbol = Typelevel_constValueOptR.symbol /** The `scalaShadowing` package is used to safely modify classes and * objects in scala so that they can be used from dotty. They will @@ -234,8 +233,8 @@ class Definitions { * in `scalaShadowing` so they don't clash with the same-named `scala` * members at runtime. */ - lazy val ScalaShadowingPackageVal = ctx.requiredPackage(nme.scalaShadowing) - def ScalaShadowingPackageClass(implicit ctx: Context) = ScalaShadowingPackageVal.moduleClass.asClass + lazy val ScalaShadowingPackageVal: TermSymbol = ctx.requiredPackage(nme.scalaShadowing) + def ScalaShadowingPackageClass(implicit ctx: Context): ClassSymbol = ScalaShadowingPackageVal.moduleClass.asClass /** Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter) * because after erasure the Any and AnyVal references get remapped to the Object methods @@ -260,23 +259,23 @@ class Definitions { * } */ lazy val AnyClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.Any, Abstract, Nil)) - def AnyType = AnyClass.typeRef + def AnyType: TypeRef = AnyClass.typeRef lazy val AnyValClass: ClassSymbol = completeClass(enterCompleteClassSymbol(ScalaPackageClass, tpnme.AnyVal, Abstract, List(AnyClass.typeRef))) - def AnyValType = AnyValClass.typeRef - - lazy val Any_== = enterMethod(AnyClass, nme.EQ, methOfAny(BooleanType), Final) - lazy val Any_!= = enterMethod(AnyClass, nme.NE, methOfAny(BooleanType), Final) - lazy val Any_equals = enterMethod(AnyClass, nme.equals_, methOfAny(BooleanType)) - lazy val Any_hashCode = enterMethod(AnyClass, nme.hashCode_, MethodType(Nil, IntType)) - lazy val Any_toString = enterMethod(AnyClass, nme.toString_, MethodType(Nil, StringType)) - lazy val Any_## = enterMethod(AnyClass, nme.HASHHASH, ExprType(IntType), Final) - lazy val Any_getClass = enterMethod(AnyClass, nme.getClass_, MethodType(Nil, ClassClass.typeRef.appliedTo(TypeBounds.empty)), Final) - lazy val Any_isInstanceOf = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOf_, _ => BooleanType, Final) - lazy val Any_asInstanceOf = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, _.paramRefs(0), Final) - lazy val Any_typeTest = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | Synthetic) + def AnyValType: TypeRef = AnyValClass.typeRef + + lazy val Any_== : TermSymbol = enterMethod(AnyClass, nme.EQ, methOfAny(BooleanType), Final) + lazy val Any_!= : TermSymbol = enterMethod(AnyClass, nme.NE, methOfAny(BooleanType), Final) + lazy val Any_equals: TermSymbol = enterMethod(AnyClass, nme.equals_, methOfAny(BooleanType)) + lazy val Any_hashCode: TermSymbol = enterMethod(AnyClass, nme.hashCode_, MethodType(Nil, IntType)) + lazy val Any_toString: TermSymbol = enterMethod(AnyClass, nme.toString_, MethodType(Nil, StringType)) + lazy val Any_## : TermSymbol = enterMethod(AnyClass, nme.HASHHASH, ExprType(IntType), Final) + lazy val Any_getClass: TermSymbol = enterMethod(AnyClass, nme.getClass_, MethodType(Nil, ClassClass.typeRef.appliedTo(TypeBounds.empty)), Final) + lazy val Any_isInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOf_, _ => BooleanType, Final) + lazy val Any_asInstanceOf: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.asInstanceOf_, _.paramRefs(0), Final) + lazy val Any_typeTest: TermSymbol = enterT1ParameterlessMethod(AnyClass, nme.isInstanceOfPM, _ => BooleanType, Final | Synthetic) // generated by pattern matcher, eliminated by erasure - def AnyMethods = List(Any_==, Any_!=, Any_equals, Any_hashCode, + def AnyMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode, Any_toString, Any_##, Any_getClass, Any_isInstanceOf, Any_asInstanceOf, Any_typeTest) lazy val ObjectClass: ClassSymbol = { @@ -293,27 +292,27 @@ class Definitions { completeClass(cls) } - def ObjectType = ObjectClass.typeRef + def ObjectType: TypeRef = ObjectClass.typeRef lazy val AnyRefAlias: TypeSymbol = enterAliasType(tpnme.AnyRef, ObjectType) - def AnyRefType = AnyRefAlias.typeRef + def AnyRefType: TypeRef = AnyRefAlias.typeRef - lazy val Object_eq = enterMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final) - lazy val Object_ne = enterMethod(ObjectClass, nme.ne, methOfAnyRef(BooleanType), Final) - lazy val Object_synchronized = enterPolyMethod(ObjectClass, nme.synchronized_, 1, + lazy val Object_eq: TermSymbol = enterMethod(ObjectClass, nme.eq, methOfAnyRef(BooleanType), Final) + lazy val Object_ne: TermSymbol = enterMethod(ObjectClass, nme.ne, methOfAnyRef(BooleanType), Final) + lazy val Object_synchronized: TermSymbol = enterPolyMethod(ObjectClass, nme.synchronized_, 1, pt => MethodType(List(pt.paramRefs(0)), pt.paramRefs(0)), Final) - lazy val Object_clone = enterMethod(ObjectClass, nme.clone_, MethodType(Nil, ObjectType), Protected) - lazy val Object_finalize = enterMethod(ObjectClass, nme.finalize_, MethodType(Nil, UnitType), Protected) - lazy val Object_notify = enterMethod(ObjectClass, nme.notify_, MethodType(Nil, UnitType), Final) - lazy val Object_notifyAll = enterMethod(ObjectClass, nme.notifyAll_, MethodType(Nil, UnitType), Final) - lazy val Object_wait = enterMethod(ObjectClass, nme.wait_, MethodType(Nil, UnitType), Final) - lazy val Object_waitL = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: Nil, UnitType), Final) - lazy val Object_waitLI = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: IntType :: Nil, UnitType), Final) - - def ObjectMethods = List(Object_eq, Object_ne, Object_synchronized, Object_clone, + lazy val Object_clone: TermSymbol = enterMethod(ObjectClass, nme.clone_, MethodType(Nil, ObjectType), Protected) + lazy val Object_finalize: TermSymbol = enterMethod(ObjectClass, nme.finalize_, MethodType(Nil, UnitType), Protected) + lazy val Object_notify: TermSymbol = enterMethod(ObjectClass, nme.notify_, MethodType(Nil, UnitType), Final) + lazy val Object_notifyAll: TermSymbol = enterMethod(ObjectClass, nme.notifyAll_, MethodType(Nil, UnitType), Final) + lazy val Object_wait: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(Nil, UnitType), Final) + lazy val Object_waitL: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: Nil, UnitType), Final) + lazy val Object_waitLI: TermSymbol = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: IntType :: Nil, UnitType), Final) + + def ObjectMethods: List[TermSymbol] = List(Object_eq, Object_ne, Object_synchronized, Object_clone, Object_finalize, Object_notify, Object_notifyAll, Object_wait, Object_waitL, Object_waitLI) - lazy val AnyKindClass = { + lazy val AnyKindClass: ClassSymbol = { val cls = ctx.newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil) if (ctx.settings.YkindPolymorphism.value) { // Enable kind-polymorphism by exposing scala.AnyKind @@ -321,60 +320,60 @@ class Definitions { } cls } - def AnyKindType = AnyKindClass.typeRef + def AnyKindType: TypeRef = AnyKindClass.typeRef /** Marker method to indicate an argument to a call-by-name parameter. * Created by byNameClosures and elimByName, eliminated by Erasure, */ - lazy val cbnArg = enterPolyMethod(OpsPackageClass, nme.cbnArg, 1, + lazy val cbnArg: TermSymbol = enterPolyMethod(OpsPackageClass, nme.cbnArg, 1, pt => MethodType(List(FunctionOf(Nil, pt.paramRefs(0))), pt.paramRefs(0))) /** Method representing a throw */ - lazy val throwMethod = enterMethod(OpsPackageClass, nme.THROWkw, + lazy val throwMethod: TermSymbol = enterMethod(OpsPackageClass, nme.THROWkw, MethodType(List(ThrowableType), NothingType)) lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol( ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef)) - def NothingType = NothingClass.typeRef - lazy val RuntimeNothingModuleRef = ctx.requiredModuleRef("scala.runtime.Nothing") + def NothingType: TypeRef = NothingClass.typeRef + lazy val RuntimeNothingModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Nothing") lazy val NullClass: ClassSymbol = enterCompleteClassSymbol( ScalaPackageClass, tpnme.Null, AbstractFinal, List(ObjectClass.typeRef)) - def NullType = NullClass.typeRef - lazy val RuntimeNullModuleRef = ctx.requiredModuleRef("scala.runtime.Null") - - lazy val ScalaPredefModuleRef = ctx.requiredModuleRef("scala.Predef") - def ScalaPredefModule(implicit ctx: Context) = ScalaPredefModuleRef.symbol - - lazy val Predef_ConformsR = ScalaPredefModule.requiredClass("<:<").typeRef - def Predef_Conforms(implicit ctx: Context) = Predef_ConformsR.symbol - lazy val Predef_conformsR = ScalaPredefModule.requiredMethodRef(nme.conforms_) - def Predef_conforms(implicit ctx: Context) = Predef_conformsR.symbol - lazy val Predef_classOfR = ScalaPredefModule.requiredMethodRef(nme.classOf) - def Predef_classOf(implicit ctx: Context) = Predef_classOfR.symbol - lazy val Predef_undefinedR = ScalaPredefModule.requiredMethodRef(nme.???) - def Predef_undefined(implicit ctx: Context) = Predef_undefinedR.symbol - - lazy val ScalaRuntimeModuleRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime") - def ScalaRuntimeModule(implicit ctx: Context) = ScalaRuntimeModuleRef.symbol - def ScalaRuntimeClass(implicit ctx: Context) = ScalaRuntimeModule.moduleClass.asClass - - def runtimeMethodRef(name: PreName) = ScalaRuntimeModule.requiredMethodRef(name) - def ScalaRuntime_dropR(implicit ctx: Context) = runtimeMethodRef(nme.drop) - def ScalaRuntime_drop(implicit ctx: Context) = ScalaRuntime_dropR.symbol - - lazy val BoxesRunTimeModuleRef = ctx.requiredModuleRef("scala.runtime.BoxesRunTime") - def BoxesRunTimeModule(implicit ctx: Context) = BoxesRunTimeModuleRef.symbol - def BoxesRunTimeClass(implicit ctx: Context) = BoxesRunTimeModule.moduleClass.asClass - lazy val ScalaStaticsModuleRef = ctx.requiredModuleRef("scala.runtime.Statics") - def ScalaStaticsModule(implicit ctx: Context) = ScalaStaticsModuleRef.symbol - def ScalaStaticsClass(implicit ctx: Context) = ScalaStaticsModule.moduleClass.asClass - - def staticsMethodRef(name: PreName) = ScalaStaticsModule.requiredMethodRef(name) - def staticsMethod(name: PreName) = ScalaStaticsModule.requiredMethod(name) + def NullType: TypeRef = NullClass.typeRef + lazy val RuntimeNullModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Null") + + lazy val ScalaPredefModuleRef: TermRef = ctx.requiredModuleRef("scala.Predef") + def ScalaPredefModule(implicit ctx: Context): Symbol = ScalaPredefModuleRef.symbol + + lazy val Predef_ConformsR: TypeRef = ScalaPredefModule.requiredClass("<:<").typeRef + def Predef_Conforms(implicit ctx: Context): Symbol = Predef_ConformsR.symbol + lazy val Predef_conformsR: TermRef = ScalaPredefModule.requiredMethodRef(nme.conforms_) + def Predef_conforms(implicit ctx: Context): Symbol = Predef_conformsR.symbol + lazy val Predef_classOfR: TermRef = ScalaPredefModule.requiredMethodRef(nme.classOf) + def Predef_classOf(implicit ctx: Context): Symbol = Predef_classOfR.symbol + lazy val Predef_undefinedR: TermRef = ScalaPredefModule.requiredMethodRef(nme.???) + def Predef_undefined(implicit ctx: Context): Symbol = Predef_undefinedR.symbol + + lazy val ScalaRuntimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.ScalaRunTime") + def ScalaRuntimeModule(implicit ctx: Context): Symbol = ScalaRuntimeModuleRef.symbol + def ScalaRuntimeClass(implicit ctx: Context): ClassSymbol = ScalaRuntimeModule.moduleClass.asClass + + def runtimeMethodRef(name: PreName): TermRef = ScalaRuntimeModule.requiredMethodRef(name) + def ScalaRuntime_dropR(implicit ctx: Context): TermRef = runtimeMethodRef(nme.drop) + def ScalaRuntime_drop(implicit ctx: Context): Symbol = ScalaRuntime_dropR.symbol + + lazy val BoxesRunTimeModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.BoxesRunTime") + def BoxesRunTimeModule(implicit ctx: Context): Symbol = BoxesRunTimeModuleRef.symbol + def BoxesRunTimeClass(implicit ctx: Context): ClassSymbol = BoxesRunTimeModule.moduleClass.asClass + lazy val ScalaStaticsModuleRef: TermRef = ctx.requiredModuleRef("scala.runtime.Statics") + def ScalaStaticsModule(implicit ctx: Context): Symbol = ScalaStaticsModuleRef.symbol + def ScalaStaticsClass(implicit ctx: Context): ClassSymbol = ScalaStaticsModule.moduleClass.asClass + + def staticsMethodRef(name: PreName): TermRef = ScalaStaticsModule.requiredMethodRef(name) + def staticsMethod(name: PreName): TermSymbol = ScalaStaticsModule.requiredMethod(name) // Dotty deviation: we cannot use a lazy val here because lazy vals in dotty // will return "null" when called recursively, see #1856. - def DottyPredefModuleRef = { + def DottyPredefModuleRef: TermRef = { if (myDottyPredefModuleRef == null) { myDottyPredefModuleRef = ctx.requiredModuleRef("dotty.DottyPredef") assert(myDottyPredefModuleRef != null) @@ -383,29 +382,29 @@ class Definitions { } private[this] var myDottyPredefModuleRef: TermRef = _ - def DottyPredefModule(implicit ctx: Context) = DottyPredefModuleRef.symbol + def DottyPredefModule(implicit ctx: Context): Symbol = DottyPredefModuleRef.symbol - lazy val Predef_ImplicitConverterR = DottyPredefModule.requiredClass("ImplicitConverter").typeRef - def Predef_ImplicitConverter(implicit ctx: Context) = Predef_ImplicitConverterR.symbol + lazy val Predef_ImplicitConverterR: TypeRef = DottyPredefModule.requiredClass("ImplicitConverter").typeRef + def Predef_ImplicitConverter(implicit ctx: Context): Symbol = Predef_ImplicitConverterR.symbol - lazy val DottyArraysModuleRef = ctx.requiredModuleRef("dotty.runtime.Arrays") - def DottyArraysModule(implicit ctx: Context) = DottyArraysModuleRef.symbol - def newGenericArrayMethod(implicit ctx: Context) = DottyArraysModule.requiredMethod("newGenericArray") - def newArrayMethod(implicit ctx: Context) = DottyArraysModule.requiredMethod("newArray") + lazy val DottyArraysModuleRef: TermRef = ctx.requiredModuleRef("dotty.runtime.Arrays") + def DottyArraysModule(implicit ctx: Context): Symbol = DottyArraysModuleRef.symbol + def newGenericArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newGenericArray") + def newArrayMethod(implicit ctx: Context): TermSymbol = DottyArraysModule.requiredMethod("newArray") // TODO: Remove once we drop support for 2.12 standard library private[this] lazy val isNewCollections = ctx.base.staticRef("scala.collection.IterableOnce".toTypeName).exists - def getWrapVarargsArrayModule = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule + def getWrapVarargsArrayModule: Symbol = if (isNewCollections) ScalaRuntimeModule else ScalaPredefModule // The set of all wrap{X, Ref}Array methods, where X is a value type - val WrapArrayMethods = new PerRun[collection.Set[Symbol]]({ implicit ctx => + val WrapArrayMethods: PerRun[collection.Set[Symbol]] = new PerRun({ implicit ctx => val methodNames = ScalaValueTypes.map(ast.tpd.wrapArrayMethodName) + nme.wrapRefArray methodNames.map(getWrapVarargsArrayModule.requiredMethodRef(_).symbol) }) - lazy val NilModuleRef = ctx.requiredModuleRef("scala.collection.immutable.Nil") - def NilModule(implicit ctx: Context) = NilModuleRef.symbol + lazy val NilModuleRef: TermRef = ctx.requiredModuleRef("scala.collection.immutable.Nil") + def NilModule(implicit ctx: Context): Symbol = NilModuleRef.symbol lazy val SingletonClass: ClassSymbol = // needed as a synthetic class because Scala 2.x refers to it in classfiles @@ -418,415 +417,415 @@ class Definitions { lazy val SeqType: TypeRef = if (isNewCollections) ctx.requiredClassRef("scala.collection.immutable.Seq") else ctx.requiredClassRef("scala.collection.Seq") - def SeqClass(implicit ctx: Context) = SeqType.symbol.asClass - lazy val Seq_applyR = SeqClass.requiredMethodRef(nme.apply) - def Seq_apply(implicit ctx: Context) = Seq_applyR.symbol - lazy val Seq_headR = SeqClass.requiredMethodRef(nme.head) - def Seq_head(implicit ctx: Context) = Seq_headR.symbol - lazy val Seq_dropR = SeqClass.requiredMethodRef(nme.drop) - def Seq_drop(implicit ctx: Context) = Seq_dropR.symbol - lazy val Seq_lengthCompareR = SeqClass.requiredMethodRef(nme.lengthCompare) - def Seq_lengthCompare(implicit ctx: Context) = Seq_lengthCompareR.symbol - lazy val Seq_lengthR = SeqClass.requiredMethodRef(nme.length) - def Seq_length(implicit ctx: Context) = Seq_lengthR.symbol - lazy val Seq_toSeqR = SeqClass.requiredMethodRef(nme.toSeq) - def Seq_toSeq(implicit ctx: Context) = Seq_toSeqR.symbol + def SeqClass(implicit ctx: Context): ClassSymbol = SeqType.symbol.asClass + lazy val Seq_applyR: TermRef = SeqClass.requiredMethodRef(nme.apply) + def Seq_apply(implicit ctx: Context): Symbol = Seq_applyR.symbol + lazy val Seq_headR: TermRef = SeqClass.requiredMethodRef(nme.head) + def Seq_head(implicit ctx: Context): Symbol = Seq_headR.symbol + lazy val Seq_dropR: TermRef = SeqClass.requiredMethodRef(nme.drop) + def Seq_drop(implicit ctx: Context): Symbol = Seq_dropR.symbol + lazy val Seq_lengthCompareR: TermRef = SeqClass.requiredMethodRef(nme.lengthCompare) + def Seq_lengthCompare(implicit ctx: Context): Symbol = Seq_lengthCompareR.symbol + lazy val Seq_lengthR: TermRef = SeqClass.requiredMethodRef(nme.length) + def Seq_length(implicit ctx: Context): Symbol = Seq_lengthR.symbol + lazy val Seq_toSeqR: TermRef = SeqClass.requiredMethodRef(nme.toSeq) + def Seq_toSeq(implicit ctx: Context): Symbol = Seq_toSeqR.symbol lazy val ArrayType: TypeRef = ctx.requiredClassRef("scala.Array") - def ArrayClass(implicit ctx: Context) = ArrayType.symbol.asClass - lazy val Array_applyR = ArrayClass.requiredMethodRef(nme.apply) - def Array_apply(implicit ctx: Context) = Array_applyR.symbol - lazy val Array_updateR = ArrayClass.requiredMethodRef(nme.update) - def Array_update(implicit ctx: Context) = Array_updateR.symbol - lazy val Array_lengthR = ArrayClass.requiredMethodRef(nme.length) - def Array_length(implicit ctx: Context) = Array_lengthR.symbol - lazy val Array_cloneR = ArrayClass.requiredMethodRef(nme.clone_) - def Array_clone(implicit ctx: Context) = Array_cloneR.symbol - lazy val ArrayConstructorR = ArrayClass.requiredMethodRef(nme.CONSTRUCTOR) - def ArrayConstructor(implicit ctx: Context) = ArrayConstructorR.symbol - lazy val ArrayModuleType = ctx.requiredModuleRef("scala.Array") - def ArrayModule(implicit ctx: Context) = ArrayModuleType.symbol.moduleClass.asClass + def ArrayClass(implicit ctx: Context): ClassSymbol = ArrayType.symbol.asClass + lazy val Array_applyR: TermRef = ArrayClass.requiredMethodRef(nme.apply) + def Array_apply(implicit ctx: Context): Symbol = Array_applyR.symbol + lazy val Array_updateR: TermRef = ArrayClass.requiredMethodRef(nme.update) + def Array_update(implicit ctx: Context): Symbol = Array_updateR.symbol + lazy val Array_lengthR: TermRef = ArrayClass.requiredMethodRef(nme.length) + def Array_length(implicit ctx: Context): Symbol = Array_lengthR.symbol + lazy val Array_cloneR: TermRef = ArrayClass.requiredMethodRef(nme.clone_) + def Array_clone(implicit ctx: Context): Symbol = Array_cloneR.symbol + lazy val ArrayConstructorR: TermRef = ArrayClass.requiredMethodRef(nme.CONSTRUCTOR) + def ArrayConstructor(implicit ctx: Context): Symbol = ArrayConstructorR.symbol + lazy val ArrayModuleType: TermRef = ctx.requiredModuleRef("scala.Array") + def ArrayModule(implicit ctx: Context): ClassSymbol = ArrayModuleType.symbol.moduleClass.asClass lazy val UnitType: TypeRef = valueTypeRef("scala.Unit", BoxedUnitType, java.lang.Void.TYPE, UnitEnc, nme.specializedTypeNames.Void) - def UnitClass(implicit ctx: Context) = UnitType.symbol.asClass - def UnitModuleClass(implicit ctx: Context) = UnitType.symbol.asClass.linkedClass - lazy val BooleanType = valueTypeRef("scala.Boolean", BoxedBooleanType, java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean) - def BooleanClass(implicit ctx: Context) = BooleanType.symbol.asClass - lazy val Boolean_notR = BooleanClass.requiredMethodRef(nme.UNARY_!) - def Boolean_! = Boolean_notR.symbol - lazy val Boolean_andR = BooleanClass.requiredMethodRef(nme.ZAND) // ### harmonize required... calls - def Boolean_&& = Boolean_andR.symbol - lazy val Boolean_orR = BooleanClass.requiredMethodRef(nme.ZOR) - def Boolean_|| = Boolean_orR.symbol - lazy val Boolean_eqeqR = BooleanClass.info.member(nme.EQ).suchThat(_.info.firstParamTypes match { + def UnitClass(implicit ctx: Context): ClassSymbol = UnitType.symbol.asClass + def UnitModuleClass(implicit ctx: Context): Symbol = UnitType.symbol.asClass.linkedClass + lazy val BooleanType: TypeRef = valueTypeRef("scala.Boolean", BoxedBooleanType, java.lang.Boolean.TYPE, BooleanEnc, nme.specializedTypeNames.Boolean) + def BooleanClass(implicit ctx: Context): ClassSymbol = BooleanType.symbol.asClass + lazy val Boolean_notR: TermRef = BooleanClass.requiredMethodRef(nme.UNARY_!) + def Boolean_! : Symbol = Boolean_notR.symbol + lazy val Boolean_andR: TermRef = BooleanClass.requiredMethodRef(nme.ZAND) // ### harmonize required... calls + def Boolean_&& : Symbol = Boolean_andR.symbol + lazy val Boolean_orR: TermRef = BooleanClass.requiredMethodRef(nme.ZOR) + def Boolean_|| : Symbol = Boolean_orR.symbol + lazy val Boolean_eqeqR: SingleDenotation = BooleanClass.info.member(nme.EQ).suchThat(_.info.firstParamTypes match { case List(pt) => (pt isRef BooleanClass) case _ => false }) - def Boolean_== = Boolean_eqeqR.symbol - lazy val Boolean_neqeqR = BooleanClass.info.member(nme.NE).suchThat(_.info.firstParamTypes match { + def Boolean_== : Symbol = Boolean_eqeqR.symbol + lazy val Boolean_neqeqR: SingleDenotation = BooleanClass.info.member(nme.NE).suchThat(_.info.firstParamTypes match { case List(pt) => (pt isRef BooleanClass) case _ => false }) - def Boolean_!= = Boolean_neqeqR.symbol + def Boolean_!= : Symbol = Boolean_neqeqR.symbol lazy val ByteType: TypeRef = valueTypeRef("scala.Byte", BoxedByteType, java.lang.Byte.TYPE, ByteEnc, nme.specializedTypeNames.Byte) - def ByteClass(implicit ctx: Context) = ByteType.symbol.asClass + def ByteClass(implicit ctx: Context): ClassSymbol = ByteType.symbol.asClass lazy val ShortType: TypeRef = valueTypeRef("scala.Short", BoxedShortType, java.lang.Short.TYPE, ShortEnc, nme.specializedTypeNames.Short) - def ShortClass(implicit ctx: Context) = ShortType.symbol.asClass + def ShortClass(implicit ctx: Context): ClassSymbol = ShortType.symbol.asClass lazy val CharType: TypeRef = valueTypeRef("scala.Char", BoxedCharType, java.lang.Character.TYPE, CharEnc, nme.specializedTypeNames.Char) - def CharClass(implicit ctx: Context) = CharType.symbol.asClass + def CharClass(implicit ctx: Context): ClassSymbol = CharType.symbol.asClass lazy val IntType: TypeRef = valueTypeRef("scala.Int", BoxedIntType, java.lang.Integer.TYPE, IntEnc, nme.specializedTypeNames.Int) - def IntClass(implicit ctx: Context) = IntType.symbol.asClass - lazy val Int_minusR = IntClass.requiredMethodRef(nme.MINUS, List(IntType)) - def Int_- = Int_minusR.symbol - lazy val Int_plusR = IntClass.requiredMethodRef(nme.PLUS, List(IntType)) - def Int_+ = Int_plusR.symbol - lazy val Int_divR = IntClass.requiredMethodRef(nme.DIV, List(IntType)) - def Int_/ = Int_divR.symbol - lazy val Int_mulR = IntClass.requiredMethodRef(nme.MUL, List(IntType)) - def Int_* = Int_mulR.symbol - lazy val Int_eqR = IntClass.requiredMethodRef(nme.EQ, List(IntType)) - def Int_== = Int_eqR.symbol - lazy val Int_geR = IntClass.requiredMethodRef(nme.GE, List(IntType)) - def Int_>= = Int_geR.symbol - lazy val Int_leR = IntClass.requiredMethodRef(nme.LE, List(IntType)) - def Int_<= = Int_leR.symbol + def IntClass(implicit ctx: Context): ClassSymbol = IntType.symbol.asClass + lazy val Int_minusR: TermRef = IntClass.requiredMethodRef(nme.MINUS, List(IntType)) + def Int_- : Symbol = Int_minusR.symbol + lazy val Int_plusR: TermRef = IntClass.requiredMethodRef(nme.PLUS, List(IntType)) + def Int_+ : Symbol = Int_plusR.symbol + lazy val Int_divR: TermRef = IntClass.requiredMethodRef(nme.DIV, List(IntType)) + def Int_/ : Symbol = Int_divR.symbol + lazy val Int_mulR: TermRef = IntClass.requiredMethodRef(nme.MUL, List(IntType)) + def Int_* : Symbol = Int_mulR.symbol + lazy val Int_eqR: TermRef = IntClass.requiredMethodRef(nme.EQ, List(IntType)) + def Int_== : Symbol = Int_eqR.symbol + lazy val Int_geR: TermRef = IntClass.requiredMethodRef(nme.GE, List(IntType)) + def Int_>= : Symbol = Int_geR.symbol + lazy val Int_leR: TermRef = IntClass.requiredMethodRef(nme.LE, List(IntType)) + def Int_<= : Symbol = Int_leR.symbol lazy val LongType: TypeRef = valueTypeRef("scala.Long", BoxedLongType, java.lang.Long.TYPE, LongEnc, nme.specializedTypeNames.Long) - def LongClass(implicit ctx: Context) = LongType.symbol.asClass - lazy val Long_XOR_Long = LongType.member(nme.XOR).requiredSymbol( + def LongClass(implicit ctx: Context): ClassSymbol = LongType.symbol.asClass + lazy val Long_XOR_Long: Symbol = LongType.member(nme.XOR).requiredSymbol( x => (x is Method) && (x.info.firstParamTypes.head isRef defn.LongClass) ) - lazy val Long_LSR_Int = LongType.member(nme.LSR).requiredSymbol( + lazy val Long_LSR_Int: Symbol = LongType.member(nme.LSR).requiredSymbol( x => (x is Method) && (x.info.firstParamTypes.head isRef defn.IntClass) ) - lazy val Long_plusR = LongClass.requiredMethodRef(nme.PLUS, List(LongType)) - def Long_+ = Long_plusR.symbol - lazy val Long_mulR = LongClass.requiredMethodRef(nme.MUL, List(LongType)) - def Long_* = Long_mulR.symbol - lazy val Long_divR = LongClass.requiredMethodRef(nme.DIV, List(LongType)) - def Long_/ = Long_divR.symbol + lazy val Long_plusR: TermRef = LongClass.requiredMethodRef(nme.PLUS, List(LongType)) + def Long_+ : Symbol = Long_plusR.symbol + lazy val Long_mulR: TermRef = LongClass.requiredMethodRef(nme.MUL, List(LongType)) + def Long_* : Symbol = Long_mulR.symbol + lazy val Long_divR: TermRef = LongClass.requiredMethodRef(nme.DIV, List(LongType)) + def Long_/ : Symbol = Long_divR.symbol lazy val FloatType: TypeRef = valueTypeRef("scala.Float", BoxedFloatType, java.lang.Float.TYPE, FloatEnc, nme.specializedTypeNames.Float) - def FloatClass(implicit ctx: Context) = FloatType.symbol.asClass + def FloatClass(implicit ctx: Context): ClassSymbol = FloatType.symbol.asClass lazy val DoubleType: TypeRef = valueTypeRef("scala.Double", BoxedDoubleType, java.lang.Double.TYPE, DoubleEnc, nme.specializedTypeNames.Double) - def DoubleClass(implicit ctx: Context) = DoubleType.symbol.asClass + def DoubleClass(implicit ctx: Context): ClassSymbol = DoubleType.symbol.asClass lazy val BoxedUnitType: TypeRef = ctx.requiredClassRef("scala.runtime.BoxedUnit") - def BoxedUnitClass(implicit ctx: Context) = BoxedUnitType.symbol.asClass + def BoxedUnitClass(implicit ctx: Context): ClassSymbol = BoxedUnitType.symbol.asClass - def BoxedUnit_UNIT(implicit ctx: Context) = BoxedUnitClass.linkedClass.requiredValue("UNIT") + def BoxedUnit_UNIT(implicit ctx: Context): TermSymbol = BoxedUnitClass.linkedClass.requiredValue("UNIT") lazy val BoxedBooleanType: TypeRef = ctx.requiredClassRef("java.lang.Boolean") - def BoxedBooleanClass(implicit ctx: Context) = BoxedBooleanType.symbol.asClass + def BoxedBooleanClass(implicit ctx: Context): ClassSymbol = BoxedBooleanType.symbol.asClass lazy val BoxedByteType: TypeRef = ctx.requiredClassRef("java.lang.Byte") - def BoxedByteClass(implicit ctx: Context) = BoxedByteType.symbol.asClass + def BoxedByteClass(implicit ctx: Context): ClassSymbol = BoxedByteType.symbol.asClass lazy val BoxedShortType: TypeRef = ctx.requiredClassRef("java.lang.Short") - def BoxedShortClass(implicit ctx: Context) = BoxedShortType.symbol.asClass + def BoxedShortClass(implicit ctx: Context): ClassSymbol = BoxedShortType.symbol.asClass lazy val BoxedCharType: TypeRef = ctx.requiredClassRef("java.lang.Character") - def BoxedCharClass(implicit ctx: Context) = BoxedCharType.symbol.asClass + def BoxedCharClass(implicit ctx: Context): ClassSymbol = BoxedCharType.symbol.asClass lazy val BoxedIntType: TypeRef = ctx.requiredClassRef("java.lang.Integer") - def BoxedIntClass(implicit ctx: Context) = BoxedIntType.symbol.asClass + def BoxedIntClass(implicit ctx: Context): ClassSymbol = BoxedIntType.symbol.asClass lazy val BoxedLongType: TypeRef = ctx.requiredClassRef("java.lang.Long") - def BoxedLongClass(implicit ctx: Context) = BoxedLongType.symbol.asClass + def BoxedLongClass(implicit ctx: Context): ClassSymbol = BoxedLongType.symbol.asClass lazy val BoxedFloatType: TypeRef = ctx.requiredClassRef("java.lang.Float") - def BoxedFloatClass(implicit ctx: Context) = BoxedFloatType.symbol.asClass + def BoxedFloatClass(implicit ctx: Context): ClassSymbol = BoxedFloatType.symbol.asClass lazy val BoxedDoubleType: TypeRef = ctx.requiredClassRef("java.lang.Double") - def BoxedDoubleClass(implicit ctx: Context) = BoxedDoubleType.symbol.asClass + def BoxedDoubleClass(implicit ctx: Context): ClassSymbol = BoxedDoubleType.symbol.asClass - lazy val BoxedBooleanModule = ctx.requiredModule("java.lang.Boolean") - lazy val BoxedByteModule = ctx.requiredModule("java.lang.Byte") - lazy val BoxedShortModule = ctx.requiredModule("java.lang.Short") - lazy val BoxedCharModule = ctx.requiredModule("java.lang.Character") - lazy val BoxedIntModule = ctx.requiredModule("java.lang.Integer") - lazy val BoxedLongModule = ctx.requiredModule("java.lang.Long") - lazy val BoxedFloatModule = ctx.requiredModule("java.lang.Float") - lazy val BoxedDoubleModule = ctx.requiredModule("java.lang.Double") - lazy val BoxedUnitModule = ctx.requiredModule("java.lang.Void") + lazy val BoxedBooleanModule: TermSymbol = ctx.requiredModule("java.lang.Boolean") + lazy val BoxedByteModule: TermSymbol = ctx.requiredModule("java.lang.Byte") + lazy val BoxedShortModule: TermSymbol = ctx.requiredModule("java.lang.Short") + lazy val BoxedCharModule: TermSymbol = ctx.requiredModule("java.lang.Character") + lazy val BoxedIntModule: TermSymbol = ctx.requiredModule("java.lang.Integer") + lazy val BoxedLongModule: TermSymbol = ctx.requiredModule("java.lang.Long") + lazy val BoxedFloatModule: TermSymbol = ctx.requiredModule("java.lang.Float") + lazy val BoxedDoubleModule: TermSymbol = ctx.requiredModule("java.lang.Double") + lazy val BoxedUnitModule: TermSymbol = ctx.requiredModule("java.lang.Void") - lazy val ByNameParamClass2x = enterSpecialPolyClass(tpnme.BYNAME_PARAM_CLASS, Covariant, Seq(AnyType)) - lazy val EqualsPatternClass = enterSpecialPolyClass(tpnme.EQUALS_PATTERN, EmptyFlags, Seq(AnyType)) + lazy val ByNameParamClass2x: ClassSymbol = enterSpecialPolyClass(tpnme.BYNAME_PARAM_CLASS, Covariant, Seq(AnyType)) + lazy val EqualsPatternClass: ClassSymbol = enterSpecialPolyClass(tpnme.EQUALS_PATTERN, EmptyFlags, Seq(AnyType)) - lazy val RepeatedParamClass = enterSpecialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, Seq(ObjectType, SeqType)) + lazy val RepeatedParamClass: ClassSymbol = enterSpecialPolyClass(tpnme.REPEATED_PARAM_CLASS, Covariant, Seq(ObjectType, SeqType)) // fundamental classes - lazy val StringClass = ctx.requiredClass("java.lang.String") + lazy val StringClass: ClassSymbol = ctx.requiredClass("java.lang.String") def StringType: Type = StringClass.typeRef - lazy val StringModule = StringClass.linkedClass + lazy val StringModule: Symbol = StringClass.linkedClass - lazy val String_+ = enterMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final) - lazy val String_valueOf_Object = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match { + lazy val String_+ : TermSymbol = enterMethod(StringClass, nme.raw.PLUS, methOfAny(StringType), Final) + lazy val String_valueOf_Object: Symbol = StringModule.info.member(nme.valueOf).suchThat(_.info.firstParamTypes match { case List(pt) => (pt isRef AnyClass) || (pt isRef ObjectClass) case _ => false }).symbol - lazy val JavaCloneableClass = ctx.requiredClass("java.lang.Cloneable") - lazy val NullPointerExceptionClass = ctx.requiredClass("java.lang.NullPointerException") - lazy val IndexOutOfBoundsException = ctx.requiredClass("java.lang.IndexOutOfBoundsException") - lazy val ClassClass = ctx.requiredClass("java.lang.Class") - lazy val BoxedNumberClass = ctx.requiredClass("java.lang.Number") - lazy val ClassCastExceptionClass = ctx.requiredClass("java.lang.ClassCastException") - lazy val ArithmeticExceptionClass = ctx.requiredClass("java.lang.ArithmeticException") - lazy val ArithmeticExceptionClass_stringConstructor = ArithmeticExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match { + lazy val JavaCloneableClass: ClassSymbol = ctx.requiredClass("java.lang.Cloneable") + lazy val NullPointerExceptionClass: ClassSymbol = ctx.requiredClass("java.lang.NullPointerException") + lazy val IndexOutOfBoundsException: ClassSymbol = ctx.requiredClass("java.lang.IndexOutOfBoundsException") + lazy val ClassClass: ClassSymbol = ctx.requiredClass("java.lang.Class") + lazy val BoxedNumberClass: ClassSymbol = ctx.requiredClass("java.lang.Number") + lazy val ClassCastExceptionClass: ClassSymbol = ctx.requiredClass("java.lang.ClassCastException") + lazy val ArithmeticExceptionClass: ClassSymbol = ctx.requiredClass("java.lang.ArithmeticException") + lazy val ArithmeticExceptionClass_stringConstructor: TermSymbol = ArithmeticExceptionClass.info.member(nme.CONSTRUCTOR).suchThat(_.info.firstParamTypes match { case List(pt) => (pt isRef StringClass) case _ => false }).symbol.asTerm - lazy val JavaSerializableClass = ctx.requiredClass("java.io.Serializable") - lazy val ComparableClass = ctx.requiredClass("java.lang.Comparable") + lazy val JavaSerializableClass: ClassSymbol = ctx.requiredClass("java.io.Serializable") + lazy val ComparableClass: ClassSymbol = ctx.requiredClass("java.lang.Comparable") - lazy val SystemClass = ctx.requiredClass("java.lang.System") - lazy val SystemModule = SystemClass.linkedClass + lazy val SystemClass: ClassSymbol = ctx.requiredClass("java.lang.System") + lazy val SystemModule: Symbol = SystemClass.linkedClass // in scalac modified to have Any as parent lazy val ThrowableType: TypeRef = ctx.requiredClassRef("java.lang.Throwable") - def ThrowableClass(implicit ctx: Context) = ThrowableType.symbol.asClass + def ThrowableClass(implicit ctx: Context): ClassSymbol = ThrowableType.symbol.asClass lazy val SerializableType: TypeRef = ctx.requiredClassRef("scala.Serializable") - def SerializableClass(implicit ctx: Context) = SerializableType.symbol.asClass + def SerializableClass(implicit ctx: Context): ClassSymbol = SerializableType.symbol.asClass lazy val StringBuilderType: TypeRef = ctx.requiredClassRef("scala.collection.mutable.StringBuilder") - def StringBuilderClass(implicit ctx: Context) = StringBuilderType.symbol.asClass + def StringBuilderClass(implicit ctx: Context): ClassSymbol = StringBuilderType.symbol.asClass lazy val MatchErrorType: TypeRef = ctx.requiredClassRef("scala.MatchError") - def MatchErrorClass(implicit ctx: Context) = MatchErrorType.symbol.asClass + def MatchErrorClass(implicit ctx: Context): ClassSymbol = MatchErrorType.symbol.asClass lazy val StringAddType: TypeRef = ctx.requiredClassRef("scala.runtime.StringAdd") - def StringAddClass(implicit ctx: Context) = StringAddType.symbol.asClass + def StringAddClass(implicit ctx: Context): ClassSymbol = StringAddType.symbol.asClass - lazy val StringAdd_plusR = StringAddClass.requiredMethodRef(nme.raw.PLUS) - def StringAdd_+(implicit ctx: Context) = StringAdd_plusR.symbol + lazy val StringAdd_plusR: TermRef = StringAddClass.requiredMethodRef(nme.raw.PLUS) + def StringAdd_+(implicit ctx: Context): Symbol = StringAdd_plusR.symbol lazy val StringContextType: TypeRef = ctx.requiredClassRef("scala.StringContext") - def StringContextClass(implicit ctx: Context) = StringContextType.symbol.asClass - lazy val StringContextSR = StringContextClass.requiredMethodRef(nme.s) - def StringContextS(implicit ctx: Context) = StringContextSR.symbol - lazy val StringContextRawR = StringContextClass.requiredMethodRef(nme.raw_) - def StringContextRaw(implicit ctx: Context) = StringContextRawR.symbol - def StringContextModule(implicit ctx: Context) = StringContextClass.companionModule - lazy val StringContextModule_applyR = StringContextModule.requiredMethodRef(nme.apply) - def StringContextModule_apply(implicit ctx: Context) = StringContextModule_applyR.symbol + def StringContextClass(implicit ctx: Context): ClassSymbol = StringContextType.symbol.asClass + lazy val StringContextSR: TermRef = StringContextClass.requiredMethodRef(nme.s) + def StringContextS(implicit ctx: Context): Symbol = StringContextSR.symbol + lazy val StringContextRawR: TermRef = StringContextClass.requiredMethodRef(nme.raw_) + def StringContextRaw(implicit ctx: Context): Symbol = StringContextRawR.symbol + def StringContextModule(implicit ctx: Context): Symbol = StringContextClass.companionModule + lazy val StringContextModule_applyR: TermRef = StringContextModule.requiredMethodRef(nme.apply) + def StringContextModule_apply(implicit ctx: Context): Symbol = StringContextModule_applyR.symbol lazy val PartialFunctionType: TypeRef = ctx.requiredClassRef("scala.PartialFunction") - def PartialFunctionClass(implicit ctx: Context) = PartialFunctionType.symbol.asClass - lazy val PartialFunction_isDefinedAtR = PartialFunctionClass.requiredMethodRef(nme.isDefinedAt) - def PartialFunction_isDefinedAt(implicit ctx: Context) = PartialFunction_isDefinedAtR.symbol - lazy val PartialFunction_applyOrElseR = PartialFunctionClass.requiredMethodRef(nme.applyOrElse) - def PartialFunction_applyOrElse(implicit ctx: Context) = PartialFunction_applyOrElseR.symbol + def PartialFunctionClass(implicit ctx: Context): ClassSymbol = PartialFunctionType.symbol.asClass + lazy val PartialFunction_isDefinedAtR: TermRef = PartialFunctionClass.requiredMethodRef(nme.isDefinedAt) + def PartialFunction_isDefinedAt(implicit ctx: Context): Symbol = PartialFunction_isDefinedAtR.symbol + lazy val PartialFunction_applyOrElseR: TermRef = PartialFunctionClass.requiredMethodRef(nme.applyOrElse) + def PartialFunction_applyOrElse(implicit ctx: Context): Symbol = PartialFunction_applyOrElseR.symbol lazy val AbstractPartialFunctionType: TypeRef = ctx.requiredClassRef("scala.runtime.AbstractPartialFunction") - def AbstractPartialFunctionClass(implicit ctx: Context) = AbstractPartialFunctionType.symbol.asClass + def AbstractPartialFunctionClass(implicit ctx: Context): ClassSymbol = AbstractPartialFunctionType.symbol.asClass lazy val FunctionXXLType: TypeRef = ctx.requiredClassRef("scala.FunctionXXL") - def FunctionXXLClass(implicit ctx: Context) = FunctionXXLType.symbol.asClass + def FunctionXXLClass(implicit ctx: Context): ClassSymbol = FunctionXXLType.symbol.asClass lazy val ScalaSymbolType: TypeRef = ctx.requiredClassRef("scala.Symbol") - def ScalaSymbolClass(implicit ctx: Context) = ScalaSymbolType.symbol.asClass - def ScalaSymbolModule(implicit ctx: Context) = ScalaSymbolClass.companionModule - lazy val ScalaSymbolModule_applyR = ScalaSymbolModule.requiredMethodRef(nme.apply, List(StringType)) - def ScalaSymbolModule_apply(implicit ctx: Context) = ScalaSymbolModule_applyR.symbol + def ScalaSymbolClass(implicit ctx: Context): ClassSymbol = ScalaSymbolType.symbol.asClass + def ScalaSymbolModule(implicit ctx: Context): Symbol = ScalaSymbolClass.companionModule + lazy val ScalaSymbolModule_applyR: TermRef = ScalaSymbolModule.requiredMethodRef(nme.apply, List(StringType)) + def ScalaSymbolModule_apply(implicit ctx: Context): Symbol = ScalaSymbolModule_applyR.symbol lazy val DynamicType: TypeRef = ctx.requiredClassRef("scala.Dynamic") - def DynamicClass(implicit ctx: Context) = DynamicType.symbol.asClass + def DynamicClass(implicit ctx: Context): ClassSymbol = DynamicType.symbol.asClass lazy val OptionType: TypeRef = ctx.requiredClassRef("scala.Option") - def OptionClass(implicit ctx: Context) = OptionType.symbol.asClass + def OptionClass(implicit ctx: Context): ClassSymbol = OptionType.symbol.asClass lazy val SomeType: TypeRef = ctx.requiredClassRef("scala.Some") - def SomeClass(implicit ctx: Context) = SomeType.symbol.asClass + def SomeClass(implicit ctx: Context): ClassSymbol = SomeType.symbol.asClass lazy val NoneModuleRef: TermRef = ctx.requiredModuleRef("scala.None") - def NoneClass(implicit ctx: Context) = NoneModuleRef.symbol.moduleClass.asClass + def NoneClass(implicit ctx: Context): ClassSymbol = NoneModuleRef.symbol.moduleClass.asClass lazy val EnumType: TypeRef = ctx.requiredClassRef("scala.Enum") - def EnumClass(implicit ctx: Context) = EnumType.symbol.asClass + def EnumClass(implicit ctx: Context): ClassSymbol = EnumType.symbol.asClass lazy val EnumValuesType: TypeRef = ctx.requiredClassRef("scala.runtime.EnumValues") - def EnumValuesClass(implicit ctx: Context) = EnumValuesType.symbol.asClass + def EnumValuesClass(implicit ctx: Context): ClassSymbol = EnumValuesType.symbol.asClass lazy val ProductType: TypeRef = ctx.requiredClassRef("scala.Product") - def ProductClass(implicit ctx: Context) = ProductType.symbol.asClass - lazy val Product_canEqualR = ProductClass.requiredMethodRef(nme.canEqual_) - def Product_canEqual(implicit ctx: Context) = Product_canEqualR.symbol - lazy val Product_productArityR = ProductClass.requiredMethodRef(nme.productArity) - def Product_productArity(implicit ctx: Context) = Product_productArityR.symbol - lazy val Product_productElementR = ProductClass.requiredMethodRef(nme.productElement) - def Product_productElement(implicit ctx: Context) = Product_productElementR.symbol - lazy val Product_productPrefixR = ProductClass.requiredMethodRef(nme.productPrefix) - def Product_productPrefix(implicit ctx: Context) = Product_productPrefixR.symbol - lazy val LanguageModuleRef = ctx.requiredModule("scala.language") - def LanguageModuleClass(implicit ctx: Context) = LanguageModuleRef.moduleClass.asClass + def ProductClass(implicit ctx: Context): ClassSymbol = ProductType.symbol.asClass + lazy val Product_canEqualR: TermRef = ProductClass.requiredMethodRef(nme.canEqual_) + def Product_canEqual(implicit ctx: Context): Symbol = Product_canEqualR.symbol + lazy val Product_productArityR: TermRef = ProductClass.requiredMethodRef(nme.productArity) + def Product_productArity(implicit ctx: Context): Symbol = Product_productArityR.symbol + lazy val Product_productElementR: TermRef = ProductClass.requiredMethodRef(nme.productElement) + def Product_productElement(implicit ctx: Context): Symbol = Product_productElementR.symbol + lazy val Product_productPrefixR: TermRef = ProductClass.requiredMethodRef(nme.productPrefix) + def Product_productPrefix(implicit ctx: Context): Symbol = Product_productPrefixR.symbol + lazy val LanguageModuleRef: TermSymbol = ctx.requiredModule("scala.language") + def LanguageModuleClass(implicit ctx: Context): ClassSymbol = LanguageModuleRef.moduleClass.asClass lazy val NonLocalReturnControlType: TypeRef = ctx.requiredClassRef("scala.runtime.NonLocalReturnControl") lazy val SelectableType: TypeRef = ctx.requiredClassRef("scala.Selectable") - lazy val ClassTagType = ctx.requiredClassRef("scala.reflect.ClassTag") - def ClassTagClass(implicit ctx: Context) = ClassTagType.symbol.asClass - def ClassTagModule(implicit ctx: Context) = ClassTagClass.companionModule + lazy val ClassTagType: TypeRef = ctx.requiredClassRef("scala.reflect.ClassTag") + def ClassTagClass(implicit ctx: Context): ClassSymbol = ClassTagType.symbol.asClass + def ClassTagModule(implicit ctx: Context): Symbol = ClassTagClass.companionModule - lazy val QuotedExprType = ctx.requiredClassRef("scala.quoted.Expr") - def QuotedExprClass(implicit ctx: Context) = QuotedExprType.symbol.asClass - def QuotedExprModule(implicit ctx: Context) = QuotedExprClass.companionModule - lazy val QuotedExpr_applyR = QuotedExprModule.requiredMethodRef(nme.apply) - def QuotedExpr_apply(implicit ctx: Context) = QuotedExpr_applyR.symbol - lazy val QuotedExpr_~ = QuotedExprClass.requiredMethod(nme.UNARY_~) + lazy val QuotedExprType: TypeRef = ctx.requiredClassRef("scala.quoted.Expr") + def QuotedExprClass(implicit ctx: Context): ClassSymbol = QuotedExprType.symbol.asClass + def QuotedExprModule(implicit ctx: Context): Symbol = QuotedExprClass.companionModule + lazy val QuotedExpr_applyR: TermRef = QuotedExprModule.requiredMethodRef(nme.apply) + def QuotedExpr_apply(implicit ctx: Context): Symbol = QuotedExpr_applyR.symbol + lazy val QuotedExpr_~ : TermSymbol = QuotedExprClass.requiredMethod(nme.UNARY_~) - lazy val QuotedExprsModule = ctx.requiredModule("scala.quoted.Exprs") - def QuotedExprsClass(implicit ctx: Context) = QuotedExprsModule.asClass + lazy val QuotedExprsModule: TermSymbol = ctx.requiredModule("scala.quoted.Exprs") + def QuotedExprsClass(implicit ctx: Context): ClassSymbol = QuotedExprsModule.asClass - lazy val QuotedTypeType = ctx.requiredClassRef("scala.quoted.Type") - def QuotedTypeClass(implicit ctx: Context) = QuotedTypeType.symbol.asClass + lazy val QuotedTypeType: TypeRef = ctx.requiredClassRef("scala.quoted.Type") + def QuotedTypeClass(implicit ctx: Context): ClassSymbol = QuotedTypeType.symbol.asClass - lazy val QuotedType_spliceR = QuotedTypeClass.requiredType(tpnme.UNARY_~).typeRef - def QuotedType_~ = QuotedType_spliceR.symbol + lazy val QuotedType_spliceR: TypeRef = QuotedTypeClass.requiredType(tpnme.UNARY_~).typeRef + def QuotedType_~ : Symbol = QuotedType_spliceR.symbol - lazy val QuotedTypeModuleType = ctx.requiredModuleRef("scala.quoted.Type") - def QuotedTypeModule(implicit ctx: Context) = QuotedTypeModuleType.symbol - lazy val QuotedType_applyR = QuotedTypeModule.requiredMethodRef(nme.apply) - def QuotedType_apply(implicit ctx: Context) = QuotedType_applyR.symbol + lazy val QuotedTypeModuleType: TermRef = ctx.requiredModuleRef("scala.quoted.Type") + def QuotedTypeModule(implicit ctx: Context): Symbol = QuotedTypeModuleType.symbol + lazy val QuotedType_applyR: TermRef = QuotedTypeModule.requiredMethodRef(nme.apply) + def QuotedType_apply(implicit ctx: Context): Symbol = QuotedType_applyR.symbol - lazy val QuotedLiftableModule = ctx.requiredModule("scala.quoted.Liftable") - def QuotedLiftableModuleClass(implicit ctx: Context) = QuotedLiftableModule.asClass + lazy val QuotedLiftableModule: TermSymbol = ctx.requiredModule("scala.quoted.Liftable") + def QuotedLiftableModuleClass(implicit ctx: Context): ClassSymbol = QuotedLiftableModule.asClass - def QuotedLiftable_BooleanIsLiftable = QuotedLiftableModule.requiredMethodRef("BooleanIsLiftable") - def QuotedLiftable_ByteIsLiftable = QuotedLiftableModule.requiredMethodRef("ByteIsLiftable") - def QuotedLiftable_CharIsLiftable = QuotedLiftableModule.requiredMethodRef("CharIsLiftable") - def QuotedLiftable_ShortIsLiftable = QuotedLiftableModule.requiredMethodRef("ShortIsLiftable") - def QuotedLiftable_IntIsLiftable = QuotedLiftableModule.requiredMethodRef("IntIsLiftable") - def QuotedLiftable_LongIsLiftable = QuotedLiftableModule.requiredMethodRef("LongIsLiftable") - def QuotedLiftable_FloatIsLiftable = QuotedLiftableModule.requiredMethodRef("FloatIsLiftable") - def QuotedLiftable_DoubleIsLiftable = QuotedLiftableModule.requiredMethodRef("DoubleIsLiftable") - def QuotedLiftable_StringIsLiftable = QuotedLiftableModule.requiredMethodRef("StringIsLiftable") + def QuotedLiftable_BooleanIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("BooleanIsLiftable") + def QuotedLiftable_ByteIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("ByteIsLiftable") + def QuotedLiftable_CharIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("CharIsLiftable") + def QuotedLiftable_ShortIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("ShortIsLiftable") + def QuotedLiftable_IntIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("IntIsLiftable") + def QuotedLiftable_LongIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("LongIsLiftable") + def QuotedLiftable_FloatIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("FloatIsLiftable") + def QuotedLiftable_DoubleIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("DoubleIsLiftable") + def QuotedLiftable_StringIsLiftable: TermRef = QuotedLiftableModule.requiredMethodRef("StringIsLiftable") - lazy val QuotedLiftableType = ctx.requiredClassRef("scala.quoted.Liftable") - def QuotedLiftableClass(implicit ctx: Context) = QuotedLiftableType.symbol.asClass + lazy val QuotedLiftableType: TypeRef = ctx.requiredClassRef("scala.quoted.Liftable") + def QuotedLiftableClass(implicit ctx: Context): ClassSymbol = QuotedLiftableType.symbol.asClass - def Unpickler_unpickleExpr = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr") - def Unpickler_liftedExpr = ctx.requiredMethod("scala.runtime.quoted.Unpickler.liftedExpr") - def Unpickler_unpickleType = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType") + def Unpickler_unpickleExpr: TermSymbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr") + def Unpickler_liftedExpr: TermSymbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.liftedExpr") + def Unpickler_unpickleType: TermSymbol = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType") - lazy val TastyTastyType = ctx.requiredClassRef("scala.tasty.Tasty") - def TastyTastyClass(implicit ctx: Context) = TastyTastyType.symbol.asClass + lazy val TastyTastyType: TypeRef = ctx.requiredClassRef("scala.tasty.Tasty") + def TastyTastyClass(implicit ctx: Context): ClassSymbol = TastyTastyType.symbol.asClass - lazy val TastyTastyModule = ctx.requiredModule("scala.tasty.Tasty") - lazy val TastyTasty_macroContext = TastyTastyModule.requiredMethod("macroContext") + lazy val TastyTastyModule: TermSymbol = ctx.requiredModule("scala.tasty.Tasty") + lazy val TastyTasty_macroContext: TermSymbol = TastyTastyModule.requiredMethod("macroContext") - lazy val EqType = ctx.requiredClassRef("scala.Eq") - def EqClass(implicit ctx: Context) = EqType.symbol.asClass - def EqModule(implicit ctx: Context) = EqClass.companionModule + lazy val EqType: TypeRef = ctx.requiredClassRef("scala.Eq") + def EqClass(implicit ctx: Context): ClassSymbol = EqType.symbol.asClass + def EqModule(implicit ctx: Context): Symbol = EqClass.companionModule - def Eq_eqAny(implicit ctx: Context) = EqModule.requiredMethod(nme.eqAny) + def Eq_eqAny(implicit ctx: Context): TermSymbol = EqModule.requiredMethod(nme.eqAny) - lazy val NotType = ctx.requiredClassRef("scala.implicits.Not") - def NotClass(implicit ctx: Context) = NotType.symbol.asClass - def NotModule(implicit ctx: Context) = NotClass.companionModule + lazy val NotType: TypeRef = ctx.requiredClassRef("scala.implicits.Not") + def NotClass(implicit ctx: Context): ClassSymbol = NotType.symbol.asClass + def NotModule(implicit ctx: Context): Symbol = NotClass.companionModule - def Not_value(implicit ctx: Context) = NotModule.requiredMethod(nme.value) + def Not_value(implicit ctx: Context): TermSymbol = NotModule.requiredMethod(nme.value) - lazy val XMLTopScopeModuleRef = ctx.requiredModuleRef("scala.xml.TopScope") + lazy val XMLTopScopeModuleRef: TermRef = ctx.requiredModuleRef("scala.xml.TopScope") - lazy val TupleTypeRef = ctx.requiredClassRef("scala.Tuple") - def TupleClass(implicit ctx: Context) = TupleTypeRef.symbol.asClass - lazy val NonEmptyTupleTypeRef = ctx.requiredClassRef("scala.NonEmptyTuple") - def NonEmptyTupleClass(implicit ctx: Context) = NonEmptyTupleTypeRef.symbol.asClass + lazy val TupleTypeRef: TypeRef = ctx.requiredClassRef("scala.Tuple") + def TupleClass(implicit ctx: Context): ClassSymbol = TupleTypeRef.symbol.asClass + lazy val NonEmptyTupleTypeRef: TypeRef = ctx.requiredClassRef("scala.NonEmptyTuple") + def NonEmptyTupleClass(implicit ctx: Context): ClassSymbol = NonEmptyTupleTypeRef.symbol.asClass - lazy val PairType = ctx.requiredClassRef("scala.*:") - def PairClass(implicit ctx: Context) = PairType.symbol.asClass - lazy val TupleXXLType = ctx.requiredClassRef("scala.TupleXXL") - def TupleXXLClass(implicit ctx: Context) = TupleXXLType.symbol.asClass - def TupleXXLModule(implicit ctx: Context) = TupleXXLClass.companionModule + lazy val PairType: TypeRef = ctx.requiredClassRef("scala.*:") + def PairClass(implicit ctx: Context): ClassSymbol = PairType.symbol.asClass + lazy val TupleXXLType: TypeRef = ctx.requiredClassRef("scala.TupleXXL") + def TupleXXLClass(implicit ctx: Context): ClassSymbol = TupleXXLType.symbol.asClass + def TupleXXLModule(implicit ctx: Context): Symbol = TupleXXLClass.companionModule - def TupleXXL_apply(implicit ctx: Context) = + def TupleXXL_apply(implicit ctx: Context): Symbol = TupleXXLModule.info.member(nme.apply).requiredSymbol(_.info.isVarArgsMethod) // Annotation base classes - lazy val AnnotationType = ctx.requiredClassRef("scala.annotation.Annotation") - def AnnotationClass(implicit ctx: Context) = AnnotationType.symbol.asClass - lazy val ClassfileAnnotationType = ctx.requiredClassRef("scala.annotation.ClassfileAnnotation") - def ClassfileAnnotationClass(implicit ctx: Context) = ClassfileAnnotationType.symbol.asClass - lazy val StaticAnnotationType = ctx.requiredClassRef("scala.annotation.StaticAnnotation") - def StaticAnnotationClass(implicit ctx: Context) = StaticAnnotationType.symbol.asClass - lazy val RefiningAnnotationType = ctx.requiredClassRef("scala.annotation.RefiningAnnotation") - def RefiningAnnotationClass(implicit ctx: Context) = RefiningAnnotationType.symbol.asClass + lazy val AnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.Annotation") + def AnnotationClass(implicit ctx: Context): ClassSymbol = AnnotationType.symbol.asClass + lazy val ClassfileAnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.ClassfileAnnotation") + def ClassfileAnnotationClass(implicit ctx: Context): ClassSymbol = ClassfileAnnotationType.symbol.asClass + lazy val StaticAnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.StaticAnnotation") + def StaticAnnotationClass(implicit ctx: Context): ClassSymbol = StaticAnnotationType.symbol.asClass + lazy val RefiningAnnotationType: TypeRef = ctx.requiredClassRef("scala.annotation.RefiningAnnotation") + def RefiningAnnotationClass(implicit ctx: Context): ClassSymbol = RefiningAnnotationType.symbol.asClass // Annotation classes - lazy val AliasAnnotType = ctx.requiredClassRef("scala.annotation.internal.Alias") - def AliasAnnot(implicit ctx: Context) = AliasAnnotType.symbol.asClass - lazy val AnnotationDefaultAnnotType = ctx.requiredClassRef("scala.annotation.internal.AnnotationDefault") - def AnnotationDefaultAnnot(implicit ctx: Context) = AnnotationDefaultAnnotType.symbol.asClass - lazy val BodyAnnotType = ctx.requiredClassRef("scala.annotation.internal.Body") - def BodyAnnot(implicit ctx: Context) = BodyAnnotType.symbol.asClass - lazy val ChildAnnotType = ctx.requiredClassRef("scala.annotation.internal.Child") - def ChildAnnot(implicit ctx: Context) = ChildAnnotType.symbol.asClass - lazy val CovariantBetweenAnnotType = ctx.requiredClassRef("scala.annotation.internal.CovariantBetween") - def CovariantBetweenAnnot(implicit ctx: Context) = CovariantBetweenAnnotType.symbol.asClass - lazy val ContravariantBetweenAnnotType = ctx.requiredClassRef("scala.annotation.internal.ContravariantBetween") - def ContravariantBetweenAnnot(implicit ctx: Context) = ContravariantBetweenAnnotType.symbol.asClass - lazy val DeprecatedAnnotType = ctx.requiredClassRef("scala.deprecated") - def DeprecatedAnnot(implicit ctx: Context) = DeprecatedAnnotType.symbol.asClass - lazy val ImplicitAmbiguousAnnotType = ctx.requiredClassRef("scala.annotation.implicitAmbiguous") - def ImplicitAmbiguousAnnot(implicit ctx: Context) = ImplicitAmbiguousAnnotType.symbol.asClass - lazy val ImplicitNotFoundAnnotType = ctx.requiredClassRef("scala.annotation.implicitNotFound") - def ImplicitNotFoundAnnot(implicit ctx: Context) = ImplicitNotFoundAnnotType.symbol.asClass - lazy val ForceInlineAnnotType = ctx.requiredClassRef("scala.forceInline") - def ForceInlineAnnot(implicit ctx: Context) = ForceInlineAnnotType.symbol.asClass - lazy val InlineParamAnnotType = ctx.requiredClassRef("scala.annotation.internal.InlineParam") - def InlineParamAnnot(implicit ctx: Context) = InlineParamAnnotType.symbol.asClass - lazy val InvariantBetweenAnnotType = ctx.requiredClassRef("scala.annotation.internal.InvariantBetween") - def InvariantBetweenAnnot(implicit ctx: Context) = InvariantBetweenAnnotType.symbol.asClass - lazy val MigrationAnnotType = ctx.requiredClassRef("scala.annotation.migration") - def MigrationAnnot(implicit ctx: Context) = MigrationAnnotType.symbol.asClass - lazy val NativeAnnotType = ctx.requiredClassRef("scala.native") - def NativeAnnot(implicit ctx: Context) = NativeAnnotType.symbol.asClass - lazy val RepeatedAnnotType = ctx.requiredClassRef("scala.annotation.internal.Repeated") - def RepeatedAnnot(implicit ctx: Context) = RepeatedAnnotType.symbol.asClass - lazy val SourceFileAnnotType = ctx.requiredClassRef("scala.annotation.internal.SourceFile") - def SourceFileAnnot(implicit ctx: Context) = SourceFileAnnotType.symbol.asClass - lazy val ScalaSignatureAnnotType = ctx.requiredClassRef("scala.reflect.ScalaSignature") - def ScalaSignatureAnnot(implicit ctx: Context) = ScalaSignatureAnnotType.symbol.asClass - lazy val ScalaLongSignatureAnnotType = ctx.requiredClassRef("scala.reflect.ScalaLongSignature") - def ScalaLongSignatureAnnot(implicit ctx: Context) = ScalaLongSignatureAnnotType.symbol.asClass - lazy val ScalaStrictFPAnnotType = ctx.requiredClassRef("scala.annotation.strictfp") - def ScalaStrictFPAnnot(implicit ctx: Context) = ScalaStrictFPAnnotType.symbol.asClass - lazy val ScalaStaticAnnotType = ctx.requiredClassRef("scala.annotation.static") - def ScalaStaticAnnot(implicit ctx: Context) = ScalaStaticAnnotType.symbol.asClass - lazy val SerialVersionUIDAnnotType = ctx.requiredClassRef("scala.SerialVersionUID") - def SerialVersionUIDAnnot(implicit ctx: Context) = SerialVersionUIDAnnotType.symbol.asClass - lazy val TASTYSignatureAnnotType = ctx.requiredClassRef("scala.annotation.internal.TASTYSignature") - def TASTYSignatureAnnot(implicit ctx: Context) = TASTYSignatureAnnotType.symbol.asClass - lazy val TASTYLongSignatureAnnotType = ctx.requiredClassRef("scala.annotation.internal.TASTYLongSignature") - def TASTYLongSignatureAnnot(implicit ctx: Context) = TASTYLongSignatureAnnotType.symbol.asClass - lazy val TailrecAnnotType = ctx.requiredClassRef("scala.annotation.tailrec") - def TailrecAnnot(implicit ctx: Context) = TailrecAnnotType.symbol.asClass - lazy val SwitchAnnotType = ctx.requiredClassRef("scala.annotation.switch") - def SwitchAnnot(implicit ctx: Context) = SwitchAnnotType.symbol.asClass - lazy val ThrowsAnnotType = ctx.requiredClassRef("scala.throws") - def ThrowsAnnot(implicit ctx: Context) = ThrowsAnnotType.symbol.asClass - lazy val TransientAnnotType = ctx.requiredClassRef("scala.transient") - def TransientAnnot(implicit ctx: Context) = TransientAnnotType.symbol.asClass - lazy val UncheckedAnnotType = ctx.requiredClassRef("scala.unchecked") - def UncheckedAnnot(implicit ctx: Context) = UncheckedAnnotType.symbol.asClass - lazy val UncheckedStableAnnotType = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedStable") - def UncheckedStableAnnot(implicit ctx: Context) = UncheckedStableAnnotType.symbol.asClass - lazy val UncheckedVarianceAnnotType = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedVariance") - def UncheckedVarianceAnnot(implicit ctx: Context) = UncheckedVarianceAnnotType.symbol.asClass - lazy val VolatileAnnotType = ctx.requiredClassRef("scala.volatile") - def VolatileAnnot(implicit ctx: Context) = VolatileAnnotType.symbol.asClass - lazy val FieldMetaAnnotType = ctx.requiredClassRef("scala.annotation.meta.field") - def FieldMetaAnnot(implicit ctx: Context) = FieldMetaAnnotType.symbol.asClass - lazy val GetterMetaAnnotType = ctx.requiredClassRef("scala.annotation.meta.getter") - def GetterMetaAnnot(implicit ctx: Context) = GetterMetaAnnotType.symbol.asClass - lazy val SetterMetaAnnotType = ctx.requiredClassRef("scala.annotation.meta.setter") - def SetterMetaAnnot(implicit ctx: Context) = SetterMetaAnnotType.symbol.asClass - lazy val ShowAsInfixAnotType = ctx.requiredClassRef("scala.annotation.showAsInfix") - def ShowAsInfixAnnot(implicit ctx: Context) = ShowAsInfixAnotType.symbol.asClass + lazy val AliasAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Alias") + def AliasAnnot(implicit ctx: Context): ClassSymbol = AliasAnnotType.symbol.asClass + lazy val AnnotationDefaultAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.AnnotationDefault") + def AnnotationDefaultAnnot(implicit ctx: Context): ClassSymbol = AnnotationDefaultAnnotType.symbol.asClass + lazy val BodyAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Body") + def BodyAnnot(implicit ctx: Context): ClassSymbol = BodyAnnotType.symbol.asClass + lazy val ChildAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Child") + def ChildAnnot(implicit ctx: Context): ClassSymbol = ChildAnnotType.symbol.asClass + lazy val CovariantBetweenAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.CovariantBetween") + def CovariantBetweenAnnot(implicit ctx: Context): ClassSymbol = CovariantBetweenAnnotType.symbol.asClass + lazy val ContravariantBetweenAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.ContravariantBetween") + def ContravariantBetweenAnnot(implicit ctx: Context): ClassSymbol = ContravariantBetweenAnnotType.symbol.asClass + lazy val DeprecatedAnnotType: TypeRef = ctx.requiredClassRef("scala.deprecated") + def DeprecatedAnnot(implicit ctx: Context): ClassSymbol = DeprecatedAnnotType.symbol.asClass + lazy val ImplicitAmbiguousAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.implicitAmbiguous") + def ImplicitAmbiguousAnnot(implicit ctx: Context): ClassSymbol = ImplicitAmbiguousAnnotType.symbol.asClass + lazy val ImplicitNotFoundAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.implicitNotFound") + def ImplicitNotFoundAnnot(implicit ctx: Context): ClassSymbol = ImplicitNotFoundAnnotType.symbol.asClass + lazy val ForceInlineAnnotType: TypeRef = ctx.requiredClassRef("scala.forceInline") + def ForceInlineAnnot(implicit ctx: Context): ClassSymbol = ForceInlineAnnotType.symbol.asClass + lazy val InlineParamAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.InlineParam") + def InlineParamAnnot(implicit ctx: Context): ClassSymbol = InlineParamAnnotType.symbol.asClass + lazy val InvariantBetweenAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.InvariantBetween") + def InvariantBetweenAnnot(implicit ctx: Context): ClassSymbol = InvariantBetweenAnnotType.symbol.asClass + lazy val MigrationAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.migration") + def MigrationAnnot(implicit ctx: Context): ClassSymbol = MigrationAnnotType.symbol.asClass + lazy val NativeAnnotType: TypeRef = ctx.requiredClassRef("scala.native") + def NativeAnnot(implicit ctx: Context): ClassSymbol = NativeAnnotType.symbol.asClass + lazy val RepeatedAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.Repeated") + def RepeatedAnnot(implicit ctx: Context): ClassSymbol = RepeatedAnnotType.symbol.asClass + lazy val SourceFileAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.SourceFile") + def SourceFileAnnot(implicit ctx: Context): ClassSymbol = SourceFileAnnotType.symbol.asClass + lazy val ScalaSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.reflect.ScalaSignature") + def ScalaSignatureAnnot(implicit ctx: Context): ClassSymbol = ScalaSignatureAnnotType.symbol.asClass + lazy val ScalaLongSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.reflect.ScalaLongSignature") + def ScalaLongSignatureAnnot(implicit ctx: Context): ClassSymbol = ScalaLongSignatureAnnotType.symbol.asClass + lazy val ScalaStrictFPAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.strictfp") + def ScalaStrictFPAnnot(implicit ctx: Context): ClassSymbol = ScalaStrictFPAnnotType.symbol.asClass + lazy val ScalaStaticAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.static") + def ScalaStaticAnnot(implicit ctx: Context): ClassSymbol = ScalaStaticAnnotType.symbol.asClass + lazy val SerialVersionUIDAnnotType: TypeRef = ctx.requiredClassRef("scala.SerialVersionUID") + def SerialVersionUIDAnnot(implicit ctx: Context): ClassSymbol = SerialVersionUIDAnnotType.symbol.asClass + lazy val TASTYSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.TASTYSignature") + def TASTYSignatureAnnot(implicit ctx: Context): ClassSymbol = TASTYSignatureAnnotType.symbol.asClass + lazy val TASTYLongSignatureAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.internal.TASTYLongSignature") + def TASTYLongSignatureAnnot(implicit ctx: Context): ClassSymbol = TASTYLongSignatureAnnotType.symbol.asClass + lazy val TailrecAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.tailrec") + def TailrecAnnot(implicit ctx: Context): ClassSymbol = TailrecAnnotType.symbol.asClass + lazy val SwitchAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.switch") + def SwitchAnnot(implicit ctx: Context): ClassSymbol = SwitchAnnotType.symbol.asClass + lazy val ThrowsAnnotType: TypeRef = ctx.requiredClassRef("scala.throws") + def ThrowsAnnot(implicit ctx: Context): ClassSymbol = ThrowsAnnotType.symbol.asClass + lazy val TransientAnnotType: TypeRef = ctx.requiredClassRef("scala.transient") + def TransientAnnot(implicit ctx: Context): ClassSymbol = TransientAnnotType.symbol.asClass + lazy val UncheckedAnnotType: TypeRef = ctx.requiredClassRef("scala.unchecked") + def UncheckedAnnot(implicit ctx: Context): ClassSymbol = UncheckedAnnotType.symbol.asClass + lazy val UncheckedStableAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedStable") + def UncheckedStableAnnot(implicit ctx: Context): ClassSymbol = UncheckedStableAnnotType.symbol.asClass + lazy val UncheckedVarianceAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.unchecked.uncheckedVariance") + def UncheckedVarianceAnnot(implicit ctx: Context): ClassSymbol = UncheckedVarianceAnnotType.symbol.asClass + lazy val VolatileAnnotType: TypeRef = ctx.requiredClassRef("scala.volatile") + def VolatileAnnot(implicit ctx: Context): ClassSymbol = VolatileAnnotType.symbol.asClass + lazy val FieldMetaAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.meta.field") + def FieldMetaAnnot(implicit ctx: Context): ClassSymbol = FieldMetaAnnotType.symbol.asClass + lazy val GetterMetaAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.meta.getter") + def GetterMetaAnnot(implicit ctx: Context): ClassSymbol = GetterMetaAnnotType.symbol.asClass + lazy val SetterMetaAnnotType: TypeRef = ctx.requiredClassRef("scala.annotation.meta.setter") + def SetterMetaAnnot(implicit ctx: Context): ClassSymbol = SetterMetaAnnotType.symbol.asClass + lazy val ShowAsInfixAnotType: TypeRef = ctx.requiredClassRef("scala.annotation.showAsInfix") + def ShowAsInfixAnnot(implicit ctx: Context): ClassSymbol = ShowAsInfixAnotType.symbol.asClass // convenient one-parameter method types - def methOfAny(tp: Type) = MethodType(List(AnyType), tp) - def methOfAnyVal(tp: Type) = MethodType(List(AnyValType), tp) - def methOfAnyRef(tp: Type) = MethodType(List(ObjectType), tp) + def methOfAny(tp: Type): MethodType = MethodType(List(AnyType), tp) + def methOfAnyVal(tp: Type): MethodType = MethodType(List(AnyValType), tp) + def methOfAnyRef(tp: Type): MethodType = MethodType(List(ObjectType), tp) // Derived types - def RepeatedParamType = RepeatedParamClass.typeRef + def RepeatedParamType: TypeRef = RepeatedParamClass.typeRef - def ClassType(arg: Type)(implicit ctx: Context) = { + def ClassType(arg: Type)(implicit ctx: Context): Type = { val ctype = ClassClass.typeRef if (ctx.phase.erasedTypes) ctype else ctype.appliedTo(arg) } /** The enumeration type, goven a value of the enumeration */ - def EnumType(sym: Symbol)(implicit ctx: Context) = + def EnumType(sym: Symbol)(implicit ctx: Context): TypeRef = // given (in java): "class A { enum E { VAL1 } }" // - sym: the symbol of the actual enumeration value (VAL1) // - .owner: the ModuleClassSymbol of the enumeration (object E) @@ -834,9 +833,9 @@ class Definitions { sym.owner.linkedClass.typeRef object FunctionOf { - def apply(args: List[Type], resultType: Type, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context) = + def apply(args: List[Type], resultType: Type, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): Type = FunctionType(args.length, isImplicit, isErased).appliedTo(args ::: resultType :: Nil) - def unapply(ft: Type)(implicit ctx: Context) = { + def unapply(ft: Type)(implicit ctx: Context): Option[(List[Type], Type, Boolean, Boolean)] = { val tsym = ft.typeSymbol if (isFunctionClass(tsym)) { val targs = ft.dealias.argInfos @@ -848,9 +847,9 @@ class Definitions { } object PartialFunctionOf { - def apply(arg: Type, result: Type)(implicit ctx: Context) = + def apply(arg: Type, result: Type)(implicit ctx: Context): Type = PartialFunctionType.appliedTo(arg :: result :: Nil) - def unapply(pft: Type)(implicit ctx: Context) = { + def unapply(pft: Type)(implicit ctx: Context): Option[(Type, List[Type])] = { if (pft.isRef(PartialFunctionClass)) { val targs = pft.dealias.argInfos if (targs.length == 2) Some((targs.head, targs.tail)) else None @@ -860,7 +859,7 @@ class Definitions { } object ArrayOf { - def apply(elem: Type)(implicit ctx: Context) = + def apply(elem: Type)(implicit ctx: Context): Type = if (ctx.erasedTypes) JavaArrayType(elem) else ArrayType.appliedTo(elem :: Nil) def unapply(tp: Type)(implicit ctx: Context): Option[Type] = tp.dealias match { @@ -895,20 +894,20 @@ class Definitions { } } - final def isTypelevel_S(sym: Symbol)(implicit ctx: Context) = + final def isTypelevel_S(sym: Symbol)(implicit ctx: Context): Boolean = sym.name == tpnme.S && sym.owner == TypelevelPackageObject // ----- Symbol sets --------------------------------------------------- - lazy val AbstractFunctionType = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0) - val AbstractFunctionClassPerRun = new PerRun[Array[Symbol]](implicit ctx => AbstractFunctionType.map(_.symbol.asClass)) - def AbstractFunctionClass(n: Int)(implicit ctx: Context) = AbstractFunctionClassPerRun()(ctx)(n) + lazy val AbstractFunctionType: Array[TypeRef] = mkArityArray("scala.runtime.AbstractFunction", MaxImplementedFunctionArity, 0) + val AbstractFunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun[Array[Symbol]](implicit ctx => AbstractFunctionType.map(_.symbol.asClass)) + def AbstractFunctionClass(n: Int)(implicit ctx: Context): Symbol = AbstractFunctionClassPerRun()(ctx)(n) private lazy val ImplementedFunctionType = mkArityArray("scala.Function", MaxImplementedFunctionArity, 0) - def FunctionClassPerRun = new PerRun[Array[Symbol]](implicit ctx => ImplementedFunctionType.map(_.symbol.asClass)) + def FunctionClassPerRun: PerRun[Array[Symbol]] = new PerRun[Array[Symbol]](implicit ctx => ImplementedFunctionType.map(_.symbol.asClass)) - lazy val TupleType = mkArityArray("scala.Tuple", MaxTupleArity, 1) + lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1) - def FunctionClass(n: Int, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context) = + def FunctionClass(n: Int, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): Symbol = if (isImplicit && isErased) ctx.requiredClass("scala.ErasedImplicitFunction" + n.toString) else if (isImplicit) @@ -920,8 +919,8 @@ class Definitions { else ctx.requiredClass("scala.Function" + n.toString) - lazy val Function0_applyR = ImplementedFunctionType(0).symbol.requiredMethodRef(nme.apply) - def Function0_apply(implicit ctx: Context) = Function0_applyR.symbol + lazy val Function0_applyR: TermRef = ImplementedFunctionType(0).symbol.requiredMethodRef(nme.apply) + def Function0_apply(implicit ctx: Context): Symbol = Function0_applyR.symbol def FunctionType(n: Int, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): TypeRef = if (n <= MaxImplementedFunctionArity && (!isImplicit || ctx.erasedTypes) && !isErased) ImplementedFunctionType(n) @@ -941,9 +940,9 @@ class Definitions { name.length > prefix.length && name.drop(prefix.length).forall(_.isDigit)) - def isBottomClass(cls: Symbol) = + def isBottomClass(cls: Symbol): Boolean = cls == NothingClass || cls == NullClass - def isBottomType(tp: Type) = + def isBottomType(tp: Type): Boolean = tp.derivesFrom(NothingClass) || tp.derivesFrom(NullClass) /** Is a function class. @@ -952,37 +951,37 @@ class Definitions { * - ErasedFunctionN for N > 0 * - ErasedImplicitFunctionN for N > 0 */ - def isFunctionClass(cls: Symbol) = scalaClassName(cls).isFunction + def isFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isFunction /** Is an implicit function class. * - ImplicitFunctionN for N >= 0 * - ErasedImplicitFunctionN for N > 0 */ - def isImplicitFunctionClass(cls: Symbol) = scalaClassName(cls).isImplicitFunction + def isImplicitFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isImplicitFunction /** Is an erased function class. * - ErasedFunctionN for N > 0 * - ErasedImplicitFunctionN for N > 0 */ - def isErasedFunctionClass(cls: Symbol) = scalaClassName(cls).isErasedFunction + def isErasedFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isErasedFunction /** Is a class that will be erased to FunctionXXL * - FunctionN for N >= 22 * - ImplicitFunctionN for N >= 22 */ - def isXXLFunctionClass(cls: Symbol) = scalaClassName(cls).functionArity > MaxImplementedFunctionArity + def isXXLFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).functionArity > MaxImplementedFunctionArity /** Is a synthetic function class * - FunctionN for N > 22 * - ImplicitFunctionN for N > 0 */ - def isSyntheticFunctionClass(cls: Symbol) = scalaClassName(cls).isSyntheticFunction + def isSyntheticFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isSyntheticFunction - def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, str.AbstractFunction) - def isTupleClass(cls: Symbol) = isVarArityClass(cls, str.Tuple) - def isProductClass(cls: Symbol) = isVarArityClass(cls, str.Product) + def isAbstractFunctionClass(cls: Symbol): Boolean = isVarArityClass(cls, str.AbstractFunction) + def isTupleClass(cls: Symbol): Boolean = isVarArityClass(cls, str.Tuple) + def isProductClass(cls: Symbol): Boolean = isVarArityClass(cls, str.Product) - def isScalaShadowingPackageClass(cls: Symbol) = + def isScalaShadowingPackageClass(cls: Symbol): Boolean = cls.name == tpnme.scalaShadowing && cls.owner == RootClass /** Returns the erased class of the function class `cls` @@ -1023,32 +1022,32 @@ class Definitions { Set("Predef$", "DeprecatedPredef", "LowPriorityImplicits").map(_.toTypeName.unmangleClassName) /** Is `cls` the predef module class, or a class inherited by Predef? */ - def isPredefClass(cls: Symbol) = + def isPredefClass(cls: Symbol): Boolean = (cls.owner eq ScalaPackageClass) && predefClassNames.contains(cls.name) - val StaticRootImportFns = List[() => TermRef]( + val StaticRootImportFns: List[() => TermRef] = List[() => TermRef]( () => JavaLangPackageVal.termRef, () => ScalaPackageVal.termRef ) - val PredefImportFns = List[() => TermRef]( + val PredefImportFns: List[() => TermRef] = List[() => TermRef]( () => ScalaPredefModuleRef, () => DottyPredefModuleRef ) - lazy val RootImportFns = + lazy val RootImportFns: List[() => TermRef] = if (ctx.settings.YnoImports.value) List.empty[() => TermRef] else if (ctx.settings.YnoPredef.value) StaticRootImportFns else StaticRootImportFns ++ PredefImportFns - lazy val ShadowableImportNames = Set("Predef", "DottyPredef").map(_.toTermName) - lazy val RootImportTypes = RootImportFns.map(_()) + lazy val ShadowableImportNames: Set[TermName] = Set("Predef", "DottyPredef").map(_.toTermName) + lazy val RootImportTypes: List[TermRef] = RootImportFns.map(_()) /** Modules whose members are in the default namespace and their module classes */ lazy val UnqualifiedOwnerTypes: Set[NamedType] = RootImportTypes.toSet[NamedType] ++ RootImportTypes.map(_.symbol.moduleClass.typeRef) - lazy val NotRuntimeClasses = Set[Symbol](AnyClass, AnyValClass, NullClass, NothingClass) + lazy val NotRuntimeClasses: Set[Symbol] = Set(AnyClass, AnyValClass, NullClass, NothingClass) /** Classes that are known not to have an initializer irrespective of * whether NoInits is set. Note: FunctionXXLClass is in this set @@ -1060,34 +1059,34 @@ class Definitions { * trait gets screwed up. Therefore, it is mandatory that FunctionXXL * is treated as a NoInit trait. */ - lazy val NoInitClasses = NotRuntimeClasses + FunctionXXLClass + lazy val NoInitClasses: Set[Symbol] = NotRuntimeClasses + FunctionXXLClass - def isPolymorphicAfterErasure(sym: Symbol) = + def isPolymorphicAfterErasure(sym: Symbol): Boolean = (sym eq Any_isInstanceOf) || (sym eq Any_asInstanceOf) - def isTupleType(tp: Type)(implicit ctx: Context) = { + def isTupleType(tp: Type)(implicit ctx: Context): Boolean = { val arity = tp.dealias.argInfos.length arity <= MaxTupleArity && TupleType(arity) != null && (tp isRef TupleType(arity).symbol) } - def tupleType(elems: List[Type]) = { + def tupleType(elems: List[Type]): Type = { TupleType(elems.size).appliedTo(elems) } - def isProductSubType(tp: Type)(implicit ctx: Context) = + def isProductSubType(tp: Type)(implicit ctx: Context): Boolean = tp.derivesFrom(ProductType.symbol) /** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN * instance? */ - def isNonDepFunctionType(tp: Type)(implicit ctx: Context) = { + def isNonDepFunctionType(tp: Type)(implicit ctx: Context): Boolean = { val arity = functionArity(tp) val sym = tp.dealias.typeSymbol arity >= 0 && isFunctionClass(sym) && tp.isRef(FunctionType(arity, sym.name.isImplicitFunction, sym.name.isErasedFunction).typeSymbol) } /** Is `tp` a representation of a (possibly depenent) function type or an alias of such? */ - def isFunctionType(tp: Type)(implicit ctx: Context) = + def isFunctionType(tp: Type)(implicit ctx: Context): Boolean = isNonDepFunctionType(tp.dropDependentRefinement) // Specialized type parameters defined for scala.Function{0,1,2}. @@ -1102,18 +1101,18 @@ class Definitions { lazy val Function2SpecializedReturnTypes: collection.Set[TypeRef] = Function1SpecializedReturnTypes - lazy val Function1SpecializedParamClasses = - new PerRun[collection.Set[Symbol]](implicit ctx => Function1SpecializedParamTypes.map(_.symbol)) - lazy val Function2SpecializedParamClasses = - new PerRun[collection.Set[Symbol]](implicit ctx => Function2SpecializedParamTypes.map(_.symbol)) - lazy val Function0SpecializedReturnClasses = - new PerRun[collection.Set[Symbol]](implicit ctx => Function0SpecializedReturnTypes.map(_.symbol)) - lazy val Function1SpecializedReturnClasses = - new PerRun[collection.Set[Symbol]](implicit ctx => Function1SpecializedReturnTypes.map(_.symbol)) - lazy val Function2SpecializedReturnClasses = - new PerRun[collection.Set[Symbol]](implicit ctx => Function2SpecializedReturnTypes.map(_.symbol)) - - def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(implicit ctx: Context) = + lazy val Function1SpecializedParamClasses: PerRun[collection.Set[Symbol]] = + new PerRun(implicit ctx => Function1SpecializedParamTypes.map(_.symbol)) + lazy val Function2SpecializedParamClasses: PerRun[collection.Set[Symbol]] = + new PerRun(implicit ctx => Function2SpecializedParamTypes.map(_.symbol)) + lazy val Function0SpecializedReturnClasses: PerRun[collection.Set[Symbol]] = + new PerRun(implicit ctx => Function0SpecializedReturnTypes.map(_.symbol)) + lazy val Function1SpecializedReturnClasses: PerRun[collection.Set[Symbol]] = + new PerRun(implicit ctx => Function1SpecializedReturnTypes.map(_.symbol)) + lazy val Function2SpecializedReturnClasses: PerRun[collection.Set[Symbol]] = + new PerRun(implicit ctx => Function2SpecializedReturnTypes.map(_.symbol)) + + def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(implicit ctx: Context): Boolean = paramTypes.length <= 2 && cls.derivesFrom(FunctionClass(paramTypes.length)) && (paramTypes match { case Nil => Function0SpecializedReturnClasses().contains(retType.typeSymbol) @@ -1128,7 +1127,7 @@ class Definitions { false }) - def functionArity(tp: Type)(implicit ctx: Context) = tp.dealias.argInfos.length - 1 + def functionArity(tp: Type)(implicit ctx: Context): Int = tp.dealias.argInfos.length - 1 /** Return underlying immplicit function type (i.e. instance of an ImplicitFunctionN class) * or NoType if none exists. The following types are considered as underlying types: @@ -1149,11 +1148,11 @@ class Definitions { def isImplicitFunctionType(tp: Type)(implicit ctx: Context): Boolean = asImplicitFunctionType(tp).exists - def isErasedFunctionType(tp: Type)(implicit ctx: Context) = + def isErasedFunctionType(tp: Type)(implicit ctx: Context): Boolean = isFunctionType(tp) && tp.dealias.typeSymbol.name.isErasedFunction /** A whitelist of Scala-2 classes that are known to be pure */ - def isAssuredNoInits(sym: Symbol) = + def isAssuredNoInits(sym: Symbol): Boolean = (sym `eq` SomeClass) || isTupleClass(sym) /** If `cls` is Tuple1..Tuple22, add the corresponding *: type as last parent to `parents` */ @@ -1179,16 +1178,16 @@ class Definitions { } } - lazy val ScalaNumericValueTypeList = List( + lazy val ScalaNumericValueTypeList: List[TypeRef] = List( ByteType, ShortType, CharType, IntType, LongType, FloatType, DoubleType) private lazy val ScalaNumericValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypeList.toSet private lazy val ScalaValueTypes: collection.Set[TypeRef] = ScalaNumericValueTypes + UnitType + BooleanType private lazy val ScalaBoxedTypes = ScalaValueTypes map (t => boxedTypes(t.name)) - val ScalaNumericValueClasses = new PerRun[collection.Set[Symbol]](implicit ctx => ScalaNumericValueTypes.map(_.symbol)) - val ScalaValueClasses = new PerRun[collection.Set[Symbol]](implicit ctx => ScalaValueTypes.map(_.symbol)) - val ScalaBoxedClasses = new PerRun[collection.Set[Symbol]](implicit ctx => ScalaBoxedTypes.map(_.symbol)) + val ScalaNumericValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaNumericValueTypes.map(_.symbol)) + val ScalaValueClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaValueTypes.map(_.symbol)) + val ScalaBoxedClasses: PerRun[collection.Set[Symbol]] = new PerRun(implicit ctx => ScalaBoxedTypes.map(_.symbol)) private val boxedTypes = mutable.Map[TypeName, TypeRef]() private val valueTypeEnc = mutable.Map[TypeName, PrimitiveClassEnc]() @@ -1221,27 +1220,27 @@ class Definitions { type PrimitiveClassEnc = Int - val ByteEnc = 2 - val ShortEnc = ByteEnc * 3 - val CharEnc = 5 - val IntEnc = ShortEnc * CharEnc - val LongEnc = IntEnc * 7 - val FloatEnc = LongEnc * 11 - val DoubleEnc = FloatEnc * 13 - val BooleanEnc = 17 - val UnitEnc = 19 - - def isValueSubType(tref1: TypeRef, tref2: TypeRef)(implicit ctx: Context) = + val ByteEnc: Int = 2 + val ShortEnc: Int = ByteEnc * 3 + val CharEnc: Int = 5 + val IntEnc: Int = ShortEnc * CharEnc + val LongEnc: Int = IntEnc * 7 + val FloatEnc: Int = LongEnc * 11 + val DoubleEnc: Int = FloatEnc * 13 + val BooleanEnc: Int = 17 + val UnitEnc: Int = 19 + + def isValueSubType(tref1: TypeRef, tref2: TypeRef)(implicit ctx: Context): Boolean = valueTypeEnc(tref2.name) % valueTypeEnc(tref1.name) == 0 - def isValueSubClass(sym1: Symbol, sym2: Symbol) = + def isValueSubClass(sym1: Symbol, sym2: Symbol): Boolean = valueTypeEnc(sym2.asClass.name) % valueTypeEnc(sym1.asClass.name) == 0 - lazy val erasedToObject = Set[Symbol](AnyClass, AnyValClass, TupleClass, NonEmptyTupleClass, SingletonClass) + lazy val erasedToObject: Set[Symbol] = Set(AnyClass, AnyValClass, TupleClass, NonEmptyTupleClass, SingletonClass) // ----- Initialization --------------------------------------------------- /** Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */ - lazy val syntheticScalaClasses = List( + lazy val syntheticScalaClasses: List[TypeSymbol] = List( AnyClass, AnyRefAlias, AnyKindClass, @@ -1253,19 +1252,19 @@ class Definitions { SingletonClass, EqualsPatternClass) - lazy val syntheticCoreClasses = syntheticScalaClasses ++ List( + lazy val syntheticCoreClasses: List[Symbol] = syntheticScalaClasses ++ List( EmptyPackageVal, OpsPackageClass) /** Lists core methods that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */ - lazy val syntheticCoreMethods = + lazy val syntheticCoreMethods: List[TermSymbol] = AnyMethods ++ ObjectMethods ++ List(String_+, throwMethod) lazy val reservedScalaClassNames: Set[Name] = syntheticScalaClasses.map(_.name).toSet private[this] var isInitialized = false - def init()(implicit ctx: Context) = { + def init()(implicit ctx: Context): Unit = { this.ctx = ctx if (!isInitialized) { // Enter all symbols from the scalaShadowing package in the scala package diff --git a/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala b/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala index 5ec1620a77f1..f8ea4fde1104 100644 --- a/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala +++ b/compiler/src/dotty/tools/dotc/core/DenotTransformers.scala @@ -8,8 +8,6 @@ import Types._ import Symbols._ import Denotations._ import Phases._ -import java.lang.AssertionError -import dotty.tools.dotc.util.DotClass object DenotTransformers { @@ -22,7 +20,7 @@ object DenotTransformers { trait DenotTransformer extends Phase { /** The last phase during which the transformed denotations are valid */ - def lastPhaseId(implicit ctx: Context) = ctx.base.nextDenotTransformerId(id + 1) + def lastPhaseId(implicit ctx: Context): Int = ctx.base.nextDenotTransformerId(id + 1) /** The validity period of the transformed denotations in the given context */ def validFor(implicit ctx: Context): Period = diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index 2100db069eb0..c4357138abad 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -2,10 +2,9 @@ package dotty.tools package dotc package core -import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation } +import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation, LazyType } import Contexts.{Context, ContextBase} import Names._ -import NameOps._ import NameKinds._ import StdNames._ import Symbols.NoSymbol @@ -15,15 +14,12 @@ import Periods._ import Flags._ import DenotTransformers._ import Decorators._ -import dotc.transform.Erasure import printing.Texts._ import printing.Printer import io.AbstractFile import config.Config import util.common._ import collection.mutable.ListBuffer -import Decorators.SymbolIteratorDecorator -import SymDenotations.LazyType /** Denotations represent the meaning of symbols and named types. * The following diagram shows how the principal types of denotations @@ -201,7 +197,7 @@ object Denotations { def isTerm: Boolean = !isType /** Is this denotation overloaded? */ - final def isOverloaded = isInstanceOf[MultiDenotation] + final def isOverloaded: Boolean = isInstanceOf[MultiDenotation] /** Denotation points to unique symbol; false for overloaded denotations * and JointRef denotations. @@ -233,7 +229,7 @@ object Denotations { def mapInfo(f: Type => Type)(implicit ctx: Context): Denotation /** If this denotation does not exist, fallback to alternative */ - final def orElse(that: => Denotation) = if (this.exists) this else that + final def orElse(that: => Denotation): Denotation = if (this.exists) this else that /** The set of alternative single-denotations making up this denotation */ final def alternatives: List[SingleDenotation] = altsWith(alwaysTrue) @@ -672,8 +668,8 @@ object Denotations { } } - final def asSingleDenotation = asInstanceOf[SingleDenotation] - final def asSymDenotation = asInstanceOf[SymDenotation] + final def asSingleDenotation: SingleDenotation = asInstanceOf[SingleDenotation] + final def asSymDenotation: SymDenotation = asInstanceOf[SymDenotation] def toText(printer: Printer): Text = printer.toText(this) @@ -709,7 +705,7 @@ object Denotations { def mapInfo(f: Type => Type)(implicit ctx: Context): SingleDenotation = derivedSingleDenotation(symbol, f(info)) - def orElse(that: => SingleDenotation) = if (this.exists) this else that + def orElse(that: => SingleDenotation): SingleDenotation = if (this.exists) this else that def altsWith(p: Symbol => Boolean): List[SingleDenotation] = if (exists && p(symbol)) this :: Nil else Nil @@ -754,8 +750,8 @@ object Denotations { private[this] var myValidFor: Period = Nowhere - def validFor = myValidFor - def validFor_=(p: Period) = { + def validFor: Period = myValidFor + def validFor_=(p: Period): Unit = { myValidFor = p symbol.invalidateDenotCache() } @@ -1020,7 +1016,7 @@ object Denotations { nextInRun = newd } - def staleSymbolError(implicit ctx: Context) = + def staleSymbolError(implicit ctx: Context): Nothing = throw new StaleSymbol(staleSymbolMsg) def staleSymbolMsg(implicit ctx: Context): String = { @@ -1052,7 +1048,7 @@ object Denotations { */ def showDcl(implicit ctx: Context): String = ctx.printer.dclText(this).show - override def toString = + override def toString: String = if (symbol == NoSymbol) symbol.toString else s"" @@ -1071,8 +1067,8 @@ object Denotations { // ------ PreDenotation ops ---------------------------------------------- - final def first = this - final def last = this + final def first: SingleDenotation = this + final def last: SingleDenotation = this final def matches(other: SingleDenotation)(implicit ctx: Context): Boolean = { val d = signature.matchDegree(other.signature) @@ -1110,7 +1106,7 @@ object Denotations { abstract class NonSymSingleDenotation(symbol: Symbol, initInfo: Type) extends SingleDenotation(symbol, initInfo) { def infoOrCompleter: Type = initInfo - def isType = infoOrCompleter.isInstanceOf[TypeType] + def isType: Boolean = infoOrCompleter.isInstanceOf[TypeType] } class UniqueRefDenotation( @@ -1127,13 +1123,13 @@ object Denotations { initInfo: Type, initValidFor: Period) extends NonSymSingleDenotation(symbol, initInfo) { validFor = initValidFor - override def hasUniqueSym = false + override def hasUniqueSym: Boolean = false protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = new JointRefDenotation(s, i, validFor) } class ErrorDenotation(implicit ctx: Context) extends NonSymSingleDenotation(NoSymbol, NoType) { - override def exists = false - override def hasUniqueSym = false + override def exists: Boolean = false + override def hasUniqueSym: Boolean = false validFor = Period.allInRun(ctx.runId) protected def newLikeThis(s: Symbol, i: Type): SingleDenotation = this } @@ -1179,8 +1175,8 @@ object Denotations { def denot2: PreDenotation assert(denot1.exists && denot2.exists, s"Union of non-existing denotations ($denot1) and ($denot2)") - def first = denot1.first - def last = denot2.last + def first: Denotation = denot1.first + def last: Denotation = denot2.last def matches(other: SingleDenotation)(implicit ctx: Context): Boolean = denot1.matches(other) || denot2.matches(other) def filterWithPredicate(p: SingleDenotation => Boolean): PreDenotation = @@ -1191,16 +1187,16 @@ object Denotations { derivedUnion(denot1.mapInherited(owndenot, prevdenot, pre), denot2.mapInherited(owndenot, prevdenot, pre)) def filterExcluded(excluded: FlagSet)(implicit ctx: Context): PreDenotation = derivedUnion(denot1.filterExcluded(excluded), denot2.filterExcluded(excluded)) - protected def derivedUnion(denot1: PreDenotation, denot2: PreDenotation) = + protected def derivedUnion(denot1: PreDenotation, denot2: PreDenotation): PreDenotation = if ((denot1 eq this.denot1) && (denot2 eq this.denot2)) this else denot1 union denot2 } final case class DenotUnion(denot1: PreDenotation, denot2: PreDenotation) extends MultiPreDenotation { - def exists = true - def toDenot(pre: Type)(implicit ctx: Context) = + def exists: Boolean = true + def toDenot(pre: Type)(implicit ctx: Context): Denotation = (denot1 toDenot pre) & (denot2 toDenot pre, pre) - def containsSym(sym: Symbol) = + def containsSym(sym: Symbol): Boolean = (denot1 containsSym sym) || (denot2 containsSym sym) type AsSeenFromResult = PreDenotation def computeAsSeenFrom(pre: Type)(implicit ctx: Context): PreDenotation = @@ -1210,12 +1206,12 @@ object Denotations { /** An overloaded denotation consisting of the alternatives of both given denotations. */ case class MultiDenotation(denot1: Denotation, denot2: Denotation) extends Denotation(NoSymbol, NoType) with MultiPreDenotation { - final def infoOrCompleter = multiHasNot("info") - final def validFor = denot1.validFor & denot2.validFor - final def isType = false - final def hasUniqueSym = false - final def name(implicit ctx: Context) = denot1.name - final def signature(implicit ctx: Context) = Signature.OverloadedSignature + final def infoOrCompleter: Type = multiHasNot("info") + final def validFor: Period = denot1.validFor & denot2.validFor + final def isType: Boolean = false + final def hasUniqueSym: Boolean = false + final def name(implicit ctx: Context): Name = denot1.name + final def signature(implicit ctx: Context): Signature = Signature.OverloadedSignature def atSignature(sig: Signature, site: Type, relaxed: Boolean)(implicit ctx: Context): Denotation = if (sig eq Signature.OverloadedSignature) this else derivedUnionDenotation(denot1.atSignature(sig, site, relaxed), denot2.atSignature(sig, site, relaxed)) @@ -1252,7 +1248,7 @@ object Denotations { type AsSeenFromResult = Denotation def computeAsSeenFrom(pre: Type)(implicit ctx: Context): Denotation = derivedUnionDenotation(denot1.asSeenFrom(pre), denot2.asSeenFrom(pre)) - override def toString = alternatives.mkString(" ") + override def toString: String = alternatives.mkString(" ") private def multiHasNot(op: String): Nothing = throw new UnsupportedOperationException( @@ -1329,6 +1325,6 @@ object Denotations { /** An exception for accessing symbols that are no longer valid in current run */ class StaleSymbol(msg: => String) extends Exception { util.Stats.record("stale symbol") - override def getMessage() = msg + override def getMessage(): String = msg } } diff --git a/compiler/src/dotty/tools/dotc/core/Flags.scala b/compiler/src/dotty/tools/dotc/core/Flags.scala index 2cdceeec4e01..f9736296524b 100644 --- a/compiler/src/dotty/tools/dotc/core/Flags.scala +++ b/compiler/src/dotty/tools/dotc/core/Flags.scala @@ -28,10 +28,10 @@ object Flags { } /** The intersection of this flag set and the given flag set */ - def & (that: FlagSet) = FlagSet(bits & that.bits) + def & (that: FlagSet): FlagSet = FlagSet(bits & that.bits) /** The intersection of this flag set with the complement of the given flag set */ - def &~ (that: FlagSet) = { + def &~ (that: FlagSet): FlagSet = { val tbits = bits & KINDFLAGS if ((tbits & that.bits) == 0) this else FlagSet(tbits | ((this.bits & ~that.bits) & ~KINDFLAGS)) @@ -65,25 +65,25 @@ object Flags { */ def is(flags: FlagConjunction, butNot: FlagSet): Boolean = is(flags) && !is(butNot) - def isEmpty = (bits & ~KINDFLAGS) == 0 + def isEmpty: Boolean = (bits & ~KINDFLAGS) == 0 /** Is this flag set a subset of that one? */ - def <= (that: FlagSet) = (bits & that.bits) == bits + def <= (that: FlagSet): Boolean = (bits & that.bits) == bits /** Does this flag set apply to terms? */ - def isTermFlags = (bits & TERMS) != 0 + def isTermFlags: Boolean = (bits & TERMS) != 0 /** Does this flag set apply to terms? */ - def isTypeFlags = (bits & TYPES) != 0 + def isTypeFlags: Boolean = (bits & TYPES) != 0 /** This flag set with all flags transposed to be type flags */ - def toTypeFlags = if (bits == 0) this else FlagSet(bits & ~KINDFLAGS | TYPES) + def toTypeFlags: FlagSet = if (bits == 0) this else FlagSet(bits & ~KINDFLAGS | TYPES) /** This flag set with all flags transposed to be term flags */ - def toTermFlags = if (bits == 0) this else FlagSet(bits & ~KINDFLAGS | TERMS) + def toTermFlags: FlagSet = if (bits == 0) this else FlagSet(bits & ~KINDFLAGS | TERMS) /** This flag set with all flags transposed to be common flags */ - def toCommonFlags = if (bits == 0) this else FlagSet(bits | KINDFLAGS) + def toCommonFlags: FlagSet = if (bits == 0) this else FlagSet(bits | KINDFLAGS) /** The number of non-kind flags in this set */ def numFlags: Int = java.lang.Long.bitCount(bits & ~KINDFLAGS) @@ -116,7 +116,7 @@ object Flags { } /** The string representation of this flag set */ - override def toString = flagStrings.mkString(" ") + override def toString: String = flagStrings.mkString(" ") } /** A class representing flag sets that should be tested @@ -124,7 +124,7 @@ object Flags { * `x is fc` tests whether `x` contains all flags in `fc`. */ case class FlagConjunction(bits: Long) { - override def toString = FlagSet(bits).toString + override def toString: String = FlagSet(bits).toString } private final val TYPESHIFT = 2 @@ -192,255 +192,255 @@ object Flags { FlagConjunction((flags0 | union(flagss: _*)).bits) } - def commonFlags(flagss: FlagSet*) = union(flagss.map(_.toCommonFlags): _*) + def commonFlags(flagss: FlagSet*): FlagSet = union(flagss.map(_.toCommonFlags): _*) /** The empty flag set */ - final val EmptyFlags = FlagSet(0) + final val EmptyFlags: FlagSet = FlagSet(0) /** The undefined flag set */ - final val UndefinedFlags = FlagSet(~KINDFLAGS) + final val UndefinedFlags: FlagSet = FlagSet(~KINDFLAGS) // Available flags: /** Labeled with `private` modifier */ - final val Private = commonFlag(2, "private") - final val PrivateTerm = Private.toTermFlags - final val PrivateType = Private.toTypeFlags + final val Private: FlagSet = commonFlag(2, "private") + final val PrivateTerm: FlagSet = Private.toTermFlags + final val PrivateType: FlagSet = Private.toTypeFlags /** Labeled with `protected` modifier */ - final val Protected = commonFlag(3, "protected") + final val Protected: FlagSet = commonFlag(3, "protected") /** Labeled with `override` modifier */ - final val Override = commonFlag(4, "override") + final val Override: FlagSet = commonFlag(4, "override") /** A declared, but not defined member */ - final val Deferred = commonFlag(5, "") - final val DeferredTerm = Deferred.toTermFlags - final val DeferredType = Deferred.toTypeFlags + final val Deferred: FlagSet = commonFlag(5, "") + final val DeferredTerm: FlagSet = Deferred.toTermFlags + final val DeferredType: FlagSet = Deferred.toTypeFlags /** Labeled with `final` modifier */ - final val Final = commonFlag(6, "final") + final val Final: FlagSet = commonFlag(6, "final") /** A method symbol. */ - final val Method = termFlag(7, "") - final val HigherKinded = typeFlag(7, "") + final val Method: FlagSet = termFlag(7, "") + final val HigherKinded: FlagSet = typeFlag(7, "") /** A (term or type) parameter to a class or method */ - final val Param = commonFlag(8, "") - final val TermParam = Param.toTermFlags - final val TypeParam = Param.toTypeFlags + final val Param: FlagSet = commonFlag(8, "") + final val TermParam: FlagSet = Param.toTermFlags + final val TypeParam: FlagSet = Param.toTypeFlags /** Labeled with `implicit` modifier (implicit value) */ - final val ImplicitCommon = commonFlag(9, "implicit") - final val Implicit = ImplicitCommon.toTermFlags + final val ImplicitCommon: FlagSet = commonFlag(9, "implicit") + final val Implicit: FlagSet = ImplicitCommon.toTermFlags /** Labeled with `lazy` (a lazy val). */ - final val Lazy = termFlag(10, "lazy") + final val Lazy: FlagSet = termFlag(10, "lazy") /** A trait */ - final val Trait = typeFlag(10, "") + final val Trait: FlagSet = typeFlag(10, "") - final val LazyOrTrait = Lazy.toCommonFlags + final val LazyOrTrait: FlagSet = Lazy.toCommonFlags /** A value or variable accessor (getter or setter) */ - final val Accessor = termFlag(11, "") + final val Accessor: FlagSet = termFlag(11, "") /** Labeled with `sealed` modifier (sealed class) */ - final val Sealed = typeFlag(11, "sealed") + final val Sealed: FlagSet = typeFlag(11, "sealed") - final val AccessorOrSealed = Accessor.toCommonFlags + final val AccessorOrSealed: FlagSet = Accessor.toCommonFlags /** A mutable var */ - final val Mutable = termFlag(12, "mutable") + final val Mutable: FlagSet = termFlag(12, "mutable") /** Symbol is local to current class (i.e. private[this] or protected[this] * pre: Private or Protected are also set */ - final val Local = commonFlag(13, "") + final val Local: FlagSet = commonFlag(13, "") /** A field generated for a primary constructor parameter (no matter if it's a 'val' or not), * or an accessor of such a field. */ - final val ParamAccessor = termFlag(14, "") + final val ParamAccessor: FlagSet = termFlag(14, "") /** A value or class implementing a module */ - final val Module = commonFlag(15, "module") - final val ModuleVal = Module.toTermFlags - final val ModuleClass = Module.toTypeFlags + final val Module: FlagSet = commonFlag(15, "module") + final val ModuleVal: FlagSet = Module.toTermFlags + final val ModuleClass: FlagSet = Module.toTypeFlags /** A value or class representing a package */ - final val Package = commonFlag(16, "") - final val PackageVal = Package.toTermFlags - final val PackageClass = Package.toTypeFlags + final val Package: FlagSet = commonFlag(16, "") + final val PackageVal: FlagSet = Package.toTermFlags + final val PackageClass: FlagSet = Package.toTypeFlags /** A case class or its companion object */ - final val Case = commonFlag(17, "case") - final val CaseClass = Case.toTypeFlags - final val CaseVal = Case.toTermFlags + final val Case: FlagSet = commonFlag(17, "case") + final val CaseClass: FlagSet = Case.toTypeFlags + final val CaseVal: FlagSet = Case.toTermFlags /** A compiler-generated symbol, which is visible for type-checking * (compare with artifact) */ - final val Synthetic = commonFlag(18, "") + final val Synthetic: FlagSet = commonFlag(18, "") /** Labelled with `inline` modifier */ - final val Inline = commonFlag(19, "inline") + final val Inline: FlagSet = commonFlag(19, "inline") /** A covariant type variable / an outer accessor */ - final val CovariantOrOuter = commonFlag(20, "") - final val Covariant = typeFlag(20, "") - final val OuterAccessor = termFlag(20, "") + final val CovariantOrOuter: FlagSet = commonFlag(20, "") + final val Covariant: FlagSet = typeFlag(20, "") + final val OuterAccessor: FlagSet = termFlag(20, "") /** A contravariant type variable / a label method */ - final val ContravariantOrLabel = commonFlag(21, "") - final val Contravariant = typeFlag(21, "") - final val Label = termFlag(21, "