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 error when using doc but not compile #14059

Closed
keirlawson opened this issue Dec 7, 2021 · 1 comment · Fixed by #16882
Closed

Cyclic reference error when using doc but not compile #14059

keirlawson opened this issue Dec 7, 2021 · 1 comment · Fixed by #16882
Assignees
Milestone

Comments

@keirlawson
Copy link

Compiler version

3.1.0

Minimized code

Based on https://github.com/chadselph/reproduce-dotty-cyclical-error

package example

import software.amazon.awssdk.services.cloudwatchlogs.model.GetLogEventsRequest

object DottyCylicalRefError {

  GetLogEventsRequest
    .builder()
    .limit(0)
}

Output

sbt:root> doc
[info] Main Scala API documentation to /home/keirlawson/Code/reproduce-dotty-cyclical-error/target/scala-3.1.0/api...
exception caught when loading trait Builder: Cyclic reference involving object GetLogEventsRequest
exception caught when loading module class GetLogEventsRequest$: Cyclic reference involving object GetLogEventsRequest
Cyclic reference involving object GetLogEventsRequest while compiling /home/keirlawson/Code/reproduce-dotty-cyclical-error/target/scala-3.1.0/classes/example/DottyCylicalRefError.tasty

Expectation

No cyclic reference as compile passes fine.

@pikinier20
Copy link
Contributor

This bug is not directly related to doctool. The problem lies in compilation from tasty which is run by Scaladoc under the hood.
Running the following command:

scalac -classpath <classpath_from_sbt> --from-tasty target/scala-3.1.2-RC1-bin-20211213-8e1054e-NIGHTLY/classes/example/DottyCylicalRefError.tasty

produces the same error:

exception caught when loading trait Builder: Cyclic reference involving object GetLogEventsRequest
exception caught when loading module class GetLogEventsRequest$: Cyclic reference involving object GetLogEventsRequest
Cyclic reference involving object GetLogEventsRequest while compiling target/scala-3.1.2-RC1-bin-20211213-8e1054e-NIGHTLY/classes/example/DottyCylicalRefError.tasty
Exception in thread "main" dotty.tools.dotc.core.CyclicReference: 
        at dotty.tools.dotc.core.CyclicReference$.apply(TypeErrors.scala:155)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:166)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser$innerClasses$.getMember$1(ClassfileParser.scala:1060)
        at dotty.tools.dotc.core.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1072)
        at dotty.tools.dotc.core.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:114)
        at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:396)
        at dotty.tools.dotc.core.classfile.ClassfileParser.processTypeArgs$1(ClassfileParser.scala:383)
        at dotty.tools.dotc.core.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:398)
        at dotty.tools.dotc.core.classfile.ClassfileParser.dotty$tools$dotc$core$classfile$ClassfileParser$$sigToType(ClassfileParser.scala:522)
        at dotty.tools.dotc.core.classfile.ClassfileParser$AttributeCompleter.complete(ClassfileParser.scala:665)
        at dotty.tools.dotc.core.classfile.ClassfileParser.parseClass(ClassfileParser.scala:190)
        at dotty.tools.dotc.core.classfile.ClassfileParser.$anonfun$1(ClassfileParser.scala:87)
        ...

@Kordyjan Kordyjan added this to the Future versions milestone Dec 15, 2022
@Kordyjan Kordyjan assigned smarter and unassigned bishabosha Jan 16, 2023
@Kordyjan Kordyjan modified the milestones: Future versions, 3.3.1-RC1 Jan 16, 2023
smarter added a commit that referenced this issue Feb 16, 2023
…lookup (#16882)

Previously, the call to `info` on the module val could lead to a cycle
since the module val might be in the process of being completed. This
commit fixes this by only using the module class which is all we need to
lookup members.

Fixes #15288.
Fixes #14059.

Co-Authored-By: Tom Grigg <tomegrigg@gmail.com>
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.

6 participants