File tree 2 files changed +24
-1
lines changed
compiler/src/dotty/tools/dotc/typer 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -1553,7 +1553,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1553
1553
case otherTpe => otherTpe.widen
1554
1554
/** Extractor for match types hidden behind an AppliedType/MatchAlias */
1555
1555
object MatchTypeInDisguise {
1556
- def unapply (tp : AppliedType )(using Context ): Option [MatchType ] = tp match {
1556
+ def unapply (tp : Type )(using Context ): Option [MatchType ] = tp match {
1557
1557
case AppliedType (tycon : TypeRef , args) =>
1558
1558
tycon.info match {
1559
1559
case MatchAlias (alias) =>
@@ -1563,6 +1563,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1563
1563
}
1564
1564
case _ => None
1565
1565
}
1566
+ case mt : MatchType => Some (mt)
1566
1567
case _ => None
1567
1568
}
1568
1569
}
Original file line number Diff line number Diff line change
1
+ type IsString [T <: Any ] = T match {
2
+ case String => true
3
+ case _ => false
4
+ }
5
+
6
+ def isString (x : Any ): IsString [x.type ] = x match
7
+ case _ : String => true
8
+ case _ => false
9
+
10
+ def isString2 (x : Any ): x.type match {
11
+ case String => true
12
+ case _ => false
13
+ } = x match
14
+ case _ : String => true
15
+ case _ => false
16
+
17
+ def isString3 [T ](x : T ): T match {
18
+ case String => true
19
+ case _ => false
20
+ } = x match
21
+ case _ : String => true
22
+ case _ => false
You can’t perform that action at this time.
0 commit comments