From 09d182eed06b69fab7b60ea996376e1b71360f1d Mon Sep 17 00:00:00 2001 From: Allan Renucci Date: Tue, 23 Jan 2018 10:20:48 +0100 Subject: [PATCH] Cleanup commit This commit cleans up a piece of code of #3774 (which is already merged). It was suggested in a review comments. --- .../dotty/tools/dotc/typer/Inferencing.scala | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala index 29fed41a91bd..3cb335d0c531 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala @@ -341,18 +341,12 @@ trait Inferencing { this: Typer => case _ => false } - var isConstrained = false - def ensureConstrained() = - if (!isConstrained) { - isConstrained = true - tree match { - case tree: Apply => // already constrained - case _ => tree.tpe match { - case _: MethodOrPoly => // already constrained - case tp => constrainResult(tp, pt) - } - } - } + var isConstrained = tree.isInstanceOf[Apply] || tree.tpe.isInstanceOf[MethodOrPoly] + + def ensureConstrained() = if (!isConstrained) { + isConstrained = true + constrainResult(tree.tpe, pt) + } // Avoid interpolating variables if typerstate has unreported errors. // Reason: The errors might reflect unsatisfiable constraints. In that