Commit Graph

163 Commits

Author SHA1 Message Date
Andrew Trick
c04e555858 Update test: protocols.swift for LifetimeDependence evaluation
Evaluating LifetimeDependence changes the order that the declarations are
diagnosed. Fix this test output by flipping the order of two declarations. The
new order actually makes more sense to me.
2025-05-21 00:25:00 -07:00
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Anthony Latsis
fe2408c0ab TypeCheckType: Unconditionally warn about missing existential any until Swift 7
https://github.com/swiftlang/swift/pull/72659 turned out to have some
source compatibility fallout that we need to fix. Instead of introducing
yet another brittle compatibility hack, stop emitting errors about a
missing `any` altogether until a future language mode.

Besides resolving the compatibility issue, this will encourage
developers to adopt any sooner and grant us ample time to gracefully
address any remaining bugs before the source compatibility burden
resurfaces.

A subsequent commit adds a diagnostic group that will allow users to
escalate these warnings to errors with `-Werror ExistentialAny`.
2025-02-12 21:20:44 +00:00
Anthony Latsis
02261dccc7 [NFC] TypeCheckType: Streamline logic in the any syntax checker 2025-02-12 21:20:44 +00:00
Alex Hoppen
66104395d7 [Sema/SourceKit] Emit same diagnostics for missing protocol requirements on the command line and in SourceKit
Some editors use diagnostics from SourceKit to replace build issues. This causes issues if the diagnostics from SourceKit are formatted differently than the build issues. Make sure they are rendered the same way, removing most uses of `DiagnosticsEditorMode`.

To do so, always emit the `add stubs for conformance` note (which previously was only emitted in editor mode) and remove all `; add <something>` suffixes from notes that state which requirements are missing.

rdar://129283608
2024-08-07 14:01:30 -07:00
Anthony Latsis
44e5286d55 ExistentialTypeSyntaxChecker: Look through any and some 2024-06-04 02:13:08 +03:00
Kavon Farvardin
48beac231c Test: misc. test updates for NoncopyableGenerics 2024-03-14 23:10:44 -07:00
Holly Borla
9ba481ad53 [Diagnostics] Clarify the wording of error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Slava Pestov
d3aa3a8db9 Adjust XFAILs 2024-02-29 13:55:48 -05:00
Nishith Shah
8e2e625543 [Diagnostics] Use imperative msg for protocol conformance & switch-case fixits
This commit changes fixit messages from a question/suggestion to an
imperative message for protocol conformances and switch-case. Addresses
https://github.com/apple/swift/issues/67510.
2023-08-13 22:34:26 -07:00
Michael Gottesman
40449a6987 [move-only] Emit a clearer message around deinits.
Specifically:

1. Fix the error message so that when we say you can't have a deinit that a
deinit can be on a noncopyable type along side a class or an actor.

2. Even though we already error on @objc enums and say they cannot be
noncopyable, we did not emit an error on the deinit saying that @objc enums
cannot have a deinit. I put in a nice to have error just to make it even
clearer.

rdar://105855978
rdar://106566054
2023-03-12 14:47:34 -07:00
Anthony Latsis
14b70f306b DiagnosticVerifier: Default expected fix-it start line to the diagnostic's 2023-03-08 12:10:27 +03:00
Anthony Latsis
4ee63da498 Gardening: Migrate test suite to GH issues: decl/protocol 2022-08-30 04:08:00 +03:00
Slava Pestov
dac8d666ee Stop passing -requirement-machine-{abstract,inferred,protocol}-signatures flags in tests
These flags are now no-ops.
2022-05-10 12:56:17 -04:00
Holly Borla
0e7594a3f9 [Sema] Require any for SE-0309 existential types. 2022-04-21 18:22:27 -07:00
Slava Pestov
4d15fa0087 RequirementMachine: Don't diagnose trivial circularity 'protocol P : P' as redundant
Every protocol gets an 'identity conformance' rule [P].[P] => [P].
A trivially-stated circularity is always redundant because of this
rule, and we diagnose circular inheritance elsewhere as a hard
error, so just add a special case to skip adding such a rule here
to avoid the useless warning on top of the existing error.
2022-04-05 21:12:51 -04:00
Slava Pestov
4068c9d707 Pass -requirement-machine-{protocol,inferred}-signatures=verify in remaining tests that fail due to diagnostics 2022-04-01 23:55:34 -04:00
Cassie Jones
bc686e733e [Diagnostics] Change phrasing of the existential_requires_any warning
The previous warning "must be explicitly marked as 'any'" isn't clear if
you don't already know the feature, this new phrasing should make it
clearer by including the correct spelling of the type as an example.

Fixes rdar://90384448
2022-03-18 18:18:35 -07:00
Holly Borla
12459cff80 [Diagnostics] Print 'any' in diagnostic arguments. 2022-03-05 14:26:45 -08:00
Kavon Farvardin
c4fc99e71d update diagnostic since actors can have deinits 2022-02-28 16:24:55 -07:00
Holly Borla
ee331a8c01 [Type System] Enable explicit existential types. 2022-01-13 19:31:35 -08:00
LucianoAlmeida
4a881739a6 [Diagnostics][Sema] Improving wording same type is check 2022-01-11 22:46:23 -03:00
Anthony Latsis
c2e5d04669 Test: Find better locations for some updated tests 2021-08-31 19:21:26 +03:00
Suyash Srijan
396087d0d4 [Test] Update existing tests 2021-08-31 19:21:26 +03:00
Kavon Farvardin
c0607b345f Revert "Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic"
The following regression test added for this feature is not passing:

