Skip to content

Commit c8f2331

Browse files
committed
AST: Don't forget to check ProtocolCompositionType::hasExplicitAnyObject() in TypeMatcher
1 parent 1336277 commit c8f2331

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

include/swift/AST/TypeMatcher.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,12 @@ class TypeMatcher {
358358
Type secondType,
359359
Type sugaredFirstType) {
360360
if (auto secondProtocolComposition = secondType->getAs<ProtocolCompositionType>()) {
361+
if (firstProtocolComposition->hasExplicitAnyObject() !=
362+
secondProtocolComposition->hasExplicitAnyObject()) {
363+
return mismatch(firstProtocolComposition.getPointer(), secondType,
364+
sugaredFirstType);
365+
}
366+
361367
auto firstMembers = firstProtocolComposition->getMembers();
362368
auto secondMembers = secondProtocolComposition->getMembers();
363369

test/Generics/issue-49200.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol B {
4+
typealias A = Any
5+
}
6+
7+
protocol D : B {
8+
// expected-error@-1 {{no type for 'Self.A' can satisfy both 'Self.A == Any' and 'Self.A == AnyObject'}}
9+
// expected-error@-2 {{no type for 'Self.A' can satisfy both 'Self.A : AnyObject' and 'Self.A == Any'}}
10+
typealias A = AnyObject
11+
}

0 commit comments

Comments
 (0)