Skip to content

Getting undefined errors when using inline methods with opaque types #12914

@ntnj

Description

@ntnj

From https://contributors.scala-lang.org/t/allow-setters-with-multiple-arguments/5143/6

Compiler version

3.0.2-RC1-bin-20210621-4aa7f90-NIGHTLY
Scastie: https://scastie.scala-lang.org/LojQGNQeSvGLstjbzwaKBw

Minimized code

object opq:
  opaque type Str = java.lang.String
  object Str:
    def apply(s: String): Str = s
  inline def lower(s: Str): String = s.toLowerCase
    //error: undefined: a.toLowerCase # -1: TermRef(TermRef(NoPrefix,val a),toLowerCase) at inlining
  extension (s: Str)
    inline def upper: String = s.toUpperCase
    //error: undefined: a.toUpperCase # -1: TermRef(TermRef(NoPrefix,val a),toUpperCase) at inlining

@main def main =
  import opq.*
  val a: Str = Str("aSd")
  println(a.upper)
  println(opq.lower(a))

Output

Doesn't compile

Expectation

ASD
asd

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions