Skip to content

Commit 53865ff

Browse files
oderskyallanrenucci
authored andcommitted
Make ValueClass operations take Symbols, not SymDenotations
1 parent 1dce677 commit 53865ff

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

compiler/src/dotty/tools/dotc/transform/TreeExtractors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ object TreeExtractors {
3636
object ValueClassUnbox {
3737
def unapply(t: Tree)(implicit ctx: Context): Option[Tree] = t match {
3838
case Apply(sel @ Select(ref, _), Nil) =>
39-
val d = ref.tpe.widenDealias.typeSymbol.denot
40-
if (isDerivedValueClass(d) && (sel.symbol eq valueClassUnbox(d.asClass))) {
39+
val sym = ref.tpe.widenDealias.typeSymbol
40+
if (isDerivedValueClass(sym) && (sel.symbol eq valueClassUnbox(sym.asClass))) {
4141
Some(ref)
4242
} else
4343
None

compiler/src/dotty/tools/dotc/transform/ValueClasses.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package transform
44
import core._
55
import Types._
66
import Symbols._
7-
import SymDenotations._
87
import Contexts._
98
import Flags._
109
import StdNames._
@@ -13,7 +12,8 @@ import SymUtils._
1312
/** Methods that apply to user-defined value classes */
1413
object ValueClasses {
1514

16-
def isDerivedValueClass(d: SymDenotation)(implicit ctx: Context) = {
15+
def isDerivedValueClass(sym: Symbol)(implicit ctx: Context): Boolean = {
16+
val d = sym.denot
1717
!ctx.settings.XnoValueClasses.value &&
1818
!d.isRefinementClass &&
1919
d.isValueClass &&
@@ -33,27 +33,27 @@ object ValueClasses {
3333
}
3434

3535
/** The member of a derived value class that unboxes it. */
36-
def valueClassUnbox(d: ClassDenotation)(implicit ctx: Context): Symbol =
36+
def valueClassUnbox(cls: ClassSymbol)(implicit ctx: Context): Symbol =
3737
// (info.decl(nme.unbox)).orElse(...) uncomment once we accept unbox methods
38-
d.classInfo.decls.find(_.is(ParamAccessor))
38+
cls.classInfo.decls.find(_.is(ParamAccessor))
3939

4040
/** For a value class `d`, this returns the synthetic cast from the underlying type to
4141
* ErasedValueType defined in the companion module. This method is added to the module
4242
* and further described in [[ExtensionMethods]].
4343
*/
44-
def u2evt(d: ClassDenotation)(implicit ctx: Context): Symbol =
45-
d.linkedClass.info.decl(nme.U2EVT).symbol
44+
def u2evt(cls: ClassSymbol)(implicit ctx: Context): Symbol =
45+
cls.linkedClass.info.decl(nme.U2EVT).symbol
4646

4747
/** For a value class `d`, this returns the synthetic cast from ErasedValueType to the
4848
* underlying type defined in the companion module. This method is added to the module
4949
* and further described in [[ExtensionMethods]].
5050
*/
51-
def evt2u(d: ClassDenotation)(implicit ctx: Context): Symbol =
52-
d.linkedClass.info.decl(nme.EVT2U).symbol
51+
def evt2u(cls: ClassSymbol)(implicit ctx: Context): Symbol =
52+
cls.linkedClass.info.decl(nme.EVT2U).symbol
5353

5454
/** The unboxed type that underlies a derived value class */
55-
def underlyingOfValueClass(d: ClassDenotation)(implicit ctx: Context): Type =
56-
valueClassUnbox(d).info.resultType
55+
def underlyingOfValueClass(sym: ClassSymbol)(implicit ctx: Context): Type =
56+
valueClassUnbox(sym).info.resultType
5757

5858
/** Whether a value class wraps itself */
5959
def isCyclic(cls: ClassSymbol)(implicit ctx: Context): Boolean = {

0 commit comments

Comments
 (0)