Skip to content

Commit 3dbffc1

Browse files
committed
Remove useless trace and add existence checking
1 parent 7a4422f commit 3dbffc1

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,8 @@ trait PatternTypeConstrainer { self: TypeComparer =>
110110
case scrut: TypeRef if scrut.symbol.isClass =>
111111
// consider all parents
112112
val parents = scrut.parents
113-
val andType = trace(i"andType of scrut", gadts) {
114-
buildAndType(parents)
115-
}
116-
constrainPatternType(pat, andType)
113+
val andType = buildAndType(parents)
114+
!andType.exists || constrainPatternType(pat, andType)
117115
case scrut @ AppliedType(tycon: TypeRef, _) if tycon.symbol.isClass =>
118116
val patClassSym = pat.classSymbol
119117
// find all shared parents in the inheritance hierarchy between pat and scrut
@@ -129,10 +127,8 @@ trait PatternTypeConstrainer { self: TypeComparer =>
129127
}
130128
val allSyms = allParentsSharedWithPat(tycon, tycon.symbol.asClass)
131129
val baseClasses = allSyms map scrut.baseType
132-
val andType = trace(i"andType of scrut", gadts) {
133-
buildAndType(baseClasses)
134-
}
135-
constrainPatternType(pat, andType)
130+
val andType = buildAndType(baseClasses)
131+
!andType.exists || constrainPatternType(pat, andType)
136132
case _ =>
137133
val upcasted: Type = scrut match {
138134
case scrut: TypeProxy => scrut.superType

0 commit comments

Comments
 (0)