Skip to content

Commit 7c77611

Browse files
committed
Fix selceting type member in unsafe nulls
1 parent a070798 commit 7c77611

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ object Types {
237237
}
238238

239239
def isBottomType(using Context): Boolean =
240-
if ctx.explicitNulls && !ctx.phase.erasedTypes then hasClassSymbol(defn.NothingClass)
240+
if ctx.mode.is(Mode.SafeNulls) && !ctx.phase.erasedTypes then hasClassSymbol(defn.NothingClass)
241241
else isBottomTypeAfterErasure
242242

243243
def isBottomTypeAfterErasure(using Context): Boolean =
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import java.util.ArrayList
2+
3+
def f[T]: ArrayList[T] = {
4+
val cz = Class.forName("java.util.ArrayList")
5+
val o = cz.newInstance() // error: T of Class[?] | Null
6+
o.asInstanceOf[ArrayList[T]]
7+
}

0 commit comments

Comments
 (0)