Skip to content
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

Fix 3187: Don't crash in requiredClass if class is missing #1

Closed
wants to merge 14 commits into from
  •  
  •  
  •  
99 changes: 5 additions & 94 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,115 +11,26 @@ clone:
- git submodule update --init --recursive

pipeline:
# TESTS:
# We run tests in parallel. Tests run in a copy of the working directory to avoid conflict
test_legacy:
group: test
image: lampepfl/dotty:2017-11-17
commands:
- cp -R . /tmp/0/ && cd /tmp/0/
- ./project/scripts/sbt legacyTests

test:
group: test
image: lampepfl/dotty:2017-11-17
image: lampepfl/dotty:2018-01-17
commands:
- cp -R . /tmp/1/ && cd /tmp/1/
- ./project/scripts/sbt ";compile ;test"
- ./project/scripts/sbtTests
- ./project/scripts/sbt "testOnly dotty.tools.dotc.CompilationTests dotty.tools.ShowClassTests"

test_bootstrapped:
group: test
image: lampepfl/dotty:2017-11-17
image: lampepfl/dotty:2018-01-17
commands:
- cp -R . /tmp/2/ && cd /tmp/2/
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"
- ./project/scripts/sbtBootstrappedTests
- ./project/scripts/sbt "dotty-bootstrapped/testOnly dotty.tools.dotc.CompilationTests dotty.tools.ShowClassTests"

test_optimised:
group: test
image: lampepfl/dotty:2017-11-17
commands:
- cp -R . /tmp/3/ && cd /tmp/3/
- ./project/scripts/sbt dotty-optimised/test

test_sbt:
group: test
image: lampepfl/dotty:2017-11-17
commands:
- cp -R . /tmp/4/ && cd /tmp/4/
- ./project/scripts/sbt sbt-dotty/scripted
when:
# sbt scripted tests are slow and don't run on PRs
event: [ push, tag, deployment ]

# DOCUMENTATION:
documentation:
image: lampepfl/dotty:2017-11-17
commands:
- ./project/scripts/genDocs
secrets: [ bot_pass ]
when:
event: push
# We only generate the documentation for the master branch
branch: master

# PUBLISHING:
# Publishing expect NIGHTLYBUILD or RELEASEBUILD to be set. See dottyVersion in Build.scala
publish_nightly:
image: lampepfl/dotty:2017-11-17
environment:
- NIGHTLYBUILD=yes
commands:
- ./project/scripts/sbtPublish ";dotty-bootstrapped/publishSigned ;sonatypeRelease"
secrets: [ sonatype_user, sonatype_pw, pgp_pw, pgp_secret ]
when:
event: deployment
environment: nightly

publish_release:
image: lampepfl/dotty:2017-11-17
environment:
- RELEASEBUILD=yes
commands:
# Produces dotty-version.{tar.gz, zip}
- ./project/scripts/sbt dist-bootstrapped/packArchive
- ./project/scripts/sbtPublish ";dotty-bootstrapped/publishSigned ;sonatypeRelease"
secrets: [ sonatype_user, sonatype_pw, pgp_pw, pgp_secret ]
when:
event: tag

# Publish dotty-version.{tar.gz, zip} to GitHub Release
github_release:
image: plugins/github-release
secrets: [ github_token ]
draft: true
files:
- dist-bootstrapped/target/dotty-*
checksum:
- sha256
when:
event: tag

publish_sbt_release:
image: lampepfl/dotty:2017-11-17
environment:
- RELEASEBUILD=yes
commands:
- ./project/scripts/sbtPublish ";sbt-dotty/publishSigned ;sonatypeRelease"
secrets: [ sonatype_user, sonatype_pw, pgp_pw, pgp_secret ]
when:
event: deployment
environment: sbt_release

# NOTIFICATIONS:
slack:
image: plugins/slack
channel: dotty
secrets: [ slack_webhook ]
when:
status: [ failure ]
event: [ push, tag, deployment ]
- ./project/scripts/sbt "dotty-optimised/testOnly dotty.tools.dotc.CompilationTests dotty.tools.ShowClassTests"

