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

infer simpler type for existentials #5579

Closed
scabug opened this issue Mar 17, 2012 · 5 comments

Comments

@scabug
Copy link

commented Mar 17, 2012

Probably it's not a bug, however looks very suspicious

class Result[+A]

case class Success[A](x: A) extends Result[A]

class Apply[A]

object Apply {
  def apply[A](f: Int => Result[A]): Apply[A] = new Apply[A]
}

object TestUnit {
  //Error is here:
  def goo = Apply { i =>
    i match {
      case 1 => Success(Some(1))
      case _ => Success(None)
    }
  }
  
  //If type is defined explicitly (which I wanted from compiler to infer), then all is ok
  def foo = Apply[t forSome {type t >: Some[Int] with None.type <: Option[Int]}] { i =>
    i match {
      case 1 => Success(Some(1))
      case _ => Success(None)
    }
  }
}
@scabug

This comment has been minimized.

Copy link
Author

commented Mar 17, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5579?orig=1
Reporter: @Alefas
Affected Versions: 2.9.1, 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

commented Mar 19, 2012

@soc said:
Error with Scala version 2.10.0-M2-0152-g5dca64cefe-2012-03-13:

<console>:12: error: no type parameters for method apply: (f: Int => Result[A])Apply[A] in object Apply exist so that it can be applied to arguments (Int => Success[_ >: Some[Int] with None.type <: Option[Int]])
 --- because ---
argument expression's type is not compatible with formal parameter type;
 found   : Int => Success[_ >: Some[Int] with None.type <: Option[Int]]
 required: Int => Result[?A]
       def goo : Apply[Option[Int]] = Apply { i =>
                                      ^
<console>:12: error: type mismatch;
 found   : Int => Success[_ >: Some[Int] with None.type <: Option[Int]]
 required: Int => Result[A]
       def goo : Apply[Option[Int]] = Apply { i =>
                                                ^
<console>:12: error: type mismatch;
 found   : Apply[A]
 required: Apply[Option[Int]]
       def goo : Apply[Option[Int]] = Apply { i =>
                                            ^
@scabug

This comment has been minimized.

Copy link
Author

commented May 7, 2012

@phaller said:
Test in pending/pos.

@SethTisue

This comment has been minimized.

Copy link
Member

commented Mar 3, 2018

"probably it's not a bug" — closing unless/until someone steps forward and says they're pretty sure it is, with evidence

@SethTisue SethTisue closed this Mar 3, 2018

@SethTisue SethTisue removed this from the Backlog milestone Mar 3, 2018

@joroKr21

This comment has been minimized.

Copy link

commented Mar 6, 2018

It's a bug - the example compiles in Dotty (modulo the explicit existential of course). The cause is the same as #10519 - unrelatable skolem doesn't contribute to the constraints of the type variable.

@SethTisue SethTisue reopened this Mar 6, 2018

@SethTisue SethTisue added this to the Backlog milestone Mar 6, 2018

joroKr21 added a commit to joroKr21/scala that referenced this issue Mar 12, 2018

Handle unrelatable skolems in TypeVar bounds
by existentially abstracting them.

Adds a necessary boolean flag to `existentialAbstraction` to flip
the variance for upper bounds which need to be minimized.

Fixes scala/bug#5559, fixes scala/bug#5579 and fixes scala/bug#10519

joroKr21 added a commit to joroKr21/scala that referenced this issue Mar 13, 2018

Handle unrelatable skolems in TypeVar bounds
by existentially abstracting them.

Adds a necessary boolean flag to `existentialAbstraction` to flip
the variance for upper bounds which need to be minimized.

Fixes scala/bug#5559, fixes scala/bug#5579, fixes scala/bug#10519
and fixes scala/bug#10771

joroKr21 added a commit to joroKr21/scala that referenced this issue Apr 24, 2018

Handle unrelatable skolems in TypeVar bounds
by existentially abstracting them.

Adds a necessary boolean flag to `existentialAbstraction` to flip
the variance for upper bounds which need to be minimized.

Fixes scala/bug#5559, fixes scala/bug#5579, fixes scala/bug#10519
and fixes scala/bug#10771

joroKr21 added a commit to joroKr21/scala that referenced this issue Apr 26, 2018

Handle unrelatable skolems in TypeVar bounds
by existentially abstracting them.

Adds a necessary boolean flag to `existentialAbstraction` to flip
the variance for upper bounds which need to be minimized.

Fixes scala/bug#5559, fixes scala/bug#5579, fixes scala/bug#10519
and fixes scala/bug#10771

adriaanm added a commit to joroKr21/scala that referenced this issue Aug 8, 2018

Handle unrelatable skolems in TypeVar bounds
by existentially abstracting them.

Adds a necessary boolean flag to `existentialAbstraction` to flip
the variance for upper bounds which need to be minimized.

Fixes scala/bug#5559, fixes scala/bug#5579, fixes scala/bug#10519
and fixes scala/bug#10771

@SethTisue SethTisue modified the milestones: Backlog, 2.13.0-M5 Aug 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.