Skip to content

inline match over Option[String] not accept None as scrutinee  #14245

Closed
@rssh

Description

@rssh

Compiler version

Master on state of Tue Jan 11 00:12:54 EET 2022

Minimized code

object Test {

  inline def get: Option[String] = None

  private transparent inline def fun: Unit =
    inline get match
      case Some(x) => println("value = $x")
      case None    => println("value not set")

  fun

}

Output

[info] compiling 1 Scala source to /Users/rssh/tests/dotty/compileTimeNoCast/target/scala-3.1.2-RC1-bin-SNAPSHOT/classes ...
[error] -- [E007] Type Mismatch Error: /Users/rssh/tests/dotty/compileTimeNoCast/src/main/scala/x/Test.scala:12:2 
[error] 12 |  fun
[error]    |  ^^^
[error]    |  Found:    Option[String]
[error]    |  Required: None.type
[error]    | This location contains code that was inlined from Test.scala:5
[error]    | This location contains code that was inlined from Test.scala:8
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed 11 Jan 2022, 00:14:05

Expectation

should be compiled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions