Skip to content

Avoid most deep subtypes in test #3272

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can use TyperState.test here/ It's cheaper and easier to use.

{
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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we could optimize this so that we do the fullyDefinedType only if the type parameter bounds are non-trivial. fullyDefinedType is somewhat expensive.


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)
Expand Down
1 change: 0 additions & 1 deletion compiler/test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
13 changes: 6 additions & 7 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand All @@ -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(
Expand Down Expand Up @@ -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) +
Expand All @@ -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) +
Expand All @@ -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))
Expand Down
1 change: 0 additions & 1 deletion compiler/test/dotty/tools/vulpix/TestConfiguration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
File renamed without changes.
File renamed without changes.