Skip to content

Commit 103beef

Browse files
committed
InfoTransformers as specific DenotTransformers
Factored out denot transformer behavior where the we transform types in a uniform way into InfoTransformers.
1 parent f39b624 commit 103beef

File tree

5 files changed

+20
-13
lines changed

5 files changed

+20
-13
lines changed

src/dotty/tools/dotc/core/DenotTransformers.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Periods._
55
import SymDenotations._
66
import Contexts._
77
import Types._
8+
import Symbols._
89
import Denotations._
910
import Phases._
1011
import java.lang.AssertionError
@@ -30,4 +31,19 @@ object DenotTransformers {
3031
/** The transformation method */
3132
def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation
3233
}
34+
35+
trait InfoTransformer extends DenotTransformer {
36+
37+
def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type
38+
39+
/** The transformation method */
40+
def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = {
41+
val info1 = transformInfo(ref.info, ref.symbol)
42+
if (info1 eq ref.info) ref
43+
else ref match {
44+
case ref: SymDenotation => ref.copySymDenotation(info = info1)
45+
case _ => ref.derivedSingleDenotation(ref.symbol, info1)
46+
}
47+
}
48+
}
3349
}

src/dotty/tools/dotc/transform/InterceptedMethods.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dotty.tools.dotc
22
package transform
33

44
import TreeTransforms._
5-
import core.DenotTransformers._
65
import core.Denotations._
76
import core.SymDenotations._
87
import core.Contexts._
@@ -27,7 +26,6 @@ import dotty.runtime.LazyVals
2726
import scala.collection.mutable.ListBuffer
2827
import dotty.tools.dotc.core.Denotations.SingleDenotation
2928
import dotty.tools.dotc.core.SymDenotations.SymDenotation
30-
import dotty.tools.dotc.core.DenotTransformers.DenotTransformer
3129
import StdNames._
3230

3331
/** Replace member references as follows:

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dotty.tools.dotc
22
package transform
33

44
import TreeTransforms._
5-
import core.DenotTransformers._
65
import core.Denotations._
76
import core.SymDenotations._
87
import core.Contexts._

src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package dotty.tools.dotc
22
package transform
33

44
import TreeTransforms._
5-
import core.DenotTransformers._
65
import core.Denotations._
76
import core.SymDenotations._
87
import core.Contexts._

src/dotty/tools/dotc/transform/UncurryTreeTransform.scala

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import core.Denotations._
77
import core.SymDenotations._
88
import core.Contexts._
99
import core.Types._
10+
import core.Symbols._
1011
import ast.Trees._
1112
import ast.tpd.{Apply, Tree, cpy}
1213

13-
class UncurryTreeTransform extends TreeTransform with DenotTransformer {
14+
class UncurryTreeTransform extends TreeTransform with InfoTransformer {
1415

1516
override def name: String = "uncurry"
1617
override def transformApply(tree: Apply)(implicit ctx: Context, info: TransformerInfo): Tree =
@@ -40,12 +41,6 @@ class UncurryTreeTransform extends TreeTransform with DenotTransformer {
4041
tp
4142
}
4243

43-
def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = {
44-
val info1 = uncurry(ref.info)
45-
if (info1 eq ref.info) ref
46-
else ref match {
47-
case ref: SymDenotation => ref.copySymDenotation(info = info1)
48-
case _ => ref.derivedSingleDenotation(ref.symbol, info1)
49-
}
50-
}
44+
def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type =
45+
uncurry(tp)
5146
}

0 commit comments

Comments
 (0)