-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Change the underlying type of TypeAliasDecls to an interface type #6321
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
Change the underlying type of TypeAliasDecls to an interface type #6321
Conversation
…ying type - TypeAliasDecl::getAliasType() is gone. Now, getDeclaredInterfaceType() always returns the NameAliasType. - NameAliasTypes now always desugar to the underlying type as an interface type. - The NameAliasType of a generic type alias no longer desugars to an UnboundGenericType; call TypeAliasDecl::getUnboundGenericType() if you want that. - The "lazy mapTypeOutOfContext()" hack for deserialized TypeAliasDecls is gone. - The process of constructing a synthesized TypeAliasDecl is much simpler now; instead of calling computeType(), setInterfaceType() and then setting the recursive properties in the right order, just call setUnderlyingType(), passing it either an interface type or a contextual type. In particular, many places weren't setting the recursive properties, such as the ClangImporter and deserialization. This meant that queries such as hasArchetype() or hasTypeParameter() would return incorrect results on NameAliasTypes, which caused various subtle problems. - Finally, add some more tests for generic typealiases, most of which fail because they're still pretty broken.
@swift-ci Please test |
declOrOffset = alias; | ||
|
||
// FIXME: Do we need to read a GenericEnvironment even if we don't | ||
// have our own generic parameters? The typealias might itself be in | ||
// generic context. |
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.
@DougGregor This looks like a bug, but changing it breaks things...
Var Dictionary.endIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index | ||
Var Dictionary.startIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index | ||
Var Set.endIndex has declared type change from SetIndex<Element> to Set<Element>.Index | ||
Var Set.startIndex has declared type change from SetIndex<Element> to Set<Element>.Index | ||
Constructor BidirectionalSlice.init(base:bounds:) has 2nd parameter type change from Range<Base.Index> to Range<BidirectionalSlice.Index> |
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.
@nkcsgexi I'm really sorry for constantly breaking the output of this tool, but we need to figure out a way to canonicalize types better.
In particular, it seems we need a better strategy for handling changes where the serialized type resolves to an alias of the same type as before, or a generic parameter that is related to the previous one by a same-type constraint. I'm at a loss as to how to work this into the model of "dump API of two serialized module files, diff them". We might need a more complex approach.
Or, since with this patch the interface type changeover is mostly complete, we can start again with a fresh dump for the "known good" API.
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.
It is surely ok to break the output, but would you please document that they are false positives? As an alternative, we should have a universal clang importer (and deserializer) in the future that can load any versions of modules and compare them in a fuller context. But, as for now, as you said, it seems too hard to eliminate false positives like these.
Build failed |
Please test with following PR: @swift-ci Please test Linux |
Build failed |
Please test with following PR: @swift-ci Please test Linux |
Build failed |
Build failed |
Please test with following PR: @swift-ci Please test Linux |
Hmm...
|
@swift-ci Please test macOS |
Build failed |
Please test with following PR: @swift-ci Please test Linux |
Build failed |
Please test with following PR: @swift-ci Please test Linux |
No description provided.