Skip to content

match expression ignores inline command #10919

@antognini

Description

@antognini

Minimized code

3.0.0-M3

object Inline1:
  inline def foo( i:Int): Int =
    inline if i == 0 then -1 
    else Math.abs(i)

  def bar(i:Int): Int = foo(i) // as expected, fails to compile
  //                    ^^^^^^
  // Cannot reduce `inline if` because its condition is not a constant value: i.==(0)


object Inline2:
  inline def foo( i:Int): Int =
    inline i match
      case 0     => -1
      case x:Int => Math.abs(x)
  
  def bar(i:Int): Int = foo(i) // a compilation error was expected, but none is reported

Expectation

inline is a command in Scala 3.0.0, not an implementation hint:
=> def bar() should fail in conjunction with inline match, as it does with inline if.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions