File tree 3 files changed +20
-1
lines changed
compiler/src/dotty/tools/dotc
3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,7 @@ class Definitions {
798
798
799
799
@ tu lazy val ReflectPackageClass : Symbol = requiredPackage(" scala.reflect.package" ).moduleClass
800
800
@ tu lazy val ClassTagClass : ClassSymbol = requiredClass(" scala.reflect.ClassTag" )
801
+ @ tu lazy val ClassTagClass_unapply : Symbol = ClassTagClass .requiredMethod(" unapply" )
801
802
@ tu lazy val ClassTagModule : Symbol = ClassTagClass .companionModule
802
803
@ tu lazy val ClassTagModule_apply : Symbol = ClassTagModule .requiredMethod(nme.apply)
803
804
Original file line number Diff line number Diff line change @@ -602,10 +602,15 @@ object SpaceEngine {
602
602
603
603
/** Whether the extractor covers the given type */
604
604
def covers (unapp : TermRef , scrutineeTp : Type , argLen : Int )(using Context ): Boolean =
605
- SpaceEngine .isIrrefutable(unapp, argLen) || unapp.symbol == defn.TypeTest_unapply && {
605
+ SpaceEngine .isIrrefutable(unapp, argLen)
606
+ || unapp.symbol == defn.TypeTest_unapply && {
606
607
val AppliedType (_, _ :: tp :: Nil ) = unapp.prefix.widen.dealias: @ unchecked
607
608
scrutineeTp <:< tp
608
609
}
610
+ || unapp.symbol == defn.ClassTagClass_unapply && {
611
+ val AppliedType (_, tp :: Nil ) = unapp.prefix.widen.dealias: @ unchecked
612
+ scrutineeTp <:< tp
613
+ }
609
614
610
615
/** Decompose a type into subspaces -- assume the type can be decomposed */
611
616
def decompose (tp : Type )(using Context ): List [Type ] = trace(i " decompose( $tp) " , debug) {
Original file line number Diff line number Diff line change
1
+ import scala .reflect .ClassTag
2
+
3
+ class Test :
4
+ type A
5
+
6
+ given ClassTag [A ] = ???
7
+
8
+ var a : A | Null = null
9
+
10
+ a match { // WARNING: match may not be exhaustive. It would fail on pattern case: _: A
11
+ case null =>
12
+ case a : A =>
13
+ }
You can’t perform that action at this time.
0 commit comments