Skip to content

Default value of inline parameter is not inlined when the path involves a pattern match against null. #23177

Open
@readren

Description

@readren

Compiler version

3.7.0 with no scala options

Minimized code

class Something

transparent inline def test(inline oNio: Something | Null = null, inline offset: Int = 0): Int = {
	inline val index = inline oNio match {
		case null => offset
		case nio: Something => -1
	}
	index
}

@main def check(): Unit = {
	test(Something(), 0) // compiles
	test(Something()) // compiles
	test(null, 0) // compiles
	test(null) // complains with: inline value must have a literal constant type 
}

Output

[error] 19 |            test(null) // complains with: inline value must have a literal constant type
[error]    |            ^^^^^^^^^^
[error]    |            inline value must have a literal constant type
[error]    |----------------------------------------------------------------------------
[error]    |Inline stack trace
[error]    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]    |This location contains code that was inlined from Borrame.scala:9
[error]  9 |                    case null => offset
[error]    |                                 ^^^^^^
[error]     ----------------------------------------------------------------------------

Expectation

The call to test(null) should compile.

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