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

resident compiler fails when compiling java then scala class with same name #9256

Closed
scabug opened this issue Mar 31, 2015 · 3 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 31, 2015

lucmac:sandbox luc$ cat A.java 
public class A { }
lucmac:sandbox luc$ cat A.scala 
class A
lucmac:sandbox luc$ scalac -Xresident

nsc> A.java

nsc> A.scala
A.scala:1: error: Companions 'class A' and 'object A' must be defined in same file:
  Found in /Users/luc/scala/scala/sandbox/A.scala and /Users/luc/scala/scala/sandbox/A.java
class A
      ^
@scabug
Copy link
Author

scabug commented Mar 31, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9256?orig=1
Reporter: @lrytz
Affected Versions: 2.11.6

@scabug
Copy link
Author

scabug commented Mar 31, 2015

@lrytz said:
The problem shows up in the JUnit compiler tests used for the backend. To reproduce, add a file test/junit/scala/tools/nsc/backend/jvm/opt/ResidentFail.scala:

package scala.tools.nsc
package backend.jvm
package opt

import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.Test
import CodeGenTools._

object ResidentFail {
  val compiler = newCompiler()
}

@RunWith(classOf[JUnit4])
class ResidentFail {
  import ResidentFail._

  @Test
  def test1(): Unit = {
    compile(compiler)("class B", List(("public class A { }", "A.java")))
  }

  @Test
  def test2(): Unit = {
    compile(compiler)("class A")
  }
}

Fails when running both tests, works when running each test separately.

@scabug
Copy link
Author

scabug commented Jun 6, 2016

@adriaanm said:
scala/scala@e108429

@scabug scabug closed this as completed Jun 6, 2016
@scabug scabug added this to the 2.12.0-M5 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants