@@ -116,40 +116,43 @@ class Typer extends Namer with Applications with Implicits {
116
116
* current context. Return the type with those alternatives as denotations
117
117
* which are accessible.
118
118
*/
119
- def checkAccessible (tpe : Type , superAccess : Boolean , pos : Position )(implicit ctx : Context ): Type = tpe match {
120
- case tpe : NamedType =>
121
- val pre = tpe.prefix
122
- val name = tpe.name
123
- val d = tpe.denot.accessibleFrom(pre, superAccess)
124
- if (! d.exists) {
125
- val d2 = pre.nonPrivateMember(name)
126
- if (reallyExists(d2) && (d2 ne tpe.denot))
127
- checkAccessible(pre.select(name, d2), superAccess, pos)
128
- else {
129
- val alts = tpe.denot.alternatives.map(_.symbol).filter(_.exists)
130
- val what = alts match {
131
- case Nil =>
132
- name.toString
133
- case sym :: Nil =>
134
- if (sym.owner == pre.typeSymbol) sym.show else sym.showLocated
135
- case _ =>
136
- i " none of the overloaded alternatives named $name"
119
+ def checkAccessible (tpe : Type , superAccess : Boolean , pos : Position )(implicit ctx : Context ): Type = {
120
+ def test (tpe : Type , firstTry : Boolean ): Type = tpe match {
121
+ case tpe : NamedType =>
122
+ val pre = tpe.prefix
123
+ val name = tpe.name
124
+ val d = tpe.denot.accessibleFrom(pre, superAccess)
125
+ if (! d.exists) {
126
+ // it could be that we found an inaccessbile private member, but there is
127
+ // an inherited non-private member with the same name and signature.
128
+ val d2 = pre.nonPrivateMember(name)
129
+ if (reallyExists(d2) && firstTry) test(pre.select(name, d2), false )
130
+ else {
131
+ val alts = tpe.denot.alternatives.map(_.symbol).filter(_.exists)
132
+ val what = alts match {
133
+ case Nil =>
134
+ name.toString
135
+ case sym :: Nil =>
136
+ if (sym.owner == pre.typeSymbol) sym.show else sym.showLocated
137
+ case _ =>
138
+ i " none of the overloaded alternatives named $name"
139
+ }
140
+ val where = if (ctx.owner.exists) s " from ${ctx.owner.enclosingClass}" else " "
141
+ val whyNot = new StringBuffer
142
+ val addendum =
143
+ alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot))
144
+ if (! tpe.isError)
145
+ ctx.error(i " $what cannot be accessed as a member of $pre$where. $whyNot" , pos)
146
+ ErrorType
137
147
}
138
- val where = if (ctx.owner.exists) s " from ${ctx.owner.enclosingClass}" else " "
139
- val whyNot = new StringBuffer
140
- val addendum =
141
- alts foreach (_.isAccessibleFrom(pre, superAccess, whyNot))
142
- if (! tpe.isError)
143
- ctx.error(i " $what cannot be accessed as a member of $pre$where. $whyNot" , pos)
144
- ErrorType
145
- }
146
- }
147
- else if (d.symbol is TypeParamAccessor ) // always dereference type param accessors
148
- checkAccessible(d.info.bounds.hi, superAccess, pos)
149
- else
150
- tpe withDenot d
151
- case _ =>
152
- tpe
148
+ } else if (d.symbol is TypeParamAccessor ) // always dereference type param accessors
149
+ checkAccessible(d.info.bounds.hi, superAccess, pos)
150
+ else
151
+ tpe withDenot d
152
+ case _ =>
153
+ tpe
154
+ }
155
+ test(tpe, true )
153
156
}
154
157
155
158
/** The enclosing class, except if we are in a super call, in which case
0 commit comments