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

REPL: Compilatation failed "Main.scala:11: Internal is renamed twice" #352

Closed
Flowdalic opened this issue Feb 23, 2016 · 12 comments
Closed
Labels

Comments

@Flowdalic
Copy link
Contributor

I'm trying to add a REPL to my Java projects build with gradle (same as #237). At first I was using the Scala REPL which worked but didn't had tab completion support. Now I was pointed to Ammonite, which I configured.

At first I was very happy, because tab completion now works, but unfortunately, when trying to invoke a method, the compilation fails:

MiniDNS REPL
Welcome to the Ammonite Repl 0.5.5
(Scala 2.11.7 Java 1.8.0_72)
@ c.q 
query

def query(x$1: String,x$2: de.measite.minidns.Record.TYPE,x$3: de.measite.minidns.Record.CLASS,x$4: java.net.InetAddress): de.measite.minidns.DNSMessage
def query(x$1: String,x$2: de.measite.minidns.Record.TYPE,x$3: de.measite.minidns.Record.CLASS,x$4: java.net.InetAddress,x$5: Int): de.measite.minidns.DNSMessage
def query(x$1: de.measite.minidns.Question): de.measite.minidns.DNSMessage
def query(x$1: de.measite.minidns.Question,x$2: String): de.measite.minidns.DNSMessage
def query(x$1: de.measite.minidns.Question,x$2: java.net.InetAddress): de.measite.minidns.DNSMessage
def query(x$1: de.measite.minidns.Question,x$2: java.net.InetAddress,x$3: Int): de.measite.minidns.DNSMessage
final def query(x$1: String,x$2: de.measite.minidns.Record.TYPE): de.measite.minidns.DNSMessage
final def query(x$1: String,x$2: de.measite.minidns.Record.TYPE,x$3: de.measite.minidns.Record.CLASS): de.measite.minidns.DNSMessage
@ c.query("foo.bar.com", TYPE.A) 
Main.scala:11: Internal is renamed twice
import ammonite.repl.frontend.ReplBridge.repl.{
       ^
Compilation Failed
@  
@lihaoyi
Copy link
Member

lihaoyi commented Feb 23, 2016

@Flowdalic can you provide standalone repro steps I can use? I haven no idea what gradle is or what miniDNS is, but this looks like it should be fixable

@Flowdalic
Copy link
Contributor Author

See mentioned commit. Steps to reproduce

git clone https://github.com/Flowdalic/minidns.git
cd minidns
git checkout -b repl
./repl

@lihaoyi
Copy link
Member

lihaoyi commented Feb 23, 2016

I'm getting

haoyi-mbp:minidns haoyi$ git checkout -b repl
Switched to a new branch 'repl'
haoyi-mbp:minidns haoyi$ ./repl
Compiling and computing classpath (May take a while)
./repl: line 15: gradle: command not found
Classpath computed, starting REPL
Error: Could not find or load main class scala.tools.nsc.MainGenericRunner
haoyi-mbp:minidns haoyi$ brew install gradle
==> Downloading https://downloads.gradle.org/distributions/gradle-2.3-bin.zip
######################################################################## 100.0%
🍺  /usr/local/Cellar/gradle/2.3: 154 files, 45M, built in 5 seconds
haoyi-mbp:minidns haoyi$ ./repl
Compiling and computing classpath (May take a while)

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/haoyi/Dropbox (Personal)/Workspace/minidns/build.gradle' line: 198

* What went wrong:
A problem occurred evaluating root project 'MiniDNS'.
> ANDROID_HOME environment variable is not set

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Classpath computed, starting REPL
Error: Could not find or load main class scala.tools.nsc.MainGenericRunner

Do I need an Android SDK set up to make this fail?

@lihaoyi
Copy link
Member

lihaoyi commented Feb 23, 2016

Could you throw together a repro that doesn't require android? Ideally I'd want something I can run on OpenJDK. I don't see anything about this failure which would be specific to Android

@lihaoyi lihaoyi added the bug label Feb 23, 2016
@PanAeon
Copy link

PanAeon commented Feb 23, 2016

The problem is that when someone imports 'repl' object everything fails:
import de.measite.minidns.repl
Steps to reproduce:
object repl

@lihaoyi
Copy link
Member

lihaoyi commented Feb 23, 2016

Yeah but i have no clue what the repl object is, and this bug shouldn't have that much to do with your code. Unfortunately, I'm not that familiar with your code or setup to know what's important or not. But if one of you could minimize this (i.e. just start a branch and delete all the trash that's irrelevant) that would help me a lot in fixing this

@PanAeon
Copy link

PanAeon commented Feb 23, 2016

No-no, just create object repl in ammonite, and then it throws compilation error.

@lihaoyi
Copy link
Member

lihaoyi commented Feb 23, 2016

Oh that's a good find

haoyi-mbp:~ haoyi$ ~/amm
Loading...
Welcome to the Ammonite Repl 0.5.5
(Scala 2.11.7 Java 1.8.0_25)
haoyi-haoyi@ 1
res0: Int = 1
haoyi-haoyi@ object repl
defined object repl
haoyi-haoyi@ 1
Main.scala:11: Internal is renamed twice
import ammonite.repl.frontend.ReplBridge.repl.{
       ^
Compilation Failed

@lihaoyi
Copy link
Member

lihaoyi commented Feb 23, 2016

@PanAeon as a workaround could you import your repl as something else, e.g. minidnsrepl or something?

@PanAeon
Copy link

PanAeon commented Feb 23, 2016

Well, it's not mine) It's Flowdalic's)

@Flowdalic
Copy link
Contributor Author

s/de.measite.minidns.repl/de.measite.minidns.minidnsrepl/ fixed the issue for me (not sure if you want/can fix it in Ammonite). Thank you. :)

Flowdalic added a commit to Flowdalic/minidns that referenced this issue Feb 23, 2016
It comes with working tab completion. \o/

Was necessary to
s/de.measite.minidns.repl/de.measite.minidns.minidnsrepl/ because of
com-lihaoyi/Ammonite#352.
@lihaoyi
Copy link
Member

lihaoyi commented Feb 28, 2016

Here's a tighter minimization of the issue:

@ object Foo{
    val bar = 1
  }
defined object Foo
@ import Foo.bar
import Foo.bar
@ import Foo.{bar => _}
import Foo.{bar => _}
@ bar
Main.scala:41: bar is renamed twice
import cmd0.Foo.{
       ^
Compilation Failed

@lihaoyi lihaoyi closed this as completed in 2953320 Mar 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants