Skip to content

inline val for opaque type alias for literal type is 'declared as erased, but is in fact used' #13852

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

Closed
armanbilge opened this issue Oct 30, 2021 · 1 comment · Fixed by #13857
Assignees
Milestone

Comments

@armanbilge
Copy link
Contributor

Compiler version

3.1.1-RC1

Minimized code

// This works:
inline val `1`: 1 = 1
def get1: 1 = `1`

// But this doesn't:
opaque type One = 1
inline val One: One = 1
def getOne: One = One
// getter One is declared as erased, but is in fact used

Output

[error] 32 |def getOne: One = One
[error]    |                  ^^^
[error]    |                  getter One is declared as erased, but is in fact used

Expectation

It should be possible to use an inline val of an opaque type alias for a literal type.

@nicolasstucki
Copy link
Contributor

The current error is

//         getter One is declared as `inline`, but was not inlined
//
//         Try increasing `-Xmax-inlines` above 32

This is the same problem as in #13851 (comment)

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 1, 2021
`inline val`s cannot contain opaque aliases as these cannot be inlined
through their type due to their opaqueness. We can support `inline def`
with opaque types.

Fixes scala#13851
Fixes scala#13852
@nicolasstucki nicolasstucki self-assigned this Nov 1, 2021
@nicolasstucki nicolasstucki linked a pull request Nov 1, 2021 that will close this issue
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
`inline val`s cannot contain opaque aliases as these cannot be inlined
through their type due to their opaqueness. We can support `inline def`
with opaque types.

Fixes scala#13851
Fixes scala#13852
@Kordyjan Kordyjan added this to the 3.1.2 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants