Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in Community Build: ScalaCheck #4032

Closed
allanrenucci opened this issue Feb 22, 2018 · 1 comment
Closed

Regression in Community Build: ScalaCheck #4032

allanrenucci opened this issue Feb 22, 2018 · 1 comment

Comments

@allanrenucci
Copy link
Contributor

https://travis-ci.org/lampepfl/dotty-community-build/jobs/342277554

@allanrenucci
Copy link
Contributor Author

#3981 introduced the regression. Here is a minimised reproduction:

import scala.concurrent.Future

class Gen[+T] {
  def map[U](f: T => U): Gen[U] = ???
}

object Gen {
  def oneOf[T](t0: T, t1: T): Gen[T] = ??? // Compile with this line commented
  def oneOf[T](g0: Gen[T], g1: Gen[T]): Gen[T] = ???
}

class Arbitrary[T]

object Arbitrary {
  def arbitrary[T]: Gen[T] = ???

  def arbFuture[T]: Gen[Future[T]] =
    Gen.oneOf(arbitrary[Future[T]], arbitrary[Throwable].map(Future.failed))
}
-- [E007] Type Mismatch Error: tests/allan/Test.scala:53:60 --------------------
53 |    Gen.oneOf(arbitrary[Future[T]], arbitrary[Throwable].map(Future.failed))
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                             found:    Gen[scala.concurrent.Future[Any]]
   |                             required: Gen[concurrent.Future[T]]
   |                             
one error found

@allanrenucci allanrenucci assigned odersky and unassigned allanrenucci Feb 22, 2018
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 1, 2018
This is an altogether unsatisfying scenario. In scala#4032 there's an unconstrained
type variable that should be interpolated and it's a coin flip whether we instantiate
it to the lower or upper bound. A completely unrelated change in scala#3981 meant that
we instantiated the variable to the upper instead of the lower bound which caused
the program to fail. We now fix it by adding another condition which is also more
or less arbitrary: if neither lower bound nor upper bound is defined, we now prefer
again the lower bound. But all of this is quite arbitrary. The fact is that we do
cut off some parts of the search space in arbitrary ways and programs have come on
rely on the specific arbitrary way in which we do it.
allanrenucci added a commit that referenced this issue Mar 5, 2018
Fix #4032: Fix direction of instantiation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants