Skip to content

Build manager incorrectly reports errors against inherited Java inner classes when using -make:... #3347

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

Closed
scabug opened this issue Apr 23, 2010 · 8 comments
Assignees

Comments

@scabug
Copy link

scabug commented Apr 23, 2010

I suspect this is related to #3133 which showed similar symptoms. Say you have a pair of Java classes:

public class Base {
  public class Inner {}
}

public class Derived extends Base {
  public void foo(Inner i) {}
}

If you run scalac on them with any -make recompilation strategy other than all, it complains:

$$ ~/scala/scala-2.8.0.RC1/bin/scalac -make:changed *.java
Derived.java:2: error: not found: type Inner
  public void foo(Inner i) {}
                  ^
one error found

This happens if a method in the derived class takes or returns an instance of the inner class, but not if it merely has a field of the inner type.

With -make:all or no -make option at all, scalac is happy.

@scabug
Copy link
Author

scabug commented Apr 23, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3347?orig=1
Reporter: rjm

@scabug
Copy link
Author

scabug commented Apr 23, 2010

@harrah said:
I don't see the error in 2.8.0.RC1 or r21666:

$$ scala-2.8.0.RC1/bin/scalac -make:changed *.java
$$ scala-2.8.0.RC1/bin/scalac -make:changed *.java
Recompiling 2 files
$$ scala-2.8.0.RC1/bin/scalac -make:changed *.java
Recompiling 2 files
$$

It might be a problem that the Java files are always recompiled, but that is a separate issue.

@scabug
Copy link
Author

scabug commented Apr 23, 2010

rjm said:
This definitely happens for me in both RC1 and the latest nightly (r21659 as I type) on both my development machines. What could be in the environment that would influence this? I've tried with both the standard Sun Java 6 and the OpenJDK Java 6 that Debian packages, with the same result.

@scabug
Copy link
Author

scabug commented Apr 24, 2010

rjm said:
Ok, I know why it works for you. It's a copy fail on my part, the inner class needs to be static for the problem to trigger, in RC1 or the latest nightly:

public class Base {
  public static class Inner {}
}

@scabug
Copy link
Author

scabug commented May 18, 2010

@hubertp said:
One workaround for this problem is to explicitly tell the compiler the type of i to be B.Inner. This then compiles for both, javac and scalac.

@scabug
Copy link
Author

scabug commented May 19, 2010

rjm said:
True, though not terribly helpful when dealing with a large, actively developed Java codebase that you're trying to introduce a Scala subsystem into. The Java devs will push back against that; not using -make:{something} at all is a better workaround in my current situation.

@scabug
Copy link
Author

scabug commented May 24, 2010

@hubertp said:
I think #1409 seems to be the main reason for this problem. I know it compiles when you just write

scalac src/B.java src/F.java

but doesn't work for dependency management because it parses the symbols and their types (and it doesn't know the type of Inner but knows of B.Inner). Because of #1409, even if you have just src/B.java and some Scala class that uses the nested static class then you will get type error from the usual compiler (that doesn't happen with full names but I realize that's a workaround far from perfect).

@scabug
Copy link
Author

scabug commented Feb 22, 2012

@hubertp said:
refined build manager is deprecated. bugs related to it will no longer be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants