Skip to content

Extension method with old syntax provokes Recursion limit exceeded #21315

Open
@DavidPerezIngeniero

Description

@DavidPerezIngeniero

Compiler version

Scala 3.3.3
Java 21
SBT 1.9.9

Minimized code

implicit class ConnectionPoolOps(pool: ConnectionPool){
    def getPoolName(): String = Option(pool).map(_.getName).getOrElse("<null>")
  }

  implicit class ConexionAbiertaOps(conn: ConexionAbierta){
    def poolName(): String = conn.pool.getPoolName()
  }

Output

Recursion limit exceeded.
Maybe there is an illegal cyclic reference?
If that's not the case, you could also try to increase the stacksize using the -Xss JVM option.
For the unprocessed stack trace, compile with -Yno-decode-stacktraces.
A recurring operation is (inner to outer):

  subtype String & K <:< Nothing
  subtype String & K <:< Nothing
  subtype String <:< scala.collection.Map[? >: String & K <: String | K, String]#K
  subtype String | K <:< scala.collection.Map[? >: String & K <: String | K, String]#K
  subtype (String | K, String) <:< (scala.collection.Map[? >: String & K <: String | K, String]#K, String)
  subtype ((scala.collection.Map[? >: String & K <: String | K, String]#K, String)) => (
  K2, V2) <:< ((String | K, String)) => B
        .map { v =>

Expectation

It compiles ok, as it used to do in Scala 2.13.14.

Notes

If I change the code to:

  extension (pool: ConnectionPool)
    def getPoolName(): String = Option(pool).map(_.getName).getOrElse("<null>")

  extension (con: ConexionAbierta)
    def poolName(): String = con.pool.getPoolName()

then it compiles ok.
The error message that I get before is very misleading.

More details: https://stackoverflow.com/questions/78820065/recursion-limit-when-compiling-with-sbt/78824037#78824037

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions