Skip to content

Let inline val implement abstract inline def/val #8832

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

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki force-pushed the let-inline-vals-implement-abstract-inline-def-or-val branch 2 times, most recently from 84e061f to a799cd9 Compare April 29, 2020 14:25
@nicolasstucki nicolasstucki marked this pull request as ready for review April 29, 2020 15:17
@nicolasstucki nicolasstucki force-pushed the let-inline-vals-implement-abstract-inline-def-or-val branch from a799cd9 to ee24482 Compare April 29, 2020 15:18
@nicolasstucki nicolasstucki marked this pull request as draft April 29, 2020 15:19
@nicolasstucki nicolasstucki self-assigned this Apr 29, 2020
@nicolasstucki nicolasstucki marked this pull request as ready for review April 29, 2020 17:49
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM


class C1 extends C:
inline val x = 1
inline val y = 2
Copy link
Contributor

Choose a reason for hiding this comment

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

A side note: in inline val, we require the rhs to be a literal type, which is not really related to inline. Meanwhile, const-folding can be achieved by annotating the constant type explicitly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, inline val requires a literal type result type and a pure body. This is a consequence of being marked as inline, as these are the only values that can be soundly inlined. We use constant folding to inline it because thee type already provides this functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's more about semantics than soundness. There is an inconsistency between inline vals and inline parameters.

@nicolasstucki nicolasstucki merged commit d7c0574 into scala:master Apr 30, 2020
@nicolasstucki nicolasstucki deleted the let-inline-vals-implement-abstract-inline-def-or-val branch April 30, 2020 08:58
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.

2 participants