Skip to content

[GSB] Use resolved type when looking for a representative constraint. #18265

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 1 commit into from
Jul 26, 2018
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
8 changes: 4 additions & 4 deletions lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7062,7 +7062,7 @@ void GenericSignatureBuilder::checkSuperclassConstraints(
EquivalenceClass *equivClass) {
assert(equivClass->superclass && "No superclass constraint?");

// Resolve any this-far-unresolved dependent types.
// Resolve any thus-far-unresolved dependent types.
Type resolvedSuperclass =
resolveDependentMemberTypes(*this, equivClass->superclass);

Expand All @@ -7075,13 +7075,13 @@ void GenericSignatureBuilder::checkSuperclassConstraints(

Type resolvedType =
resolveDependentMemberTypes(*this, constraint.value);
return resolvedType->isEqual(equivClass->superclass);
return resolvedType->isEqual(resolvedSuperclass);
},
[&](const Constraint<Type> &constraint) {
Type superclass = constraint.value;

// If this class is a superclass of the "best"
if (superclass->isExactSuperclassOf(equivClass->superclass))
if (superclass->isExactSuperclassOf(resolvedSuperclass))
return ConstraintRelation::Redundant;

// Otherwise, it conflicts.
Expand All @@ -7091,7 +7091,7 @@ void GenericSignatureBuilder::checkSuperclassConstraints(
diag::redundant_superclass_constraint,
diag::superclass_redundancy_here);

// Resolve any this-far-unresolved dependent types.
// Record the resolved superclass type.
equivClass->superclass = resolvedSuperclass;

// If we have a concrete type, check it.
Expand Down
17 changes: 17 additions & 0 deletions validation-test/compiler_crashers_2_fixed/0169-sr8179.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %target-swift-frontend -emit-sil %s

protocol SignalInterface {
associatedtype OutputValue
}

class Signal<OV>: SignalInterface {
typealias OutputValue = OV
}

extension Signal {
func foo<U>(_: U) -> SignalChannel<[U], Signal<Array<U>>>
where OutputValue == Optional<U> { return SignalChannel() }
}

struct SignalChannel<OutputValue, Output: Signal<OutputValue>> { }