diff options
author | Martin Odersky <odersky@gmail.com> | 2013-11-14 17:50:10 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-11-14 18:05:41 +0100 |
commit | ffe9e2237956d167b51c9ab1e571a04163b525f7 (patch) | |
tree | 952d7177e26997df8761452844df0f375a3aae75 /src/dotty/tools | |
parent | fe865cd382bb21026b79070eafa597b865fe461c (diff) | |
download | dotty-ffe9e2237956d167b51c9ab1e571a04163b525f7.tar.gz dotty-ffe9e2237956d167b51c9ab1e571a04163b525f7.tar.bz2 dotty-ffe9e2237956d167b51c9ab1e571a04163b525f7.zip |
Some configuation parameters
Caching, plus whether we want to match on signatures or types.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/config/Config.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 18 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 18 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 6 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 7 |
7 files changed, 47 insertions, 31 deletions
diff --git a/src/dotty/tools/dotc/config/Config.scala b/src/dotty/tools/dotc/config/Config.scala new file mode 100644 index 000000000..af75aea89 --- /dev/null +++ b/src/dotty/tools/dotc/config/Config.scala @@ -0,0 +1,13 @@ +package dotty.tools.dotc.config + +object Config { + + final val cacheMemberNames = true + final val cacheAsSeenFrom = true + + /** When set, use new signature-based matching. + * Advantantage of doing so: It's supposed to be faster + * Disadvantage: It might hide inconsistencies, so while debugging it's better to turn it off + */ + final val newMatch = false +}
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 4ab911160..60a4df9fa 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -12,6 +12,7 @@ import Types._, Periods._, Flags._, Transformers._, Decorators._ import printing.Texts._ import printing.Printer import io.AbstractFile +import config.Config import Decorators.SymbolIteratorDecorator @@ -643,14 +644,15 @@ object Denotations { type AsSeenFromResult <: PreDenotation /** The denotation with info(s) as seen from prefix type */ - final def asSeenFrom(pre: Type)(implicit ctx: Context): AsSeenFromResult = { - if ((cachedPrefix ne pre) || ctx.period != validAsSeenFrom) { - cachedAsSeenFrom = computeAsSeenFrom(pre) - cachedPrefix = pre - validAsSeenFrom = ctx.period - } - cachedAsSeenFrom - } + final def asSeenFrom(pre: Type)(implicit ctx: Context): AsSeenFromResult = + if (Config.cacheAsSeenFrom) { + if ((cachedPrefix ne pre) || ctx.period != validAsSeenFrom) { + cachedAsSeenFrom = computeAsSeenFrom(pre) + cachedPrefix = pre + validAsSeenFrom = ctx.period + } + cachedAsSeenFrom + } else computeAsSeenFrom(pre) protected def computeAsSeenFrom(pre: Type)(implicit ctx: Context): AsSeenFromResult diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index d6032aee3..af2e6a8ca 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -10,6 +10,7 @@ import collection.immutable.BitSet import scala.reflect.io.AbstractFile import Decorators.SymbolIteratorDecorator import annotation.tailrec +import config.Config trait SymDenotations { this: Context => import SymDenotations._ @@ -921,14 +922,15 @@ object SymDenotations { * The elements of the returned pre-denotation all * have existing symbols. */ - final def membersNamed(name: Name)(implicit ctx: Context): PreDenotation = { - var denots: PreDenotation = memberCache lookup name - if (denots == null) { - denots = computeMembersNamed(name) - memberCache enter (name, denots) - } - denots - } + final def membersNamed(name: Name)(implicit ctx: Context): PreDenotation = + if (Config.cacheMemberNames) { + var denots: PreDenotation = memberCache lookup name + if (denots == null) { + denots = computeMembersNamed(name) + memberCache enter (name, denots) + } + denots + } else computeMembersNamed(name) private def computeMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = if (!classSymbol.hasChildren || (memberFingerPrint contains name)) { diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 27e177de6..14ebba57d 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -22,6 +22,7 @@ import transform.Erasure import printing.Printer import scala.util.hashing.{ MurmurHash3 => hashing } import collection.mutable +import config.Config object Types { @@ -416,7 +417,7 @@ object Types { final def member(name: Name)(implicit ctx: Context): Denotation = track("member-" + name) { try findMember(name, widenIfUnstable, EmptyFlags) catch { - case ex: Throwable => println(s"error occurred during: $this member $name"); throw ex // DEBUG + case ex: Throwable => println(s"error occurred during: $this: ${this.widen} member $name"); throw ex // DEBUG } } @@ -572,10 +573,12 @@ object Types { * - Or phase.erasedTypes is false and both types are neither method nor * poly types. */ - def matches(that: Type)(implicit ctx: Context): Boolean = track("matches") { - ctx.typeComparer.matchesType( - this, that, alwaysMatchSimple = !ctx.phase.erasedTypes) - } + def matches(that: Type)(implicit ctx: Context): Boolean = + if (Config.newMatch) this.signature == that.signature + else track("matches") { + ctx.typeComparer.matchesType( + this, that, alwaysMatchSimple = !ctx.phase.erasedTypes) + } /** The non-private symbol with given name in the given class that matches this type. * @param inClass The class containing the symbol's definition diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 7dc6eb799..201f928a9 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -14,7 +14,6 @@ import Denotations._ import NameOps._ import Symbols._ import Types._ -import Typer.TreeDecorator import Decorators._ import ErrorReporting._ import Trees._ @@ -406,7 +405,7 @@ trait Applications extends Compatibility { self: Typer => val result ={ var typedArgs = typedArgBuf.toList - val ownType = ctx.traceIndented(i"apply $methRef to $typedArgs") { + val ownType = ctx.traceIndented(i"apply $methRef to $typedArgs%, %", show = true) { if (!success) ErrorType else { if (!sameSeq(app.args, orderedArgs)) { diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 78d3f15c1..6cda24808 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -293,7 +293,7 @@ trait Implicits { self: Typer => def searchImplicits(eligible: List[TermRef], contextual: Boolean): SearchResult = { /** Try to typecheck an implicit reference */ - def typedImplicit(ref: TermRef)(implicit ctx: Context): SearchResult = track("typedImplicit") { ctx.traceIndented(s"typed implicit $ref, pt = $pt, implicitsEnabled == ${ctx.mode is ImplicitsEnabled}", show = true) { + def typedImplicit(ref: TermRef)(implicit ctx: Context): SearchResult = track("typedImplicit") { ctx.traceIndented(i"typed implicit $ref, pt = $pt, implicitsEnabled == ${ctx.mode is ImplicitsEnabled}", show = true) { var generated: Tree = Ident(ref).withPos(pos) if (!argument.isEmpty) generated = typedUnadapted( @@ -329,6 +329,10 @@ trait Implicits { self: Typer => case best :: alts => alts find (alt => isAsGood(alt.ref, best.ref)(ctx.fresh.withExploreTyperState)) match { case Some(alt) => + /* !!! DEBUG + println(i"ambiguous refs: ${hits map (_.ref) map (_.show) mkString ", "}") + isAsGood(best.ref, alt.ref, explain = true)(ctx.fresh.withExploreTyperState) + */ new AmbiguousImplicits(best.ref, alt.ref, pt, argument) case None => ctx.runInfo.useCount(best.ref) += 1 diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index c7b79bad3..5142f7360 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -45,13 +45,6 @@ object Typer { def isImportPrec(prec: Int) = prec == namedImport || prec == wildImport } - implicit class TreeDecorator(tree: Tree) { - def qualifierType(implicit ctx: Context): Type = tree.tpe match { - case tpe: TermRef if !tpe.symbol.isStable => tpe.info - case tpe => tpe - } - } - case class StateFul[T](value: T, state: TyperState) { def commit()(implicit ctx: Context): T = { state.commit() |