From 0712c1903de8383d58a8f7f9e21c10dc32f4159f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sat, 24 Aug 2013 12:45:07 +0200 Subject: Optimized case for findMember on a type refinement. --- src/dotty/tools/dotc/core/Types.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index f66070dc4..f8b98cdd8 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -351,10 +351,15 @@ object Types { final def findMember(name: Name, pre: Type, excluded: FlagSet)(implicit ctx: Context): Denotation = this match { case tp: RefinedType => val pdenot = tp.parent.findMember(name, pre, excluded) - if (name eq tp.refinedName) - pdenot & (new JointRefDenotation(NoSymbol, tp.refinedInfo.substThis(tp, pre), Period.allInRun(ctx.runId)), pre) - else - pdenot + if (name eq tp.refinedName) { + val rinfo = tp.refinedInfo.substThis(tp, pre) + if (name.isTypeName) // simplified case that runs more efficiently + pdenot.asInstanceOf[SingleDenotation].derivedSingleDenotation( + pdenot.symbol, pdenot.info & rinfo) + else + pdenot & (new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId)), pre) + } + else pdenot case tp: ThisType => val d = tp.underlying.findMember(name, pre, excluded) if (d.exists) d -- cgit v1.2.3