Skip to content

Commit 85f109f

Browse files
Merge pull request #5211 from dotty-staging/followup-5203
Followup to #5203
2 parents 3b7322f + 35646ae commit 85f109f

16 files changed

+28
-51
lines changed

compiler/src/dotty/tools/dotc/config/Settings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ object Settings {
193193

194194
class SettingGroup {
195195

196-
private[this] val _allSettings: ArrayBuffer[Setting[_]] = new ArrayBuffer[Setting[_]]
196+
private[this] val _allSettings = new ArrayBuffer[Setting[_]]
197197
def allSettings: Seq[Setting[_]] = _allSettings
198198

199199
def defaultState: SettingsState = new SettingsState(allSettings map (_.default))

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,6 +1952,7 @@ object SymDenotations {
19521952
def apply(sym: Symbol): LazyType = this
19531953
def apply(module: TermSymbol, modcls: ClassSymbol): LazyType = this
19541954

1955+
private[this] val NoSymbolFn = (_: Context) => NoSymbol
19551956
private[this] var myDecls: Scope = EmptyScope
19561957
private[this] var mySourceModuleFn: Context => Symbol = NoSymbolFn
19571958
private[this] var myModuleClassFn: Context => Symbol = NoSymbolFn
@@ -1985,8 +1986,6 @@ object SymDenotations {
19851986
unsupported("completerTypeParams") // should be abstract, but Scala-2 will then compute the wrong type for it
19861987
}
19871988

1988-
val NoSymbolFn: Context => Symbol = (ctx: Context) => NoSymbol
1989-
19901989
/** A missing completer */
19911990
@sharable class NoCompleter extends LazyType {
19921991
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = unsupported("complete")

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,11 @@ trait Symbols { this: Context =>
270270
newSymbol(cls, nme.CONSTRUCTOR, flags | Method, MethodType(paramNames, paramTypes, cls.typeRef), privateWithin, coord)
271271

272272
/** Create an empty default constructor symbol for given class `cls`. */
273-
def newDefaultConstructor(cls: ClassSymbol): Symbol =
273+
def newDefaultConstructor(cls: ClassSymbol): TermSymbol =
274274
newConstructor(cls, EmptyFlags, Nil, Nil)
275275

276276
/** Create a synthetic lazy implicit value */
277-
def newLazyImplicit(info: Type): Symbol =
277+
def newLazyImplicit(info: Type): TermSymbol =
278278
newSymbol(owner, LazyImplicitName.fresh(), Lazy, info)
279279

280280
/** Create a symbol representing a selftype declaration for class `cls`. */
@@ -308,7 +308,7 @@ trait Symbols { this: Context =>
308308
/** Create a new skolem symbol. This is not the same as SkolemType, even though the
309309
* motivation (create a singleton referencing to a type) is similar.
310310
*/
311-
def newSkolem(tp: Type): Symbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | NonMember | Permanent, tp)
311+
def newSkolem(tp: Type): TermSymbol = newSymbol(defn.RootClass, nme.SKOLEM, SyntheticArtifact | NonMember | Permanent, tp)
312312

313313
def newErrorSymbol(owner: Symbol, name: Name, msg: => Message): Symbol = {
314314
val errType = ErrorType(msg)

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -656,8 +656,7 @@ class TreePickler(pickler: TastyPickler) {
656656
// Such annotations will be reconstituted when unpickling the child class.
657657
// See tests/pickling/i3149.scala
658658
case _ =>
659-
if (Inliner.typedInline) ann.symbol == defn.BodyAnnot // inline bodies are reconstituted automatically when unpickling
660-
else false
659+
ann.symbol == defn.BodyAnnot // inline bodies are reconstituted automatically when unpickling
661660
}
662661

663662
def pickleAnnotation(owner: Symbol, ann: Annotation)(implicit ctx: Context): Unit =

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import core.quoted.PickledQuotes
2222
import scala.quoted
2323
import scala.quoted.Types.TreeType
2424
import scala.quoted.Exprs.TastyTreeExpr
25-
import typer.Inliner.typedInline
2625

2726
import scala.annotation.internal.sharable
2827

@@ -555,7 +554,7 @@ class TreeUnpickler(reader: TastyReader,
555554
sym.completer.withDecls(newScope)
556555
forkAt(templateStart).indexTemplateParams()(localContext(sym))
557556
}
558-
else if (typedInline && sym.isInlineMethod)
557+
else if (sym.isInlineMethod)
559558
sym.addAnnotation(LazyBodyAnnotation { ctx0 =>
560559
implicit val ctx: Context = localContext(sym)(ctx0).addMode(Mode.ReadPositions)
561560
// avoids space leaks by not capturing the current context
@@ -643,14 +642,9 @@ class TreeUnpickler(reader: TastyReader,
643642
val lazyAnnotTree = readLaterWithOwner(end, rdr => ctx => rdr.readTerm()(ctx))
644643

645644
owner =>
646-
if (tp.isRef(defn.BodyAnnot)) {
647-
assert(!typedInline)
648-
LazyBodyAnnotation(implicit ctx => lazyAnnotTree(owner).complete)
649-
}
650-
else
651-
Annotation.deferredSymAndTree(
652-
implicit ctx => tp.typeSymbol,
653-
implicit ctx => lazyAnnotTree(owner).complete)
645+
Annotation.deferredSymAndTree(
646+
implicit ctx => tp.typeSymbol,
647+
implicit ctx => lazyAnnotTree(owner).complete)
654648
}
655649

656650
/** Create symbols for the definitions in the statement sequence between
@@ -749,7 +743,7 @@ class TreeUnpickler(reader: TastyReader,
749743
def readRhs(implicit ctx: Context) =
750744
if (nothingButMods(end))
751745
EmptyTree
752-
else if (sym.isInlineMethod && typedInline)
746+
else if (sym.isInlineMethod)
753747
// The body of an inline method is stored in an annotation, so no need to unpickle it again
754748
new Trees.Lazy[Tree] {
755749
def complete(implicit ctx: Context) = typer.Inliner.bodyToInline(sym)

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
758758
TempClassInfoType(until(end, () => readTypeRef()), symScope(clazz), clazz)
759759
case METHODtpe | IMPLICITMETHODtpe =>
760760
val restpe = readTypeRef()
761-
val params = until(end, () => readSymbolRef()).asInstanceOf[List[Symbol]]
761+
val params = until(end, () => readSymbolRef())
762762
def isImplicit =
763763
tag == IMPLICITMETHODtpe ||
764764
params.nonEmpty && (params.head is Implicit)

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ object Scanners {
8282

8383
/** A character buffer for literals
8484
*/
85-
protected val litBuf: mutable.StringBuilder = new StringBuilder
85+
protected val litBuf = new mutable.StringBuilder
8686

8787
/** append Unicode character to "litBuf" buffer
8888
*/
@@ -194,7 +194,7 @@ object Scanners {
194194
def getDocComment(pos: Int): Option[Comment] = docstringMap.get(pos)
195195

196196
/** A buffer for comments */
197-
private[this] val commentBuf: mutable.StringBuilder = new StringBuilder
197+
private[this] val commentBuf = new mutable.StringBuilder
198198

199199
private def handleMigration(keyword: Token): Token =
200200
if (!isScala2Mode) keyword

compiler/src/dotty/tools/dotc/printing/Highlighting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object Highlighting {
3131
}
3232

3333
case class HighlightBuffer(hl: Highlight)(implicit ctx: Context) {
34-
private[this] val buffer: mutable.ListBuffer[String] = new mutable.ListBuffer[String]
34+
private[this] val buffer = new mutable.ListBuffer[String]
3535

3636
buffer += hl.show
3737

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class Erasure extends Phase with DenotTransformer {
9090
ref.derivedSingleDenotation(ref.symbol, transformInfo(ref.symbol, ref.symbol.info))
9191
}
9292

93-
private val eraser: Erasure.Typer = new Erasure.Typer(this)
93+
private[this] val eraser = new Erasure.Typer(this)
9494

9595
def run(implicit ctx: Context): Unit = {
9696
val unit = ctx.compilationUnit

compiler/src/dotty/tools/dotc/transform/FunctionalInterfaces.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class FunctionalInterfaces extends MiniPhase {
2323

2424
def phaseName: String = FunctionalInterfaces.name
2525

26-
private val functionName: TermName = "JFunction".toTermName
27-
private val functionPackage: TermName = "scala.compat.java8.".toTermName
26+
private[this] val functionName = "JFunction".toTermName
27+
private[this] val functionPackage = "scala.compat.java8.".toTermName
2828

2929
override def transformClosure(tree: Closure)(implicit ctx: Context): Tree = {
3030
val cls = tree.tpe.widen.classSymbol.asClass

compiler/src/dotty/tools/dotc/transform/LazyVals.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
2929
/** this map contains mutable state of transformation: OffsetDefs to be appended to companion object definitions,
3030
* and number of bits currently used */
3131
class OffsetInfo(var defs: List[Tree], var ord:Int)
32-
private[this] val appendOffsetDefs: mutable.Map[Symbol, OffsetInfo] = mutable.Map.empty[Symbol, OffsetInfo]
32+
private[this] val appendOffsetDefs = mutable.Map.empty[Symbol, OffsetInfo]
3333

3434
override def phaseName: String = "lazyVals"
3535

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class TreeChecker extends Phase with SymTransformer {
130130

131131
class Checker(phasesToCheck: Seq[Phase]) extends ReTyper with Checking {
132132

133-
private[this] val nowDefinedSyms: mutable.HashSet[Symbol] = new mutable.HashSet[Symbol]
134-
private[this] val everDefinedSyms: MutableSymbolMap[untpd.Tree] = newMutableSymbolMap[untpd.Tree]
133+
private[this] val nowDefinedSyms = new mutable.HashSet[Symbol]
134+
private[this] val everDefinedSyms = newMutableSymbolMap[untpd.Tree]
135135

136136
// don't check value classes after typer, as the constraint about constructors doesn't hold after transform
137137
override def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context): Unit = ()

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import util.Positions.Position
2525
object Inliner {
2626
import tpd._
2727

28-
val typedInline: Boolean = true
29-
3028
/** `sym` is an inline method with a known body to inline (note: definitions coming
3129
* from Scala2x class files might be `@forceInline`, but still lack that body).
3230
*/

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ trait NamerContextOps { this: Context =>
137137
if (isJava)
138138
for (param <- params)
139139
if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType
140-
make.fromSymbols(params.asInstanceOf[List[Symbol]], resultType)
140+
make.fromSymbols(params, resultType)
141141
}
142142
if (typeParams.nonEmpty) PolyType.fromParams(typeParams.asInstanceOf[List[TypeSymbol]], monotpe)
143143
else if (valueParamss.isEmpty) ExprType(monotpe)
@@ -840,7 +840,7 @@ class Namer { typer: Typer =>
840840

841841
val TypeDef(name, impl @ Template(constr, parents, self, _)) = original
842842

843-
private val ((params: List[Tree]), (rest: List[Tree])) = impl.body span {
843+
private val (params, rest): (List[Tree], List[Tree]) = impl.body.span {
844844
case td: TypeDef => td.mods is Param
845845
case vd: ValDef => vd.mods is ParamAccessor
846846
case _ => false

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ object ProtoTypes {
7575
* achieved by replacing expected type parameters with wildcards.
7676
*/
7777
def constrainResult(meth: Symbol, mt: Type, pt: Type)(implicit ctx: Context): Boolean =
78-
if (Inliner.isInlineable(meth) && !Inliner.typedInline) {
79-
constrainResult(mt, wildApprox(pt))
80-
true
81-
}
82-
else constrainResult(mt, pt)
78+
constrainResult(mt, pt)
8379
}
8480

8581
object NoViewsAllowed extends Compatibility {

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,17 +1992,9 @@ class Typer extends Namer
19921992
case none =>
19931993
typed(mdef) match {
19941994
case mdef1: DefDef if Inliner.hasBodyToInline(mdef1.symbol) =>
1995-
if (Inliner.typedInline) {
1996-
buf += inlineExpansion(mdef1)
1997-
// replace body with expansion, because it will be used as inlined body
1998-
// from separately compiled files - the original BodyAnnotation is not kept.
1999-
}
2000-
else {
2001-
assert(mdef1.symbol.isInlineMethod, mdef.symbol)
2002-
Inliner.bodyToInline(mdef1.symbol) // just make sure accessors are computed,
2003-
buf += mdef1 // but keep original definition, since inline-expanded code
2004-
// is pickled in this case.
2005-
}
1995+
buf += inlineExpansion(mdef1)
1996+
// replace body with expansion, because it will be used as inlined body
1997+
// from separately compiled files - the original BodyAnnotation is not kept.
20061998
case mdef1 =>
20071999
import untpd.modsDeco
20082000
mdef match {
@@ -2453,8 +2445,7 @@ class Typer extends Namer
24532445
!ctx.settings.YnoInline.value &&
24542446
!ctx.isAfterTyper &&
24552447
!ctx.reporter.hasErrors &&
2456-
(!Inliner.typedInline || tree.tpe <:< pt)) {
2457-
if (!Inliner.typedInline) tree.tpe <:< wildApprox(pt)
2448+
tree.tpe <:< pt) {
24582449
readaptSimplified(Inliner.inlineCall(tree, pt))
24592450
}
24602451
else if (tree.tpe <:< pt) {

0 commit comments

Comments
 (0)