Skip to content

Intersection of implicit function types is not an implicit function type #5473

Closed
@smarter

Description

@smarter

E.g.:

trait A
trait B

object Test {
  val x: (implicit A => Int) & (implicit B => Int) = 42
    // error: found: 42, required: (implicit A => Int) & (implicit B => Int)
}

We probably should treat this as an implicit function type, otherwise distributing an intersection (something that the compiler will do in some situations) would change the semantics. But then should we allow this too ?

trait A
trait Foo extends ImplicitFunction[A, Int]

object Test {
  val x: Foo = 42
}

@odersky WDYT ?

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