From 4f05aa9bf0d3c29eae720115433ffe29b239d70f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 15 Oct 2013 14:55:00 +0200 Subject: Changes to adaptation and local type inference. --- src/dotty/tools/dotc/typer/Inferencing.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Inferencing.scala') diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index 8d85c1911..cbce206ef 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -10,7 +10,7 @@ import annotation.unchecked import util.Positions._ import util.Stats import Decorators._ -import ErrorReporting.InfoString +import ErrorReporting.{errorType, InfoString} object Inferencing { @@ -113,7 +113,7 @@ object Inferencing { * any uninstantiated type variables, provided that * - the instance type for the variable is not Nothing or Null * - the overall result of `isFullYDefined` is `true`. - * Variables that are succesfully minimized do not count as uninstantiated. + * Variables that are successfully minimized do not count as uninstantiated. */ def isFullyDefined(tp: Type, forceIt: Boolean = false)(implicit ctx: Context): Boolean = { val nestedCtx = ctx.fresh.withNewTyperState @@ -122,6 +122,13 @@ object Inferencing { result } + def forceFullyDefined(tp: Type)(implicit ctx: Context): Boolean = + isFullyDefined(tp, forceIt = true) + + def fullyDefinedType(tp: Type, what: String, pos: Position)(implicit ctx: Context) = + if (forceFullyDefined(tp)) tp + else errorType(i"internal error: type of $what $tp is not fully defined", pos) + private class IsFullyDefinedAccumulator(forceIt: Boolean)(implicit ctx: Context) extends TypeAccumulator[Boolean] { def traverse(tp: Type): Boolean = apply(true, tp) def apply(x: Boolean, tp: Type) = !x || isOK(tp) && foldOver(x, tp) -- cgit v1.2.3