diff options
author | Martin Odersky <odersky@gmail.com> | 2016-07-15 14:28:11 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-07-15 14:28:18 +0200 |
commit | 7ec75f35e192a795945e889bf383ef02521e4b69 (patch) | |
tree | fcb36089c8bc80b06d843801cb3d418ad8df2338 /src | |
parent | b93ffa5cc46533cb8a74d19fbc46e0287cedecdd (diff) | |
download | dotty-7ec75f35e192a795945e889bf383ef02521e4b69.tar.gz dotty-7ec75f35e192a795945e889bf383ef02521e4b69.tar.bz2 dotty-7ec75f35e192a795945e889bf383ef02521e4b69.zip |
Refine disambiguation logic and add test case.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index e23e66b95..132f04aa9 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -305,6 +305,14 @@ object Denotations { !sym2.derivesFrom(sym1) && precedesIn(pre.baseClasses)) } + /** Similar to SymDenotation#accessBoundary, but without the special cases. */ + def accessBoundary(sym: Symbol) = + if (sym.is(Private)) sym.owner + else sym.privateWithin.orElse( + if (sym.is(Protected)) sym.owner.enclosingPackageClass + else defn.RootClass + ) + /** Establish a partial order "preference" order between symbols. * Give preference to `sym1` over `sym2` if one of the following * conditions holds, in decreasing order of weight: @@ -324,8 +332,7 @@ object Denotations { sym1.isAsConcrete(sym2) && (!sym2.isAsConcrete(sym1) || precedes(sym1.owner, sym2.owner) || - sym2.accessBoundary(sym2.enclosingPackageClass) - .isProperlyContainedIn(sym1.accessBoundary(sym1.enclosingPackageClass)) || + accessBoundary(sym2).isProperlyContainedIn(accessBoundary(sym1)) || sym1.is(Method) && !sym2.is(Method)) /** Sym preference provided types also override */ @@ -338,7 +345,11 @@ object Denotations { if (sym1Accessible && prefer(sym1, sym2, info1, info2)) denot1 else if (sym1Accessible && sym2.exists && !sym2Accessible) denot1 else if (sym2Accessible && sym1.exists && !sym1Accessible) denot2 - else if (isDoubleDef(sym1, sym2)) doubleDefError(denot1, denot2, pre) + else if (isDoubleDef(sym1, sym2)) { + if (preferSym(sym1, sym2)) denot1 + else if (preferSym(sym2, sym1)) denot2 + else doubleDefError(denot1, denot2, pre) + } else { val sym = if (!sym1.exists) sym2 |