Skip to content

Compiler error with multiple inline methods with parameters of opaque types #17243

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
natsukagami opened this issue Apr 13, 2023 · 0 comments · Fixed by #22381
Closed

Compiler error with multiple inline methods with parameters of opaque types #17243

natsukagami opened this issue Apr 13, 2023 · 0 comments · Fixed by #22381

Comments

@natsukagami
Copy link
Contributor

Compiler version

v3.1.3 and latest main.

Minimized code

object Opaque:
  opaque type A = Int

  val va: A = 1

  inline def a(x: A) =
    x + 1

object Opaque2:
  opaque type B = Opaque.A

  val vb: B = Opaque.va

  inline def b(x: B) = Opaque.a(x)

@main def Test() =
  print(Opaque2.b(Opaque2.vb))

Output

-- [E173] Reference Error: Test.scala:17:17 ------------------------------------
17 |  print(Opaque2.b(Opaque2.vb))
   |        ^^^^^^^^^^^^^^^^^^^^^
   |+ cannot be accessed as a member of (x$proxy1 : (Opaque2.vb : Opaque2.B) & $proxy1.B) from module class Test$package$.
   |----------------------------------------------------------------------------
   |Inline stack trace
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from Test.scala:7
 7 |    x + 1
   |    ^^^
   |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
   |This location contains code that was inlined from Test.scala:7
14 |  inline def b(x: B) = Opaque.a(x)
   |                       ^^^^^^^^^^^
    ----------------------------------------------------------------------------

Expectation

Should compile fine.

Note that if we remove at least one of the inlines, everything compiles fine. If we remove at least one of the opaques, everything compiles fine.

@natsukagami natsukagami added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 13, 2023
@nicolasstucki nicolasstucki added area:inline area:opaque-types and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 17, 2023
@jchyb jchyb closed this as completed in fe2e6e9 Jan 20, 2025
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
tgodzik pushed a commit to scala/scala3-lts that referenced this issue Apr 1, 2025
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.

3 participants