Skip to content

Have derivedValueClass run at initial stage #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,12 @@ object Symbols {
def filter(p: Symbol => Boolean): Symbol = if (p(this)) this else NoSymbol

/** Is this symbol a user-defined value class? */
final def isDerivedValueClass(implicit ctx: Context): Boolean =
final def isDerivedValueClass(implicit ctx: Context): Boolean = {
this.derivesFrom(defn.AnyValClass)(ctx.withPhase(denot.validFor.firstPhaseId))
// Simulate ValueClasses.isDerivedValueClass
false // will migrate to ValueClasses.isDerivedValueClass;
// unsupported value class code will continue to use this stub while it exists
}

/** The current name of this symbol */
final def name(implicit ctx: Context): ThisName = denot.name.asInstanceOf[ThisName]
Expand Down
14 changes: 9 additions & 5 deletions src/dotty/tools/dotc/transform/ValueClasses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import Flags._
/** Methods that apply to user-defined value classes */
object ValueClasses {

def isDerivedValueClass(d: SymDenotation)(implicit ctx: Context) =
d.isClass &&
d.derivesFrom(defn.AnyValClass) &&
(d.symbol ne defn.AnyValClass) &&
!d.isPrimitiveValueClass
def isDerivedValueClass(d: SymDenotation)(implicit ctx: Context) = {
val di = d.initial.asSymDenotation
di.isClass &&
di.derivesFrom(defn.AnyValClass)(ctx.withPhase(di.validFor.firstPhaseId)) &&
// need to check derivesFrom at initialPhase to avoid cyclic references caused
// by forcing in transformInfo
(di.symbol ne defn.AnyValClass) &&
!di.isPrimitiveValueClass
}

def isMethodWithExtension(d: SymDenotation)(implicit ctx: Context) =
d.isSourceMethod &&
Expand Down