Skip to content

Commit 2543b1d

Browse files
authored
Merge pull request llvm#23977 from slavapestov/simplify-type-dynamic-self-fix
Sema: Correctly simplify member types with a DynamicSelfType base
2 parents afb9a65 + 1889d5a commit 2543b1d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,8 @@ Type simplifyTypeImpl(ConstraintSystem &cs, Type type, Fn getFixedTypeFn) {
21972197
// through lvalue, inout and IUO types here
21982198
Type lookupBaseType = newBase->getWithoutSpecifierType();
21992199

2200-
if (lookupBaseType->mayHaveMembers()) {
2200+
if (lookupBaseType->mayHaveMembers() ||
2201+
lookupBaseType->is<DynamicSelfType>()) {
22012202
auto *proto = assocType->getProtocol();
22022203
auto conformance = cs.DC->getParentModule()->lookupConformance(
22032204
lookupBaseType, proto);

test/decl/func/dynamic_self.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,18 +320,24 @@ func testOptionalSelf(_ y : Y) {
320320
// Conformance lookup on Self
321321

322322
protocol Runcible {
323+
associatedtype Runcer
323324
}
324325

325326
extension Runcible {
326327
func runce() {}
328+
329+
func runced(_: Runcer) {}
327330
}
328331

329332
func wantsRuncible<T : Runcible>(_: T) {}
330333

331334
class Runce : Runcible {
335+
typealias Runcer = Int
336+
332337
func getRunced() -> Self {
333338
runce()
334339
wantsRuncible(self)
340+
runced(3)
335341
return self
336342
}
337343
}

0 commit comments

Comments
 (0)