8000 more localness · scala/scala@ea341fa · GitHub
[go: up one dir, main page]

Skip to content

Commit ea341fa

Browse files
committed
more localness
1 parent 24983a3 commit ea341fa

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/reflect/scala/reflect/internal/Symbols.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,14 +1025,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
10251025
)
10261026
/** Is this symbol effectively final or a concrete term member of sealed class whose children do not override it */
10271027
final def isEffectivelyFinalOrNotOverridden: Boolean = {
1028-
def hasLocalOwner(c: Symbol) = { val k = c.originalOwner; k != NoSymbol && k.isTerm }
10291028
def isNotOverriddenAt(c: Symbol, hasLocalOwner: Boolean): Boolean = {
1030-
def checkOverrideIn(sc: Symbol) = overridingSymbol(sc) == NoSymbol && isNotOverriddenAt(sc, hasLocalOwner)
1029+
def checkOverrideIn(sc: Symbol) = overridingSymbol(sc) == NoSymbol && isNotOverriddenAt(sc, hasLocalOwner || sc.originalOwner.isTerm)
10311030
c.isClass && (c.isEffectivelyFinal || {
10321031
(c.isSealed || hasLocalOwner) && c.children.forall(checkOverrideIn)
10331032
})
10341033
}
1035-
isEffectivelyFinal || isTerm && !isDeferred && isNotOverriddenAt(owner, hasLocalOwner(originalOwner))
1034+
isEffectivelyFinal || isTerm && !isDeferred && isNotOverriddenAt(owner, owner.originalOwner.isTerm)
10361035
}
10371036

10381037
/** Is this symbol owned by a package? */

test/files/pos/t9414.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,39 @@ object E {
4040
def notBar = 42
4141
}
4242
}
43+
44+
class F {
45+
def foo = {
46+
class Parent {
47+
@tailrec def bar: Int = {
48+
println("here we go again")
49+
bar
50+
}
51+
}
52+
class K {
53+
class Child extends Parent {
54+
def notBar = 42
55+
}
56+
class GrandChild extends Child {
57+
def neitherBar = 42
58+
}
59+
}
60+
}
61+
}
62+
63+
class G {
64+
sealed class Parent {
65+
@tailrec def bar: Int = {
66+
println("here we go again")
67+
bar
68+
}
69+
}
70+
def foo = {
71+
class Child extends Parent {
72+
def notBar = 42
73+
}
74+
class GrandChild extends Child {
75+
def neitherBar = 42
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)
0