@@ -4,6 +4,7 @@ package core
44
55import Contexts ._ , Symbols ._ , Types ._ , Flags ._ , Scopes ._ , Decorators ._ , Names ._ , NameOps ._
66import SymDenotations .{LazyType , SymDenotation }, StdNames .nme
7+ import TypeApplications .EtaExpansion
78
89/** Operations that are shared between Namer and TreeUnpickler */
910object NamerOps :
@@ -72,16 +73,23 @@ object NamerOps:
7273 /** The flags of an `apply` method that serves as a constructor proxy */
7374 val ApplyProxyFlags = Synthetic | ConstructorProxy | Inline | Method
7475
76+ /** If this is a reference to a class and the reference has a stable prefix, the reference
77+ * otherwise NoType
78+ */
79+ private def underlyingStableClassRef (tp : Type )(using Context ): TypeRef | NoType .type = tp match
80+ case EtaExpansion (tp1) => underlyingStableClassRef(tp1)
81+ case _ => tp.underlyingClassRef(refinementOK = false ) match
82+ case ref : TypeRef if ref.prefix.isStable => ref
83+ case _ => NoType
84+
7585 /** Does symbol `sym` need constructor proxies to be generated? */
7686 def needsConstructorProxies (sym : Symbol )(using Context ): Boolean =
7787 sym.isClass
7888 && ! sym.flagsUNSAFE.isOneOf(NoConstructorProxyNeededFlags )
7989 && ! sym.isAnonymousClass
8090 ||
8191 sym.isType && sym.is(Exported )
82- && sym.info.loBound.underlyingClassRef(refinementOK = false ).match
83- case tref : TypeRef => tref.prefix.isStable
84- case _ => false
92+ && underlyingStableClassRef(sym.info.loBound).exists
8593
8694 /** The completer of a constructor proxy apply method */
8795 class ApplyProxyCompleter (constr : Symbol )(using Context ) extends LazyType :
@@ -152,7 +160,7 @@ object NamerOps:
152160 then
153161 classConstructorCompanion(mbr).entered
154162 case _ =>
155- mbr.info.loBound.underlyingClassRef(refinementOK = false ) match
163+ underlyingStableClassRef( mbr.info.loBound) : @ unchecked match
156164 case ref : TypeRef =>
157165 val proxy = ref.symbol.registeredCompanion
158166 if proxy.is(ConstructorProxy ) && ! memberExists(cls, mbr.name.toTermName) then
0 commit comments