@@ -14,6 +14,7 @@ import Decorators.*
14
14
import scala .collection .mutable
15
15
import DenotTransformers .*
16
16
import NameOps .*
17
+ import SymDenotations .SymDenotation
17
18
import NameKinds .OuterSelectName
18
19
import StdNames .*
19
20
import config .Feature
@@ -35,22 +36,26 @@ object FirstTransform {
35
36
* if (true) A else B ==> A
36
37
* if (false) A else B ==> B
37
38
*/
38
- class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
39
+ class FirstTransform extends MiniPhase with SymTransformer { thisPhase =>
39
40
import ast .tpd .*
40
41
41
42
override def phaseName : String = FirstTransform .name
42
43
43
44
override def description : String = FirstTransform .description
44
45
45
- /** eliminate self symbol in ClassInfo */
46
- override def transformInfo (tp : Type , sym : Symbol )(using Context ): Type = tp match {
47
- case tp @ ClassInfo (_, _, _, _, self : Symbol ) =>
48
- tp.derivedClassInfo(selfInfo = self.info)
49
- case _ =>
50
- tp
51
- }
52
-
53
- override protected def infoMayChange (sym : Symbol )(using Context ): Boolean = sym.isClass
46
+ /** eliminate self symbol in ClassInfo, reset Deferred for @native methods */
47
+ override def transformSym (sym : SymDenotation )(using Context ): SymDenotation =
48
+ if sym.isClass then
49
+ sym.info match
50
+ case tp @ ClassInfo (_, _, _, _, self : Symbol ) =>
51
+ val info1 = tp.derivedClassInfo(selfInfo = self.info)
52
+ sym.copySymDenotation(info = info1).copyCaches(sym, ctx.phase.next)
53
+ case _ =>
54
+ sym
55
+ else if sym.isAllOf(DeferredMethod ) && sym.hasAnnotation(defn.NativeAnnot ) then
56
+ sym.copySymDenotation(initFlags = sym.flags &~ Deferred )
57
+ else
58
+ sym
54
59
55
60
override def checkPostCondition (tree : Tree )(using Context ): Unit =
56
61
tree match {
@@ -121,7 +126,6 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
121
126
override def transformDefDef (ddef : DefDef )(using Context ): Tree =
122
127
val meth = ddef.symbol.asTerm
123
128
if meth.hasAnnotation(defn.NativeAnnot ) then
124
- meth.resetFlag(Deferred )
125
129
DefDef (meth, _ =>
126
130
ref(defn.Sys_error .termRef).withSpan(ddef.span)
127
131
.appliedTo(Literal (Constant (s " native method stub " ))))
0 commit comments