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

Lost type arguments on super calls #1321

Closed
jensjoha opened this issue Nov 14, 2023 · 1 comment · Fixed by #1520
Closed

Lost type arguments on super calls #1321

jensjoha opened this issue Nov 14, 2023 · 1 comment · Fixed by #1520
Labels

Comments

@jensjoha
Copy link
Contributor

jensjoha commented Nov 14, 2023

The formatter produced unexpected output. Input was:
class A {
  A(int foo<T>(int a));
}
class B extends A {
  B.sub1(int super.bar1<T1>(int a1),);
  B.sub2(int super.bar2<T2>(int a2),);
}
main() {}

Which formatted to:

class A {
  A(int foo<T>(int a));
}

class B extends A {
  B.sub1(
    int super.bar1(int a1),
  );
  B.sub2(
    int super.bar2(int a2),
  );
}

main() {}

(So formatting throws away the <T1> and <T2>)

@munificent munificent added the bug label Nov 15, 2023
@munificent munificent changed the title The formatter produced unexpected output Lost type arguments on super calls Nov 15, 2023
@munificent
Copy link
Member

Oh, wow. It took me several reads to even figure out what's going on here. So it's a super parameter that is passing a generic function to the superclass and the parameter declaration in the subclass uses the old style function-typed parameter syntax. That is indeed a dark corner of the grammar.

munificent added a commit that referenced this issue Aug 8, 2024
If you have a parameter that:

- uses "this." or "super.",
- and also uses the old function-typed formal parameter syntax,
- and also is a generic function...

then the short style formatter would drop the type parameters on the
floor. The tall style already does the right thing.

Fix the short style and add regression tests for both.

Fix #1321.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants