Skip to content

Weird case of double-parentheses impacting type inference in List.apply #10062

Closed
@neko-kai

Description

@neko-kai

Minimized code

class X

object X {
  extension (x: List[X]) { def isNull = x.head == null }
}

@main def test = List(null: X).isNull

https://scastie.scala-lang.org/He9Pm96ySZCBCziHLktlXg

Output

Error:

Found:    X
Required: Any*

Expectation

Should compile. If a redundant second set of parentheses is added in List((null: X)), then the example compiles:

class X

object X {
  extension (x: List[X]) { def isNull = x.head == null }
}

@main def test = List((null: X)).isNull

https://scastie.scala-lang.org/dwFH7NAsQyqKpoXHuzAWiA

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions