@@ -2,32 +2,23 @@ package dotty.tools.dotc
22package transform
33
44import core ._
5- import Names ._
65import dotty .tools .dotc .transform .MegaPhase ._
7- import ast .Trees ._
8- import ast .untpd
96import Flags ._
107import Types ._
11- import Constants .Constant
128import Contexts .Context
139import Symbols ._
1410import Decorators ._
15- import Annotations ._
16- import Annotations .ConcreteAnnotation
1711import Denotations .SingleDenotation
1812import SymDenotations .SymDenotation
19- import scala .collection .mutable
2013import DenotTransformers ._
21- import NameOps ._
22- import NameKinds .OuterSelectName
23- import StdNames ._
14+ import TypeUtils ._
2415
2516object ElimOpaque {
2617 val name : String = " elimOpaque"
2718}
2819
2920/** Rewrites opaque type aliases to normal alias types */
30- class ElimOpaque extends MiniPhase with SymTransformer {
21+ class ElimOpaque extends MiniPhase with DenotTransformer {
3122
3223 override def phaseName : String = ElimOpaque .name
3324
@@ -37,11 +28,21 @@ class ElimOpaque extends MiniPhase with SymTransformer {
3728 // base types of opaque aliases change
3829 override def changesBaseTypes = true
3930
40- def transformSym (sym : SymDenotation )(implicit ctx : Context ): SymDenotation =
41- if (sym.isOpaqueHelper) {
42- sym.copySymDenotation(
43- info = TypeAlias (sym.opaqueAlias),
44- initFlags = sym.flags &~ (Opaque | Deferred ))
31+ def transform (ref : SingleDenotation )(implicit ctx : Context ): SingleDenotation = {
32+ val sym = ref.symbol
33+ ref match {
34+ case ref : SymDenotation if sym.isOpaqueHelper =>
35+ ref.copySymDenotation(
36+ info = TypeAlias (ref.opaqueAlias),
37+ initFlags = ref.flags &~ (Opaque | Deferred ))
38+ case ref : SymDenotation if sym.isOpaqueCompanion =>
39+ val ref1 = ref.copySymDenotation(initFlags = ref.flags &~ Opaque )
40+ ref1.registeredCompanion = NoSymbol
41+ ref1
42+ case _ if sym.isOpaqueHelper =>
43+ ref.derivedSingleDenotation(sym, TypeAlias (ref.info.extractOpaqueAlias))
44+ case _ =>
45+ ref
4546 }
46- else sym
47+ }
4748}
0 commit comments