@@ -4,7 +4,6 @@ package transform
4
4
import core ._
5
5
import Types ._
6
6
import Symbols ._
7
- import SymDenotations ._
8
7
import Contexts ._
9
8
import Flags ._
10
9
import StdNames ._
@@ -13,15 +12,14 @@ import SymUtils._
13
12
/** Methods that apply to user-defined value classes */
14
13
object ValueClasses {
15
14
16
- def isDerivedValueClass (d : SymDenotation )(implicit ctx : Context ): Boolean = {
15
+ def isDerivedValueClass (sym : Symbol )(implicit ctx : Context ): Boolean = {
16
+ val d = sym.denot
17
17
! ctx.settings.XnoValueClasses .value &&
18
18
! d.isRefinementClass &&
19
19
d.isValueClass &&
20
20
(d.initial.symbol ne defn.AnyValClass ) && // Compare the initial symbol because AnyVal does not exist after erasure
21
21
! d.isPrimitiveValueClass
22
22
}
23
- def isDerivedValueClass (sym : Symbol )(implicit ctx : Context ): Boolean =
24
- isDerivedValueClass(sym.denot)
25
23
26
24
def isMethodWithExtension (sym : Symbol )(implicit ctx : Context ) =
27
25
ctx.atPhaseNotLaterThan(ctx.extensionMethodsPhase) { implicit ctx =>
@@ -35,12 +33,9 @@ object ValueClasses {
35
33
}
36
34
37
35
/** The member of a derived value class that unboxes it. */
38
- def valueClassUnbox (d : ClassDenotation )(implicit ctx : Context ): Symbol =
39
- // (info.decl(nme.unbox)).orElse(...) uncomment once we accept unbox methods
40
- d.classInfo.decls.find(_.is(ParamAccessor ))
41
-
42
36
def valueClassUnbox (cls : ClassSymbol )(implicit ctx : Context ): Symbol =
43
- valueClassUnbox(cls.classDenot)
37
+ // (info.decl(nme.unbox)).orElse(...) uncomment once we accept unbox methods
38
+ cls.classInfo.decls.find(_.is(ParamAccessor ))
44
39
45
40
/** For a value class `d`, this returns the synthetic cast from the underlying type to
46
41
* ErasedValueType defined in the companion module. This method is added to the module
@@ -57,10 +52,8 @@ object ValueClasses {
57
52
d.linkedClass.info.decl(nme.EVT2U ).symbol
58
53
59
54
/** The unboxed type that underlies a derived value class */
60
- def underlyingOfValueClass (d : ClassDenotation )(implicit ctx : Context ): Type =
61
- valueClassUnbox(d).info.resultType
62
55
def underlyingOfValueClass (sym : ClassSymbol )(implicit ctx : Context ): Type =
63
- underlyingOfValueClass (sym.classDenot)
56
+ valueClassUnbox (sym).info.resultType
64
57
65
58
/** Whether a value class wraps itself */
66
59
def isCyclic (cls : ClassSymbol )(implicit ctx : Context ): Boolean = {
0 commit comments