Skip to content

[GSB] Always ensure that we wire up typealiases in protocol extensions. #14974

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3743,13 +3743,11 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
if (!nestedPA)
return ResolvedType::forUnresolved(baseEquivClass);

if (resolutionKind != ArchetypeResolutionKind::AlreadyKnown) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. As far as I can tell this change just means that updateNestedTypeForConformance now gets called with ArchetypeResolutionKind::AlreadyKnown in addition to the other two kinds, but, I can't see a way in which that call actually does anything.

https://github.com/apple/swift/blob/adfead025138474a5b4a6f3c1dee585c5654cc42/lib/AST/GenericSignatureBuilder.cpp#L2796-L2934

It seems like that function does three "interesting" things, but none of them happen with this kind:

What am I missing?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're both right and... somewhere I messed something up locally, because the test marked as fixed doesn't seem to be fixed. Very sorry :(

// Update for all of the concrete decls with this name, which will
// introduce various same-type constraints.
for (auto concreteDecl : concreteDecls) {
(void)basePA->updateNestedTypeForConformance(*this, concreteDecl,
resolutionKind);
}
// Update for all of the concrete decls with this name, which will
// introduce various same-type constraints.
for (auto concreteDecl : concreteDecls) {
(void)basePA->updateNestedTypeForConformance(*this, concreteDecl,
resolutionKind);
}

// If base resolved to the anchor, then the nested potential archetype
Expand Down
26 changes: 26 additions & 0 deletions validation-test/compiler_crashers_2_fixed/0145-sr7097.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %target-swift-frontend %s -emit-ir -o - | %FileCheck %s

protocol P1 { }

protocol P2 {
associatedtype Assoc
}

protocol P3 : P2 { }

struct S0<M: P3> where M.Assoc: P1 { }

struct ConformsToP1: P1 { }

extension P3 {
typealias Assoc = ConformsToP1
}

protocol P5 {
}

extension P5 {
func testSR7097<M>(_: S0<M>.Type) {}
}