forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 351
Open
Description
Description:
The Clang compiler incorrectly allows sending protocol-defined messages to __kindof types when the protocol is visible in the current scope, even if the base type doesn't conform to that protocol.
Steps to Reproduce:
-
Case A (Incorrect Behavior):
@protocol A <NSObject> - (void)aaa; @end __kindof UIView *v; [v aaa]; // Compiles without error (UNEXPECTED)
Actual Result: Compilation succeeds despite
UIViewnot conforming to protocolA. -
Case B (Correct Behavior):
__kindof UIView *v; [v aaa]; // Compiler error (EXPECTED)
Actual Result: Properly errors with
No known instance method for selector 'aaa'.
Expected Behavior:
Both cases should fail compilation with No known instance method for selector 'aaa' since:
__kindof UIView *representsUIViewor its subclassesUIViewdoesn't implement-aaa- Protocol visibility shouldn't affect method availability for unrelated types
Impact:
Creates false sense of type safety with __kindof when unrelated protocols are visible, potentially leading to runtime crashes.
Environment:
- Clang version: [16.0.0]
- Xcode: 16.0
Metadata
Metadata
Assignees
Labels
No labels