diff --git a/compiler/src/dotty/tools/dotc/config/Settings.scala b/compiler/src/dotty/tools/dotc/config/Settings.scala index 910cbe5da569..8ba6c8786b6f 100644 --- a/compiler/src/dotty/tools/dotc/config/Settings.scala +++ b/compiler/src/dotty/tools/dotc/config/Settings.scala @@ -193,7 +193,7 @@ object Settings { class SettingGroup { - private[this] val _allSettings: ArrayBuffer[Setting[_]] = new ArrayBuffer[Setting[_]] + private[this] val _allSettings = new ArrayBuffer[Setting[_]] def allSettings: Seq[Setting[_]] = _allSettings def defaultState: SettingsState = new SettingsState(allSettings map (_.default)) diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index 26295efd2288..c593fa17333d 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1952,6 +1952,7 @@ object SymDenotations { def apply(sym: Symbol): LazyType = this def apply(module: TermSymbol, modcls: ClassSymbol): LazyType = this + private[this] val NoSymbolFn = (_: Context) => NoSymbol private[this] var myDecls: Scope = EmptyScope private[this] var mySourceModuleFn: Context => Symbol = NoSymbolFn private[this] var myModuleClassFn: Context => Symbol = NoSymbolFn @@ -1985,8 +1986,6 @@ object SymDenotations { unsupported("completerTypeParams") // should be abstract, but Scala-2 will then compute the wrong type for it } - val NoSymbolFn: Context => Symbol = (ctx: Context) => NoSymbol - /** A missing completer */ @sharable class NoCompleter extends LazyType { def complete(denot: SymDenotation)(implicit ctx: Context): Unit = unsupported("complete") diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 18ac9e389ee0..2d339cc013ba 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -270,11 +270,11 @@ trait Symbols { this: Context => newSymbol(cls, nme.CONSTRUCTOR, flags | Method, MethodType(paramNames, paramTypes, cls.typeRef), privateWithin, coord) /** Create an empty default constructor symbol for given class `cls`. */ - def newDefaultConstructor(cls: ClassSymbol): Symbol = + def newDefaultConstructor(cls: ClassSymbol): TermSymbol = newConstructor(cls, EmptyFlags, Nil, Nil) /** Create a synthetic lazy implicit value */ - def newLazyImplicit(info: Type): Symbol = + def newLazyImplicit(info: Type): TermSymbol = newSymbol(owner, LazyImplicitName.fresh(), Lazy, info) /** Create a symbol representing a selftype declaration for class `cls`. */ @@ -308,7 +308,7 @@ trait Symbols { this: Context => /** Create a new skolem symbol. This is not the same as SkolemType, even though the * motivation (create a singleton referencing to a type) is similar. */ - def newSkolem(tp: Type): Symbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | NonMember | Permanent, tp) + def newSkolem(tp: Type): TermSymbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | NonMember | Permanent, tp) def newErrorSymbol(owner: Symbol, name: Name, msg: => Message): Symbol = { val errType = ErrorType(msg) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 468332513ae3..5217b45200b0 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -656,8 +656,7 @@ class TreePickler(pickler: TastyPickler) { // Such annotations will be reconstituted when unpickling the child class. // See tests/pickling/i3149.scala case _ => - if (Inliner.typedInline) ann.symbol == defn.BodyAnnot // inline bodies are reconstituted automatically when unpickling - else false + ann.symbol == defn.BodyAnnot // inline bodies are reconstituted automatically when unpickling } def pickleAnnotation(owner: Symbol, ann: Annotation)(implicit ctx: Context): Unit = diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 51528469a826..465ae5f7fbd4 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -22,7 +22,6 @@ import core.quoted.PickledQuotes import scala.quoted import scala.quoted.Types.TreeType import scala.quoted.Exprs.TastyTreeExpr -import typer.Inliner.typedInline import scala.annotation.internal.sharable @@ -555,7 +554,7 @@ class TreeUnpickler(reader: TastyReader, sym.completer.withDecls(newScope) forkAt(templateStart).indexTemplateParams()(localContext(sym)) } - else if (typedInline && sym.isInlineMethod) + else if (sym.isInlineMethod) sym.addAnnotation(LazyBodyAnnotation { ctx0 => implicit val ctx: Context = localContext(sym)(ctx0).addMode(Mode.ReadPositions) // avoids space leaks by not capturing the current context @@ -643,14 +642,9 @@ class TreeUnpickler(reader: TastyReader, val lazyAnnotTree = readLaterWithOwner(end, rdr => ctx => rdr.readTerm()(ctx)) owner => - if (tp.isRef(defn.BodyAnnot)) { - assert(!typedInline) - LazyBodyAnnotation(implicit ctx => lazyAnnotTree(owner).complete) - } - else - Annotation.deferredSymAndTree( - implicit ctx => tp.typeSymbol, - implicit ctx => lazyAnnotTree(owner).complete) + Annotation.deferredSymAndTree( + implicit ctx => tp.typeSymbol, + implicit ctx => lazyAnnotTree(owner).complete) } /** Create symbols for the definitions in the statement sequence between @@ -749,7 +743,7 @@ class TreeUnpickler(reader: TastyReader, def readRhs(implicit ctx: Context) = if (nothingButMods(end)) EmptyTree - else if (sym.isInlineMethod && typedInline) + else if (sym.isInlineMethod) // The body of an inline method is stored in an annotation, so no need to unpickle it again new Trees.Lazy[Tree] { def complete(implicit ctx: Context) = typer.Inliner.bodyToInline(sym) diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala index fc9bce38c7fd..943f466d2584 100644 --- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala @@ -758,7 +758,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas TempClassInfoType(until(end, () => readTypeRef()), symScope(clazz), clazz) case METHODtpe | IMPLICITMETHODtpe => val restpe = readTypeRef() - val params = until(end, () => readSymbolRef()).asInstanceOf[List[Symbol]] + val params = until(end, () => readSymbolRef()) def isImplicit = tag == IMPLICITMETHODtpe || params.nonEmpty && (params.head is Implicit) diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 5b54f4f42308..731a280f0407 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -82,7 +82,7 @@ object Scanners { /** A character buffer for literals */ - protected val litBuf: mutable.StringBuilder = new StringBuilder + protected val litBuf = new mutable.StringBuilder /** append Unicode character to "litBuf" buffer */ @@ -194,7 +194,7 @@ object Scanners { def getDocComment(pos: Int): Option[Comment] = docstringMap.get(pos) /** A buffer for comments */ - private[this] val commentBuf: mutable.StringBuilder = new StringBuilder + private[this] val commentBuf = new mutable.StringBuilder private def handleMigration(keyword: Token): Token = if (!isScala2Mode) keyword diff --git a/compiler/src/dotty/tools/dotc/printing/Highlighting.scala b/compiler/src/dotty/tools/dotc/printing/Highlighting.scala index 1b2236d96880..7b84b61f99f7 100644 --- a/compiler/src/dotty/tools/dotc/printing/Highlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/Highlighting.scala @@ -31,7 +31,7 @@ object Highlighting { } case class HighlightBuffer(hl: Highlight)(implicit ctx: Context) { - private[this] val buffer: mutable.ListBuffer[String] = new mutable.ListBuffer[String] + private[this] val buffer = new mutable.ListBuffer[String] buffer += hl.show diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index 14a39ff9c9ee..7bce3fa200b5 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -90,7 +90,7 @@ class Erasure extends Phase with DenotTransformer { ref.derivedSingleDenotation(ref.symbol, transformInfo(ref.symbol, ref.symbol.info)) } - private val eraser: Erasure.Typer = new Erasure.Typer(this) + private[this] val eraser = new Erasure.Typer(this) def run(implicit ctx: Context): Unit = { val unit = ctx.compilationUnit diff --git a/compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala b/compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala index e0720aab5a47..069eea1644db 100644 --- a/compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala +++ b/compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala @@ -23,8 +23,8 @@ class FunctionalInterfaces extends MiniPhase { def phaseName: String = FunctionalInterfaces.name - private val functionName: TermName = "JFunction".toTermName - private val functionPackage: TermName = "scala.compat.java8.".toTermName + private[this] val functionName = "JFunction".toTermName + private[this] val functionPackage = "scala.compat.java8.".toTermName override def transformClosure(tree: Closure)(implicit ctx: Context): Tree = { val cls = tree.tpe.widen.classSymbol.asClass diff --git a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala index 0ac46fffc868..4f1df2e825d3 100644 --- a/compiler/src/dotty/tools/dotc/transform/LazyVals.scala +++ b/compiler/src/dotty/tools/dotc/transform/LazyVals.scala @@ -29,7 +29,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer { /** this map contains mutable state of transformation: OffsetDefs to be appended to companion object definitions, * and number of bits currently used */ class OffsetInfo(var defs: List[Tree], var ord:Int) - private[this] val appendOffsetDefs: mutable.Map[Symbol, OffsetInfo] = mutable.Map.empty[Symbol, OffsetInfo] + private[this] val appendOffsetDefs = mutable.Map.empty[Symbol, OffsetInfo] override def phaseName: String = "lazyVals" diff --git a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala index 8b1e7dd1397d..a6d8d5b8f83e 100644 --- a/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/compiler/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -130,8 +130,8 @@ class TreeChecker extends Phase with SymTransformer { class Checker(phasesToCheck: Seq[Phase]) extends ReTyper with Checking { - private[this] val nowDefinedSyms: mutable.HashSet[Symbol] = new mutable.HashSet[Symbol] - private[this] val everDefinedSyms: MutableSymbolMap[untpd.Tree] = newMutableSymbolMap[untpd.Tree] + private[this] val nowDefinedSyms = new mutable.HashSet[Symbol] + private[this] val everDefinedSyms = newMutableSymbolMap[untpd.Tree] // don't check value classes after typer, as the constraint about constructors doesn't hold after transform override def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context): Unit = () diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 140428122b5c..c3f379ac3a78 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -25,8 +25,6 @@ import util.Positions.Position object Inliner { import tpd._ - val typedInline: Boolean = true - /** `sym` is an inline method with a known body to inline (note: definitions coming * from Scala2x class files might be `@forceInline`, but still lack that body). */ diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 67cfbef85ae5..fe1c85a915cf 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -137,7 +137,7 @@ trait NamerContextOps { this: Context => if (isJava) for (param <- params) if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType - make.fromSymbols(params.asInstanceOf[List[Symbol]], resultType) + make.fromSymbols(params, resultType) } if (typeParams.nonEmpty) PolyType.fromParams(typeParams.asInstanceOf[List[TypeSymbol]], monotpe) else if (valueParamss.isEmpty) ExprType(monotpe) @@ -840,7 +840,7 @@ class Namer { typer: Typer => val TypeDef(name, impl @ Template(constr, parents, self, _)) = original - private val ((params: List[Tree]), (rest: List[Tree])) = impl.body span { + private val (params, rest): (List[Tree], List[Tree]) = impl.body.span { case td: TypeDef => td.mods is Param case vd: ValDef => vd.mods is ParamAccessor case _ => false diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index a75f344f3da6..6322105e3e75 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -75,11 +75,7 @@ object ProtoTypes { * achieved by replacing expected type parameters with wildcards. */ def constrainResult(meth: Symbol, mt: Type, pt: Type)(implicit ctx: Context): Boolean = - if (Inliner.isInlineable(meth) && !Inliner.typedInline) { - constrainResult(mt, wildApprox(pt)) - true - } - else constrainResult(mt, pt) + constrainResult(mt, pt) } object NoViewsAllowed extends Compatibility { diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index d9e33c624994..861f9733ff62 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1992,17 +1992,9 @@ class Typer extends Namer case none => typed(mdef) match { case mdef1: DefDef if Inliner.hasBodyToInline(mdef1.symbol) => - if (Inliner.typedInline) { - buf += inlineExpansion(mdef1) - // replace body with expansion, because it will be used as inlined body - // from separately compiled files - the original BodyAnnotation is not kept. - } - else { - assert(mdef1.symbol.isInlineMethod, mdef.symbol) - Inliner.bodyToInline(mdef1.symbol) // just make sure accessors are computed, - buf += mdef1 // but keep original definition, since inline-expanded code - // is pickled in this case. - } + buf += inlineExpansion(mdef1) + // replace body with expansion, because it will be used as inlined body + // from separately compiled files - the original BodyAnnotation is not kept. case mdef1 => import untpd.modsDeco mdef match { @@ -2453,8 +2445,7 @@ class Typer extends Namer !ctx.settings.YnoInline.value && !ctx.isAfterTyper && !ctx.reporter.hasErrors && - (!Inliner.typedInline || tree.tpe <:< pt)) { - if (!Inliner.typedInline) tree.tpe <:< wildApprox(pt) + tree.tpe <:< pt) { readaptSimplified(Inliner.inlineCall(tree, pt)) } else if (tree.tpe <:< pt) {