Skip to content

Possible regression in type inference #15652

Closed
@griggt

Description

@griggt

This is a reproducer for the community build failure of h8io/borscht reported in #15647

Compiler version

3.2.0-RC2
Works in 3.1.3

Minimized code

trait Node
type NodeParser[T] = Node => T

def child(key: String): Option[Node] = ???

def optionalOneOf[T](in: Map[String, NodeParser[? <: T]]): Option[T] =
  val mappings = in flatMap { (key, parser) =>
    child(key) map { node =>
      key -> (() => parser(node))
    }
  }
  mappings.headOption map (_._2())

Output

-- [E007] Type Mismatch Error: borscht.scala:12:31 -----------------------------
12 |  mappings.headOption map (_._2())
   |                           ^^^^^^
   |                           Found:    Any
   |                           Required: T
   |
   | longer explanation available when compiling with `-explain`
1 error found

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions