Skip to content

Commit 4cb34e5

Browse files
committed
tweak: try the original name first and then fallback to module
Avoid skipping searchin a member by the original name even when name is likely companion module name.
1 parent 22d98d6 commit 4cb34e5

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/ContextOps.scala

+10-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,16 @@ object ContextOps:
5959
val preSym = pre.typeSymbol
6060
// 1. Try to search in current type and parents.
6161
val directSearch =
62-
if name.isTypeName && name.endsWith(StdNames.str.MODULE_SUFFIX) then
63-
pre.findMember(name.stripModuleClassSuffix, pre, required, excluded) match
64-
case NoDenotation => NoDenotation
65-
case symDenot: SymDenotation =>
66-
symDenot.companionModule.denot
67-
else
68-
pre.findMember(name, pre, required, excluded)
62+
def asModule =
63+
if name.isTypeName && name.endsWith(StdNames.str.MODULE_SUFFIX) then
64+
pre.findMember(name.stripModuleClassSuffix, pre, required, excluded) match
65+
case NoDenotation => NoDenotation
66+
case symDenot: SymDenotation =>
67+
symDenot.companionModule.denot
68+
else NoDenotation
69+
pre.findMember(name, pre, required, excluded) match
70+
case NoDenotation => asModule
71+
case denot => denot
6972

7073
// 2. Try to search in companion class if current is an object.
7174
def searchCompanionClass = if lookInCompanion && preSym.is(Flags.Module) then

0 commit comments

Comments
 (0)