diff options
author | Martin Odersky <odersky@gmail.com> | 2013-08-24 12:45:07 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-08-24 12:45:07 +0200 |
commit | 0712c1903de8383d58a8f7f9e21c10dc32f4159f (patch) | |
tree | fdf45fd69ffbccc760d09a9fe5eca87f6d010d6d /src/dotty/tools/dotc/core/Types.scala | |
parent | 69623da92518c591e0c4ab651cade28e94ee9a9a (diff) | |
download | dotty-0712c1903de8383d58a8f7f9e21c10dc32f4159f.tar.gz dotty-0712c1903de8383d58a8f7f9e21c10dc32f4159f.tar.bz2 dotty-0712c1903de8383d58a8f7f9e21c10dc32f4159f.zip |
Optimized case for findMember on a type refinement.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 13 |
1 files changed, 9 insertions, 4 deletions
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 |