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

3.2.1 regression with partially applied classes #16320

Closed
andrzejressel opened this issue Nov 11, 2022 · 3 comments
Closed

3.2.1 regression with partially applied classes #16320

andrzejressel opened this issue Nov 11, 2022 · 3 comments
Labels
area:typer itype:bug regression This worked in a previous version but doesn't anymore

Comments

@andrzejressel
Copy link
Contributor

andrzejressel commented Nov 11, 2022

Compiler version

3.2.1
3.2.2-RC1

Minimized code

//> using platform "jvm"
//> using scala "3.2.1"

@main
def main() = {
  A { (a: Unit) => () }
}

object A {
  def apply[E] = new PartiallyApplied[E]
  final class PartiallyApplied[E] {
    def apply[T1](fn: (T1) => Unit): Unit = ()
  }
}

Output

[error] .\partial.scala:6:3: method apply in object A does not take parameters
[error]   A { (a: Unit) => () }
[error]

Expectation

No error like with Scala 3.2.0

@andrzejressel andrzejressel added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 11, 2022
@KacperFKorban KacperFKorban added the regression This worked in a previous version but doesn't anymore label Nov 11, 2022
@KacperFKorban
Copy link
Member

Minimized a bit:

final class PartiallyApplied {
  def apply(fn: Int): Unit = ()
}

object A {
  def apply[X] = new PartiallyApplied
}

def Test =
  A(1)

@KacperFKorban KacperFKorban added area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Nov 11, 2022
@andrzejressel
Copy link
Contributor Author

I've bisected it to 882b435

@odersky
Copy link
Contributor

odersky commented Nov 12, 2022

Yes, that's intentioinal. We do not synthesize more than one apply method in a row. But here A(1) would expand to

A.apply[Int].apply(1)

This restriction is to guard against infinite apply expansion.

@KacperFKorban KacperFKorban closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2022
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

No branches or pull requests

3 participants