aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/DenotTransformers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-12 17:12:44 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-12 17:12:44 +0100
commitc4aa3c058904912ba1b5696b2aaa4d9234dc5c79 (patch)
tree88202fd564fabaa60bc135ded32d9216e83029a7 /src/dotty/tools/dotc/core/DenotTransformers.scala
parent7978a5f6a1be13ca9c482c3f2e9c2102018cfcf0 (diff)
downloaddotty-c4aa3c058904912ba1b5696b2aaa4d9234dc5c79.tar.gz
dotty-c4aa3c058904912ba1b5696b2aaa4d9234dc5c79.tar.bz2
dotty-c4aa3c058904912ba1b5696b2aaa4d9234dc5c79.zip
Avoid forcing infos of some symbols in InfoTransforms
Provides the "mayChange" hook to exclude symbols from being completed prior to a transformInfo.
Diffstat (limited to 'src/dotty/tools/dotc/core/DenotTransformers.scala')
-rw-r--r--src/dotty/tools/dotc/core/DenotTransformers.scala20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/core/DenotTransformers.scala b/src/dotty/tools/dotc/core/DenotTransformers.scala
index 0e31d87e6..02d27ea33 100644
--- a/src/dotty/tools/dotc/core/DenotTransformers.scala
+++ b/src/dotty/tools/dotc/core/DenotTransformers.scala
@@ -38,13 +38,23 @@ object DenotTransformers {
def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type
def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = {
- val info1 = transformInfo(ref.info, ref.symbol)
- if (info1 eq ref.info) ref
- else ref match {
- case ref: SymDenotation => ref.copySymDenotation(info = info1)
- case _ => ref.derivedSingleDenotation(ref.symbol, info1)
+ val sym = ref.symbol
+ if (sym.exists && !mayChange(sym)) ref
+ else {
+ val info1 = transformInfo(ref.info, ref.symbol)
+ if (info1 eq ref.info) ref
+ else ref match {
+ case ref: SymDenotation => ref.copySymDenotation(info = info1)
+ case _ => ref.derivedSingleDenotation(ref.symbol, info1)
+ }
}
}
+
+ /** Denotations with a symbol where `mayChange` is false are guaranteed to be
+ * unaffected by this transform, so `transformInfo` need not be run. This
+ * can save time, and more importantly, can help avoid forcing symbol completers.
+ */
+ protected def mayChange(sym: Symbol)(implicit ctx: Context): Boolean = true
}
/** A transformer that only transforms SymDenotations */