@@ -26,26 +26,22 @@ object desugar {
2626 /** If a Select node carries this attachment, suppress the check
2727 * that its type refers to an acessible symbol.
2828 */
29- val SuppressAccessCheck : Property .Key [Unit ] = new Property .Key
29+ val SuppressAccessCheck : Property .Key [Unit ] = Property .Key ()
3030
3131 /** An attachment for companion modules of classes that have a `derives` clause.
3232 * The position value indicates the start position of the template of the
3333 * deriving class.
3434 */
35- val DerivingCompanion : Property .Key [SourcePosition ] = new Property .Key
35+ val DerivingCompanion : Property .Key [SourcePosition ] = Property .Key ()
3636
3737 /** An attachment for match expressions generated from a PatDef or GenFrom.
3838 * Value of key == one of IrrefutablePatDef, IrrefutableGenFrom
3939 */
40- val CheckIrrefutable : Property .Key [MatchCheck ] = new Property .StickyKey
41-
42- /** What static check should be applied to a Match (none, irrefutable, exhaustive) */
43- class MatchCheck (val n : Int ) extends AnyVal
44- object MatchCheck {
45- val None = new MatchCheck (0 )
46- val Exhaustive = new MatchCheck (1 )
47- val IrrefutablePatDef = new MatchCheck (2 )
48- val IrrefutableGenFrom = new MatchCheck (3 )
40+ val CheckIrrefutable : Property .Key [MatchCheck ] = Property .StickyKey ()
41+
42+ /** What static check should be applied to a Match? */
43+ enum MatchCheck {
44+ case None , Exhaustive , IrrefutablePatDef , IrrefutableGenFrom
4945 }
5046
5147 /** Info of a variable in a pattern: The named tree and its type */
@@ -136,17 +132,17 @@ object desugar {
136132 def derivedTypeParam (tdef : TypeDef , suffix : String = " " )(implicit ctx : Context ): TypeDef =
137133 cpy.TypeDef (tdef)(
138134 name = tdef.name ++ suffix,
139- rhs = new DerivedFromParamTree (suffix).withSpan(tdef.rhs.span).watching(tdef)
135+ rhs = DerivedFromParamTree (suffix).withSpan(tdef.rhs.span).watching(tdef)
140136 )
141137
142138 /** A derived type definition watching `sym` */
143139 def derivedTypeParam (sym : TypeSymbol )(implicit ctx : Context ): TypeDef =
144- TypeDef (sym.name, new DerivedFromParamTree (" " ).watching(sym)).withFlags(TypeParam )
140+ TypeDef (sym.name, DerivedFromParamTree (" " ).watching(sym)).withFlags(TypeParam )
145141
146142 /** A value definition copied from `vdef` with a tpt typetree derived from it */
147143 def derivedTermParam (vdef : ValDef )(implicit ctx : Context ): ValDef =
148144 cpy.ValDef (vdef)(
149- tpt = new DerivedFromParamTree (" " ).withSpan(vdef.tpt.span).watching(vdef))
145+ tpt = DerivedFromParamTree (" " ).withSpan(vdef.tpt.span).watching(vdef))
150146
151147// ----- Desugar methods -------------------------------------------------
152148
@@ -165,7 +161,7 @@ object desugar {
165161 // val getter = ValDef(mods, name, tpt, rhs) withPos vdef.pos?
166162 // right now vdef maps via expandedTree to a thicket which concerns itself.
167163 // I don't see a problem with that but if there is one we can avoid it by making a copy here.
168- val setterParam = makeSyntheticParameter(tpt = ( new SetterParamTree ).watching(vdef))
164+ val setterParam = makeSyntheticParameter(tpt = SetterParamTree ( ).watching(vdef))
169165 // The rhs gets filled in later, when field is generated and getter has parameters (see Memoize miniphase)
170166 val setterRhs = if (vdef.rhs.isEmpty) EmptyTree else unitLiteral
171167 val setter = cpy.DefDef (vdef)(
@@ -217,7 +213,7 @@ object desugar {
217213 val meth @ DefDef (_, tparams, vparamss, tpt, rhs) = transformQuotedPatternName(meth0)
218214 val methName = normalizeName(meth, tpt).asTermName
219215 val mods = meth.mods
220- val epbuf = new ListBuffer [ValDef ]
216+ val epbuf = ListBuffer [ValDef ]()
221217 def desugarContextBounds (rhs : Tree ): Tree = rhs match {
222218 case ContextBounds (tbounds, cxbounds) =>
223219 epbuf ++= makeImplicitParameters(cxbounds, Implicit , forPrimaryConstructor = isPrimaryConstructor)
@@ -443,7 +439,7 @@ object desugar {
443439 val (enumCases, enumStats) = stats.partition(DesugarEnums .isEnumCase)
444440 if (enumCases.isEmpty)
445441 ctx.error(" Enumerations must constain at least one case" , namePos)
446- val enumCompanionRef = new TermRefTree ()
442+ val enumCompanionRef = TermRefTree ()
447443 val enumImport = Import (importDelegate = false , enumCompanionRef, enumCases.flatMap(caseIds))
448444 (enumImport :: enumStats, enumCases, enumCompanionRef)
449445 }
@@ -456,7 +452,7 @@ object desugar {
456452 val derivedVparamss = constrVparamss.nestedMap(derivedTermParam(_))
457453 val arity = constrVparamss.head.length
458454
459- val classTycon : Tree = new TypeRefTree // watching is set at end of method
455+ val classTycon : Tree = TypeRefTree () // watching is set at end of method
460456
461457 def appliedTypeTree (tycon : Tree , args : List [Tree ]) =
462458 (if (args.isEmpty) tycon else AppliedTypeTree (tycon, args))
@@ -895,8 +891,8 @@ object desugar {
895891 }
896892 else x
897893 }
898- private val typeNameExtractor = new NameExtractor (followArgs = true )
899- private val argNameExtractor = new NameExtractor (followArgs = false )
894+ private val typeNameExtractor = NameExtractor (followArgs = true )
895+ private val argNameExtractor = NameExtractor (followArgs = false )
900896
901897 private def inventTypeName (tree : Tree )(implicit ctx : Context ): String = typeNameExtractor(" " , tree)
902898
@@ -1207,7 +1203,7 @@ object desugar {
12071203 def makeContextualFunction (formals : List [Type ], body : Tree , isErased : Boolean )(implicit ctx : Context ): Tree = {
12081204 val mods = if (isErased) Given | Erased else Given
12091205 val params = makeImplicitParameters(formals.map(TypeTree ), mods)
1210- new FunctionWithMods (params, body, Modifiers (mods))
1206+ FunctionWithMods (params, body, Modifiers (mods))
12111207 }
12121208
12131209 /** Add annotation to tree:
@@ -1419,7 +1415,7 @@ object desugar {
14191415 val pdefs = (valeqs, defpats, rhss).zipped.map(makePatDef(_, Modifiers (), _, _))
14201416 val rhs1 = makeFor(nme.map, nme.flatMap, GenFrom (defpat0, gen.expr, gen.checkMode) :: Nil , Block (pdefs, makeTuple(id0 :: ids)))
14211417 val allpats = gen.pat :: pats
1422- val vfrom1 = new GenFrom (makeTuple(allpats), rhs1, GenCheckMode .Ignore )
1418+ val vfrom1 = GenFrom (makeTuple(allpats), rhs1, GenCheckMode .Ignore )
14231419 makeFor(mapName, flatMapName, vfrom1 :: rest1, body)
14241420 case (gen : GenFrom ) :: test :: rest =>
14251421 val filtered = Apply (rhsSelect(gen, nme.withFilter), makeLambda(gen, test))
@@ -1594,7 +1590,7 @@ object desugar {
15941590 * without duplicates
15951591 */
15961592 private def getVariables (tree : Tree )(implicit ctx : Context ): List [VarInfo ] = {
1597- val buf = new ListBuffer [VarInfo ]
1593+ val buf = ListBuffer [VarInfo ]()
15981594 def seenName (name : Name ) = buf exists (_._1.name == name)
15991595 def add (named : NameTree , t : Tree ): Unit =
16001596 if (! seenName(named.name) && named.name.isTermName) buf += ((named, t))
0 commit comments