From 131ab5c1261608715cf2fde3aa44a04777cbda64 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 18 Jun 2015 13:27:43 +0200 Subject: Avoid double context creation when modes change on a fresh context. Move addMode and friends to two decorators, one for Context, the other for FreshContext. Implement behavior accordingly. This avoids creating two contexts in situations like: c.fresh.setxploreTyperState.addMode(...) Mow we can write c.fresh.addMode(...).setExploreTyperState Because addMode returns a fresh context when applied to a fresh context. Note that we specifically do not want virtual dispatch of addMode, that's why it was moved to a decorator. Also: removed mention of ".fresh: when just forllowed by an addMode, because that one is redundant. --- src/dotty/tools/dotc/typer/Namer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/typer/Namer.scala') diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 11a0bd76e..d5a6ec8f4 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -701,7 +701,7 @@ class Namer { typer: Typer => // println(s"final inherited for $sym: ${inherited.toString}") !!! // println(s"owner = ${sym.owner}, decls = ${sym.owner.info.decls.show}") - val rhsCtx = ctx.fresh addMode Mode.InferringReturnType + val rhsCtx = ctx.addMode(Mode.InferringReturnType) def rhsType = ctx.deskolemize( typedAheadExpr(mdef.rhs, rhsProto)(rhsCtx).tpe.widen.approximateUnion) def lhsType = fullyDefinedType(rhsType, "right-hand side", mdef.pos) -- cgit v1.2.3