Skip to content

GSB: Don't forget to concretize conformances when processing a same-type requirement #38207

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
Merged
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
9 changes: 6 additions & 3 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2413,7 +2413,7 @@ void DelayedRequirement::dump(llvm::raw_ostream &out) const {
case Type:
case Layout:
out << ": ";
break;
break;

case SameType:
out << " == ";
Expand Down Expand Up @@ -5047,6 +5047,9 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenTypeParameters(
equivClass->concreteTypeConstraints.end(),
equivClass2->concreteTypeConstraints.begin(),
equivClass2->concreteTypeConstraints.end());

for (const auto &conforms : equivClass->conformsTo)
(void)resolveConcreteConformance(T1, conforms.first);
}

// Make T1 the representative of T2, merging the equivalence classes.
Expand Down Expand Up @@ -5775,9 +5778,9 @@ void GenericSignatureBuilder::ExplicitRequirement::dump(

out << getSubjectType();
if (getKind() == RequirementKind::SameType)
out << " : ";
else
out << " == ";
else
out << " : ";

if (auto type = rhs.dyn_cast<Type>())
out << type;
Expand Down
20 changes: 20 additions & 0 deletions test/Generics/rdar79570734.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %target-typecheck-verify-swift
// RUN: %target-swift-frontend -typecheck -debug-generic-signatures %s 2>&1 | %FileCheck %s

public protocol P1 {
associatedtype A
}

public protocol P2 {}

public struct S1: P1 {
public typealias A = S2
}

public struct S2: P2 {}

// CHECK-LABEL: Generic signature: <X, Y where X : P1, Y : P2, Y == X.A>
public struct G<X: P1, Y: P2> where Y == X.A {}

// CHECK-LABEL: Generic signature: <X, Y where X == S1, Y == S1.A>
public extension G where X == S1 {}