Skip to content

Commit 00b0a9c

Browse files
committed
sig2typeBounds: avoid unnecessary work
When skiptvs we don't need to construct a type at all, we're just skipping over part of the byte stream.
1 parent 312a420 commit 00b0a9c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,17 @@ class ClassfileParser(
461461
val ts = new ListBuffer[Type]
462462
while (sig(index) == ':') {
463463
index += 1
464-
if (sig(index) != ':') // guard against empty class bound
465-
ts += sig2type(tparams, skiptvs)
464+
if (sig(index) != ':') { // guard against empty class bound
465+
val tp = sig2type(tparams, skiptvs)
466+
if (!skiptvs)
467+
ts += tp
468+
}
469+
}
470+
if (!skiptvs) {
471+
val bound = if ts.isEmpty then defn.AnyType else ts.reduceLeft(AndType.apply)
472+
TypeBounds.upper(bound)
466473
}
467-
val bound = if ts.isEmpty then defn.AnyType else ts.reduceLeft(AndType.apply)
468-
TypeBounds.upper(bound)
474+
else NoType
469475
}
470476

471477
var tparams = classTParams

0 commit comments

Comments
 (0)