@@ -2,10 +2,9 @@ package dotty.tools.dotc
2
2
package core
3
3
4
4
import 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
7
7
import ast .untpd
8
- import dotty .tools .dotc .core .SymDenotations .NoDenotation
9
8
10
9
/** Extension methods for contexts where we want to keep the ctx.<methodName> syntax */
11
10
object ContextOps :
@@ -35,19 +34,17 @@ object ContextOps:
35
34
if (elem.name == name) return elem.sym.denot // return self
36
35
}
37
36
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)
43
39
}
44
40
else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext.
45
41
ctx.owner.findMember(name, ctx.owner.thisType, required, excluded)
46
42
else
47
43
ctx.scope.denotsNamed(name).filterWithFlags(required, excluded).toDenot(NoPrefix )
48
44
}
49
45
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 =
51
48
inContext(ctx) {
52
49
val preSym = pre.typeSymbol
53
50
val denot = pre.findMember(name, pre, required, excluded)
@@ -56,11 +53,11 @@ object ContextOps:
56
53
// In Java code, static innner classes, which we model as members of the companion object,
57
54
// can be referenced from an ident in a subclass or by a selection prefixed by the subclass.
58
55
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
61
58
else Nil
62
59
else
63
- preSym.asClass.baseClasses.tail
60
+ preSym.asClass.nonSelfBaseClasses
64
61
65
62
toSearch.iterator.map { bc =>
66
63
val pre1 = bc.thisType
@@ -69,14 +66,12 @@ object ContextOps:
69
66
case NoDenotation =>
70
67
val companionModule = pre1.typeSymbol.companionClass
71
68
val pre2 = companionModule.thisType
72
- val result = pre2.findMember(name, pre2, required, excluded)
73
- result
69
+ pre2.findMember(name, pre2, required, excluded)
74
70
case denot => denot
75
71
}
76
72
}.find(_.exists).getOrElse(NoDenotation )
77
73
}
78
74
}
79
- }
80
75
81
76
/** A fresh local context with given tree and owner.
82
77
* Owner might not exist (can happen for self valdefs), in which case
0 commit comments