From eb2fdf273f7305e79196477347593f7417f19eb4 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sun, 17 Sep 2017 00:11:20 +0200 Subject: [PATCH] Avoid most deep subtypes in test The only remaining testcase requiring deep subtype is t8146a.scala for good reasons. --- .../dotty/tools/dotc/typer/Applications.scala | 16 ++++++++++++++-- compiler/test/dotc/tests.scala | 1 - .../test/dotty/tools/dotc/CompilationTests.scala | 13 ++++++------- .../dotty/tools/vulpix/TestConfiguration.scala | 1 - .../t8146a.scala | 0 tests/{pos-deep-subtype => pos}/sets.scala | 0 6 files changed, 20 insertions(+), 11 deletions(-) rename tests/{pos-special => pos-deep-subtype}/t8146a.scala (100%) rename tests/{pos-deep-subtype => pos}/sets.scala (100%) diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 4bb4b7820c98..9e42b1dfd58e 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1089,8 +1089,20 @@ trait Applications extends Compatibility { self: Typer with Dynamic => isApplicable(alt2, formals1, WildcardType) || tp1.paramInfos.isEmpty && tp2.isInstanceOf[LambdaType] case tp1: PolyType => // (2) - val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds) - isAsSpecific(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2) + val nestedCtx = ctx.fresh.setExploreTyperState() + + { + implicit val ctx = nestedCtx + + // Fully define the type so that the types of the tparams created + // below never contain TypeRefs whose underling types contain + // uninstantiated TypeVars, this could lead to cycles in `isSubType` + // as a TypeVar might get constrained by a TypeRef it's part of. + val tp1a = fullyDefinedType(tp1, "alternative", alt1.symbol.pos).asInstanceOf[PolyType] + + val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1a.instantiateBounds) + isAsSpecific(alt1, tp1a.instantiate(tparams.map(_.typeRef)), alt2, tp2) + } case _ => // (3) tp2 match { case tp2: MethodType => true // (3a) diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala index 7b0672a55939..a21496ed0e8f 100644 --- a/compiler/test/dotc/tests.scala +++ b/compiler/test/dotc/tests.scala @@ -168,7 +168,6 @@ class tests extends CompilerTest { @Test def rewrites = compileFile(posScala2Dir, "rewrites", "-rewrite" :: scala2mode) - @Test def pos_t8146a = compileFile(posSpecialDir, "t8146a")(allowDeepSubtypes) @Test def pos_jon = compileFile(posSpecialDir, "jon")(allowDeepSubtypes) @Test def pos_t5545 = { diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index d3df0708c0ba..4412e8a8714b 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -40,8 +40,8 @@ class CompilationTests extends ParallelTesting { compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")) + compileDir("../compiler/src/dotty/tools/dotc/ast", defaultOptions) + compileDir("../compiler/src/dotty/tools/dotc/config", defaultOptions) + - compileDir("../compiler/src/dotty/tools/dotc/core", allowDeepSubtypes) + - compileDir("../compiler/src/dotty/tools/dotc/transform", allowDeepSubtypes) + + compileDir("../compiler/src/dotty/tools/dotc/core", defaultOptions) + + compileDir("../compiler/src/dotty/tools/dotc/transform", defaultOptions) + compileDir("../compiler/src/dotty/tools/dotc/parsing", defaultOptions) + compileDir("../compiler/src/dotty/tools/dotc/printing", defaultOptions) + compileDir("../compiler/src/dotty/tools/dotc/reporting", defaultOptions) + @@ -51,7 +51,6 @@ class CompilationTests extends ParallelTesting { compileDir("../compiler/src/dotty/tools/dotc/core", TestFlags(classPath, noCheckOptions)) + compileFile("../tests/pos/nullarify.scala", defaultOptions.and("-Ycheck:nullarify")) + compileFile("../tests/pos-scala2/rewrites.scala", scala2Mode.and("-rewrite")).copyToTarget() + - compileFile("../tests/pos-special/t8146a.scala", allowDeepSubtypes) + compileFile("../tests/pos-special/utf8encoded.scala", explicitUTF8) + compileFile("../tests/pos-special/utf16encoded.scala", explicitUTF16) + compileList( @@ -198,8 +197,8 @@ class CompilationTests extends ParallelTesting { // lower level of concurrency as to not kill their running VMs @Test def testPickling: Unit = { - compileDir("../compiler/src/dotty/tools", picklingOptionsAllowDeepSubTypes) + - compileDir("../compiler/src/dotty/tools/dotc", picklingOptionsAllowDeepSubTypes) + + compileDir("../compiler/src/dotty/tools", picklingOptions) + + compileDir("../compiler/src/dotty/tools/dotc", picklingOptions) + compileFilesInDir("../tests/new", picklingOptions) + compileFilesInDir("../tests/pickling", picklingOptions) + compileDir("../library/src/dotty/runtime", picklingOptions) + @@ -211,7 +210,7 @@ class CompilationTests extends ParallelTesting { compileDir("../compiler/src/dotty/tools/dotc/printing", picklingOptions) + compileDir("../compiler/src/dotty/tools/repl", picklingOptions) + compileDir("../compiler/src/dotty/tools/dotc/rewrite", picklingOptions) + - compileDir("../compiler/src/dotty/tools/dotc/transform", picklingOptionsAllowDeepSubTypes) + + compileDir("../compiler/src/dotty/tools/dotc/transform", picklingOptions) + compileDir("../compiler/src/dotty/tools/dotc/typer", picklingOptions) + compileDir("../compiler/src/dotty/tools/dotc/util", picklingOptions) + compileDir("../compiler/src/dotty/tools/io", picklingOptions) + @@ -237,7 +236,7 @@ class CompilationTests extends ParallelTesting { def lib = compileDir("../library/src", - allowDeepSubtypes.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir)) + defaultOptions.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir)) val compilerDir = Paths.get("../compiler/src") val compilerSources = sources(Files.walk(compilerDir)) diff --git a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala index 9ebd7a6cae91..b0a31e6e1ce8 100644 --- a/compiler/test/dotty/tools/vulpix/TestConfiguration.scala +++ b/compiler/test/dotty/tools/vulpix/TestConfiguration.scala @@ -55,7 +55,6 @@ object TestConfiguration { "-Ytest-pickler", "-Yprintpos" ) - val picklingOptionsAllowDeepSubTypes = picklingOptions without "-Yno-deep-subtypes" val scala2Mode = defaultOptions and "-language:Scala2" val explicitUTF8 = defaultOptions and ("-encoding", "UTF8") val explicitUTF16 = defaultOptions and ("-encoding", "UTF16") diff --git a/tests/pos-special/t8146a.scala b/tests/pos-deep-subtype/t8146a.scala similarity index 100% rename from tests/pos-special/t8146a.scala rename to tests/pos-deep-subtype/t8146a.scala diff --git a/tests/pos-deep-subtype/sets.scala b/tests/pos/sets.scala similarity index 100% rename from tests/pos-deep-subtype/sets.scala rename to tests/pos/sets.scala