Skip to content

Inlining issue for named tuples hidden behind opaque types #22324

Closed
@hamzaremmal

Description

@hamzaremmal

Compiler version

3.6.2

Minimized code

//> using scala 3.6.2
//> using options -experimental

import scala.language.experimental.namedTuples

opaque type System = (wires: Any)

extension (system: System)
  inline def foo = system.wires
end extension

val simulation: System = ???
val _ = simulation.foo

Output

-- Error: solution.scala:12:19 -------------------------------------------------
 12 |val _ = simulation.foo
    |        ^^^^^^^^^^^^^^
    |undefined: tup.productElement # -1: TermRef(TermRef(NoPrefix,val tup),productElement) at inlining
    |---------------------------------------------------------------------------
    |Inline stack trace
    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |This location contains code that was inlined from NamedTuple.scala:144
    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |This location contains code that was inlined from NamedTuple.scala:144
    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |This location contains code that was inlined from NamedTuple.scala:144
  9 |  inline def foo = system.wires
    |                   ^^^^^^^^^^^^
     ---------------------------------------------------------------------------
1 error found

Expectation

Compiles without any issue

Notes

  • The soft keyword opaque in System is important to reproduce the issue
  • The soft keyword inline in foo is important to reproduce the issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions