-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Sema: Restrict use of SPI operators to files importing the corresponding SPI group #77737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@swift-ci Please smoke test |
| // RUN: %target-swift-frontend -typecheck %s -emit-module-interface-path %t/Main.swiftinterface -emit-private-module-interface-path %t/Main.private.swiftinterface -enable-library-evolution -swift-version 5 -I %t -module-name Main | ||
| // RUN: %FileCheck -check-prefix=CHECK-PUBLIC %s < %t/Main.swiftinterface | ||
| // RUN: %FileCheck -check-prefix=CHECK-PRIVATE %s < %t/Main.private.swiftinterface | ||
| // RUN: cat %t/Main.swiftinterface | %FileCheck -check-prefix=CHECK-PUBLIC %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use cat instead of < here, out of curiosity? FWIW, switching to --input-file instead would improve debugging somewhat (that way FileCheck will print the path to the file when there are mismatches)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was it, I prefer that style now to see the name of the file in the outputs. I'll take a look at --input-file, maybe it will be worth switching style again.
lib/AST/Decl.cpp
Outdated
| case AccessLevel::Public: | ||
| case AccessLevel::Open: | ||
| case AccessLevel::Open: { | ||
| if (VD->isOperator() && VD->isSPI()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth a comment explaining why operators need to be special cased here. I'm having trouble following the surrounding logic and why the existing centralized logic does not apply to them.
1548887 to
04378f1
Compare
|
@swift-ci Please smoke test |
…erface This was already working as expected. Adding a test to ensure it doesn't regress.
Ensure that calls to SPI operators are only accepted in source files importing the corresponding SPI group. This applies the same logic to operators as we do for functions. rdar://137713966
This new check is source breaking. Let's gate it behind an opt-in flag for now and enable it by default on a new language mode or similar.
04378f1 to
a4865be
Compare
|
@swift-ci Please smoke test |
|
@swift-ci Please smoke test macOS |
Ensure that calls to SPI operators are only accepted in source files importing the corresponding SPI group. This applies the same logic to operators as we do for functions, patching a hole in type-checking. SPI operators were already correctly detected when used in inlinable code and printed as expected in public module interfaces only.
rdar://137713966