Skip to content

Commit

Permalink
Adaptations to checkSymAssign
Browse files Browse the repository at this point in the history
(1) Also allow symbols to switch between a member of a class
    and a member of its selftype. Seen in the wild in TraversableViewLike.scala.
    Test case in pickling/selfSym.scala

(2) Tidy up the error message.
  • Loading branch information
odersky committed Dec 14, 2015
1 parent ac99941 commit 8203177
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1387,7 +1387,7 @@ object Types {
}

private def checkSymAssign(sym: Symbol)(implicit ctx: Context) = {
def ownerSelfType = sym.owner.info match {
def selfTypeOf(sym: Symbol) = sym.owner.info match {
case info: ClassInfo => info.givenSelfType
case _ => NoType
}
Expand All @@ -1404,8 +1404,13 @@ object Types {
(lastSymbol.infoOrCompleter == ErrorType ||
sym.owner != lastSymbol.owner &&
(sym.owner.derivesFrom(lastSymbol.owner) ||
ownerSelfType.derivesFrom(lastSymbol.owner))),
s"data race? overwriting symbol of ${this.show} / $this / ${this.getClass} / ${lastSymbol.id} / ${sym.id} / ${lastSymbol.owner} / ${sym.owner} / ${ctx.phase} at run ${ctx.runId}")
selfTypeOf(sym).derivesFrom(lastSymbol.owner) ||
selfTypeOf(lastSymbol).derivesFrom(sym.owner))),
s"""data race? overwriting symbol of type ${this.show},
|long form = $this of class ${this.getClass},
|last sym id = ${lastSymbol.id}, new sym id = ${sym.id},
|last owner = ${lastSymbol.owner}, new owner = ${sym.owner},
|period = ${ctx.phase} at run ${ctx.runId}""".stripMargin)
}

protected def sig: Signature = Signature.NotAMethod
Expand Down

0 comments on commit 8203177

Please sign in to comment.