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

Cyclic reference involving class when calling method of Java class on Scala 3.0.1 #13336

Closed
wiwiwa opened this issue Aug 19, 2021 · 1 comment · Fixed by #13341
Closed

Cyclic reference involving class when calling method of Java class on Scala 3.0.1 #13336

wiwiwa opened this issue Aug 19, 2021 · 1 comment · Fixed by #13341
Assignees
Milestone

Comments

@wiwiwa
Copy link

wiwiwa commented Aug 19, 2021

When calling a method of Java class in Spring Security library, Scala code failed to compile.

I saw similar errors when searching error message in this project, but it seems all problem got fixed in earlier version.

Compiler version

3.0.1

Minimized code

import org.springframework.security.config.annotation.web.builders.HttpSecurity

object TestCyclicReference:
  def securityFilter(http: HttpSecurity) = http.authorizeRequests

The above code need dependency org.springframework.security:spring-security-config:5.5.2 to compile.

Output

TestCyclicReference.scala:4:44 Cyclic reference involving class AbstractInterceptUrlRegistry [4:44]

The code at error position: http.authorizeRequests

Expectation

The code should be compiled successful

@smarter smarter added compat:java stat:needs minimization Needs a self contained minimization labels Aug 19, 2021
@griggt
Copy link
Contributor

griggt commented Aug 19, 2021

Self-contained:

Configurer.java

abstract class AbstractConfigurer {
    abstract class AbstractRegistry<R extends AbstractRegistry<R>> {}
}

public final class Configurer extends AbstractConfigurer {
    public final class Registry extends AbstractRegistry<Registry> {}
    public Registry registry() { return null; }
}

Test.scala

object Test:
  def registry(cfg: Configurer) = cfg.registry
$ javac -version && scalac -3.head -version
javac 1.8.0_292
Scala compiler version 3.1.0-RC1-bin-20210818-868906d-NIGHTLY-git-868906d -- Copyright 2002-2021, LAMP/EPFL

$ javac Configurer.java
$ scalac -3.head Test.scala 
exception caught when loading class AbstractRegistry: Cyclic reference involving class AbstractRegistry
exception caught when loading class Registry: Cyclic reference involving class AbstractRegistry
-- [E046] Cyclic Error: Test.scala:2:34 ----------------------------------------
2 |  def registry(cfg: Configurer) = cfg.registry
  |                                  ^
  |                         Cyclic reference involving class AbstractRegistry

@griggt griggt removed the stat:needs minimization Needs a self contained minimization label Aug 19, 2021
@smarter smarter self-assigned this Aug 19, 2021
smarter added a commit to dotty-staging/dotty that referenced this issue Aug 19, 2021
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
@Kordyjan Kordyjan added this to the 3.1.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants