title: Symbol value does not exist in someMethod
body: <p>This is my source code for testing:</p>
  
  <pre><code>import org.openqa.selenium.firefox.FirefoxDriver
  import org.scalatest.FlatSpec
  import org.scalatest.Matchers
  
  import play.api.test.FakeApplication
  import play.api.test.WithApplication
  
  class FunctionalSpec extends FlatSpec with Matchers {
    def withDriver(f: FirefoxDriver =&gt; Unit) = {
      val driver = new FirefoxDriver
      try {
        new WithApplication(
          new FakeApplication(additionalConfiguration = Map("application.secret" -&gt; "secret"))) {
          f(driver)
        }
      } finally {
        driver.quit
      }
    }
  }
  </code></pre>
  
  <p>It doesn't show any compile-error in Eclipse. But when I execute the <code>test</code> command it shows <a href="http://pastebin.com/FkJJU7UR" rel="nofollow">a very long error message</a>. This is the first line of the errors:</p>
  
  <blockquote>
    <p>symbol value f$1 does not exist in test.FunctionalSpec$$anon$1$delayedInit$body.apply</p>
  </blockquote>
  
  <p>I tried to play around a bit by modifying the code as shown below:</p>
  
  <pre><code>  def withDriver(f: FirefoxDriver =&gt; Unit) = {
      val driver = new FirefoxDriver
      try {
        val g = f
        val driver2 = driver
        new WithApplication(
          new FakeApplication(additionalConfiguration = Map("application.secret" -&gt; "secret"))) {
          val h = g
          val driver3 = driver2
          h(driver3)
        }
      } finally {
        driver.quit
      }
    }
  </code></pre>
  
  <p>There are no errors thrown when I executed the <code>test</code> command. Any idea what's happening? Is there any limit of how deep a block of code can go in order to keep the identifiers recognised?</p>
  
  <p>EDIT:
  Using my modified code above results in <a href="http://pastebin.com/a4VSgSuP" rel="nofollow">runtime-error</a>. I added the code below:</p>
  
  <pre><code>"The admin" should "be able to login and logout correctly" in withDriver { implicit driver =&gt;
    // Don't do anything yet.
  }
  </code></pre>
  
  <p>This one is displayed in one line of the runtime-error messages:</p>
  
  <blockquote>
    <p>Cause: java.lang.NoSuchFieldError: g$1</p>
  </blockquote>
  
  <p>Any suggestion for a workaround?</p>
  
  <p><strong>ADDITIONAL NOTE:</strong>
  All the codes above compile just fine. Neither Eclipse or <code>scalac</code> complain. All the errors above happen only when I do the <code>test</code> command from the Play command shell.</p>