diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-11-02 22:30:08 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-11-02 22:30:08 +1000 |
commit | d1a76d5af7faa12ebebea0923812af26c40eebc9 (patch) | |
tree | cfd235e067944568b2a56c9df8a7a61822f371b5 /test/files/presentation/private-case-class-members/Test.scala | |
parent | b473e7c99b2e2e37b3fdb17af2693bf0ed7a02b2 (diff) | |
parent | 134d97dbf56fe96f0a820c78780dd92e8bf9c5e2 (diff) | |
download | scala-d1a76d5af7faa12ebebea0923812af26c40eebc9.tar.gz scala-d1a76d5af7faa12ebebea0923812af26c40eebc9.tar.bz2 scala-d1a76d5af7faa12ebebea0923812af26c40eebc9.zip |
Merge pull request #4081 from retronym/ticket/8943
SI-8943 Handle non-public case fields in pres. compiler
Diffstat (limited to 'test/files/presentation/private-case-class-members/Test.scala')
-rw-r--r-- | test/files/presentation/private-case-class-members/Test.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/files/presentation/private-case-class-members/Test.scala b/test/files/presentation/private-case-class-members/Test.scala new file mode 100644 index 0000000000..e64c8238ea --- /dev/null +++ b/test/files/presentation/private-case-class-members/Test.scala @@ -0,0 +1,34 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.reflect.internal.util.SourceFile +import scala.tools.nsc.interactive.Response + +object Test extends InteractiveTest { + override def execute(): Unit = { + val source = loadSourceAndWaitUntilTypechecked("State.scala") + checkErrors(source) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + compiler.askToDoFirst(sourceFile) + val res = new Response[Unit] + compiler.askReload(List(sourceFile), res) + res.get + askLoadedTyped(sourceFile).get + // the second round of type-checking makes it fail + compiler.askReload(List(sourceFile), res) + res.get + askLoadedTyped(sourceFile).get + + sourceFile + } + + private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => + val problems = unit.problems.toList + if(problems.isEmpty) reporter.println("Test OK") + else problems.foreach(problem => reporter.println(problem.msg)) + + case None => reporter.println("No compilation unit found for " + source.file.name) + } +} |