@@ -2,10 +2,9 @@ package dotty.tools.dotc
22package core
33
44import Contexts ._ , Symbols ._ , Types ._ , Flags ._ , Scopes ._ , Decorators ._ , NameOps ._
5- import Denotations ._
6- import SymDenotations . LazyType , Names .Name , StdNames .nme
5+ import Denotations ._ , SymDenotations . _
6+ import Names .Name , StdNames .nme
77import ast .untpd
8- import dotty .tools .dotc .core .SymDenotations .NoDenotation
98
109/** Extension methods for contexts where we want to keep the ctx.<methodName> syntax */
1110object ContextOps :
@@ -35,19 +34,17 @@ object ContextOps:
3534 if (elem.name == name) return elem.sym.denot // return self
3635 }
3736 val pre = ctx.owner.thisType
38- if (ctx.isJava) {
39- javaFindMember(name, pre, required, excluded)
40- } else {
41- pre.findMember(name, pre, required, excluded)
42- }
37+ if (ctx.isJava) then javaFindMember(name, pre, required, excluded)
38+ else pre.findMember(name, pre, required, excluded)
4339 }
4440 else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext.
4541 ctx.owner.findMember(name, ctx.owner.thisType, required, excluded)
4642 else
4743 ctx.scope.denotsNamed(name).filterWithFlags(required, excluded).toDenot(NoPrefix )
4844 }
4945
50- final def javaFindMember (name : Name , pre : Type , required : FlagSet = EmptyFlags , excluded : FlagSet = EmptyFlags ): Denotation = {
46+ // Only invoke this when ctx.isJava == true
47+ final def javaFindMember (name : Name , pre : Type , required : FlagSet = EmptyFlags , excluded : FlagSet = EmptyFlags ): Denotation =
5148 inContext(ctx) {
5249 val preSym = pre.typeSymbol
5350 val denot = pre.findMember(name, pre, required, excluded)
@@ -56,11 +53,11 @@ object ContextOps:
5653 // In Java code, static innner classes, which we model as members of the companion object,
5754 // can be referenced from an ident in a subclass or by a selection prefixed by the subclass.
5855 val toSearch = if (preSym.is(Flags .Module )) then
59- if pre.typeSymbol.sourceModule .companionClass.exists then
60- pre.typeSymbol.sourceModule. companionClass.asClass.baseClasses.tail
56+ if preSym .companionClass.exists then
57+ preSym. companionClass.asClass.nonSelfBaseClasses
6158 else Nil
6259 else
63- preSym.asClass.baseClasses.tail
60+ preSym.asClass.nonSelfBaseClasses
6461
6562 toSearch.iterator.map { bc =>
6663 val pre1 = bc.thisType
@@ -69,14 +66,12 @@ object ContextOps:
6966 case NoDenotation =>
7067 val companionModule = pre1.typeSymbol.companionClass
7168 val pre2 = companionModule.thisType
72- val result = pre2.findMember(name, pre2, required, excluded)
73- result
69+ pre2.findMember(name, pre2, required, excluded)
7470 case denot => denot
7571 }
7672 }.find(_.exists).getOrElse(NoDenotation )
7773 }
7874 }
79- }
8075
8176 /** A fresh local context with given tree and owner.
8277 * Owner might not exist (can happen for self valdefs), in which case
0 commit comments