Unable to find class in inherited scope
See original GitHub issueCompiler version
Using Scala 3.0.0, I am unable to compile Java code that is generated by protoc (protobuf compiler). The following is a minimized version of the generated code to demonstrate the issue.
Minimized code
// src/main/java/mytest/Ex.java
package mytest;
public final class Ex {
private Ex() {}
public static final class Foo extends MyInterface {
private Foo() {
}
@SuppressWarnings({"unused"})
protected java.lang.Object newInstance(
UnusedPrivateParameter unused) {
return new Foo();
}
}
}
// src/main/java/mytest/MyInterface.java
package mytest;
public class MyInterface {
public static final class UnusedPrivateParameter {};
}
The Scala code doesn’t matter, but it needs to exist:
// src/main/scala/Main.scala
package foo
object Main {}
Output
sbt:ppp> compile
[info] compiling 1 Scala source and 2 Java sources to /tmp/ppp/target/scala-3.0.0/classes ...
[error] -- [E006] Not Found Error: /tmp/ppp/src/main/java/mytest/Ex.java:12:8 ----------
[error] 12 | UnusedPrivateParameter unused) {
[error] | ^^^^^^^^^^^^^^^^^^^^^^
[error] | Not found: type UnusedPrivateParameter
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed May 22, 2021, 10:36:18 AM
Expectation
Should compile with no errors.
Workaround
Adding compileOrder := CompileOrder.JavaThenScala
results in successful compilation.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
PHP: Can't use inheritance. It won't find the class
1 Answer 1 ... You need to include the mother.php too. Otherwise it can't find the class as the error states. ... <?php...
Read more >cannot find type in scope xcode 13 | Apple Developer Forums
I had many swift compiler errors of this type : "Cannot find type 'className' in scope" after passing from Xcode 12.5 to Xcode...
Read more >How to Resolve The Cannot Find Symbol Error in Java - Rollbar
The cannot find symbol error refers to a situation where the Java compiler is unable to find the symbol associated with a given...
Read more >Inheritance — What your mother never told you, C++ FAQ
See the reasons under given for final classes. Is it okay for a non- virtual function of the base class to call a...
Read more >about Classes - PowerShell | Microsoft Learn
Define custom types in PowerShell using familiar object-oriented programming semantics like classes, properties, methods, inheritance, etc.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@som-snytt That looks like the probaby fix, yes. Maybe we can get a volunteer to forward port it?
OK I see someone is already looking into the other ticket. Oh wait, that was 2019. OSS is hard.