Commit Graph

19 Commits

Author SHA1 Message Date
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Allan Shortlidge
550d7bb754 Sema: Allow overrides to be unavailable in the current Swift language mode.
Fixes a regression from https://github.com/swiftlang/swift/pull/83354.

Resolves rdar://158262522
2025-08-13 17:57:05 -07:00
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Robert Widmann
2fca132152 Add a Fixit to Rewrite NSObject.hash(into:) Overrides 2021-02-08 12:17:16 -08:00
Robert Widmann
58110fe2df [NFC] Make override_nsobject_hash_error Look Like override_nsobject_hashvalue_error 2021-02-08 11:23:28 -08:00
Minhyuk Kim
f138ce0b19 Add specific warning for overriden NSObject.hash(into:) 2021-01-21 23:23:00 +09:00
Jordan Rose
3c740e4f2e Don't fix access of an 'open' decl in a 'public' extension
This is reasonable to diagnose with a warning, but dropping the 'open'
down to 'public' isn't the right fix, because now it's not a valid
override. The declaration has to get moved to another extension instead,
or the extension has to not set a default access level.

This turned out to be a source compat issue because the same logic
that emits the fix-it also updates the access of the member, which
then resulted in "must be as accessible as the declaration it
overrides" in the /same/ build. It's not immediately clear what caused
this; probably something's just being validated in a different order
than it was before. The change makes sense either way.

Stepping back, it's weird that a warning would change how the compiler
saw the code, and while we could check for 'override' explicitly, we
can't know if the member might be satisfying a protocol requirement.
Better to just not guess at the right answer here.

rdar://problem/47557376&28493971
2019-01-28 18:25:06 -08:00
Jordan Rose
1f06cd7e6d Tweak diagnostic for a high-access member in a low-access extension
Before: declaring a public instance method in a private extension
After: 'public' modifier conflicts with extension's default access of
       'private'
2019-01-28 18:24:12 -08:00
Karoy Lorentey
6af814d76c [test] Test new fix-it for NSObject.hashValue overrides 2019-01-23 19:44:01 -08:00
Karoy Lorentey
666a22feff [test] Modernize hashing throughout the test suite 2018-11-29 17:38:29 +00:00
Doug Gregor
cc4c99227a [Type checker] Warn about overrides of NSObject.hashValue.
NSObject.hashValue is provided to satisfy the hashValue constraint of
the Hashable protocol. However, it is not the correct customization
point for interoperating with Objective-C, because Objective-C code
will call through the -hash method. Warn about overrides of
NSObject.hashValue; users should override NSObject.hash instead.

Fixes rdar://problem/42780635.
2018-07-31 11:40:10 -07:00
Doug Gregor
b70466dc63 [Type Checker] Add a request kind for computing 'ValueDecl::isObjC()'.
Still a WIP
2018-07-18 14:50:39 -07:00
Doug Gregor
7279eeeeac [Type checker] Perform more minimal checking in resolveOverriddenDecl().
Rather than deferring to the heavyweight validateDeclForNameLookup()
to perform the “get overridden decls” operation, perform a much more
minimal validation that only looks for exact matches when the ‘override’
modifier is present.

The more-extensive checking (e.g., that one didn’t forget an override
modifier) is only performed as part of the “full” type checking of
a declaration, which will typically only be done within the same source
file as the declaration. The intent here is to reduce the amount of
work performed to check overrides cross-file, and limit the dependencies
of the “get overridden decls” operation.
2018-07-03 17:26:38 -07:00
Slava Pestov
57af488f63 Migrate ClangImporter tests to Swift 4 2018-06-26 16:56:33 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Jordan Rose
1ab51ea3bd Hack: allow dropping noescape-ness when overriding ObjC methods (#10775)
In today's Swift, only non-optional function parameters can be
non-escaping (and are by default). An optional function parameter uses
a function type as a generic argument to Optional, and like any other
generics that's considered an opaque and therefore possibly escaping
use of the type. This is certainly unfortunate since it means a
function parameter cannot be both Optional and non-escaping.

However, this "unfortunate" becomes a concrete problem when dealing
with Objective-C, which /does/ allow applying its 'noescape' attribute
to a callback block marked 'nullable'. This is fine for /uses/ of
methods with such parameters, but prevents anyone from /overriding/
these methods.

This patch pokes a very narrow hole into the override checking to
accomodate this: if a declaration comes from Objective-C, and it has
an optional, non-escaping closure parameter, it's okay to override it
in Swift with an optional, escaping closure parameter. This isn't
strictly safe because a caller could be relying on the
non-escaping-ness, but we don't have anything better for now. (This
behavior will probably be deprecated in the future.)

(Some people have noted that the old 'noescape' type attribute in
Swift still works, albeit with a warning. That's not something people
should have to type, though---we want to remove it from the language,
as described in SE-0103.)

rdar://problem/32903155
2017-07-10 16:03:37 -07:00
Rintaro Ishizaki
384ab780e9 [Diagnostic verifier] Make '<unknown>' check optional
Added frontend option '-verify-ignore-unknown'
2017-02-02 10:49:32 +09:00
Rintaro Ishizaki
827c6e7c3d [Diagnostic verifier] Diagnostics at '<unknown>:0' are unexpected 2017-02-02 10:48:54 +09:00
Jordan Rose
61798ff6ec [test] Rename test/ClangModules to test/ClangImporter. (#5618)
...to match the component in include/ and lib/. No content change.
2016-11-02 18:00:53 -07:00