Skip to content

Followup to #5203 #5211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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`. */
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
16 changes: 5 additions & 11 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/printing/Highlighting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Erasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/LazyVals.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ()
Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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).
*/
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 1 addition & 5 deletions compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
17 changes: 4 additions & 13 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down