Skip to content

Cyclic reference of extension method when exported and used at toplevel #13669

Closed
@soronpo

Description

@soronpo

Compiler version

v3.1.0-RC2

Minimized code

https://scastie.scala-lang.org/upOXnTlLTgaIZoVUhlsMGg

trait MyExtensions:
  extension (lhs: Int) def bash: Unit = {}

object MyExtensions extends MyExtensions

object Internal:
  export MyExtensions.*
  val works = 1.bash

export MyExtensions.*
val fails = 1.bash

Output

-- [E046] Cyclic Error: test.scala:2:18 -------------------------------------------
2 |  extension (lhs: Int) def bash: Unit = {}
  |                  ^
  |                  Cyclic reference involving method bash

longer explanation available when compiling with `-explain`
-- [E008] Not Found Error: test.scala:11:14 ---------------------------------------
11 |val fails = 1.bash
   |            ^^^^^^
   |            value bash is not a member of Int

Expectation

No error.
Note: if used in scastie in Worksheet mode, this example compiles successfully.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions