Skip to content

Commit 5fc95dd

Browse files
committed
Address most of review comments
1 parent 86e8779 commit 5fc95dd

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -530,18 +530,6 @@ object Symbols {
530530
/** The current name of this symbol */
531531
final def name(implicit ctx: Context): ThisName = denot.name.asInstanceOf[ThisName]
532532

533-
def isHigherOrderTypeParameter(implicit ctx: Context): Boolean = this.maybeOwner.isTypeParameterOrSkolem
534-
def isTypeParameterOrSkolem(implicit ctx: Context): Boolean = this.isTypeParam
535-
def enclClassChain(implicit ctx: Context): List[Symbol] = this.maybeOwner.enclClassChain
536-
final def isDerivedValueClass(implicit ctx: Context): Boolean =
537-
isClass && !denot.is(Flags.Package) && !denot.is(Flags.Trait) &&
538-
!ctx.phase.erasedTypes && denot.info.firstParent.typeSymbol == defn.AnyValClass && !denot.isPrimitiveValueClass
539-
540-
/** If this is a derived value class, return its unbox method
541-
* or NoSymbol if it does not exist.
542-
*/
543-
def derivedValueClassUnbox(implicit ctx: Context): Symbol = NoSymbol
544-
545533
/** The source or class file from which this class or
546534
* the class containing this symbol was generated, null if not applicable.
547535
* Overridden in ClassSymbol
@@ -648,30 +636,17 @@ object Symbols {
648636
denot.asInstanceOf[ClassDenotation]
649637

650638
override protected def prefixString = "ClassSymbol"
651-
652-
override def enclClassChain(implicit ctx: Context): List[Symbol] =
653-
if (this.is(Flags.PackageClass)) Nil
654-
else this :: denot.owner.enclClassChain
655-
656-
override def derivedValueClassUnbox(implicit ctx: Context): Symbol =
657-
// (info.decl(nme.unbox)) orElse uncomment once we accept unbox methods
658-
(denot.info.decls.find(_.denot.is(Flags.ParamAccessor | Flags.Method)))
659-
660639
}
661640

662641
class ErrorSymbol(val underlying: Symbol, msg: => String)(implicit ctx: Context) extends Symbol(NoCoord, ctx.nextId) {
663642
type ThisName = underlying.ThisName
664643
denot = underlying.denot
665-
666-
override def enclClassChain(implicit ctx: Context): List[Symbol] = Nil
667644
}
668645

669646
@sharable object NoSymbol extends Symbol(NoCoord, 0) {
670647
denot = NoDenotation
671648
override def associatedFile(implicit ctx: Context): AbstractFile = NoSource.file
672649
override def recomputeDenot(lastd: SymDenotation)(implicit ctx: Context): SymDenotation = NoDenotation
673-
674-
override def enclClassChain(implicit ctx: Context): List[Symbol] = Nil
675650
}
676651

677652
implicit class Copier[N <: Name](sym: Symbol { type ThisName = N })(implicit ctx: Context) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ object Erasure {
751751
case GenericArray(level, core) if !(core <:< defn.AnyRefType) =>
752752
level
753753
case AndType(tp1, tp2) =>
754-
Math.max(unboundedGenericArrayLevel(tp1), unboundedGenericArrayLevel(tp2))
754+
unboundedGenericArrayLevel(tp1) max unboundedGenericArrayLevel(tp2)
755755
case _ =>
756756
0
757757
}
@@ -761,15 +761,15 @@ object Erasure {
761761
// * type parameters appearing in method parameters
762762
// * type members not visible in an enclosing template
763763
private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol)(implicit ctx: Context) = {
764-
!sym.isHigherOrderTypeParameter &&
765-
sym.isTypeParameterOrSkolem && (
766-
(initialSymbol.enclClassChain.exists(sym isContainedIn _)) ||
764+
!sym.maybeOwner.isTypeParam &&
765+
sym.isTypeParam && (
766+
sym.isContainedIn(initialSymbol.topLevelClass) ||
767767
(initialSymbol.is(Flags.Method) && initialSymbol.typeParams.contains(sym))
768768
)
769769
}
770770

771771
final def javaSig(sym0: Symbol, info: Type)(implicit ctx: Context): Option[String] =
772-
ctx.atPhase(ctx.erasurePhase) { implicit ctx => javaSig0(sym0, info) }
772+
javaSig0(sym0, info)(ctx.withPhase(ctx.erasurePhase))
773773

774774
@noinline
775775
private final def javaSig0(sym0: Symbol, info: Type)(implicit ctx: Context): Option[String] = {
@@ -945,9 +945,9 @@ object Erasure {
945945
else if (sym == defn.UnitClass) jsig(defn.BoxedUnitType)
946946
else builder.append(sym.info.toTag)
947947
}
948-
else if (sym.isDerivedValueClass) {
949-
val unboxed = sym.derivedValueClassUnbox.info.finalResultType
950-
val unboxedSeen = (tp.memberInfo(sym.derivedValueClassUnbox)).finalResultType
948+
else if (ValueClasses.isDerivedValueClass(sym)) {
949+
val unboxed = ValueClasses.valueClassUnbox(sym.asClass).info.finalResultType
950+
val unboxedSeen = tp.memberInfo(ValueClasses.valueClassUnbox(sym.asClass)).finalResultType
951951
if (unboxedSeen.isPrimitiveValueType && !primitiveOK)
952952
classSig
953953
else

0 commit comments

Comments
 (0)