-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
bugfixes for showing type aliases #39366
Conversation
If you had 2 aliases that both matched, we might print ```S{T} where T (alias for S{T} where T)``` which is clearly unnecessary.
Always a bit more compact in this form, and somewhat easier to implement too (thus keeping this consistent with the corrected typealias printing).
@@ -554,7 +555,7 @@ function make_typealias(@nospecialize(x::Type)) | |||
for name in names(mod) | |||
if isdefined(mod, name) && !isdeprecated(mod, name) && isconst(mod, name) | |||
alias = getfield(mod, name) | |||
if alias isa Type && !has_free_typevars(alias) && !isvarargtype(alias) && !print_without_params(alias) && x <: alias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this change be removed for the backport to 1.6?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this commit can be ignored for the backport
Only tangentially related, but is it worth considering memoization? Or is it not worth the 265-risk? #36263 (comment) |
We probably should do some, since this otherwise is hammering runtime reflection pretty hard. It doesn't really matter if the information is stale, as long as it remains reasonable. Some of the string output might have module prefixes (in the parameters), so we would want to cache before that point. Perhaps an IdDict mapping from Type{T} -> GlobalRef? |
There were some cases where the
where
clause we print would be incorrect in some way. This alters the printing to prefer the compact form of where (with {}`), and ensures it prints the environments correctly.