Skip to content

Commit 5a3db66

Browse files
author
changvvb
committed
update test
update
1 parent 66f44fe commit 5a3db66

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

compiler/src/dotty/tools/dotc/core/ContextOps.scala

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package dotty.tools.dotc
22
package core
33

44
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
77
import 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 */
1110
object 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

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,9 @@ object SymDenotations {
18661866
def baseClasses(implicit onBehalf: BaseData, ctx: Context): List[ClassSymbol] =
18671867
baseData._1
18681868

1869+
def nonSelfBaseClasses(implicit onBehalf: BaseData, ctx: Context): List[ClassSymbol] =
1870+
baseClasses.tail
1871+
18691872
/** Like `baseClasses.length` but more efficient. */
18701873
def baseClassesLength(using BaseData, Context): Int =
18711874
// `+ 1` because the baseClassSet does not include the current class unlike baseClasses

compiler/test/dotc/run-test-pickling.blacklist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ varargs-abstract
3535
zero-arity-case-class.scala
3636
i12194.scala
3737
i12753
38-
t1638
39-
t1638-2
38+
t6138
39+
t6138-2
File renamed without changes.

0 commit comments

Comments
 (0)