Skip to content

Add Reference.pre_initialize and .unsafe_construct#14108

Merged
straight-shoota merged 10 commits intocrystal-lang:masterfrom
HertzDevil:feature/reference-unsafe-construct
Dec 20, 2023
Merged

Add Reference.pre_initialize and .unsafe_construct#14108
straight-shoota merged 10 commits intocrystal-lang:masterfrom
HertzDevil:feature/reference-unsafe-construct

Conversation

@HertzDevil
Copy link
Contributor

See #13481.

This PR references ReferenceStorage from #14106 in documentation only. These methods are not defined on struct or value types, nor implemented inside the interpreter.

# otherwise all calls will refer to the sole instantiation in
# `Reference.class`. This is necessary when the receiver is a virtual
# metaclass type. Apparently this works even for primitives
{% @type %}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not entirely sure what to do with this. A fresh compiler will break if the existing compiler's version is below 1.2.0 and the compiler itself uses .pre_initialize / .unsafe_construct on a virtual metaclass. I don't think that is very likely, but if we must do it, the only solution seems to be explicitly defining .pre_initialize in every subclass of Reference in the compiler, similar to .allocate.

@HertzDevil HertzDevil marked this pull request as ready for review December 18, 2023 08:51
Co-authored-by: Johannes Müller <straightshoota@gmail.com>
@straight-shoota
Copy link
Member

@HertzDevil In case you missed it, I also left a comment on a previously resolved thread: #14108 (comment) WDYT?

@straight-shoota straight-shoota added this to the 1.11.0 milestone Dec 19, 2023
@straight-shoota straight-shoota merged commit b41fda9 into crystal-lang:master Dec 20, 2023
@HertzDevil HertzDevil deleted the feature/reference-unsafe-construct branch December 21, 2023 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants