@@ -34,7 +34,7 @@ object ContextOps:
34
34
if (elem.name == name) return elem.sym.denot // return self
35
35
}
36
36
val pre = ctx.owner.thisType
37
- if ctx.isJava then javaFindMember(name, pre, required, excluded)
37
+ if ctx.isJava then javaFindMember(name, pre, lookInCompanion = true , required, excluded)
38
38
else pre.findMember(name, pre, required, excluded)
39
39
}
40
40
else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext.
@@ -43,7 +43,10 @@ object ContextOps:
43
43
ctx.scope.denotsNamed(name).filterWithFlags(required, excluded).toDenot(NoPrefix )
44
44
}
45
45
46
- final def javaFindMember (name : Name , pre : Type , required : FlagSet = EmptyFlags , excluded : FlagSet = EmptyFlags ): Denotation =
46
+ /** Look in the prefix with Java semantics.
47
+ * @param lookInCompanion If true, try in the companion class of a module as a fallback.
48
+ */
49
+ final def javaFindMember (name : Name , pre : Type , lookInCompanion : Boolean , required : FlagSet = EmptyFlags , excluded : FlagSet = EmptyFlags ): Denotation =
47
50
assert(ctx.isJava)
48
51
inContext(ctx) {
49
52
@@ -53,7 +56,7 @@ object ContextOps:
53
56
val directSearch = pre.findMember(name, pre, required, excluded)
54
57
55
58
// 2. Try to search in companion class if current is an object.
56
- def searchCompanionClass = if preSym.is(Flags .Module ) then
59
+ def searchCompanionClass = if lookInCompanion && preSym.is(Flags .Module ) then
57
60
preSym.companionClass.thisType.findMember(name, pre, required, excluded)
58
61
else NoDenotation
59
62
0 commit comments