@@ -90,14 +90,12 @@ object ProtoTypes {
90
90
*
91
91
* [ ].name: proto
92
92
*/
93
- abstract case class SelectionProto (val name : Name , val memberProto : Type , val compat : Compatibility )
93
+ abstract case class SelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )
94
94
extends CachedProxyType with ProtoType with ValueTypeOrProto {
95
95
96
96
override def isMatchedBy (tp1 : Type )(implicit ctx : Context ) = {
97
97
name == nme.WILDCARD || {
98
- val mbr =
99
- if (tp1.widen.classSymbol.isLinkedWith(ctx.owner.enclosingClass)) tp1.member(name)
100
- else tp1.nonPrivateMember(name)
98
+ val mbr = if (privateOK) tp1.member(name) else tp1.nonPrivateMember(name)
101
99
def qualifies (m : SingleDenotation ) =
102
100
memberProto.isRef(defn.UnitClass ) ||
103
101
compat.normalizedCompatible(m.info, memberProto)
@@ -112,11 +110,11 @@ object ProtoTypes {
112
110
113
111
def derivedSelectionProto (name : Name , memberProto : Type , compat : Compatibility )(implicit ctx : Context ) =
114
112
if ((name eq this .name) && (memberProto eq this .memberProto) && (compat eq this .compat)) this
115
- else SelectionProto (name, memberProto, compat)
113
+ else SelectionProto (name, memberProto, compat, privateOK )
116
114
117
115
override def equals (that : Any ): Boolean = that match {
118
116
case that : SelectionProto =>
119
- (name eq that.name) && (memberProto == that.memberProto) && (compat eq that.compat)
117
+ (name eq that.name) && (memberProto == that.memberProto) && (compat eq that.compat) && (privateOK == that.privateOK)
120
118
case _ =>
121
119
false
122
120
}
@@ -126,14 +124,18 @@ object ProtoTypes {
126
124
127
125
override def deepenProto (implicit ctx : Context ) = derivedSelectionProto(name, memberProto.deepenProto, compat)
128
126
129
- override def computeHash = addDelta(doHash(name, memberProto), if (compat eq NoViewsAllowed ) 1 else 0 )
127
+ override def computeHash = {
128
+ val delta = (if (compat eq NoViewsAllowed ) 1 else 0 ) | (if (privateOK) 2 else 0 )
129
+ addDelta(doHash(name, memberProto), delta)
130
+ }
130
131
}
131
132
132
- class CachedSelectionProto (name : Name , memberProto : Type , compat : Compatibility ) extends SelectionProto (name, memberProto, compat)
133
+ class CachedSelectionProto (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )
134
+ extends SelectionProto (name, memberProto, compat, privateOK)
133
135
134
136
object SelectionProto {
135
- def apply (name : Name , memberProto : Type , compat : Compatibility )(implicit ctx : Context ): SelectionProto = {
136
- val selproto = new CachedSelectionProto (name, memberProto, compat)
137
+ def apply (name : Name , memberProto : Type , compat : Compatibility , privateOK : Boolean )(implicit ctx : Context ): SelectionProto = {
138
+ val selproto = new CachedSelectionProto (name, memberProto, compat, privateOK )
137
139
if (compat eq NoViewsAllowed ) unique(selproto) else selproto
138
140
}
139
141
}
@@ -145,7 +147,7 @@ object ProtoTypes {
145
147
if (name.isConstructorName) WildcardType
146
148
else tp match {
147
149
case tp : UnapplyFunProto => new UnapplySelectionProto (name)
148
- case tp => SelectionProto (name, IgnoredProto (tp), typer)
150
+ case tp => SelectionProto (name, IgnoredProto (tp), typer, privateOK = true )
149
151
}
150
152
151
153
/** A prototype for expressions [] that are in some unspecified selection operation
@@ -156,10 +158,10 @@ object ProtoTypes {
156
158
* operation is further selection. In this case, the expression need not be a value.
157
159
* @see checkValue
158
160
*/
159
- @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed )
161
+ @ sharable object AnySelectionProto extends SelectionProto (nme.WILDCARD , WildcardType , NoViewsAllowed , true )
160
162
161
163
/** A prototype for selections in pattern constructors */
162
- class UnapplySelectionProto (name : Name ) extends SelectionProto (name, WildcardType , NoViewsAllowed )
164
+ class UnapplySelectionProto (name : Name ) extends SelectionProto (name, WildcardType , NoViewsAllowed , true )
163
165
164
166
trait ApplyingProto extends ProtoType
165
167
0 commit comments