Skip to content

Remove PreName add (almost) all other implicit conversions #4077

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

Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ compiler/after-pickling.txt
*.dotty-ide-version

*.decompiled.out
bench/compile.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object CollectEntryPoints{
def fail(msg: String, pos: Position = sym.pos) = {
ctx.warning( sym.name +
s" has a main method with parameter type Array[String], but ${toDenot(sym).fullName} will not be a runnable program.\n Reason: $msg",
sourcePos(sym.pos)
sym.pos
// TODO: make this next claim true, if possible
// by generating valid main methods as static in module classes
// not sure what the jvm allows here
Expand Down
40 changes: 21 additions & 19 deletions compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
lazy val Predef_classOf: Symbol = defn.ScalaPredefModule.requiredMethod(nme.classOf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer we leave PreName, but move the String -> PreName conversion to the companion object of PreName.

Copy link
Contributor Author

@OlivierBlanvillain OlivierBlanvillain Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't work as moving it the companion of PreName is not enough to make .toTermName and .toTypeName available on Strings. I guess we could have two implicit conversions, one in PreName's companion and one available by import, but I feel it would just make things worse...

Are you sure you don't like this commit as is? In my opinion, completely removing an abstraction from the code base is a clear simplification. The diff might look large but in reality, most of the line changes are about making type more precise by having the TermName/TypeName instead of PreName. The balance sheet in term of added boilerplate is also reasonable:

toTermName added: 22
toTermName removed: 12

toTypeName added: 12
toTypeName removed: 4

+4 overloaded methods with String & Name arguments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should leave PreName. I don't like to have to overload methods, and the problem is, if you are systematic about it (and you should be!) you will end up with a lot more overloaded methods. PreName is a single abstraction which fixes this quite nicely. For me it is really analogous to IterableOnce in collections. Before we had some overloaded methods that took Iterables and Iterators respectively. At first there were only a few. Then people complained that, by rights, some other methods should also be dual purpose, and then some others more, and so on. The introduction of IterableOnce stopped the bleeding.

I realize it's a contentious issue, but then the maxime "when in doubt, don't change it" applies.

One other thing: We have to tell everyone working on the compiler that Decorators is a highly recommended (maybe mandatory?) input. I have seen so much awkward code because people did not know about it. Is there a good place where we can put it so people will read it?


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 AnnotationRetentionSourceAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("SOURCE".toTermName)
lazy val AnnotationRetentionClassAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("CLASS".toTermName)
lazy val AnnotationRetentionRuntimeAttr = ctx.requiredClass("java.lang.annotation.RetentionPolicy").linkedClass.requiredValue("RUNTIME".toTermName)
lazy val JavaAnnotationClass = ctx.requiredClass("java.lang.annotation.Annotation")

def boxMethods: Map[Symbol, Symbol] = defn.ScalaValueClasses().map{x => // @darkdimius Are you sure this should be a def?
Expand Down Expand Up @@ -366,7 +366,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def getAnnotPickle(jclassName: String, sym: Symbol): Option[Annotation] = None


def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname.toTermName)
def getRequiredClass(fullname: String): Symbol = ctx.requiredClass(fullname)

def getClassIfDefined(fullname: String): Symbol = NoSymbol // used only for android. todo: implement

Expand All @@ -376,12 +376,12 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
}

def requiredClass[T](implicit evidence: ClassTag[T]): Symbol =
ctx.requiredClass(erasureString(evidence.runtimeClass).toTermName)
ctx.requiredClass(erasureString(evidence.runtimeClass))

def requiredModule[T](implicit evidence: ClassTag[T]): Symbol = {
val moduleName = erasureString(evidence.runtimeClass)
val className = if (moduleName.endsWith("$")) moduleName.dropRight(1) else moduleName
ctx.requiredModule(className.toTermName)
ctx.requiredModule(className)
}


Expand Down Expand Up @@ -498,7 +498,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
// unrelated change.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am against merging this as is. I believe the original version is both clearer and more efficient. Computing | on the fly as a cost, that's why we created all these flag set. Doing several flag tests in a row also has a cost. On the other hand, testing against a FlagConjunction with is is fast and does not require boxing.

ctx.base.settings.YnoGenericSig.value
|| sym.is(Flags.Artifact)
|| sym.is(Flags.allOf(Flags.Method, Flags.Lifted))
|| sym.isBoth(Flags.Method, and = Flags.Lifted)
|| sym.is(Flags.Bridge)
)

Expand Down Expand Up @@ -679,7 +679,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def isConstructor: Boolean = toDenot(sym).isConstructor
def isAnonymousFunction: Boolean = toDenot(sym).isAnonymousFunction
def isMethod: Boolean = sym is Flags.Method
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, Flags.Private | Flags.Protected)
def isPublic: Boolean = sym.flags.is(Flags.EmptyFlags, butNot=Flags.Private | Flags.Protected)
def isSynthetic: Boolean = sym is Flags.Synthetic
def isPackageClass: Boolean = sym is Flags.PackageClass
def isModuleClass: Boolean = sym is Flags.ModuleClass
Expand Down Expand Up @@ -716,7 +716,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def isDeprecated: Boolean = false
def isMutable: Boolean = sym is Flags.Mutable
def hasAbstractFlag: Boolean =
(sym is Flags.Abstract) || (sym is Flags.JavaInterface) || (sym is Flags.Trait)
(sym is Flags.Abstract) || (sym is Flags.Trait)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def hasModuleFlag: Boolean = sym is Flags.Module
def isSynchronized: Boolean = sym is Flags.Synchronized
def isNonBottomSubClass(other: Symbol): Boolean = sym.derivesFrom(other)
Expand Down Expand Up @@ -808,26 +808,28 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
else Nil

def annotations: List[Annotation] = toDenot(sym).annotations
def companionModuleMembers: List[Symbol] = {

def companionModuleMembers: List[Symbol] = {
// phase travel to exitingPickler: this makes sure that memberClassesOf only sees member classes,
// not local classes of the companion module (E in the exmaple) that were lifted by lambdalift.
if (linkedClass.isTopLevelModuleClass) /*exitingPickler*/ linkedClass.memberClasses
else Nil
}

def fieldSymbols: List[Symbol] = {
toDenot(sym).info.decls.filter(p => p.isTerm && !p.is(Flags.Method))
}

def methodSymbols: List[Symbol] =
for (f <- toDenot(sym).info.decls.toList if f.isMethod && f.isTerm && !f.isModule) yield f
def serialVUID: Option[Long] = None

def serialVUID: Option[Long] = None

def freshLocal(cunit: CompilationUnit, name: String, tpe: Type, pos: Position, flags: Flags): Symbol = {
ctx.newSymbol(sym, name.toTermName, FlagSet(flags), tpe, NoSymbol, pos)
}
def freshLocal(cunit: CompilationUnit, name: String, tpe: Type, pos: Position, flags: Flags): Symbol =
ctx.newSymbol(sym, name.toTermName, FlagSet(flags), tpe, NoSymbol, pos.toCoord)

def getter(clz: Symbol): Symbol = decorateSymbol(sym).getter
def setter(clz: Symbol): Symbol = decorateSymbol(sym).setter
def getter(clz: Symbol): Symbol = new SymUtilsOps(sym).getter
def setter(clz: Symbol): Symbol = new SymUtilsOps(sym).setter

def moduleSuffix: String = "" // todo: validate that names already have $ suffix
def outputDirectory: AbstractFile = DottyBackendInterface.this.outputDirectory
Expand All @@ -840,7 +842,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
* Redundant interfaces are removed unless there is a super call to them.
*/
def superInterfaces: List[Symbol] = {
val directlyInheritedTraits = decorateSymbol(sym).directlyInheritedTraits
val directlyInheritedTraits = new SymUtilsOps(sym).directlyInheritedTraits
val directlyInheritedTraitsSet = directlyInheritedTraits.toSet
val allBaseClasses = directlyInheritedTraits.iterator.flatMap(_.symbol.asClass.baseClasses.drop(1)).toSet
val superCalls = superCallsMap.getOrElse(sym, Set.empty)
Expand Down Expand Up @@ -1193,8 +1195,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
val arity = field.meth.tpe.widenDealias.paramTypes.size - _1.size
val returnsUnit = field.meth.tpe.widenDealias.resultType.classSymbol == UnitClass
if (returnsUnit)
ctx.requiredClass(("scala.compat.java8.JProcedure" + arity).toTermName)
else ctx.requiredClass(("scala.compat.java8.JFunction" + arity).toTermName)
ctx.requiredClass("scala.compat.java8.JProcedure" + arity)
else ctx.requiredClass("scala.compat.java8.JFunction" + arity)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
*/
protected[this] def rootContext(implicit ctx: Context): Context = {
ctx.initialize()(ctx)
ctx.setPhasePlan(comp.phases)
ctx.base.setPhasePlan(comp.phases)
val rootScope = new MutableScope
val bootstrap = ctx.fresh
.setPeriod(Period(comp.nextRunId, FirstPhaseId))
Expand Down Expand Up @@ -147,23 +147,23 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
}

protected def compileUnits()(implicit ctx: Context) = Stats.maybeMonitored {
ctx.checkSingleThreaded()
ctx.base.checkSingleThreaded()
compiling = true

// If testing pickler, make sure to stop after pickling phase:
val stopAfter =
if (ctx.settings.YtestPickler.value) List("pickler")
else ctx.settings.YstopAfter.value

val phases = ctx.squashPhases(ctx.phasePlan,
val phases = ctx.base.squashPhases(ctx.base.phasePlan,
ctx.settings.Yskip.value, ctx.settings.YstopBefore.value, stopAfter, ctx.settings.Ycheck.value)
ctx.usePhases(phases)
ctx.base.usePhases(phases)

def runPhases(implicit ctx: Context) = {
var lastPrintedTree: PrintedTree = NoPrintedTree
val profiler = ctx.profiler

for (phase <- ctx.allPhases)
for (phase <- ctx.base.allPhases)
if (phase.isRunnable)
Stats.trackTime(s"$phase ms ") {
val start = System.currentTimeMillis
Expand Down Expand Up @@ -222,7 +222,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
private def printTree(last: PrintedTree)(implicit ctx: Context): PrintedTree = {
val unit = ctx.compilationUnit
val prevPhase = ctx.phase.prev // can be a mini-phase
val squashedPhase = ctx.squashed(prevPhase)
val squashedPhase = ctx.base.squashed(prevPhase)
val treeString = unit.tpdTree.show(ctx.withProperty(XprintMode, Some(())))

ctx.echo(s"result of $unit after $squashedPhase:")
Expand Down Expand Up @@ -268,4 +268,4 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
myUnits = null
myUnitsCached = null
}
}
}
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ object desugar {
val ValDef(name, tpt, rhs) = vdef
val mods = vdef.mods
val setterNeeded =
(mods is Mutable) && ctx.owner.isClass && (!(mods is PrivateLocal) || (ctx.owner is Trait))
mods.is(Mutable) && ctx.owner.isClass && (!mods.isBoth(Private, and = Local) || ctx.owner.is(Trait))
if (setterNeeded) {
// TODO: copy of vdef as getter needed?
// val getter = ValDef(mods, name, tpt, rhs) withPos vdef.pos?
Expand All @@ -149,7 +149,7 @@ object desugar {

def makeImplicitParameters(tpts: List[Tree], forPrimaryConstructor: Boolean = false)(implicit ctx: Context) =
for (tpt <- tpts) yield {
val paramFlags: FlagSet = if (forPrimaryConstructor) PrivateLocalParamAccessor else Param
val paramFlags: FlagSet = if (forPrimaryConstructor) Private | Local | ParamAccessor else Param
val epname = EvidenceParamName.fresh()
ValDef(epname, tpt, EmptyTree).withFlags(paramFlags | Implicit)
}
Expand Down Expand Up @@ -260,9 +260,9 @@ object desugar {
@sharable private val synthetic = Modifiers(Synthetic)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this commit should not be merged. There is a reason for rawMods/modsDeco: mods should not be called on a typed tree because there mods is typically outdated - one should consult symbol.flags instead. The setup here makes sure that in code working with typed trees using a

import tpd._

import, mods is not visible, because modsDeco is not in scope. So this is a safety measure, not a convenience implicit.

private def toDefParam(tparam: TypeDef): TypeDef =
tparam.withMods(tparam.rawMods & EmptyFlags | Param)
tparam.withMods(tparam.mods & EmptyFlags | Param)
private def toDefParam(vparam: ValDef): ValDef =
vparam.withMods(vparam.rawMods & (Implicit | Erased) | Param)
vparam.withMods(vparam.mods & (Implicit | Erased) | Param)

/** The expansion of a class definition. See inline comments for what is involved */
def classDef(cdef: TypeDef)(implicit ctx: Context): Tree = {
Expand Down Expand Up @@ -314,7 +314,7 @@ object desugar {
lazy val derivedEnumParams = enumClass.typeParams.map(derivedTypeParam)
val impliedTparams =
if (isEnumCase && originalTparams.isEmpty)
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | PrivateLocal))
derivedEnumParams.map(tdef => tdef.withFlags(tdef.mods.flags | Private | Local))
else
originalTparams
val constrTparams = impliedTparams.map(toDefParam)
Expand Down Expand Up @@ -729,7 +729,7 @@ object desugar {
case _ =>
val tmpName = UniqueName.fresh()
val patMods =
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal else EmptyFlags)
mods & Lazy | Synthetic | (if (ctx.owner.isClass) Private | Local else EmptyFlags)
val firstDef =
ValDef(tmpName, TypeTree(), matchExpr)
.withPos(pat.pos.union(rhs.pos)).withMods(patMods)
Expand Down
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/ast/Positioned.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ abstract class Positioned extends DotClass with Product {

setPos(initialPos)

/** The item's position.
*/
/** The item's position. */
def pos: Position = curPos

/** The item's coord. */
def coord: Coord = curPos.toCoord
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong. "Coord" is an optimization for Symbols, so that they can take alternatively a Position or an Index. It's wrong to pollute other data types with this distinction - they should have no idea what a Coord is nor how to covert to it.


/** Destructively update `curPos` to given position. Also, set any missing
* positions in children.
*/
Expand Down
14 changes: 8 additions & 6 deletions compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object Trees {
/** The type constructor at the root of the tree */
type ThisTree[T >: Untyped] <: Tree[T]

private[this] var myTpe: T = _
protected var myTpe: T @uncheckedVariance = _

/** Destructively set the type of the tree. This should be called only when it is known that
* it is safe under sharing to do so. One use-case is in the withType method below
Expand All @@ -91,7 +91,7 @@ object Trees {
/** The type of the tree. In case of an untyped tree,
* an UnAssignedTypeException is thrown. (Overridden by empty trees)
*/
def tpe: T @uncheckedVariance = {
final def tpe: T @uncheckedVariance = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit LGTM

if (myTpe == null)
throw new UnAssignedTypeException(this)
myTpe
Expand Down Expand Up @@ -310,7 +310,7 @@ object Trees {

private[this] var myMods: untpd.Modifiers = null

private[dotc] def rawMods: untpd.Modifiers =
def mods: untpd.Modifiers =
if (myMods == null) untpd.EmptyModifiers else myMods

def rawComment: Option[Comment] = getAttachment(DocComment)
Expand Down Expand Up @@ -338,7 +338,7 @@ object Trees {
*/
def namePos =
if (pos.exists)
if (rawMods.is(Synthetic)) Position(pos.point, pos.point)
if (mods.is(Synthetic)) Position(pos.point, pos.point)
else Position(pos.point, pos.point + name.stripModuleClassSuffix.lastPart.length, pos.point)
else pos
}
Expand Down Expand Up @@ -727,7 +727,6 @@ object Trees {
}

trait WithoutTypeOrPos[-T >: Untyped] extends Tree[T] {
override def tpe: T @uncheckedVariance = NoType.asInstanceOf[T]
override def withTypeUnchecked(tpe: Type) = this.asInstanceOf[ThisTree[Type]]
override def pos = NoPosition
override def setPos(pos: Position) = {}
Expand All @@ -740,6 +739,8 @@ object Trees {
*/
case class Thicket[-T >: Untyped](trees: List[Tree[T]])
extends Tree[T] with WithoutTypeOrPos[T] {
myTpe = NoType.asInstanceOf[T]

type ThisTree[-T >: Untyped] = Thicket[T]
override def isEmpty: Boolean = trees.isEmpty
override def toList: List[Tree[T]] = flatten(trees)
Expand All @@ -758,8 +759,9 @@ object Trees {

class EmptyValDef[T >: Untyped] extends ValDef[T](
nme.WILDCARD, genericEmptyTree[T], genericEmptyTree[T]) with WithoutTypeOrPos[T] {
myTpe = NoType.asInstanceOf[T]
override def isEmpty: Boolean = true
setMods(untpd.Modifiers(PrivateLocal))
setMods(untpd.Modifiers(Private | Local))
}

@sharable val theEmptyTree: Thicket[Type] = Thicket(Nil)
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
ta.assignType(untpd.ValDef(sym.name, TypeTree(sym.info), rhs), sym)

def SyntheticValDef(name: TermName, rhs: Tree)(implicit ctx: Context): ValDef =
ValDef(ctx.newSymbol(ctx.owner, name, Synthetic, rhs.tpe.widen, coord = rhs.pos), rhs)
ValDef(ctx.newSymbol(ctx.owner, name, Synthetic, rhs.tpe.widen, coord = rhs.coord), rhs)

def DefDef(sym: TermSymbol, tparams: List[TypeSymbol], vparamss: List[List[TermSymbol]],
resultType: Type, rhs: Tree)(implicit ctx: Context): DefDef =
Expand Down Expand Up @@ -270,7 +270,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
if (parents.head.classSymbol.is(Trait)) parents.head.parents.head :: parents
else parents
val cls = ctx.newNormalizedClassSymbol(owner, tpnme.ANON_CLASS, Synthetic, parents1,
coord = fns.map(_.pos).reduceLeft(_ union _))
coord = fns.map(_.pos).reduceLeft(_ union _).toCoord)
val constr = ctx.newConstructor(cls, Synthetic, Nil, Nil).entered
def forwarder(fn: TermSymbol, name: TermName) = {
val fwdMeth = fn.copy(cls, name, Synthetic | Method).entered.asTerm
Expand All @@ -284,7 +284,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
// { <label> def while$(): Unit = if (cond) { body; while$() } ; while$() }
def WhileDo(owner: Symbol, cond: Tree, body: List[Tree])(implicit ctx: Context): Tree = {
val sym = ctx.newSymbol(owner, nme.WHILE_PREFIX, Flags.Label | Flags.Synthetic,
MethodType(Nil, defn.UnitType), coord = cond.pos)
MethodType(Nil, defn.UnitType), coord = cond.coord)

val call = Apply(ref(sym), Nil)
val rhs = If(cond, Block(body, call), unitLiteral)
Expand Down
16 changes: 4 additions & 12 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
mods: List[Mod] = Nil) extends Positioned with Cloneable {

def is(fs: FlagSet): Boolean = flags is fs
def is(fc: FlagConjunction): Boolean = flags is fc
def isBoth(fc: FlagSet, and: FlagSet): Boolean = flags.isBoth(fc, and)
def is(fc: FlagSet, butNot: FlagSet): Boolean = flags.is(fc, butNot = butNot)

def | (fs: FlagSet): Modifiers = withFlags(flags | fs)
Expand Down Expand Up @@ -349,7 +349,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
makeConstructor(Nil, Nil)

def makeSelfDef(name: TermName, tpt: Tree)(implicit ctx: Context) =
ValDef(name, tpt, EmptyTree).withFlags(PrivateLocal)
ValDef(name, tpt, EmptyTree).withFlags(Private | Local)

def makeTupleOrParens(ts: List[Tree])(implicit ctx: Context) = ts match {
case t :: Nil => Parens(t)
Expand All @@ -365,7 +365,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
ValDef(pname, tpe, EmptyTree).withMods(mods | Param)

def makeSyntheticParameter(n: Int = 1, tpt: Tree = TypeTree())(implicit ctx: Context): ValDef =
ValDef(nme.syntheticParamName(n), tpt, EmptyTree).withFlags(SyntheticTermParam)
ValDef(nme.syntheticParamName(n), tpt, EmptyTree).withFlags(Synthetic | TermParam)

def lambdaAbstract(tparams: List[TypeDef], tpt: Tree)(implicit ctx: Context) =
if (tparams.isEmpty) tpt else LambdaTypeTree(tparams, tpt)
Expand All @@ -381,14 +381,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
/** A repeated argument such as `arg: _*` */
def repeated(arg: Tree)(implicit ctx: Context) = 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
}

// --------- Copier/Transformer/Accumulator classes for untyped trees -----

override val cpy: UntypedTreeCopier = new UntypedTreeCopier
Expand All @@ -400,7 +392,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

def postProcess(tree: Tree, copied: MemberDef): copied.ThisTree[Untyped] = {
tree match {
case tree: MemberDef => copied.withMods(tree.rawMods)
case tree: MemberDef => copied.withMods(tree.mods)
case _ => copied
}
}.asInstanceOf[copied.ThisTree[Untyped]]
Expand Down
Loading