Skip to content

Commit df76400

Browse files
committed
[ConstraintSystem] Add a new reason for invalid member reference
This new reason indicates that result type of a static member doesn't conform to a specific protocol so it can't be referenced on a protocol metatype.
1 parent 03d869a commit df76400

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,11 @@ struct MemberLookupResult {
14601460
UR_ReferenceWritableKeyPathOnMutatingMember,
14611461

14621462
/// This is a KeyPath whose root type is AnyObject
1463-
UR_KeyPathWithAnyObjectRootType
1463+
UR_KeyPathWithAnyObjectRootType,
1464+
1465+
/// This is a static member being access through a protocol metatype
1466+
/// but its result type doesn't conform to this protocol.
1467+
UR_InvalidStaticMemberOnProtocolMetatype,
14641468
};
14651469

14661470
/// This is a list of considered (but rejected) candidates, along with a

lib/Sema/CSSimplify.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7369,7 +7369,10 @@ fixMemberRef(ConstraintSystem &cs, Type baseTy,
73697369
break;
73707370
case MemberLookupResult::UR_KeyPathWithAnyObjectRootType:
73717371
return AllowAnyObjectKeyPathRoot::create(cs, locator);
7372-
}
7372+
7373+
case MemberLookupResult::UR_InvalidStaticMemberOnProtocolMetatype:
7374+
return AllowInvalidStaticMemberRefOnProtocolMetatype::create(cs, locator);
7375+
}
73737376
}
73747377

73757378
return nullptr;

0 commit comments

Comments
 (0)