@@ -4,6 +4,7 @@ package core
4
4
5
5
import Contexts ._ , Symbols ._ , Types ._ , Flags ._ , Scopes ._ , Decorators ._ , Names ._ , NameOps ._
6
6
import SymDenotations .{LazyType , SymDenotation }, StdNames .nme
7
+ import TypeApplications .EtaExpansion
7
8
8
9
/** Operations that are shared between Namer and TreeUnpickler */
9
10
object NamerOps :
@@ -72,16 +73,23 @@ object NamerOps:
72
73
/** The flags of an `apply` method that serves as a constructor proxy */
73
74
val ApplyProxyFlags = Synthetic | ConstructorProxy | Inline | Method
74
75
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
+
75
85
/** Does symbol `sym` need constructor proxies to be generated? */
76
86
def needsConstructorProxies (sym : Symbol )(using Context ): Boolean =
77
87
sym.isClass
78
88
&& ! sym.flagsUNSAFE.isOneOf(NoConstructorProxyNeededFlags )
79
89
&& ! sym.isAnonymousClass
80
90
||
81
91
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
85
93
86
94
/** The completer of a constructor proxy apply method */
87
95
class ApplyProxyCompleter (constr : Symbol )(using Context ) extends LazyType :
@@ -152,7 +160,7 @@ object NamerOps:
152
160
then
153
161
classConstructorCompanion(mbr).entered
154
162
case _ =>
155
- mbr.info.loBound.underlyingClassRef(refinementOK = false ) match
163
+ underlyingStableClassRef( mbr.info.loBound) : @ unchecked match
156
164
case ref : TypeRef =>
157
165
val proxy = ref.symbol.registeredCompanion
158
166
if proxy.is(ConstructorProxy ) && ! memberExists(cls, mbr.name.toTermName) then
0 commit comments