aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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