Skip to content

Commit 6780dbd

Browse files
committed
Make data race detection more liberal.
Allow to rebind a NmedType to refer to a symbol in a subclass of where the previous symbol was defined. This generalizes the previous rule that we allow to rebind from a root method to its synthetic implementation. The change is not necessary to make the new scheme of computeDenot pass the tests, but it seems useful to avoid spurious errors elsehere.
1 parent cfa2ba0 commit 6780dbd

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ class Definitions {
451451

452452
lazy val RootImports = List[Symbol](JavaLangPackageVal, ScalaPackageVal, ScalaPredefModule, DottyPredefModule)
453453

454-
lazy val overriddenBySynthetic = Set[Symbol](Any_equals, Any_hashCode, Any_toString, Product_canEqual)
455454
def isTupleType(tp: Type)(implicit ctx: Context) = {
456455
val arity = tp.dealias.argInfos.length
457456
arity <= MaxTupleArity && (tp isRef TupleClass(arity))

src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,9 +1283,7 @@ object Types {
12831283
(lastDefRunId == NoRunId)
12841284
} ||
12851285
(lastSymbol.infoOrCompleter == ErrorType ||
1286-
defn.overriddenBySynthetic.contains(lastSymbol)
1287-
// for overriddenBySynthetic symbols a TermRef such as SomeCaseClass.this.hashCode
1288-
// might be rewritten from Object#hashCode to the hashCode generated at SyntheticMethods
1286+
sym.owner.derivesFrom(lastSymbol.owner) && sym.owner != lastSymbol.owner
12891287
),
12901288
s"data race? overwriting symbol of ${this.show} / $this / ${this.getClass} / ${lastSymbol.id} / ${sym.id} / ${sym.owner} / ${lastSymbol.owner} / ${ctx.phase}")
12911289

0 commit comments

Comments
 (0)