Skip to content

Commit 5c01ada

Browse files
committed
Always compute asSeenFroms on opaque companion members
For a member of an opaque companion C, it makes a difference whether the prefix is C or C.this - opaque aliases are visible for C.this but not for C. So we can never omit an asSeenFrom on these members.
1 parent 5d7aabc commit 5c01ada

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,10 @@ object SymDenotations {
762762
*/
763763
def membersNeedAsSeenFrom(pre: Type)(implicit ctx: Context): Boolean =
764764
!( this.isTerm
765-
|| this.isStaticOwner
765+
|| this.isStaticOwner && !this.isOpaqueCompanion
766766
|| ctx.erasedTypes
767-
|| (pre eq NoPrefix) || (pre eq thisType)
767+
|| (pre eq NoPrefix)
768+
|| (pre eq thisType)
768769
)
769770

770771
/** Is this symbol concrete, or that symbol deferred? */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
5353
tp match {
5454
case tp: NamedType =>
5555
val sym = tp.symbol
56-
if (sym.isStatic || (tp.prefix `eq` NoPrefix)) tp
56+
if (sym.isStatic && !sym.maybeOwner.isOpaqueCompanion || (tp.prefix `eq` NoPrefix)) tp
5757
else derivedSelect(tp, atVariance(variance max 0)(this(tp.prefix)))
5858
case tp: ThisType =>
5959
toPrefix(pre, cls, tp.cls)

0 commit comments

Comments
 (0)