Skip to content

Commit 19a1477

Browse files
authored
Refine isEffectivelyFinal to avoid no-owner crash (#23675)
Fixes #23637
2 parents 4d98df9 + 310f239 commit 19a1477

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ object SymDenotations {
12201220
|| is(Inline, butNot = Deferred)
12211221
|| is(JavaDefinedVal, butNot = Method)
12221222
|| isConstructor
1223-
|| !owner.isExtensibleClass && !is(Deferred)
1223+
|| exists && !owner.isExtensibleClass && !is(Deferred)
12241224
// Deferred symbols can arise through parent refinements under x.modularity.
12251225
// For them, the overriding relationship reverses anyway, so
12261226
// being in a final class does not mean the symbol cannot be

tests/neg/i23637.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E083] Type Error: tests/neg/i23637.scala:6:9 -----------------------------------------------------------------------
2+
6 | export foo.pin.* // error: (because we need reflection to get at foo.pin)
3+
| ^^^^^^^
4+
| (Test.foo.pin : Object) is not a valid export prefix, since it is not an immutable path
5+
|
6+
| longer explanation available when compiling with `-explain`

tests/neg/i23637.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
trait Foo extends reflect.Selectable
2+
object Test:
3+
val foo = new Foo:
4+
object pin:
5+
val x = 1
6+
export foo.pin.* // error: (because we need reflection to get at foo.pin)
7+
8+
object OK:
9+
object Foo:
10+
object pin:
11+
val x = 1
12+
export Foo.pin.*

0 commit comments

Comments
 (0)