Skip to content

Commit c62c453

Browse files
committed
Cleanup of isSubType
1 parent d93907e commit c62c453

File tree

1 file changed

+19
-24
lines changed

1 file changed

+19
-24
lines changed

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -207,38 +207,32 @@ class TypeComparer(initctx: Context) extends DotClass {
207207
else {
208208
val saved = constraint
209209
val savedSuccessCount = successCount
210-
val savedTotalCount = totalCount
211-
//if (Stats.monitored) Stats.record(s"isSubType ${tp1.show} <:< ${tp2.show}")
212210
try {
213-
recCount += 1
214-
/* !!! DEBUG
215-
if (isWatched(tp1) && isWatched(tp2) && !(this.isInstanceOf[ExplainingTypeComparer])) {
216-
val explained = new ExplainingTypeComparer(ctx)
217-
println("***** watched:")
218-
println(TypeComparer.explained(_.typeComparer.isSubType(tp1, tp2)))
219-
}
220-
*/
211+
recCount = recCount + 1
221212
val result =
222213
if (recCount < LogPendingSubTypesThreshold) firstTry(tp1, tp2)
223214
else monitoredIsSubType(tp1, tp2)
224-
successCount += 1
225-
totalCount += 1
226-
recCount -= 1
227-
if (!result) {
228-
constraint = saved
229-
successCount = savedSuccessCount
230-
}
231-
else if (recCount == 0) {
232-
if (needsGc) state.gc()
233-
Stats.record("successful subType", successCount)
234-
Stats.record("total subType", totalCount)
235-
successCount = 0
236-
totalCount = 0
215+
recCount = recCount - 1
216+
if (!result) constraint = saved
217+
else if (recCount == 0 && needsGc) state.gc()
218+
219+
def recordStatistics = {
220+
// Stats.record(s"isSubType ${tp1.show} <:< ${tp2.show}")
221+
totalCount += 1
222+
if (result) successCount += 1 else successCount = savedSuccessCount
223+
if (recCount == 0) {
224+
Stats.record("successful subType", successCount)
225+
Stats.record("total subType", totalCount)
226+
successCount = 0
227+
totalCount = 0
228+
}
237229
}
230+
if (Stats.monitored) recordStatistics
231+
238232
result
239233
} catch {
240234
case ex: Throwable =>
241-
if (ex.isInstanceOf[AssertionError]) { // !!!DEBUG
235+
def showState = {
242236
println(disambiguated(implicit ctx => s"assertion failure for ${tp1.show} <:< ${tp2.show}, frozen = $frozenConstraint"))
243237
def explainPoly(tp: Type) = tp match {
244238
case tp: PolyParam => println(s"polyparam ${tp.show} found in ${tp.binder.show}")
@@ -249,6 +243,7 @@ class TypeComparer(initctx: Context) extends DotClass {
249243
explainPoly(tp1)
250244
explainPoly(tp2)
251245
}
246+
if (ex.isInstanceOf[AssertionError]) showState
252247
recCount -= 1
253248
constraint = saved
254249
successCount = savedSuccessCount

0 commit comments

Comments
 (0)