aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-05-04 21:20:38 +0200
committerMartin Odersky <odersky@gmail.com>2015-05-04 21:20:47 +0200
commit6780dbd0a66fdaec6a7be2faac78620e8922cbd4 (patch)
tree136404b6503bc36ff23d6ed7728e0143987dccf3
parentcfa2ba030becec1f0e12994f120b65ca5e99badb (diff)
downloaddotty-6780dbd0a66fdaec6a7be2faac78620e8922cbd4.tar.gz
dotty-6780dbd0a66fdaec6a7be2faac78620e8922cbd4.tar.bz2
dotty-6780dbd0a66fdaec6a7be2faac78620e8922cbd4.zip
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.
-rw-r--r--src/dotty/tools/dotc/core/Definitions.scala1
-rw-r--r--src/dotty/tools/dotc/core/Types.scala4
2 files changed, 1 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Definitions.scala b/src/dotty/tools/dotc/core/Definitions.scala
index 784773fd3..c21620048 100644
--- a/src/dotty/tools/dotc/core/Definitions.scala
+++ b/src/dotty/tools/dotc/core/Definitions.scala
@@ -451,7 +451,6 @@ class Definitions {
lazy val RootImports = List[Symbol](JavaLangPackageVal, ScalaPackageVal, ScalaPredefModule, DottyPredefModule)
- lazy val overriddenBySynthetic = Set[Symbol](Any_equals, Any_hashCode, Any_toString, Product_canEqual)
def isTupleType(tp: Type)(implicit ctx: Context) = {
val arity = tp.dealias.argInfos.length
arity <= MaxTupleArity && (tp isRef TupleClass(arity))
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 60255bd72..97e3f0390 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1283,9 +1283,7 @@ object Types {
(lastDefRunId == NoRunId)
} ||
(lastSymbol.infoOrCompleter == ErrorType ||
- defn.overriddenBySynthetic.contains(lastSymbol)
- // for overriddenBySynthetic symbols a TermRef such as SomeCaseClass.this.hashCode
- // might be rewritten from Object#hashCode to the hashCode generated at SyntheticMethods
+ sym.owner.derivesFrom(lastSymbol.owner) && sym.owner != lastSymbol.owner
),
s"data race? overwriting symbol of ${this.show} / $this / ${this.getClass} / ${lastSymbol.id} / ${sym.id} / ${sym.owner} / ${lastSymbol.owner} / ${ctx.phase}")