Moving this here gives us access to ClangImporter's internal APIs for
future improvements. It also keeps changes to interop-specific
diagnostics localized to the interop-specific part of the compiler.
Diagnose missing imports for members referenced by key paths as errors, rather
than warnings. This reverts the downgrade that was originally implemented in
https://github.com/swiftlang/swift/pull/84160.
Resolves rdar://160154529.
The compiler synthesized references to these members previously weren't
diagnosed at all in closure contexts. With changes to how `for-in` loops
are type-checked, they are now picked up by `MemberImportVisibility` checking,
but errors about them have to be downgraded to warnings to maintain source
compatibility for the existing code.
Resolves: rdar://169565467
In 53ca5c57309a45700978e4d92c7f5a215fa33547, we started treating the
return type of a constructor as the type that it is constructing
(rather than void, which is the return type stored in the AST) in
some places. This was necessary to suppress warnings that constructors
were annotated with RETURNS_{,UN}RETAINED despite them not technically
returning a FRT.
This patch adjusts some other places to be consistent about this.
However, this patch should be an NFC because constructors shouldn't
end up along these code paths, because by the time we're here we
should already have wrapped those constructors with synthesized shim
factory functions.
This is a follow-up to https://github.com/swiftlang/swift/pull/86499.
Make sure that the error is downgraded even when there is no parent
expression, this covers pattern binding initializer expressions which
started to error after `DynamicSelf` change.
Replace a custom "will be an error in Swift 6" with a modern
downgrade API.
This updates a large number of internal symbols, function names,
and types to match the final approved terminology. Matching the
surface language terminology and the compiler internals should
make the code easier for people to understand into the future.
Lexer should always set `Token.CommentLength` correctly because it
necessary for restoring to the token position with comments.
Otherwise, 'Token::isAtStartOfLine()' might not correctly set.
Removes the underscored prefixes from the @_section and @_used attributes, making them public as @section and @used respectively. The SymbolLinkageMarkers experimental feature has been removed as these attributes are now part of the standard language. Implemented expression syntactic checking rules per SE-0492.
Major parts:
- Renamed @_section to @section and @_used to @used
- Removed the SymbolLinkageMarkers experimental feature
- Added parsing support for the old underscored names with deprecation warnings
- Updated all tests and examples to use the new attribute names
- Added syntactic validation for @section to align with SE-0492 (reusing the legality checker by @artemcm)
- Changed @DebugDescription macro to explicitly use a tuple type instead of type inferring it, to comply with the expression syntax rules
- Added a testcase for the various allowed and disallowed syntactic forms, `test/ConstValues/SectionSyntactic.swift`.
This change makes the warning for unannotated C++ functions returning foreign
reference types (FRT) enabled by default, improving memory safety for Swift/C++
interop users. Also added CxxForeignReferenceType diagnostic group for better control
Availability macros are rejected from library-evolution inlinable code
as the compiler didn't know how to print them in the swiftinterface.
This isn't a concern with the embedded style of fragile functions, we
can allow availability macros there.
Add support for the `Swift` availability domain, which represents availability
with respect to the Swift runtime. Use of this domain is restricted by the
experimental feature `SwiftRuntimeAvailability`.
This check will run on each type-checked primary input of the current compilation and emit a warning diagnostic for all discovered occurences of this code pattern when the performance hint diagnostic is enabled
Not all clients can properly handle the presence of placeholders in
interface types and it doesn't seem worth the complexity for the
type replacement diagnostic.
Embedded Swift doesn't have protocol conformance metadata, so it cannot
handle dynamic casts to existentials (nor should it).
Another part of rdar://119383905.
This attribute forces programmers to acknowledge every
copy that is required to happen in the body of the
function. Only those copies that make sense according
to Swift's ownership rules should be "required".
The way this is implemented as of now is to flag each
non-explicit copy in a function, coming from SILGen, as
an error through PerformanceDiagnostics.
We don't want to just check the first pattern, we're interested in
the first pattern that binds the given variable. That can be determined
by checking if it's canonical or not.
The diagnostic pass that checks whether expressions reference member
declarations that have not been imported failed to handle key path expressions.
Resolves rdar://159093481.
When emitting statement diagnostics for `if #available` queries, diagnose the
availability of the decls representing the referenced availability domains.
Among other things, this checks that the domains are sufficiently visible to be
used in the containing function body context.
This patch improves the warning for C++ APIs returning
`SWIFT_SHARED_REFERENCE` types but not annotated with either
`SWIFT_RETURNS_RETAINED` or `SWIFT_RETURNS_UNRETAINED` in the following
ways:
1. The warning for missing `SWIFT_RETURNS_(UN)RETAINED` annotations is
now emitted on Swift use sites, rather than while importing the API
(func/method decls).
- This logic is now implemented as a Misl Diagnostic in function
`diagnoseCxxFunctionCalls` in file lib/Sema/MiscDiagnostics.cpp.
- The warning is now triggered only when the API is actually used, which
reduces noise in large C++ headers.
- These warnings are still gated behind experimental-feature-flag `WarnUnannotatedReturnOfCxxFrt`
rdar://150800115