Skip to content

Match type reduction inhibition #20475

Open
@Bersier

Description

@Bersier

Compiler version

3.5.0-RC1

Minimized code

inline def foo[I <: Int](i: I): ZeroOne[I] = i match
  case _: 0 => 0
  case _ => 1

// Wrapping the return value and type somehow inhibits proper match type reduction
inline def bar[I <: Int](i: I): W[ZeroOne[I]] = i match
  case _: 0 => W(0)
  case _ => W(1)

class W[S <: Int & Singleton](s: S)

type ZeroOne[I <: Int] <: Int = I match
  case 0 => 0
  case _ => 1

Compiler Output

Found:    W[(0 : Int)]
Required: W[ZeroOne[I]]

Expectation

No compile-error.

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