Skip to content

Commit 02aafea

Browse files
committed
[CS] Remove invalid DependentMemberType workaround for tuples
We can produce a hole here now without regressing diagnostics.
1 parent 17d8f1f commit 02aafea

File tree

3 files changed

+1
-24
lines changed

3 files changed

+1
-24
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6807,22 +6807,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
68076807
}
68086808
}
68096809

6810-
// If the left-hand side of a 'sequence element' constraint
6811-
// is a dependent member type without any type variables it
6812-
// means that conformance check has been "fixed".
6813-
// Let's record other side of the conversion as a "hole"
6814-
// to give the solver a chance to continue and avoid
6815-
// producing diagnostics for both missing conformance and
6816-
// invalid element type.
6817-
if (shouldAttemptFixes()) {
6818-
if (locator.endsWith<LocatorPathElt::SequenceElementType>() &&
6819-
desugar1->is<DependentMemberType>() &&
6820-
!desugar1->hasTypeVariable()) {
6821-
recordPotentialHole(typeVar2);
6822-
return getTypeMatchSuccess();
6823-
}
6824-
}
6825-
68266810
return formUnsolvedResult();
68276811
}
68286812

lib/Sema/ConstraintSystem.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,12 +3926,6 @@ struct TypeSimplifier {
39263926
auto conformance = CS.DC->getParentModule()->lookupConformance(
39273927
lookupBaseType, proto);
39283928
if (!conformance) {
3929-
// FIXME: This regresses diagnostics if removed, but really the
3930-
// handling of a missing conformance should be the same for
3931-
// tuples and non-tuples.
3932-
if (lookupBaseType->is<TupleType>())
3933-
return DependentMemberType::get(lookupBaseType, assocType);
3934-
39353929
// If the base type doesn't conform to the associatedtype's protocol,
39363930
// there will be a missing conformance fix applied in diagnostic mode,
39373931
// so the concrete dependent member type is considered a "hole" in

test/Constraints/static_members_on_protocol_in_generic_context.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ test_combo(.genericFn(42)) // expected-error {{global function 'test_combo' requ
177177

178178
extension P { // expected-note 13 {{missing same-type requirement on 'Self'}} {{12-12= where Self == <#Type#>}}
179179
static func generic<T>(_: T) -> T { fatalError() }
180-
static func genericWithReqs<T: Collection, Q>(_: T) -> Q where T.Element == Q { // expected-note {{in call to function 'genericWithReqs'}} expected-note {{required by static method 'genericWithReqs' where 'T' = '()'}}
180+
static func genericWithReqs<T: Collection, Q>(_: T) -> Q where T.Element == Q { // expected-note {{required by static method 'genericWithReqs' where 'T' = '()'}}
181181
fatalError()
182182
}
183183
}
@@ -217,7 +217,6 @@ _ = P.genericWithReqs([42])
217217
_ = P.genericWithReqs(())
218218
// expected-error@-1 {{type '()' cannot conform to 'Collection'}} expected-note@-1 {{only concrete types such as structs, enums and classes can conform to protocols}}
219219
// expected-error@-2 {{static member 'genericWithReqs' cannot be used on protocol metatype '(any P).Type'}}
220-
// expected-error@-3 {{generic parameter 'Q' could not be inferred}}
221220
_ = P[q: ""]
222221
// expected-error@-1 {{static member 'subscript' cannot be used on protocol metatype '(any P).Type'}}
223222
_ = P[q: ""].other

0 commit comments

Comments
 (0)