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

ClassfileParser: Avoid cycle when accessing companion in inner class lookup #16882

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1086,10 +1086,10 @@ class ClassfileParser(
if (sym == classRoot.symbol)
staticScope.lookup(name)
else {
var module = sym.companionModule
if (!module.exists && sym.isAbsent())
module = sym.scalacLinkedClass
module.info.member(name).symbol
var moduleClass = sym.registeredCompanion
if (!moduleClass.exists && sym.isAbsent())
moduleClass = sym.scalacLinkedClass
moduleClass.info.member(name).symbol
}
else if (sym == classRoot.symbol)
instanceScope.lookup(name)
Expand Down
9 changes: 9 additions & 0 deletions sbt-test/java-compat/i15288/QueryRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
interface CopyableBuilder<B, T> {}
interface ToCopyableBuilder<B, T> {}

public class QueryRequest implements ToCopyableBuilder<QueryRequest.Builder, QueryRequest> {
public static Builder builder() { throw new UnsupportedOperationException(); }
public interface Builder extends CopyableBuilder<Builder, QueryRequest> {
void build();
}
}
2 changes: 2 additions & 0 deletions sbt-test/java-compat/i15288/Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Test:
def makeQuery = QueryRequest.builder().build()
1 change: 1 addition & 0 deletions sbt-test/java-compat/i15288/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scalaVersion := sys.props("plugin.scalaVersion")
5 changes: 5 additions & 0 deletions sbt-test/java-compat/i15288/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## This could just be a pos test checked by FromTastyTests, but
## ParallelTesting#compileTastyInDir does not support test with multiple files
## currently.
> compile
> doc