diff options
author | Martin Odersky <odersky@gmail.com> | 2013-10-15 14:55:00 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-10-15 14:55:09 +0200 |
commit | 4f05aa9bf0d3c29eae720115433ffe29b239d70f (patch) | |
tree | dbc9c8a430351c0a5b372adc9442c1b74ff92d54 /src/dotty/tools/dotc/typer/Inferencing.scala | |
parent | cdafc3058566d5eede8995f0812fe57a3a1ad6ee (diff) | |
download | dotty-4f05aa9bf0d3c29eae720115433ffe29b239d70f.tar.gz dotty-4f05aa9bf0d3c29eae720115433ffe29b239d70f.tar.bz2 dotty-4f05aa9bf0d3c29eae720115433ffe29b239d70f.zip |
Changes to adaptation and local type inference.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Inferencing.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 11 |
1 files changed, 9 insertions, 2 deletions
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) |