8000 Can't resolve to overloaded apply (regression 2.11.9 ?) · Issue #352 · scala/scala-dev · GitHub
[go: up one dir, main page]

Skip to content
Can't resolve to overloaded apply (regression 2.11.9 ?) #352
Closed
@xuwei-k

Description

@xuwei-k

https://github.com/xuwei-k/apply-overload-2.11.9

import org.scalacheck.{Arbitrary, Gen}

case class Foo[A](x: Option[Int], y: A)

object Foo {
  // error
  implicit def arbitrary[A](implicit a: Arbitrary[A]): Arbitrary[Foo[A]] =
    Arbitrary(Gen.resultOf[Option[Int], A, Foo[A]](Foo.apply[A]))

  def apply[A](x: Int, y: A): Foo[A] = Foo(Some(x), y)
}

[error]  found   : (Int, A) => example.Foo[A]
[error]  required: (Option[Int], A) => example.Foo[A]
[error]     Arbitrary(Gen.resultOf[Option[Int], A, Foo[A]](Foo.apply[A]))
[error]                                                             ^

but this is ok (change method definition order)

object Foo {
  def apply[A](x: Int, y: A): Foo[A] = Foo(Some(x), y)

  // ok
  implicit def arbitrary[A](implicit a: Arbitrary[A]): Arbitrary[Foo[A]] =
    Arbitrary(Gen.resultOf[Option[Int], A, Foo[A]](Foo.apply[A]))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0