Skip to content

Commit 1a72dc6

Browse files
committed
Prevent checking public flexible types on anonymous classes
1 parent b556293 commit 1a72dc6

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,7 @@ object RefChecks {
12031203
def checkPublicFlexibleTypes(sym: Symbol)(using Context): Unit =
12041204
if ctx.explicitNulls && !ctx.isJava
12051205
&& sym.exists && sym.owner.isClass
1206+
&& !sym.owner.isAnonymousClass
12061207
&& !sym.isOneOf(JavaOrPrivateOrSynthetic | InlineProxy | Param | Exported) then
12071208
val resTp = sym.info.finalResultType
12081209
if resTp.existsPart(_.isInstanceOf[FlexibleType], StopAt.Static) then

tests/explicit-nulls/pos/i24440.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ trait AwtComponentLogging extends java.awt.Component:
99
private def superPS1 = super.getPreferredSize
1010

1111
private val superPS2 = super.getPreferredSize
12+
13+
class Test:
14+
def getCompoment: java.awt.Component =
15+
new java.awt.Component {
16+
override def getPreferredSize = super.getPreferredSize
17+
}

0 commit comments

Comments
 (0)