Skip to content

Commit 3571fa8

Browse files
committed
AST: Preserve sugar in TypeMatcher::visitBoundGenericType()
1 parent 298a84a commit 3571fa8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/swift/AST/TypeMatcher.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,8 @@ class TypeMatcher {
419419

420420
bool visitBoundGenericType(CanBoundGenericType firstBGT,
421421
Type secondType, Type sugaredFirstType) {
422-
auto _secondBGT = secondType->getCanonicalType();
423-
if (firstBGT->getKind() == _secondBGT->getKind()) {
424-
auto secondBGT = cast<BoundGenericType>(_secondBGT);
422+
if (firstBGT->getKind() == secondType->getDesugaredType()->getKind()) {
423+
auto secondBGT = secondType->castTo<BoundGenericType>();
425424
if (firstBGT->getDecl() != secondBGT->getDecl())
426425
return mismatch(firstBGT.getPointer(), secondBGT, sugaredFirstType);
427426

test/Generics/requirement_machine_diagnostics.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,7 @@ func inferred3<T : P11>(_: T) where T.X : Hashable, T.Z == Set<T.Y>, T.X == T.Y
194194
func inferred4<T : P11>(_: T) where T.Z == Set<T.Y>, T.X : Hashable, T.X == T.Y {}
195195
func inferred5<T : P11>(_: T) where T.Z == Set<T.X>, T.Y : Hashable, T.X == T.Y {}
196196
func inferred6<T : P11>(_: T) where T.Y : Hashable, T.Z == Set<T.X>, T.X == T.Y {}
197+
198+
func typeMatcherSugar<T>(_: T) where Array<Int> == Array<T>, Array<Int> == Array<T> {}
199+
// expected-warning@-1 2{{redundant same-type constraint 'Array<Int>' == 'Array<T>'}}
200+
// expected-warning@-2{{redundant same-type constraint 'T' == 'Int'}}

0 commit comments

Comments
 (0)