compat: Support the TypeEq type-system refactor (JuliaLang/julia#61915)#11
Open
Keno wants to merge 1 commit into
Open
compat: Support the TypeEq type-system refactor (JuliaLang/julia#61915)#11Keno wants to merge 1 commit into
Keno wants to merge 1 commit into
Conversation
Under the TypeEq type-system refactor, `typeof(Type{T})` is `TypeEq` rather
than `DataType`. As a consequence `Type{T}` is no longer `isa DataType`, so it
can neither satisfy a `::DataType` return annotation (the implicit
`convert(DataType, Type{T})` throws a `MethodError`) nor be used as a key in an
`IdDict{DataType,Layout}`.
`Reflect.basetype(Core.Type)` walks `Core.Type` to its innermost body `Type{T}`,
which made `insertbuiltins!` throw the moment any layout was reflected. Loosen
the `partialtype`/`basetype` return annotations to `::Type`, short-circuit
`basetype` for `Base.isType` bodies (whose `.name` access is also deprecated),
guard the abstract `Type` builtin registration so a non-`DataType` key is not
inserted, and route `Type{T}`-typed struct fields to a `WeakValue` directly via
`Base.isType` (previously handled through the `fieldtype isa DataType` branch).
Behavior on released Julia versions is unchanged.
This change was made with the assistance of generative AI (Claude Code).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
|
Thanks for the heads-up! |
Taaitaaiger
reviewed
Jun 4, 2026
| return false | ||
| elseif !has_pointer_free_partialtype(ty, env) | ||
| return false | ||
| end |
Owner
There was a problem hiding this comment.
Suggested change
| elseif Base.isType(ty) | |
| return false | |
| end |
Owner
There was a problem hiding this comment.
The added branch in structfield was never reached by the tests, I wrote a quick test and noticed this one needs to be added as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[This PR is partly a heads up with a Claude-suggested change - please check carefully and further refinements may be required]
Under the TypeEq type-system refactor,
typeof(Type{T})isTypeEqrather thanDataType. As a consequenceType{T}is no longerisa DataType, so it can neither satisfy a::DataTypereturn annotation (the implicitconvert(DataType, Type{T})throws aMethodError) nor be used as a key in anIdDict{DataType,Layout}.Reflect.basetype(Core.Type)walksCore.Typeto its innermost bodyType{T}, which madeinsertbuiltins!throw the moment any layout was reflected. Loosen thepartialtype/basetypereturn annotations to::Type, short-circuitbasetypeforBase.isTypebodies (whose.nameaccess is also deprecated), guard the abstractTypebuiltin registration so a non-DataTypekey is not inserted, and routeType{T}-typed struct fields to aWeakValuedirectly viaBase.isType(previously handled through thefieldtype isa DataTypebranch). Behavior on released Julia versions is unchanged.This change was made with the assistance of generative AI (Claude Code).