Skip to content

Commit ce61070

Browse files
authored
Merge pull request #10982 from dotty-staging/fix-#9352
Refine criterion when we can skip an asSeenFrom
2 parents 87102a0 + ebcb04d commit ce61070

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,16 @@ object Denotations {
10631063
info.asSeenFrom(pre, owner),
10641064
if (symbol.is(Opaque) || this.prefix != NoPrefix) pre else this.prefix)
10651065

1066-
if (!owner.membersNeedAsSeenFrom(pre) || symbol.is(NonMember)) this
1066+
// Tt could happen that we see the symbol with prefix `this` as a member a different class
1067+
// through a self type and that it then has a different info. In this case we have to go
1068+
// through the asSeenFrom to switch the type back. Test case is pos/i9352.scala.
1069+
def hasOriginalInfo: Boolean = this match
1070+
case sd: SymDenotation => true
1071+
case _ => info eq symbol.info
1072+
1073+
if !owner.membersNeedAsSeenFrom(pre) && ((pre ne owner.thisType) || hasOriginalInfo)
1074+
|| symbol.is(NonMember)
1075+
then this
10671076
else derived(symbol.info)
10681077
}
10691078
}

tests/pos/i9352.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
abstract class Foo[B] extends Bar[B]
2+
3+
trait Bar[A]:
4+
self: Foo[A] =>
5+
6+
def foo : Unit = bar(???)
7+
def bar(f: A) : Unit
8+

0 commit comments

Comments
 (0)