@@ -2,32 +2,23 @@ package dotty.tools.dotc
2
2
package transform
3
3
4
4
import core ._
5
- import Names ._
6
5
import dotty .tools .dotc .transform .MegaPhase ._
7
- import ast .Trees ._
8
- import ast .untpd
9
6
import Flags ._
10
7
import Types ._
11
- import Constants .Constant
12
8
import Contexts .Context
13
9
import Symbols ._
14
10
import Decorators ._
15
- import Annotations ._
16
- import Annotations .ConcreteAnnotation
17
11
import Denotations .SingleDenotation
18
12
import SymDenotations .SymDenotation
19
- import scala .collection .mutable
20
13
import DenotTransformers ._
21
- import NameOps ._
22
- import NameKinds .OuterSelectName
23
- import StdNames ._
14
+ import TypeUtils ._
24
15
25
16
object ElimOpaque {
26
17
val name : String = " elimOpaque"
27
18
}
28
19
29
20
/** Rewrites opaque type aliases to normal alias types */
30
- class ElimOpaque extends MiniPhase with SymTransformer {
21
+ class ElimOpaque extends MiniPhase with DenotTransformer {
31
22
32
23
override def phaseName : String = ElimOpaque .name
33
24
@@ -37,11 +28,21 @@ class ElimOpaque extends MiniPhase with SymTransformer {
37
28
// base types of opaque aliases change
38
29
override def changesBaseTypes = true
39
30
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
45
46
}
46
- else sym
47
+ }
47
48
}
0 commit comments