Skip to content

Conversation

@sjrd
Copy link
Member

@sjrd sjrd commented Nov 19, 2020

By making them final, the Scala.js back-end can process them not only for reflectiveSelectable, but for any custom subclass of reflect.Selectable. This removes its main limitation on Scala.js.

We add @inline to the default implementation in reflectiveSelectable (which requires to make it a named class) so that the Scala.js optimizer can completely optimize it away at link time. On the JVM, this change has no effect.


builds on top of #10388.

@sjrd sjrd requested review from gzm0 and odersky November 19, 2020 14:46
@sjrd sjrd assigned odersky and gzm0 Nov 19, 2020
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

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

Nice! Only minor stuff.

sjrd added 2 commits November 19, 2020 16:43
This simplifies the life of everyone: the expansion of structural
calls, the implementation of `scala.reflect.Selectable`, and the
reverse engineering performed by the Scala.js back-end.

As a side benefit, the new transformation supports bottom types in
the arguments. It was previously limited because we do not allow
the generation of `ClassTag`s for `Null` and `Nothing`: they are
unsound in arrays, which is what `ClassTag`s are designed for, but
on their own they have perfectly valid `Class`'es.
By making them final, the Scala.js back-end can process them not
only for `reflectiveSelectable`, but for any custom subclass of
`reflect.Selectable`. This removes its main limitation on Scala.js.

We add `@inline` to the default implementation in
`reflectiveSelectable` (which requires to make it a named class) so
that the Scala.js optimizer can completely optimize it away at
link time. On the JVM, this change has no effect.
@sjrd sjrd force-pushed the final-reflect-selectable-methods branch from 73ea507 to da39683 Compare November 19, 2020 15:47
@sjrd sjrd merged commit cc3da61 into scala:master Nov 20, 2020
@sjrd sjrd deleted the final-reflect-selectable-methods branch November 20, 2020 14:04
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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