aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-01-06 11:49:48 +0100
committerMartin Odersky <odersky@gmail.com>2014-01-06 11:49:48 +0100
commitd495cf9a0c24fb6ea63acb3e20f35b634814f1aa (patch)
tree74f400fef6380e5d9eb83ff78df4a29d6a619938
parentbdb0103d5196e3d64e9ea2d977058f49a78d749d (diff)
downloaddotty-d495cf9a0c24fb6ea63acb3e20f35b634814f1aa.tar.gz
dotty-d495cf9a0c24fb6ea63acb3e20f35b634814f1aa.tar.bz2
dotty-d495cf9a0c24fb6ea63acb3e20f35b634814f1aa.zip
Relax isFullyDefined test
Previously, if forceDegree = noBottom, we failed the test if a type variable was minimized to Null or Nothing. Now we succeed and maximize the type variable instead. It seems Scala2x does soemthing similar, at least the change is needed to make PathResolvers.scala compile.
-rw-r--r--src/dotty/tools/dotc/core/Types.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Inferencing.scala9
-rw-r--r--test/dotc/tests.scala2
3 files changed, 10 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 92f65c1fe..d281af733 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1729,7 +1729,7 @@ object Types {
* is also a singleton type.
*/
def instantiate(fromBelow: Boolean)(implicit ctx: Context): Type = {
- val upperBound = ctx.typerState.constraint.bounds(origin).hi
+ def upperBound = ctx.typerState.constraint.bounds(origin).hi
def isSingleton(tp: Type): Boolean = tp match {
case tp: SingletonType => true
case AndType(tp1, tp2) => isSingleton(tp1) | isSingleton(tp2)
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala
index fd11e71f2..fbc604db9 100644
--- a/src/dotty/tools/dotc/typer/Inferencing.scala
+++ b/src/dotty/tools/dotc/typer/Inferencing.scala
@@ -265,10 +265,15 @@ object Inferencing {
case _: WildcardType =>
false
case tvar: TypeVar if !tvar.isInstantiated =>
+ def isBottomType(tp: Type) = tp == defn.NothingType || tp == defn.NullType
force != ForceDegree.none && {
- val inst = tvar.instantiate(fromBelow = !isContravariant(tvar))
+ val forceUp =
+ isContravariant(tvar) ||
+ force == ForceDegree.noBottom &&
+ isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true))
+ val inst = tvar.instantiate(fromBelow = !forceUp)
typr.println(i"forced instantiation of ${tvar.origin} = $inst")
- (force == ForceDegree.all || inst != defn.NothingType && inst != defn.NullType) && traverse(inst)
+ traverse(inst)
}
case _ =>
true
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 22c557b7d..e612e269d 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -48,4 +48,6 @@ class tests extends CompilerTest {
@Test def dotc_settings = compileFile(dotcDir + "tools/dotc/config/", "Settings")
@Test def dotc_compilercommand = compileFile(dotcDir + "tools/dotc/config/", "CompilerCommand")
@Test def dotc_javaplatform = compileFile(dotcDir + "tools/dotc/config/", "JavaPlatform")
+ @Test def dotc_outputdirs = compileFile(dotcDir + "tools/dotc/config/", "OutputDirs")
+ @Test def dotc_pathresolver = compileFile(dotcDir + "tools/dotc/config/", "PathResolver")
} \ No newline at end of file