Skip to content

object caps does not have a member type Cap #21107

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

Closed
jxnu-liguobin opened this issue Jul 7, 2024 · 6 comments
Closed

object caps does not have a member type Cap #21107

jxnu-liguobin opened this issue Jul 7, 2024 · 6 comments

Comments

@jxnu-liguobin
Copy link
Member

I'm upgrading from 3.3.3 to 3.4.1 and after rewriting syntax I try to commit the code but the CI complained.

Compiler version

3.4.1

Minimized code

According to the logs, dotty crashes at AnalyzerException, which is just a simple code.

package bitlap.sbt.analyzer.model

import bitlap.sbt.analyzer.DependencyScopeEnum

sealed abstract class AnalyzerException(msg: String)           extends RuntimeException(msg)
final case class AnalyzerCommandNotFoundException(msg: String) extends AnalyzerException(msg)

final case class AnalyzerCommandUnknownException(
  command: String,
  moduleId: String,
  scope: DependencyScopeEnum,
  msg: String
) extends AnalyzerException(msg)

It's ok on my Mac OSX:

Output (click arrow to expand)

[info] compiling 42 Scala sources and 1 Java source to /home/runner/work/intellij-sbt-dependency-analyzer/intellij-sbt-dependency-analyzer/target/scala-3.4.1/classes ...
  unhandled exception while running MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, checkStatic, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher} on /home/runner/work/intellij-sbt-dependency-analyzer/intellij-sbt-dependency-analyzer/src/main/scala/bitlap/sbt/analyzer/model/AnalyzerException.scala
  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.
     while compiling: /home/runner/work/intellij-sbt-dependency-analyzer/intellij-sbt-dependency-analyzer/src/main/scala/bitlap/sbt/analyzer/model/AnalyzerException.scala
        during phase: MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, checkStatic, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.1
            settings: -Werror true -classpath /home/runner/work/intellij-sbt-dependency-analyzer/intellij-sbt-dependency-analyzer/target/scala-3.4.1/classes:/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.9.10/kotlin-scripting-compiler-embeddable-1.9.10.jar:/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/guru/nidi/graphviz-java-min-deps/0.18.1/graphviz-java-min-deps-0.18.1.jar:/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.5.6/logback-classic-1.5.6.jar:/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jooq/joor/0.9.15/joor-0.9.15.jar:/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-scripting-compiler-impl-embeddable/1.9.10/kotlin-scripting-compiler-impl-embeddable-1.9.10.jar:/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.9.10/kotlin-stdlib-1.9.10.jar:/home/runner/.cache/cour
[error] ## Exception when compiling 43 sources to /home/runner/work/intellij-sbt-dependency-analyzer/intellij-sbt-dependency-analyzer/target/scala-3.4.1/classes
[error] dotty.tools.dotc.core.TypeError$$anon$1: object caps does not have a member type Cap
[error] 
[error]            
[error] dotty.tools.dotc.core.TypeError$$anon$1: object caps does not have a member type Cap
[error] (Compile / compileIncremental) dotty.tools.dotc.core.TypeError$$anon$1: object caps does not have a member type Cap
[error] Total time: 26 s, completed Jul 7, 2024, 5:[51](https://github.com/bitlap/intellij-sbt-dependency-analyzer/actions/runs/9825009887/job/27124625884?pr=101#step:4:52):08 AM
@jxnu-liguobin jxnu-liguobin added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 7, 2024
@WojciechMazur
Copy link
Contributor

This should be fixed already in #20493, I think it should be available in 3.5.1 but we might backport it to 3.3.4 LTS. The minimization is missing the dependencies, so I cannot confirm it yet.

@Gedochao Gedochao added area:initialization area:opaque-types stat:needs minimization Needs a self contained minimization and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jul 8, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Jul 8, 2024

@jxnu-liguobin can you help us minimise this?
or at least provide us the dependencies/project configuration to reproduce this issue?

@jxnu-liguobin
Copy link
Member Author

@jxnu-liguobin can you help us minimise this? or at least provide us the dependencies/project configuration to reproduce this issue?

My repo is here. You can see the details from Github Action.
https://github.com/bitlap/intellij-sbt-dependency-analyzer/tree/rewrite-3.4.1-syntax

I did not reproduce it on Mac OSX, which is why I submitted an ISSUE.

@Gedochao
Copy link
Contributor

Gedochao commented Jul 9, 2024

We'll still need this minimised, rather than the whole repo... we'd welcome help, it may take time before someone on the maintenance team has time to dive into this.

I'm guessing the Kotlin plugin is where the imports from the snippet come from...
https://index.scala-lang.org/bitlap/kotlin-plugin

@WojciechMazur
Copy link
Contributor

It seems that issue originates due to specific classpath entries added by the SbtIdeaPlugin and IntellijPlugins

// build.sbt

lazy val `sbt-dependency-analyzer` = (project in file("."))
  .enablePlugins(SbtIdeaPlugin)
  .settings(
    scalaVersion := "3.4.1",
    intellijPlugins ++= Seq("com.intellij.java", "com.intellij.java-i18n", "org.intellij.scala").map(_.toPlugin),
  )
// project/plugins.sbt

addSbtPlugin("org.jetbrains" % "sbt-idea-plugin"   % "3.26.2")
// src/main/scala/AnalyzerException.scala

sealed abstract class AnalyzerException(msg: String)           extends RuntimeException(msg)
final case class AnalyzerCommandNotFoundException(msg: String) extends AnalyzerException(msg)

I'm not yet sure what exactly causes that, but I can confirm it's 3.6.0-RC1-bin-20240708-0e36424-NIGHTLY
I suggest to backport #20493 to 3.5.0-RC4 as the issue probably originates when trying to enter some fallback path where it tries to use non-existing caps object declared in the compiler definitions - it expects type which does not exist, it should refer to class instead

@WojciechMazur
Copy link
Contributor

It was fixed in 3.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants