Skip to content

Constant fold expressions of type Null and Unit #12198

Open
@nicolasstucki

Description

@nicolasstucki

Compiler version

3.0.0-RC3

Expectation

Constant folding should be able to handle Null and Unit.

Possible use cases

class A[T]:
  val x: T
object B extends A[Unit]:
    val x: Unit = ()
object C extends A[Null]:
    val x: Null = ()
def test1 =  B.x // should be constant folded to `()`
def test2 = C.x // should be constant folded to `null`
inline val n = null
inline val u = ()
def test1 = n // should be constant folded to `null`
def test2 = u // should be constant folded to `()`

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