Skip to content

Commit 522273e

Browse files
committed
AST: TypeMatcher needs to walk into DynamicSelfType
1 parent 36c9da5 commit 522273e

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

include/swift/AST/TypeMatcher.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,27 @@ class TypeMatcher {
229229
}
230230

231231
TRIVIAL_CASE(ModuleType)
232-
TRIVIAL_CASE(DynamicSelfType)
233232
TRIVIAL_CASE(ArchetypeType)
234233

234+
bool visitDynamicSelfType(CanDynamicSelfType firstDynamicSelf,
235+
Type secondType,
236+
Type sugaredFirstType) {
237+
if (auto secondDynamicSelf = secondType->getAs<DynamicSelfType>()) {
238+
auto firstBase = firstDynamicSelf->getSelfType();
239+
auto secondBase = secondDynamicSelf->getSelfType();
240+
auto firstSugaredBase = sugaredFirstType->getAs<DynamicSelfType>()
241+
->getSelfType();
242+
243+
if (!this->visit(CanType(firstBase), secondBase, firstSugaredBase))
244+
return false;
245+
246+
return true;
247+
}
248+
249+
return mismatch(firstDynamicSelf.getPointer(), secondType,
250+
sugaredFirstType);
251+
}
252+
235253
bool visitDependentMemberType(CanDependentMemberType firstType,
236254
Type secondType,
237255
Type sugaredFirstType) {

test/SILGen/dynamic_self.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %target-swift-emit-silgen -swift-version 4 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop | %FileCheck %s
2-
// RUN: %target-swift-emit-sil -swift-version 4 -O %s -disable-objc-attr-requires-foundation-module -enable-objc-interop
3-
// RUN: %target-swift-emit-ir -swift-version 4 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop
1+
// RUN: %target-swift-emit-silgen -swift-version 4 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop -requirement-machine-abstract-signatures=verify | %FileCheck %s
2+
// RUN: %target-swift-emit-sil -swift-version 4 -O %s -disable-objc-attr-requires-foundation-module -enable-objc-interop -requirement-machine-abstract-signatures=verify
3+
// RUN: %target-swift-emit-ir -swift-version 4 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop -requirement-machine-abstract-signatures=verify
44

5-
// RUN: %target-swift-emit-silgen -swift-version 5 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop | %FileCheck %s
6-
// RUN: %target-swift-emit-sil -swift-version 5 -O %s -disable-objc-attr-requires-foundation-module -enable-objc-interop
7-
// RUN: %target-swift-emit-ir -swift-version 5 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop
5+
// RUN: %target-swift-emit-silgen -swift-version 5 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop -requirement-machine-abstract-signatures=verify | %FileCheck %s
6+
// RUN: %target-swift-emit-sil -swift-version 5 -O %s -disable-objc-attr-requires-foundation-module -enable-objc-interop -requirement-machine-abstract-signatures=verify
7+
// RUN: %target-swift-emit-ir -swift-version 5 %s -disable-objc-attr-requires-foundation-module -enable-objc-interop -requirement-machine-abstract-signatures=verify
88

99
protocol P {
1010
func f() -> Self

0 commit comments

Comments
 (0)