Skip to content

Commit 7b7d499

Browse files
committed
Address most of review comments
1 parent 83e90dc commit 7b7d499

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
@@ -531,18 +531,6 @@ object Symbols {
531531
/** The current name of this symbol */
532532
final def name(implicit ctx: Context): ThisName = denot.name.asInstanceOf[ThisName]
533533

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

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

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

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

678653
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
@@ -750,7 +750,7 @@ object Erasure {
750750
case GenericArray(level, core) if !(core <:< defn.AnyRefType) =>
751751
level
752752
case AndType(tp1, tp2) =>
753-
Math.max(unboundedGenericArrayLevel(tp1), unboundedGenericArrayLevel(tp2))
753+
unboundedGenericArrayLevel(tp1) max unboundedGenericArrayLevel(tp2)
754754
case _ =>
755755
0
756756
}
@@ -760,15 +760,15 @@ object Erasure {
760760
// * type parameters appearing in method parameters
761761
// * type members not visible in an enclosing template
762762
private def isTypeParameterInSig(sym: Symbol, initialSymbol: Symbol)(implicit ctx: Context) = {
763-
!sym.isHigherOrderTypeParameter &&
764-
sym.isTypeParameterOrSkolem && (
765-
(initialSymbol.enclClassChain.exists(sym isContainedIn _)) ||
763+
!sym.maybeOwner.isTypeParam &&
764+
sym.isTypeParam && (
765+
sym.isContainedIn(initialSymbol.topLevelClass) ||
766766
(initialSymbol.is(Flags.Method) && initialSymbol.typeParams.contains(sym))
767767
)
768768
}
769769

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

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

0 commit comments

Comments
 (0)