Skip to content

Fix #5720: don't output X <: Long in Java generic signatures #5816

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

Merged

Conversation

Blaisorblade
Copy link
Contributor

@Blaisorblade Blaisorblade commented Jan 29, 2019

In generic signature generator jsig, flag primitiveOK remembers if jsig is
allowed to output primitive types or not; for instance, upper bounds can't
contain primitive types. When transforming higher-kinded upper bounds [X] => T, jsig correctly recurs on T, but must remember flag primitiveOK.

The status of toplevel should not change either (since it tracks if are still
at the toplevel of the output signature, or instead we have started producing
output), so passing it seems safest. Ideally we should test it at least on
higher types whose body is a suitable ClassInfo; with polymorphic function
types, we should also test PolyType bodies.

Fix #5720.

@ghost ghost assigned Blaisorblade Jan 29, 2019
@ghost ghost added the review label Jan 29, 2019
@Blaisorblade Blaisorblade force-pushed the fix-5720-higher-kind-erasure branch from 944e698 to 01f16a0 Compare January 29, 2019 16:45
@nicolasstucki nicolasstucki self-requested a review January 29, 2019 16:54
@Blaisorblade

This comment has been minimized.

@Blaisorblade
Copy link
Contributor Author

Still todo: maybe move tests/fuzzy/IAE-4a69457e1319217c3bac170110ea4ba58dca11a6.scala to pos (or drop it, as it's a subset of the new test).

@smarter

This comment has been minimized.

@Blaisorblade Blaisorblade force-pushed the fix-5720-higher-kind-erasure branch 2 times, most recently from 5901575 to 1fc9b1b Compare January 29, 2019 21:10
@ghost ghost assigned Blaisorblade Jan 29, 2019
@smarter
Copy link
Member

smarter commented Jan 29, 2019

@biboudis Your bot keeps assigning people to PR, can you make it stop ?

@Blaisorblade Blaisorblade assigned smarter and unassigned Blaisorblade Jan 29, 2019
@@ -0,0 +1,5 @@
class A[B[_] <: Long]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add some tests in the form of

class A[B[_] <: Foo]
class Foo(val i: Int) extends AnyVal

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And with an opaque type that has a primitive type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have tests for all primitives

class AByte[B[_] <: Byte]
...
class AInt[B[_] <: Int]
...

@nicolasstucki
Copy link
Contributor

The fix LGTM

@biboudis
Copy link
Contributor

biboudis commented Jan 30, 2019

@smarter looking into it!

In generic signature generator `jsig`, flag `primitiveOK` remembers if `jsig` is
allowed to output primitive types or not; for instance, upper bounds can't
contain primitive types. When transforming higher-kinded upper bounds `[X] =>
T`, `jsig` correctly recurs on `T`, but must remember flag `primitiveOK`.

The status of `toplevel` should not change either (since it tracks if are still
at the toplevel of the output signature, or instead we have started producing
output), so passing it seems safest. Ideally we should test it at least on
higher types whose body is a suitable `ClassInfo`; with polymorphic function
types, we should also test `PolyType` bodies.

Revised with tests requested in review.
@Blaisorblade Blaisorblade force-pushed the fix-5720-higher-kind-erasure branch from 81a005c to c954ef0 Compare January 30, 2019 11:01
@Blaisorblade Blaisorblade dismissed nicolasstucki’s stale review January 30, 2019 11:02

Added requested tests :-)

@nicolasstucki nicolasstucki merged commit 0eb5167 into scala:master Jan 30, 2019
@nicolasstucki nicolasstucki deleted the fix-5720-higher-kind-erasure branch January 30, 2019 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants