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

Typer regression in 3.2.0 #15940

Closed
WojciechMazur opened this issue Aug 31, 2022 · 1 comment · Fixed by #15951
Closed

Typer regression in 3.2.0 #15940

WojciechMazur opened this issue Aug 31, 2022 · 1 comment · Fixed by #15951
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

WojciechMazur commented Aug 31, 2022

Compiler version

Fails in 3.2.0
Fails in 3.2.1-RC1-bin-20220830-8504b8d-NIGHTLY
Compiles with 3.1.3

Minimized code

object Ops:
  implicit class EitherSeqOps[E, T](private val seq: Seq[Either[E, T]]) extends AnyVal:
    def sequence: Either[::[E], Seq[T]] = ???

trait BuildException
case class CompositeBuildException(ex: ::[BuildException]) extends BuildException

trait ActionableDiagnostic
trait ActionableHandler[A <: ActionableDiagnostic]:
  def exec: Either[BuildException, Seq[A]]

import Ops._

val test: Either[BuildException, Seq[ActionableDiagnostic]] =
  // Can be replaced with Seq[Either[BuildException, Seq[ _ <: ActionableDiagnostic]]] , but current version matches better type of missing implicit
  Seq.empty[ActionableHandler[_]].map(_.exec)
    .sequence
    .left.map(_.head)
    .map(_.flatten) // error

Dirty workaround:

   Seq.empty[ActionableHandler[_]].map(_.exec)
    .sequence
    .left.map(_.head)
    .map{ (v: Seq[Seq[Any]]) => v.flatten }
    .asInstanceOf[Either[BuildException, Seq[ActionableDiagnostic]]]

would also work for Seq.empty[ActionableHandler[_ <: ActionableDiagnostic]].map(_.exec)

Output

[error] ./test.scala:21:19: 
[error] No given instance of type Seq[Any] => IterableOnce[B] was found for parameter asIterable of method flatten in trait IterableOps
[error] where:    B is a type variable with constraint <: ActionableDiagnostic
[error]     .map(_.flatten) // error
[error]      

Expectation

Should compile

@WojciechMazur WojciechMazur added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label regression This worked in a previous version but doesn't anymore labels Aug 31, 2022
@WojciechMazur
Copy link
Contributor Author

Bisect points to 7be0dd9

odersky added a commit to dotty-staging/dotty that referenced this issue Sep 2, 2022
If we see a class type parameter that has a wildcard argument, we now intersect
the original info of the class type parameter and the argument. Previously we
replaced the class type parameter info with the argument info, but that might lose
information.

Fixes scala#15940
@prolativ prolativ added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 5, 2022
odersky added a commit that referenced this issue Sep 9, 2022
If we see a class type parameter that has a wildcard argument, we now
intersect
the original info of the class type parameter and the argument.
Previously we
replaced the class type parameter info with the argument info, but that
might lose
information.

Fixes #15940
Kordyjan pushed a commit to dotty-staging/dotty that referenced this issue Sep 15, 2022
If we see a class type parameter that has a wildcard argument, we now intersect
the original info of the class type parameter and the argument. Previously we
replaced the class type parameter info with the argument info, but that might lose
information.

Fixes scala#15940
mpollmeier pushed a commit to mpollmeier/dotty that referenced this issue Oct 16, 2022
If we see a class type parameter that has a wildcard argument, we now intersect
the original info of the class type parameter and the argument. Previously we
replaced the class type parameter info with the argument info, but that might lose
information.

Fixes scala#15940
@Kordyjan Kordyjan added this to the 3.2.2 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants