File tree 2 files changed +32
-3
lines changed
compiler/src/dotty/tools/dotc/transform
tests/explicit-nulls/pos-patmat
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -784,9 +784,11 @@ object Erasure {
784
784
}
785
785
786
786
override def typedTypeApply (tree : untpd.TypeApply , pt : Type )(using Context ): Tree = {
787
- val ntree = atPhase(erasurePhase)(
788
- interceptTypeApply(tree.asInstanceOf [TypeApply ])
789
- ).withSpan(tree.span)
787
+ val ntree = atPhase(erasurePhase){
788
+ // Use erased-type semantic to intercept TypeApply in explicit nulls
789
+ val interceptCtx = if ctx.explicitNulls then ctx.retractMode(Mode .SafeNulls ) else ctx
790
+ interceptTypeApply(tree.asInstanceOf [TypeApply ])(using interceptCtx)
791
+ }.withSpan(tree.span)
790
792
791
793
ntree match {
792
794
case TypeApply (fun, args) =>
Original file line number Diff line number Diff line change
1
+ // Ensure we don't get "the type test for argType cannot be checked at runtime" warning
2
+
3
+ class Symbol {
4
+ type ThisName
5
+ }
6
+
7
+ type TermSymbol = Symbol { type ThisName = String }
8
+
9
+ type TermSymbolOrNull = TermSymbol | Null
10
+
11
+ def testSimple =
12
+ val x : Symbol | Null = ???
13
+ x match
14
+ case key : Symbol => 1
15
+ case null => 0
16
+
17
+ def testWithRefinedType =
18
+ val x : TermSymbol | Null = ???
19
+ x match
20
+ case key : TermSymbol => 1
21
+ case null => 0
22
+
23
+ def testWithAlias =
24
+ val x : TermSymbolOrNull = ???
25
+ x match
26
+ case key : TermSymbol => 1
27
+ case null => 0
You can’t perform that action at this time.
0 commit comments