Skip to content

Commit 7c8f557

Browse files
authored
Merge pull request #3272 from dotty-staging/fix-deep-subtypes
Avoid most deep subtypes in test
2 parents a4e2320 + eb2fdf2 commit 7c8f557

File tree

6 files changed

+20
-11
lines changed

6 files changed

+20
-11
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,8 +1089,20 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
10891089
isApplicable(alt2, formals1, WildcardType) ||
10901090
tp1.paramInfos.isEmpty && tp2.isInstanceOf[LambdaType]
10911091
case tp1: PolyType => // (2)
1092-
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds)
1093-
isAsSpecific(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
1092+
val nestedCtx = ctx.fresh.setExploreTyperState()
1093+
1094+
{
1095+
implicit val ctx = nestedCtx
1096+
1097+
// Fully define the type so that the types of the tparams created
1098+
// below never contain TypeRefs whose underling types contain
1099+
// uninstantiated TypeVars, this could lead to cycles in `isSubType`
1100+
// as a TypeVar might get constrained by a TypeRef it's part of.
1101+
val tp1a = fullyDefinedType(tp1, "alternative", alt1.symbol.pos).asInstanceOf[PolyType]
1102+
1103+
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1a.instantiateBounds)
1104+
isAsSpecific(alt1, tp1a.instantiate(tparams.map(_.typeRef)), alt2, tp2)
1105+
}
10941106
case _ => // (3)
10951107
tp2 match {
10961108
case tp2: MethodType => true // (3a)

compiler/test/dotc/tests.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ class tests extends CompilerTest {
168168

169169
@Test def rewrites = compileFile(posScala2Dir, "rewrites", "-rewrite" :: scala2mode)
170170

171-
@Test def pos_t8146a = compileFile(posSpecialDir, "t8146a")(allowDeepSubtypes)
172171
@Test def pos_jon = compileFile(posSpecialDir, "jon")(allowDeepSubtypes)
173172

174173
@Test def pos_t5545 = {

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class CompilationTests extends ParallelTesting {
4040
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")) +
4141
compileDir("../compiler/src/dotty/tools/dotc/ast", defaultOptions) +
4242
compileDir("../compiler/src/dotty/tools/dotc/config", defaultOptions) +
43-
compileDir("../compiler/src/dotty/tools/dotc/core", allowDeepSubtypes) +
44-
compileDir("../compiler/src/dotty/tools/dotc/transform", allowDeepSubtypes) +
43+
compileDir("../compiler/src/dotty/tools/dotc/core", defaultOptions) +
44+
compileDir("../compiler/src/dotty/tools/dotc/transform", defaultOptions) +
4545
compileDir("../compiler/src/dotty/tools/dotc/parsing", defaultOptions) +
4646
compileDir("../compiler/src/dotty/tools/dotc/printing", defaultOptions) +
4747
compileDir("../compiler/src/dotty/tools/dotc/reporting", defaultOptions) +
@@ -51,7 +51,6 @@ class CompilationTests extends ParallelTesting {
5151
compileDir("../compiler/src/dotty/tools/dotc/core", TestFlags(classPath, noCheckOptions)) +
5252
compileFile("../tests/pos/nullarify.scala", defaultOptions.and("-Ycheck:nullarify")) +
5353
compileFile("../tests/pos-scala2/rewrites.scala", scala2Mode.and("-rewrite")).copyToTarget() +
54-
compileFile("../tests/pos-special/t8146a.scala", allowDeepSubtypes) +
5554
compileFile("../tests/pos-special/utf8encoded.scala", explicitUTF8) +
5655
compileFile("../tests/pos-special/utf16encoded.scala", explicitUTF16) +
5756
compileList(
@@ -198,8 +197,8 @@ class CompilationTests extends ParallelTesting {
198197
// lower level of concurrency as to not kill their running VMs
199198

200199
@Test def testPickling: Unit = {
201-
compileDir("../compiler/src/dotty/tools", picklingOptionsAllowDeepSubTypes) +
202-
compileDir("../compiler/src/dotty/tools/dotc", picklingOptionsAllowDeepSubTypes) +
200+
compileDir("../compiler/src/dotty/tools", picklingOptions) +
201+
compileDir("../compiler/src/dotty/tools/dotc", picklingOptions) +
203202
compileFilesInDir("../tests/new", picklingOptions) +
204203
compileFilesInDir("../tests/pickling", picklingOptions) +
205204
compileDir("../library/src/dotty/runtime", picklingOptions) +
@@ -211,7 +210,7 @@ class CompilationTests extends ParallelTesting {
211210
compileDir("../compiler/src/dotty/tools/dotc/printing", picklingOptions) +
212211
compileDir("../compiler/src/dotty/tools/repl", picklingOptions) +
213212
compileDir("../compiler/src/dotty/tools/dotc/rewrite", picklingOptions) +
214-
compileDir("../compiler/src/dotty/tools/dotc/transform", picklingOptionsAllowDeepSubTypes) +
213+
compileDir("../compiler/src/dotty/tools/dotc/transform", picklingOptions) +
215214
compileDir("../compiler/src/dotty/tools/dotc/typer", picklingOptions) +
216215
compileDir("../compiler/src/dotty/tools/dotc/util", picklingOptions) +
217216
compileDir("../compiler/src/dotty/tools/io", picklingOptions) +
@@ -237,7 +236,7 @@ class CompilationTests extends ParallelTesting {
237236

238237
def lib =
239238
compileDir("../library/src",
240-
allowDeepSubtypes.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir))
239+
defaultOptions.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir))
241240

242241
val compilerDir = Paths.get("../compiler/src")
243242
val compilerSources = sources(Files.walk(compilerDir))

compiler/test/dotty/tools/vulpix/TestConfiguration.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ object TestConfiguration {
5555
"-Ytest-pickler",
5656
"-Yprintpos"
5757
)
58-
val picklingOptionsAllowDeepSubTypes = picklingOptions without "-Yno-deep-subtypes"
5958
val scala2Mode = defaultOptions and "-language:Scala2"
6059
val explicitUTF8 = defaultOptions and ("-encoding", "UTF8")
6160
val explicitUTF16 = defaultOptions and ("-encoding", "UTF16")
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)