Skip to content

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

Merged

Conversation

slavapestov
Copy link
Contributor

No description provided.

…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.
@slavapestov
Copy link
Contributor Author

@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.
Copy link
Contributor Author

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>
Copy link
Contributor Author

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.

Copy link
Contributor

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.

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 2c6b9f7
Test requested by - @slavapestov

@slavapestov
Copy link
Contributor Author

Please test with following PR:
apple/swift-lldb#107

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 2c6b9f7
Test requested by - @slavapestov

@slavapestov
Copy link
Contributor Author

Please test with following PR:
apple/swift-lldb#107

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 2c6b9f7
Test requested by - @slavapestov

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 2c6b9f7
Test requested by - @slavapestov

@slavapestov
Copy link
Contributor Author

Please test with following PR:
apple/swift-lldb#107

@swift-ci Please test Linux

@slavapestov
Copy link
Contributor Author

Hmm...

23:29:18 0  swift                    0x000000011149ea06 SignalHandler(int) + 454
23:29:18 1  libsystem_platform.dylib 0x00007fff84ba652a _sigtramp + 26
23:29:18 2  swift                    0x000000010ecd2d08 swift::ArchetypeBuilder::resolveArchetype(swift::Type) + 72
23:29:18 3  swift                    0x000000010ecd2d78 swift::ArchetypeBuilder::resolveArchetype(swift::Type) + 184
23:29:18 4  swift                    0x000000010ecd2d78 swift::ArchetypeBuilder::resolveArchetype(swift::Type) + 184
23:29:18 5  swift                    0x000000010ecd2d78 swift::ArchetypeBuilder::resolveArchetype(swift::Type) + 184
23:29:18 6  swift                    0x000000010ecd4de3 swift::ArchetypeType::resolveNestedType(std::__1::pair<swift::Identifier, swift::Type>&) const + 51
23:29:18 7  swift                    0x000000010ede78e2 swift::ArchetypeType::getAllNestedTypes(bool) const + 66
23:29:18 8  swift                    0x000000010e4cd3b8 profileArchetypeConstraints(swift::Type, llvm::FoldingSetNodeID&, llvm::DenseMap<swift::ArchetypeType*, unsigned int, llvm::DenseMapInfo<swift::ArchetypeType*>, llvm::detail::DenseMapPair<swift::ArchetypeType*, unsigned int> >&) + 552
23:29:18 9  swift                    0x000000010e4cd3de profileArchetypeConstraints(swift::Type, llvm::FoldingSetNodeID&, llvm::DenseMap<swift::ArchetypeType*, unsigned int, llvm::DenseMapInfo<swift::ArchetypeType*>, llvm::detail::DenseMapPair<swift::ArchetypeType*, unsigned int> >&) + 590
23:29:18 10 swift                    0x000000010e4cd3de profileArchetypeConstraints(swift::Type, llvm::FoldingSetNodeID&, llvm::DenseMap<swift::ArchetypeType*, unsigned int, llvm::DenseMapInfo<swift::ArchetypeType*>, llvm::detail::DenseMapPair<swift::ArchetypeType*, unsigned int> >&) + 590
23:29:18 11 swift                    0x000000010e4cd4d2 swift::irgen::TypeConverter::getExemplarArchetype(swift::ArchetypeType*) + 114
23:29:18 12 swift                    0x000000010e4d4687 swift::Type llvm::function_ref<swift::Type (swift::Type)>::callback_fn<swift::irgen::TypeConverter::getExemplarType(swift::CanType)::$_0>(long, swift::Type) + 23
23:29:18 13 swift                    0x000000010ede91c4 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 68
23:29:18 14 swift                    0x000000010ede94c7 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 839
23:29:18 15 swift                    0x000000010e4cd62d swift::irgen::TypeConverter::getExemplarType(swift::CanType) + 93

@slavapestov
Copy link
Contributor Author

@swift-ci Please test macOS

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 2c6b9f7
Test requested by - @slavapestov

@slavapestov
Copy link
Contributor Author

Please test with following PR:
apple/swift-lldb#107

@swift-ci Please test Linux

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 2c6b9f7
Test requested by - @slavapestov

@slavapestov
Copy link
Contributor Author

Please test with following PR:
apple/swift-lldb#107

@swift-ci Please test Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants