@@ -278,12 +278,16 @@ object Contexts {
278
278
}
279
279
280
280
final def withMode (mode : Mode ): Context =
281
- if (mode != this .mode) fresh.withNewMode(mode) else this
281
+ if (mode != this .mode) fresh.setMode(mode) else this
282
+
283
+ /**
284
+ * This method will always return a phase period equal to phaseId, thus will never return squashed phases
285
+ */
286
+ final def withPhase (phaseId : PhaseId ): Context =
287
+ if (this .phaseId == phaseId) this else fresh.setPhase(phaseId)
288
+ final def withPhase (phase : Phase ): Context =
289
+ if (this .period == phase.period) this else fresh.setPhase(phase)
282
290
283
- def withPhase (phase : PhaseId ): Context =
284
- if (this .phaseId == phaseId) this else fresh.withPhase(phase)
285
- def withPhase (phase : Phase ): Context =
286
- withPhase(phase.id)
287
291
288
292
final def addMode (mode : Mode ): Context = withMode(this .mode | mode)
289
293
final def maskMode (mode : Mode ): Context = withMode(this .mode & mode)
@@ -306,36 +310,36 @@ object Contexts {
306
310
* of its attributes using the with... methods.
307
311
*/
308
312
abstract class FreshContext extends Context {
309
- def withPeriod (period : Period ): this .type = { this .period = period; this }
310
- def withNewMode (mode : Mode ): this .type = { this .mode = mode; this }
311
- def withTyperState (typerState : TyperState ): this .type = { this .typerState = typerState; this }
312
- def withNewTyperState : this .type = withTyperState (typerState.fresh(isCommittable = true ))
313
- def withExploreTyperState : this .type = withTyperState (typerState.fresh(isCommittable = false ))
314
- def withPrinterFn (printer : Context => Printer ): this .type = { this .printerFn = printer; this }
315
- def withOwner (owner : Symbol ): this .type = { assert(owner != NoSymbol ); this .owner = owner; this }
316
- def withSettings (sstate : SettingsState ): this .type = { this .sstate = sstate; this }
317
- def withCompilationUnit (compilationUnit : CompilationUnit ): this .type = { this .compilationUnit = compilationUnit; this }
318
- def withTree (tree : Tree [_ >: Untyped ]): this .type = { this .tree = tree; this }
319
- def withScope (scope : Scope ): this .type = { this .scope = scope; this }
320
- def withNewScope : this .type = { this .scope = newScope; this }
321
- def withTypeAssigner (typeAssigner : TypeAssigner ): this .type = { this .typeAssigner = typeAssigner; this }
322
- def withTyper (typer : Typer ): this .type = { this .scope = typer.scope; withTypeAssigner (typer) }
323
- def withImportInfo (importInfo : ImportInfo ): this .type = { this .importInfo = importInfo; this }
324
- def withRunInfo (runInfo : RunInfo ): this .type = { this .runInfo = runInfo; this }
325
- def withDiagnostics (diagnostics : Option [StringBuilder ]): this .type = { this .diagnostics = diagnostics; this }
326
- def withTypeComparerFn (tcfn : Context => TypeComparer ): this .type = { this .typeComparer = tcfn(this ); this }
327
- def withSearchHistory (searchHistory : SearchHistory ): this .type = { this .searchHistory = searchHistory; this }
328
- def withMoreProperties (moreProperties : Map [String , Any ]): this .type = { this .moreProperties = moreProperties; this }
329
-
330
- def withProperty (prop : (String , Any )): this .type = withMoreProperties (moreProperties + prop)
331
-
332
- override def withPhase (pid : PhaseId ): this .type = withPeriod (Period (runId, pid))
333
- override def withPhase (phase : Phase ): this .type = withPhase( phase.id )
334
-
335
- def withSetting [T ](setting : Setting [T ], value : T ): this .type =
336
- withSettings (setting.updateIn(sstate, value))
337
-
338
- def withDebug = withSetting (base.settings.debug, true )
313
+ def setPeriod (period : Period ): this .type = { this .period = period; this }
314
+ def setMode (mode : Mode ): this .type = { this .mode = mode; this }
315
+ def setTyperState (typerState : TyperState ): this .type = { this .typerState = typerState; this }
316
+ def clearTyperState : this .type = setTyperState (typerState.fresh(isCommittable = true ))
317
+ def setExploreTyperState : this .type = setTyperState (typerState.fresh(isCommittable = false ))
318
+ def setPrinterFn (printer : Context => Printer ): this .type = { this .printerFn = printer; this }
319
+ def setOwner (owner : Symbol ): this .type = { assert(owner != NoSymbol ); this .owner = owner; this }
320
+ def setSettings (sstate : SettingsState ): this .type = { this .sstate = sstate; this }
321
+ def setCompilationUnit (compilationUnit : CompilationUnit ): this .type = { this .compilationUnit = compilationUnit; this }
322
+ def setTree (tree : Tree [_ >: Untyped ]): this .type = { this .tree = tree; this }
323
+ def setScope (scope : Scope ): this .type = { this .scope = scope; this }
324
+ def clearScope : this .type = { this .scope = newScope; this }
325
+ def setTypeAssigner (typeAssigner : TypeAssigner ): this .type = { this .typeAssigner = typeAssigner; this }
326
+ def setTyper (typer : Typer ): this .type = { this .scope = typer.scope; setTypeAssigner (typer) }
327
+ def setImportInfo (importInfo : ImportInfo ): this .type = { this .importInfo = importInfo; this }
328
+ def setRunInfo (runInfo : RunInfo ): this .type = { this .runInfo = runInfo; this }
329
+ def setDiagnostics (diagnostics : Option [StringBuilder ]): this .type = { this .diagnostics = diagnostics; this }
330
+ def setTypeComparerFn (tcfn : Context => TypeComparer ): this .type = { this .typeComparer = tcfn(this ); this }
331
+ def setSearchHistory (searchHistory : SearchHistory ): this .type = { this .searchHistory = searchHistory; this }
332
+ def setMoreProperties (moreProperties : Map [String , Any ]): this .type = { this .moreProperties = moreProperties; this }
333
+
334
+ def setProperty (prop : (String , Any )): this .type = setMoreProperties (moreProperties + prop)
335
+
336
+ def setPhase (pid : PhaseId ): this .type = setPeriod (Period (runId, pid))
337
+ def setPhase (phase : Phase ): this .type = setPeriod( Period (runId, phase.start, phase.end) )
338
+
339
+ def setSetting [T ](setting : Setting [T ], value : T ): this .type =
340
+ setSettings (setting.updateIn(sstate, value))
341
+
342
+ def setDebug = setSetting (base.settings.debug, true )
339
343
}
340
344
341
345
/** A class defining the initial context with given context base
0 commit comments