diff options
author | Martin Odersky <odersky@gmail.com> | 2014-10-21 16:38:27 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-10-26 16:24:01 +0100 |
commit | 04001befb1a7f08da0c38166eed61322104adbaf (patch) | |
tree | 1eb21c86a91aaea1c9a5be0583072df4da139ecb | |
parent | e3b0fa2ede56393165759eecd7bc916d24835ee1 (diff) | |
download | dotty-04001befb1a7f08da0c38166eed61322104adbaf.tar.gz dotty-04001befb1a7f08da0c38166eed61322104adbaf.tar.bz2 dotty-04001befb1a7f08da0c38166eed61322104adbaf.zip |
Two fixes to avoid scanning package contents
typeParams and outerAccessor both potentially scan all declarations of a class.
The fixes make sure this is never done for packages.
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 9a5be70d1..4cc15897c 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -976,7 +976,7 @@ object SymDenotations { /** The type parameters of this class */ override final def typeParams(implicit ctx: Context): List[TypeSymbol] = { def computeTypeParams = { - if (ctx.erasedTypes && (symbol ne defn.ArrayClass)) Nil + if (ctx.erasedTypes || is(Module)) Nil // fast return for modules to avoid scanning package decls else if (this ne initial) initial.asSymDenotation.typeParams else decls.filter(sym => (sym is TypeParam) && sym.owner == symbol).asInstanceOf[List[TypeSymbol]] diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 179f8d712..d056d7e35 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -179,7 +179,8 @@ object ExplicitOuter { * definitions in the class to find the one with the OuterAccessor flag. */ def outerAccessor(cls: ClassSymbol)(implicit ctx: Context): Symbol = - cls.info.member(outerAccName(cls)).suchThat(_ is OuterAccessor).symbol orElse + if (cls.isStatic) NoSymbol // fast return to avoid scanning package decls + else cls.info.member(outerAccName(cls)).suchThat(_ is OuterAccessor).symbol orElse cls.info.decls.find(_ is OuterAccessor).getOrElse(NoSymbol) /** Class has an outer accessor. Can be called only after phase ExplicitOuter. */ |