question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to find class in inherited scope

See original GitHub issue

Compiler 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:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
oderskycommented, May 23, 2021

@som-snytt That looks like the probaby fix, yes. Maybe we can get a volunteer to forward port it?

0reactions
som-snyttcommented, May 23, 2021

OK I see someone is already looking into the other ticket. Oh wait, that was 2019. OSS is hard.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found