Skip to content
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

Merged
merged 4 commits into from
Jan 25, 2021
Merged

bugfixes for showing type aliases #39366

merged 4 commits into from
Jan 25, 2021

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Jan 22, 2021

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.

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).
@vtjnash vtjnash added bugfix This change fixes an existing bug backport 1.6 Change should be backported to release-1.6 labels Jan 22, 2021
@vtjnash vtjnash requested a review from JeffBezanson January 22, 2021 23:41
@vtjnash vtjnash closed this Jan 25, 2021
@vtjnash vtjnash reopened this Jan 25, 2021
@@ -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
Copy link
Member

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?

Copy link
Member Author

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

@timholy
Copy link
Member

timholy commented Jan 25, 2021

Only tangentially related, but is it worth considering memoization? Or is it not worth the 265-risk? #36263 (comment)

@vtjnash vtjnash merged commit fb59c19 into master Jan 25, 2021
@vtjnash vtjnash deleted the jn/compacttypealias branch January 25, 2021 21:24
@vtjnash
Copy link
Member Author

vtjnash commented Jan 25, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants