From a93cdf4077003dad3428a4af34ba30c3d812dc78 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Jan 2016 15:53:07 +0100 Subject: [PATCH 1/5] Avoid repeated evaluations of parentIsYounger. --- src/dotty/tools/dotc/core/SymDenotations.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index d384bd5c4951..d1abfbfb6f77 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1250,8 +1250,8 @@ object SymDenotations { if (parentIsYounger) { incremental.println(s"parents of $this are invalid; symbol id = ${symbol.id}, copying ...\n") invalidateInheritedInfo() - firstRunId = ctx.runId } + firstRunId = ctx.runId this } From 3686713abe506f5d815fd850e9db012497b1aa5c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Jan 2016 16:36:50 +0100 Subject: [PATCH 2/5] Don't force symbol denotation when taking fingerprint. --- src/dotty/tools/dotc/config/Config.scala | 2 +- src/dotty/tools/dotc/core/SymDenotations.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dotty/tools/dotc/config/Config.scala b/src/dotty/tools/dotc/config/Config.scala index cf43d277ea2c..212defbbf003 100644 --- a/src/dotty/tools/dotc/config/Config.scala +++ b/src/dotty/tools/dotc/config/Config.scala @@ -4,7 +4,7 @@ object Config { final val cacheMembersNamed = true final val cacheAsSeenFrom = true - final val useFingerPrints = true + final val useFingerPrints = true // note: it currently seems to be slightly faster not to use them! my junit test: 548s without, 560s with. final val cacheMemberNames = true final val cacheImplicitScopes = true diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index d1abfbfb6f77..ac4c870a6ab6 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -1384,7 +1384,7 @@ object SymDenotations { var fp = FingerPrint() var e = info.decls.lastEntry while (e != null) { - fp.include(e.sym.name) + fp.include(e.name) e = e.prev } var ps = classParents From 0ae58a58498d4659e4877f6c3dd836c22e90013d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Jan 2016 18:28:49 +0100 Subject: [PATCH 3/5] Small refactoring --- src/dotty/tools/dotc/core/Types.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index cc81b95580f8..e266bab6f482 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -406,14 +406,17 @@ object Types { /** The member of this type with the given name */ final def member(name: Name)(implicit ctx: Context): Denotation = /*>|>*/ track("member") /*<|<*/ { - findMember(name, widenIfUnstable, EmptyFlags) + memberExcluding(name, EmptyFlags) } /** The non-private member of this type with the given name. */ final def nonPrivateMember(name: Name)(implicit ctx: Context): Denotation = track("nonPrivateMember") { - findMember(name, widenIfUnstable, Flags.Private) + memberExcluding(name, Flags.Private) } + final def memberExcluding(name: Name, excluding: FlagSet)(implicit ctx: Context): Denotation = + findMember(name, widenIfUnstable, excluding) + /** Find member of this type with given name and * produce a denotation that contains the type of the member * as seen from given prefix `pre`. Exclude all members that have From 5e9a40a45503eab81d58368ab7f26de7fbe458ba Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Jan 2016 18:29:33 +0100 Subject: [PATCH 4/5] Perform isCurrent at transform phase instead of the one after it. Fixes problem with t7475b.scala --- src/dotty/tools/dotc/transform/MixinOps.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/dotty/tools/dotc/transform/MixinOps.scala b/src/dotty/tools/dotc/transform/MixinOps.scala index f56c83f96469..db89f939bf7f 100644 --- a/src/dotty/tools/dotc/transform/MixinOps.scala +++ b/src/dotty/tools/dotc/transform/MixinOps.scala @@ -34,9 +34,14 @@ class MixinOps(cls: ClassSymbol, thisTransform: DenotTransformer)(implicit ctx: //sup.select(target) } - /** Is `sym` a member of implementing class `cls`? */ - def isCurrent(sym: Symbol) = cls.info.member(sym.name).hasAltWith(_.symbol == sym) - + /** Is `sym` a member of implementing class `cls`? + * The test is performed at phase `thisTransform`. + */ + def isCurrent(sym: Symbol) = + ctx.atPhase(thisTransform) { implicit ctx => + cls.info.member(sym.name).hasAltWith(_.symbol == sym) + } + def needsForwarder(meth: Symbol): Boolean = { lazy val overridenSymbols = meth.allOverriddenSymbols def needsDisambiguation = !overridenSymbols.forall(_ is Deferred) From 2042adc79cff35cdafef4130b74ed90d0d5841bf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 19 Jan 2016 19:13:31 +0100 Subject: [PATCH 5/5] Extend test We verified that before the combination abstract/concrete for `x` also led to AMEs. So we test it here explicitly, too. --- tests/run/t7475b.check | 2 ++ tests/run/t7475b.scala | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tests/run/t7475b.check b/tests/run/t7475b.check index 51993f072d58..487b1165348b 100644 --- a/tests/run/t7475b.check +++ b/tests/run/t7475b.check @@ -1,2 +1,4 @@ 2 2 +2 +2 diff --git a/tests/run/t7475b.scala b/tests/run/t7475b.scala index a205602b6d78..d3b0435b0525 100644 --- a/tests/run/t7475b.scala +++ b/tests/run/t7475b.scala @@ -1,11 +1,16 @@ trait A { private val x = 1 } trait B { val x = 2 } +trait C { val x: Int } trait C1 extends B with A { println(x) } trait C2 extends A with B { println(x) } +trait C3 extends C with B { println(x) } +trait C4 extends B with C { println(x) } object Test { def main(args: Array[String]): Unit = { new C1 { } new C2 { } + new C3 { } + new C4 { } } }