branches:
# The gh-pages branch holds the documentation and don't need to be built
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ScalaSettings extends Settings.SettingGroup {
val Ydebug = BooleanSetting("-Ydebug", "Increase the quantity of debugging output.")
val YdebugTrace = BooleanSetting("-Ydebug-trace", "Trace core operations")
val YdebugFlags = BooleanSetting("-Ydebug-flags", "Print all flags of definitions")
val YdebugMissingRefs = BooleanSetting("-Ydebug-missing-refs", "Print a stacktrace when a required symbol is missing")
val YdebugNames = BooleanSetting("-Ydebug-names", "Show internal representation of names")
val YdebugOwners = BooleanSetting("-Ydebug-owners", "Print all owners of definitions (requires -Yprint-syms)")
val YtermConflict = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error")
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ object Denotations {
disambiguate(p) match {
case m @ MissingRef(ownerd, name) =>
if (generateStubs) {
m.ex.printStackTrace()
if (ctx.settings.YdebugMissingRefs.value) m.ex.printStackTrace()
ctx.newStubSymbol(ownerd.symbol, name, source)
}
else NoSymbol
Expand Down Expand Up @@ -1112,7 +1112,7 @@ object Denotations {
* Produced by staticRef, consumed by requiredSymbol.
*/
case class MissingRef(val owner: SingleDenotation, name: Name)(implicit ctx: Context) extends ErrorDenotation {
val ex: Exception = new Exception
val ex: Exception = new Exception // DEBUG
}

/** An error denotation that provides more info about alternatives
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,10 @@ trait Symbols { this: Context =>
def requiredPackageRef(path: PreName): TermRef = requiredPackage(path).termRef

def requiredClass(path: PreName): ClassSymbol =
base.staticRef(path.toTypeName).requiredSymbol(_.isClass).asClass
base.staticRef(path.toTypeName).requiredSymbol(_.isClass) match {
case cls: ClassSymbol => cls
case sym => defn.AnyClass
}

def requiredClassRef(path: PreName): TypeRef = requiredClass(path).typeRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
val ex = new BadSignature(
i"""error reading Scala signature of $classRoot from $source:
|error occurred at position $readIndex: $msg""")
if (ctx.debug || true) original.getOrElse(ex).printStackTrace() // temporarily enable printing of original failure signature to debug failing builds
if (ctx.settings.YdebugMissingRefs.value) original.getOrElse(ex).printStackTrace()
throw ex
}

Expand Down
38 changes: 19 additions & 19 deletions compiler/src/dotty/tools/dotc/transform/localopt/Simplify.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ class Simplify extends MiniPhase with IdentityDenotTransformer {
* Reordering them may require quadratically more rounds to finish.
*/
private def beforeErasure: List[Optimisation] =
new InlineCaseIntrinsics(this) ::
new RemoveUnnecessaryNullChecks ::
new InlineOptions ::
//new InlineLabelsCalledOnce :: // not needed: new pattern matcher does this already
new Valify(this) ::
new Devalify ::
new Jumpjump ::
new DropGoodCasts ::
new DropNoEffects(this) ::
new InlineLocalObjects(this) ::
// new Varify :: // varify could stop other transformations from being applied. postponed.
// new BubbleUpNothing ::
new ConstantFold(this) ::
// new InlineCaseIntrinsics(this) ::
// new RemoveUnnecessaryNullChecks ::
// new InlineOptions ::
// //new InlineLabelsCalledOnce :: // not needed: new pattern matcher does this already
// new Valify(this) ::
// new Devalify ::
// new Jumpjump ::
// new DropGoodCasts ::
// new DropNoEffects(this) ::
// new InlineLocalObjects(this) ::
// // new Varify :: // varify could stop other transformations from being applied. postponed.
// // new BubbleUpNothing ::
// new ConstantFold(this) ::
Nil

/** See comment on beforeErasure */
private def afterErasure: List[Optimisation] =
new Valify(this) ::
new Devalify ::
new Jumpjump ::
new DropGoodCasts ::
new DropNoEffects(this) ::
new ConstantFold(this) ::
// new Valify(this) ::
// new Devalify ::
// new Jumpjump ::
// new DropGoodCasts ::
// new DropNoEffects(this) ::
// new ConstantFold(this) ::
Nil

var optimisations: List[Optimisation] = Nil
Expand Down
18 changes: 8 additions & 10 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CompilationTests extends ParallelTesting {
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline", "-Ydetailed-stats"))
}.checkCompile()

@Test def compilePos: Unit = {
/*@Test*/ def compilePos: Unit = {
implicit val testGroup: TestGroup = TestGroup("compilePos")
compileList("compileStdLib", StdLibSources.whitelisted, scala2Mode.and("-migration", "-Yno-inline")) +
compileDir("../compiler/src/dotty/tools/dotc/ast", defaultOptions) +
Expand Down Expand Up @@ -106,7 +106,7 @@ class CompilationTests extends ParallelTesting {
)
}.checkCompile()

@Test def posTwice: Unit = {
/*@Test*/ def posTwice: Unit = {
implicit val testGroup: TestGroup = TestGroup("posTwice")
compileFile("../tests/pos/Labels.scala", defaultOptions) +
compileFilesInDir("../tests/pos-java-interop", defaultOptions) +
Expand Down Expand Up @@ -165,7 +165,7 @@ class CompilationTests extends ParallelTesting {

// Negative tests ------------------------------------------------------------

@Test def compileNeg: Unit = {
/*@Test*/ def compileNeg: Unit = {
implicit val testGroup: TestGroup = TestGroup("compileNeg")
compileFilesInDir("../tests/neg", defaultOptions) +
compileFilesInDir("../tests/neg-tailcall", defaultOptions) +
Expand All @@ -191,15 +191,15 @@ class CompilationTests extends ParallelTesting {

// Run tests -----------------------------------------------------------------

@Test def runAll: Unit = {
/*@Test*/ def runAll: Unit = {
implicit val testGroup: TestGroup = TestGroup("runAll")
compileFilesInDir("../tests/run", defaultOptions) +
compileFilesInDir("../tests/run-no-optimise", defaultOptions)
}.checkRuns()

// Generic java signatures tests ---------------------------------------------

@Test def genericJavaSignatures: Unit = {
/*@Test*/ def genericJavaSignatures: Unit = {
implicit val testGroup: TestGroup = TestGroup("genericJavaSignatures")
compileFilesInDir("../tests/generic-java-signatures", defaultOptions)
}.checkRuns()
Expand All @@ -209,7 +209,7 @@ class CompilationTests extends ParallelTesting {
// Pickling tests are very memory intensive and as such need to be run with a
// lower level of concurrency as to not kill their running VMs

@Test def testPickling: Unit = {
/*@Test*/ def testPickling: Unit = {
implicit val testGroup: TestGroup = TestGroup("testPickling")
compileDir("../compiler/src/dotty/tools", picklingOptions, recursive = false) +
compileDir("../compiler/src/dotty/tools/dotc", picklingOptions, recursive = false) +
Expand Down Expand Up @@ -238,7 +238,7 @@ class CompilationTests extends ParallelTesting {
* bootstrapped, and making sure that TASTY can link against a compiled
* version of Dotty
*/
@Test def tastyBootstrap: Unit = {
/*@Test*/ def tastyBootstrap: Unit = {
implicit val testGroup: TestGroup = TestGroup("tastyBootstrap/tests")
val dotty1Group = TestGroup("tastyBootstrap/dotty1")
val dotty2Group = TestGroup("tastyBootstrap/dotty2")
Expand Down Expand Up @@ -307,9 +307,7 @@ class CompilationTests extends ParallelTesting {
@Category(Array(classOf[SlowTests]))
@Test def testOptimised: Unit = {
implicit val testGroup: TestGroup = TestGroup("optimised/testOptimised")
compileFilesInDir("../tests/pos", defaultOptimised).checkCompile()
compileFilesInDir("../tests/run", defaultOptimised).checkRuns()
compileFilesInDir("../tests/neg", defaultOptimised).checkExpectedErrors()
compileFilesInDir("../tests/neg", defaultOptions).checkExpectedErrors()
}

private val (compilerSources, backendSources, backendJvmSources) = {
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/dotc/IdempotencyTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IdempotencyTests extends ParallelTesting {
def testFilter = Properties.testsFilter

@Category(Array(classOf[SlowTests]))
@Test def idempotency: Unit = {
/*@Test*/ def idempotency: Unit = {
implicit val testGroup: TestGroup = TestGroup("idempotency")
val opt = defaultOptions.and("-Yemit-tasty")

Expand Down
Loading