File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -957,6 +957,10 @@ object SymDenotations {
957
957
else
958
958
companionNamed(name)(ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next)
959
959
960
+ /** Is this symbol the same or a linked class of `sym`? */
961
+ final def isLinkedWith (sym : Symbol )(implicit ctx : Context ): Boolean =
962
+ (symbol eq sym) || (linkedClass eq sym)
963
+
960
964
/** If this is a class, the module class of its companion object.
961
965
* If this is a module class, its companion class.
962
966
* NoSymbol otherwise.
Original file line number Diff line number Diff line change @@ -215,13 +215,13 @@ object TypeErasure {
215
215
}
216
216
217
217
/** The erased least upper bound is computed as follows
218
- * - if both argument are arrays of objects, an array of the lub of the element types
218
+ * - if both argument are arrays of objects, an array of the erased lub of the element types
219
219
* - if both arguments are arrays of same primitives, an array of this primitive
220
220
* - if one argument is array of primitives and the other is array of objects, Object
221
221
* - if one argument is an array, Object
222
222
* - otherwise a common superclass or trait S of the argument classes, with the
223
223
* following two properties:
224
- * S is minimal: no other common superclass or trait derives from S]
224
+ * S is minimal: no other common superclass or trait derives from S
225
225
* S is last : in the linearization of the first argument type `tp1`
226
226
* there are no minimal common superclasses or traits that
227
227
* come after S.
Original file line number Diff line number Diff line change @@ -95,7 +95,9 @@ object ProtoTypes {
95
95
96
96
override def isMatchedBy (tp1 : Type )(implicit ctx : Context ) = {
97
97
name == nme.WILDCARD || {
98
- val mbr = tp1.member(name)
98
+ val mbr =
99
+ if (tp1.widen.classSymbol.isLinkedWith(ctx.owner.enclosingClass)) tp1.member(name)
100
+ else tp1.nonPrivateMember(name)
99
101
def qualifies (m : SingleDenotation ) =
100
102
memberProto.isRef(defn.UnitClass ) ||
101
103
compat.normalizedCompatible(m.info, memberProto)
Original file line number Diff line number Diff line change
1
+ class Foo
2
+
3
+ object Test {
4
+ implicit class One (x : Foo ) {
5
+ def meth : Unit = {}
6
+ }
7
+
8
+ implicit class Two (x : Foo ) {
9
+ private def meth : Unit = {}
10
+ }
11
+
12
+ def test (foo : Foo ): Unit = {
13
+ foo.meth
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments