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 contextual higher kinded types #15171

Closed
WojciechMazur opened this issue May 12, 2022 · 3 comments · Fixed by #15223
Closed

Typer regression in contextual higher kinded types #15171

WojciechMazur opened this issue May 12, 2022 · 3 comments · Fixed by #15223
Assignees
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore
Milestone

Comments

@WojciechMazur
Copy link
Contributor

WojciechMazur commented May 12, 2022

Compiler version

3.2.0-RC1-bin-20220429-400427d-NIGHTLY

Works with 3.1.2

First bad commit fe40c59 in #14840

Minimized code

Based on https://github.com/rssh/dotty-cps-async/blob/7563fc15c0de9efffee3d166d01f0e83d1d20433/shared/src/test/scala/cps/gopherlike/SLBase.scala#L136-L148

//> using scala "3.2.0-RC1-bin-20220429-400427d-NIGHTLY"
// //> using scala "3.1.2" // Last stable working version

case class Expr[+T](get: T)
trait Ctx[F[_]]
sealed trait Selector[F[_]]:
  def appended(base: Expr[SelectLoop[F]]): Expr[SelectLoop[F]]
  
 // Without Ctx[F] argument it would compile correctly
class SelectLoop[F[_]](using Ctx[F])
object SelectLoop:
  def loopImpl[F[_]](ctx: Ctx[F])(caseDefs: List[Selector[F]]): Expr[Unit] = 
    // Adding explicit type :Expr[SelectLoop[F]] satifies the compiler
    val s0 = Expr(new SelectLoop[F](using ctx)) 
    val g = caseDefs.foldRight(s0)(_.appended(_))
    Expr(())

Output

[error] ./test.scala:13:47: Found:    (_$6 : Expr[Object])
[error] Required: Expr[SelectLoop[F]]
[error] 
[error] where:    F is a type in method loopImpl with bounds <: [_] =>> Any
[error]     val g = caseDefs.foldRight(s0)(_.appended(_))
[error]                                               ^

Expectation

Should compile like in the 3.1.2, without need for explicit type annotation

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

It looks like the problem occurs only if Ctx[F] is a using parameter of class SelectLoop and is passed to the constructor explicitly. So both

class SelectLoop[F[_]](ctx: Ctx[F])

...

    val s0 = Expr(new SelectLoop[F](ctx)) 

and

class SelectLoop[F[_]](using ctx: Ctx[F])

...

    given Ctx[F] = ctx
    val s0 = Expr(new SelectLoop[F]) 

work correctly.

@Kordyjan Kordyjan added this to the 3.1.3 milestone May 16, 2022
@nicolasstucki
Copy link
Contributor

Started failing in 3.2.0-RC1-bin-20220423-17ec9a7-NIGHTLY

@nicolasstucki
Copy link
Contributor

First bad commit fe40c59 in #14840

@bishabosha bishabosha modified the milestones: 3.1.3, 3.2.0-RC1 May 17, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue May 18, 2022
@odersky odersky assigned odersky and bishabosha and unassigned bishabosha May 18, 2022
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue May 20, 2022
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
@Kordyjan Kordyjan modified the milestones: 3.2.0-RC1, 3.2.0 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.

6 participants