Swift(linux-x86_64) :: decl/protocol/protocols_with_self_or_assoc_reqs_executable.swift

with a compiler crash happening during SILFunctionTransform "Devirtualizer".

Reverting to unblock CI.

This reverts commit f96057e260, reversing
changes made to 3fc18f3603.
2021-08-26 16:46:42 -07:00
Anthony Latsis
749a0ae853 Test: Find better locations for some updated tests 2021-08-16 18:30:26 +03:00
Suyash Srijan
7834120a87 [Test] Update existing tests 2021-08-16 18:30:26 +03:00
Holly Borla
b9040c751d [Diagnostics] Use warnUntilSwiftVersion for the ownership_invalid_in_protocols
diagnostic and remove ownership_invalid_in_protocols_compat_warning.
2021-07-07 18:01:12 -07:00
Slava Pestov
b81afe3c51 Sema: Don't need to explicitly calculate existentialTypeSupported() 2021-02-11 00:19:24 -05:00
Robert Widmann
0009209cba Correct the Location of a Protocol Requirement Fixit
The old fixit mistakenly used getLoc() instead of getEndLoc() on the
type repr, which for simple identifiers will do the right thing. For
compound ones like `[T]`, it instead points inside of the repr inside
which leads to nonsensical fixes like [ { get }T]

rdar://73632764
2021-02-01 16:50:26 -08:00
Hassan El Desouky
d0b6d9f2c1 Improve diagnostic for read-only properties
Make the message within 80 columns width
Improve diagnostic for read-only properties
Improve diagnostic for read-only properties
Improve diagnostic for read-only properties
2020-03-09 04:48:54 +02:00
Slava Pestov
a92724b09c AST: Fix computeSelfParam() to respect __consuming on class methods
Fixes <rdar://problem/58887618>.
2020-01-31 16:37:04 -08:00
Luciano Almeida
0238a29e70 [tests] Fixing tests 2020-01-08 07:07:49 -03:00
Robert Widmann
0063b8ecab Add Regression Tests for Bogus Existential Checked Casts
Try to make sure we don't do the wrong thing here in the future.  We've
been accepting the optional code for a long long time.

See rdar://57674858
2019-12-06 15:12:24 -08:00
Pavel Yaskevich
58329e0c27 Revert "[Diagnostics][Qol] SR-11295 Emit diagnostics for same type coercion. " 2019-10-25 01:05:07 -07:00
Luciano Almeida
16bd889514 Fixing coercion error tests 2019-10-21 23:09:47 -03:00
Suyash Srijan
ab1184208a [CSDiagnostics] Offer a fix-it to conform the decl context to the missing protocols during contextual failure 2019-09-05 02:50:24 +01:00
Holly Borla
9f19597f73 Sema: implement existentialTypeSupported using a request evaluator.
Add the request `ExistentialTypeSupportedRequest` to lazily determine
if we are allowed to refer to an existential type conforming to a
protocol.
2019-07-22 15:35:10 -07:00
Holly Borla
71fb2629ac Sema: implement requiresClass using a request evaluator.
Add the request `ProtocolRequiresClassRequest` to lazily determine if a
`ProtocolDecl` requires conforming types to be a class.

Note that using the request evaluator to compute `requiresClass` introduces
cycle errors for protocol declarations, where this computation didn't
previously emit diagnostics. For now, we'll allow duplicate diagnostics in this
case, with the eventual goal of removing explicitly checking for cycles
via `checkCircularity` (instead letting the request evaluator handle cycle
diagnostics).
2019-07-17 16:04:24 -07:00
Sam Lazarus
facb2d8574 Sema / Test: Allow fallback to CSDiag still using the new diagnostic 2019-05-30 18:28:12 -04:00
gregomni
2e23ee5257 Exclude non-matching name diagonses for all candidates. 2018-10-15 07:48:24 -07:00
MIZUNO Hiroki
f2bdce8251 [SR-8340]Improve fix-it for var and subscript in Protocol (#19660)
* [Parser] Improve fix-it for subscription in protocol
* [Sema] Add fix-it for property in protocol

https://bugs.swift.org/browse/SR-8340
2018-10-05 07:50:03 +09:00
Davide Italiano
ef46ec08fc [AST] Update tests now that we preserve sugar. 2018-09-18 09:23:02 -07:00
Slava Pestov
9ec1926731 Sema: Allow classes in protocol inheritance clauses 2018-07-02 22:06:33 -07:00
Slava Pestov
94f175fcad Sema: Remove redundant protocol circularity check 2018-07-02 22:06:33 -07:00
Slava Pestov
ba30de0f08 Sema: Re-word circular inheritance diagnostics 2018-06-28 16:54:28 -07:00
Doug Gregor
18569e5f77 Merge pull request #16963 from DougGregor/evaluator-type-checker
[Type checker] Use the request-evaluator in the type checker.
2018-06-15 22:41:31 -07:00
Matt Diephouse
87aaf10e6b [Diagnostics] Improve error when type parameters aren't equal 2018-06-15 15:08:05 -04:00
Doug Gregor
ebd774bcd1 [Sema] Eliminate the last use of the IterativeTypeChecker.
Implement TypeChecker::resolveInheritedProtocols() in terms of
"getInheritedType()" queries, instead.

[Sema] Put back resolveInheritedProtocols().

We're still depending on it to update state in some cases.
2018-06-14 15:29:57 -07:00
Doug Gregor
2b2e143f59 [Request-Evaluator] Introduce a request for getting an "inherited type". 2018-06-14 15:29:57 -07:00