Skip to content

Sema: Eliminate some piecemeal unavailability diagnostics #77236

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

Merged

Conversation

tshortli
Copy link
Contributor

There were a few parts of the compiler that were specifically diagnosing just the unavailability of declarations in certain synthesized code:

  • Extraction of enum elements from ClangImporter synthesized enum element accessors with Swift 2-era names.
  • References to wrappedValue accessors in synthesized property accessors for wrapped vars.

These piecemeal diagnostics can be subsumed by performing full availability checks on the decl refs instead to catch more issues while also reducing the amount of availability spaghetti there is to maintain and refactor.

Call `checkDeclarationAvailability()`, instead of just diagnosing
unavailability.
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

Call `checkDeclarationAvailability()`, instead of just diagnosing
unavailability.
@tshortli tshortli force-pushed the refactor-diagnose-explicit-unavailability branch from 99eeea1 to 7e6e8ed Compare October 25, 2024 23:51
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli tshortli merged commit 49e4e06 into swiftlang:main Oct 26, 2024
3 checks passed
@tshortli tshortli deleted the refactor-diagnose-explicit-unavailability branch October 26, 2024 05:03
@aschwaighofer
Copy link
Contributor

Could this have caused the failures on https://ci.swift.org/job/swift-main-source-compat-suite/938/ and https://ci.swift.org/job/swift-main-source-compat-suite-debug/938/

/Users/ec2-user/jenkins/workspace/swift-main-source-compat-suite-debug/swift-source-compat-suite/project_cache/Doggie/Sources/DoggieGeometry/ApplePlatform/Geometry/CGPath.swift:238:19: error: 'curveTo' is only available in macOS 11.0 or newer
206 | #elseif canImport(AppKit)
207 | 
208 | extension NSBezierPath: BezierPathConvertible {
    | `- note: add @available attribute to enclosing extension
209 |     
210 |     fileprivate var _currentPoint: Point {
    :
228 |     }
229 |     
230 |     fileprivate func _copy<Other: BezierPathConvertible>(to path: inout Other) {
    |                      `- note: add @available attribute to enclosing instance method
231 |         
232 |         var points = [CGPoint](repeating: CGPoint(), count: 3)
    :
236 |             case .moveTo: path._move(to: Point(points[0]))
237 |             case .lineTo: path._line(to: Point(points[0]))
238 |             case .curveTo: path._curve(to: Point(points[2]), control1: Point(points[0]), control2: Point(points[1]))
    |                   |- error: 'curveTo' is only available in macOS 11.0 or newer
    |                   `- note: add 'if #available' version check
239 |             case .closePath: path._close()
240 |             @unknown default: break

rdar://138771328

@tshortli
Copy link
Contributor Author

Could this have caused the failures on https://ci.swift.org/job/swift-main-source-compat-suite/938/ and https://ci.swift.org/job/swift-main-source-compat-suite-debug/938/

Yes, it probably has. I'm taking a look, thanks for the heads up!

tshortli added a commit to tshortli/swift that referenced this pull request Oct 28, 2024
swiftlang#77236 caused a source compatibility
regression because `extractEnumElement()` does not suppress its diagnostics in
the context of pattern matching. Potentially unavailable enum elements should
not be diagnosed when pattern matching since the generated code will not
retrieve the potentially unavailable element value on versions where it is
unavailable.

Fixes rdar://138771328.
tshortli added a commit to tshortli/swift that referenced this pull request Jan 17, 2025
Partially revert swiftlang#77236 in order to work
around some issues related to the way `@_spi` attributes are printed and
checked in swiftinterfaces.

Resolves rdar://143029729.
tshortli added a commit that referenced this pull request Jan 20, 2025
…icit-unavailability-6.1

[6.1] Sema: Partially revert #77236
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants