Skip to content

Commit 236486c

Browse files
committed
Code refactoring
1 parent 4841ecb commit 236486c

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,12 @@ object TypeOps:
686686
}
687687
}
688688

689-
def isPatternTypeSymbol(sym: Symbol) = !sym.isClass && sym.is(Case)
690-
691689
// replace uninstantiated type vars with WildcardType, check tests/patmat/3333.scala
692690
def instUndetMap(implicit ctx: Context) = new TypeMap {
693691
def apply(t: Type): Type = t match {
694692
case tvar: TypeVar if !tvar.isInstantiated =>
695693
WildcardType(tvar.origin.underlying.bounds)
696-
case tref: TypeRef if isPatternTypeSymbol(tref.typeSymbol) =>
694+
case tref: TypeRef if tref.typeSymbol.isPatternBound =>
697695
WildcardType(tref.underlying.bounds)
698696
case _ => mapOver(t)
699697
}

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,20 @@ object TypeTestsCasts {
5555
*/
5656
def checkable(X: Type, P: Type, span: Span)(using Context): Boolean = {
5757
def isAbstract(P: Type) = !P.dealias.typeSymbol.isClass
58-
def isPatternTypeSymbol(sym: Symbol) = !sym.isClass && sym.is(Case)
5958

6059
def replaceP(tp: Type)(implicit ctx: Context) = new TypeMap {
6160
def apply(tp: Type) = tp match {
62-
case tref: TypeRef
63-
if isPatternTypeSymbol(tref.typeSymbol) => WildcardType
64-
case AnnotatedType(_, annot)
65-
if annot.symbol == defn.UncheckedAnnot => WildcardType
61+
case tref: TypeRef if tref.typeSymbol.isPatternBound =>
62+
WildcardType
63+
case AnnotatedType(_, annot) if annot.symbol == defn.UncheckedAnnot =>
64+
WildcardType
6665
case _ => mapOver(tp)
6766
}
6867
}.apply(tp)
6968

7069
def replaceX(tp: Type)(implicit ctx: Context) = new TypeMap {
7170
def apply(tp: Type) = tp match {
72-
case tref: TypeRef
73-
if isPatternTypeSymbol(tref.typeSymbol) =>
71+
case tref: TypeRef if tref.typeSymbol.isPatternBound =>
7472
if (variance == 1) tref.info.hiBound
7573
else if (variance == -1) tref.info.loBound
7674
else OrType(defn.AnyType, defn.NothingType)

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
464464
* }
465465
*/
466466
private def erase(tp: Type, inArray: Boolean = false): Type = trace(i"$tp erased to", debug) {
467-
def isPatternTypeSymbol(sym: Symbol) = !sym.isClass && sym.is(Case)
468467

469468
tp match {
470469
case tp @ AppliedType(tycon, args) =>
@@ -476,7 +475,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
476475
AndType(erase(tp1, inArray), erase(tp2, inArray))
477476
case tp @ RefinedType(parent, _, _) =>
478477
erase(parent)
479-
case tref: TypeRef if isPatternTypeSymbol(tref.typeSymbol) =>
478+
case tref: TypeRef if tref.typeSymbol.isPatternBound =>
480479
if (inArray) tref.underlying else WildcardType
481480
case _ => tp
482481
}

0 commit comments

Comments
 (0)