Skip to content

Commit b22f22a

Browse files
committed
Constrain result types less often
Performance tests indicated a 3% slowdown for dotty. Trying to mitigate that by avoiding constraining types multiple times.
1 parent 6ce1ac7 commit b22f22a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,13 @@ trait Inferencing { this: Typer =>
345345
def ensureConstrained() =
346346
if (!isConstrained) {
347347
isConstrained = true
348-
constrainResult(tree.tpe, pt)
348+
tree match {
349+
case tree: Apply => // already constrained
350+
case _ => tree.tpe match {
351+
case _: MethodOrPoly => // already constrained
352+
case tp => constrainResult(tp, pt)
353+
}
354+
}
349355
}
350356

351357
// Avoid interpolating variables if typerstate has unreported errors.

0 commit comments

Comments
 (0)