Commit Graph

64 Commits

Author SHA1 Message Date
Hamish Knight
71f8e68655 [Sema] Check for placeholders in extended type first
Avoid emitting a diagnostic about `<<hole>>` being a non-nominal type.
2025-09-17 20:41:20 +01:00
Meghana Gupta
e8abd59da5 Update tests 2024-11-18 18:09:19 -08:00
iMostfa
80a8a0746b Replace uses of the word "accessor" in diagnostics with user-facing terminology (#74462)
In this PR i worked on replacing the word accessor in diagnostics with more user-facing terminologies like setter, getter, didSet Observer, and members based on the context of the message.

in some messages i didn't need to pass DescriptiveDeclKind instead i just changed the text copy itself.

i also updated tests, so you might find it easier to check my changes this way.

Please let me know if there's something i should've done in a better way, and request changes if needed. !

i can squash my commits after reviewing getting the PR Reviewed, just to make it easier to be checked commit by commit

Resolves #55887
2024-08-16 16:29:30 -07:00
Nate Chandler
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Kavon Farvardin
f0a69a3ef1 prevent uses of Escapable in general
This protocol appears in the stdlib as scaffolding for the
`NonescapableTypes` feature, which is still experimental and not gone
through evolution as an approved addition to the stdlib.

Rather than delete it from the stdlib, because it needs to still remain
to support that feature work, gate references to it behind a feature
flag.

Additionally, prevent documentation from seeing this declaration.

rdar://126705184
2024-04-22 20:40:11 -07:00
Kavon Farvardin
3ab4c7548c Sema: ban extensions of known marker protocols
There's no good reason to permit them. Conformances like Copyable and
Sendable are pervasive, so it's as though we are permitting extensions
of `Any`. Until there's a good argument in favor of such extensions,
remove the capability now.
2024-02-07 14:54:36 -08:00
Slava Pestov
ea15d9f9b2 Stop passing -warn-redundant-requirements in tests 2024-02-02 14:57:19 -05:00
Slava Pestov
fd06bd87aa AST: Allow the extended type of an extension to refer to be a tuple type
Either directly, or via a type alias.
2023-09-05 23:21:26 -04:00
Nate Chandler
594e690a00 [Test] Added new redundancy warnings.
Now that `InferredGenericSignatureRequest` creates
`StructuralRequirement`s from of the generic signature with valid source
locations, additional redundancy warnings are produced.  Update tests
with the new warnings.
2023-05-17 15:16:23 -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
Casper Jeukendrup
d47bba6644 Improve diagnostics when attempting to extend existential type 2022-09-23 19:27:05 +02:00
Anthony Latsis
0c749b2651 Gardening: Migrate test suite to GH issues: decl/ext 2022-08-26 03:26:32 +03:00
Slava Pestov
b1182ebc15 Sema: Improved check for failure to bind an extension
Calling computeExtendedNominal() won't catch the case where the
extended type did not exist at extension binding time but then
appeared later, like an inferred associated type witness for
example.
2022-08-02 23:12:24 -04:00
Holly Borla
609733bb88 [SE-0361] Update tests for bound generic extensions. 2022-06-30 17:25:17 -07:00
Slava Pestov
f39372b33d RequirementMachine: Turn off redundant requirement warnings by default and add -warn-redundant-requirements frontend flag 2022-05-10 01:49:56 -04:00
Kavon Farvardin
c4fc99e71d update diagnostic since actors can have deinits 2022-02-28 16:24:55 -07:00
Anthony Latsis
5215fe5d95 AST: Make sure malscoped extensions get their extended nominal computed 2021-11-08 17:29:38 +03:00
Slava Pestov
299ff02684 GSB: Diagnose redundant layout requirements using the redundant requirement graph 2021-03-27 00:35:19 -04:00
Suyash Srijan
6e6de518eb [Sema] Improve diagnostics for use of self access kind modifier on accessors inside classes (#33602) 2020-08-25 20:02:52 +01:00
Rintaro Ishizaki
bc2085683f [Test] Add a test case for extension where clause with missing body
rdar://problem/66943328
2020-08-12 16:36:16 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Owen Voorhees
77aa5642c3 [Diagnostics] Expand test coverage of existing edu notes 2020-04-09 18:18:25 -07:00
Slava Pestov
54155fe290 Sema: Check generic requirements of parent context when realizing non-generic types
When realizing a type like Foo<A>.Bar, we have to account for the
possibility that Bar is defined in a constrained extension of Foo,
and has generic requirements beyond those that Foo itself places
on 'A'.

Previously we only handled this for types referenced from the
constraint system as part of openUnboundGenericType(), so we were
allowing invalid types through in type context.

Add the right checking to applyGenericArguments() to close the
hole. Note that the old code path still exists in the constraint
solver; it is used for member accesses on metatype bases only.

Fixes <https://bugs.swift.org/browse/SR-10466>.
2019-11-14 18:26:43 -05:00
Robert Widmann
c75af38a7a Drop ConformanceContexts out of the TypeChecker 2019-11-06 11:41:03 -08:00
Suyash Srijan
2033201fb0 [Test] Add more test cases 2019-10-15 01:35:47 +01:00
Suyash Srijan
528558d0e0 [Test] Adds another test case 2019-10-15 01:35:46 +01:00
Suyash Srijan
09067cf3b3 [Test] Check if the fix-its are being offered and being correctly applied 2019-10-15 01:35:46 +01:00
Suyash Srijan
4473cb898d [Test] Update fix-it range for test case and add comments 2019-10-15 01:35:46 +01:00
Suyash Srijan
6ca121dd2a [Typechecker] Do not incorrectly mark explicitly mutating methods as non-mutatingif we're in a class-constrained protocol extension 2019-10-15 01:35:46 +01:00
Suyash Srijan
70d77e9fe2 Revert "Revert "Merge pull request #27057 from theblixguy/unrevert/SR-11298""
This reverts commit 7725818275.
2019-10-15 01:35:46 +01:00
Jordan Rose
7725818275 Revert "Merge pull request #27057 from theblixguy/unrevert/SR-11298"
This reverts commit c99facb48b, reversing
changes made to 9a24013228.

rdar://problem/56165420
2019-10-10 14:29:52 -07:00
Suyash Srijan
54a4615e6f [Diagnostics] Do not offer a mutating fix-it if we have a mutating protocol requirement
Do not offer a mutating fix-it if we have a mutating protocol requirement and we're assigning to it from an implicitly nonmutating setter inside a protocol extension
2019-09-06 23:40:07 +01:00
Suyash Srijan
0c0a72677c Merge branch 'master' into unrevert/SR-11298 2019-09-06 19:32:03 +01:00
Suyash Srijan
fc6a49e834 [Test] Update tests 2019-09-06 18:37:11 +01:00
Harlan Haskins
2062ee837d Merge pull request #26999 from harlanhaskins/my-internal-conflict
[Sema] Point to declaration when looking for a member type
2019-09-03 16:51:04 -07:00
Harlan Haskins
fb546513da [Sema] Point to declaration when looking for a member type
When there's a module with the same name as a type in a
different module, lookup will look into the type, not the module, when
resolving members. Until that behavior is fixed, add a note showing what
lookup was trying to look into, to make the behavior more clear.

Helps rdar://54770139
2019-09-03 15:27:28 -07:00
Robert Widmann
59687518e2 Reject nominal extensions (with a bit of indirection)
If the canonical type is a nominal type then we can offer a diagnostic
that rewrites to it.

Resolves rdar://54799560
2019-09-01 01:52:41 -05:00
Suyash Srijan
b732344190 [Test] Add test cases where a protocol extension is constrained to a class and the protocol does not impose a class requirement (#26696) 2019-08-19 11:32:57 -07:00
Jordan Rose
edb153afd1 Revert "[Sema] Setter has incorrect mutating-ness inside class-constrained protocol extension" 2019-08-16 11:32:58 -07:00
Suyash Srijan
304449b1c5 [Test] Add a test case 2019-08-15 21:40:39 +01:00
Doug Gregor
3018becde7 [Type checker] Eliminate type checking from early extension binding.
Use ExtensionDecl::getExtendedNominal() to wire up extensions to their
nominal types early in type checking (the bindExtensions()) operation,
rather than going through type validation to do so.
2018-08-03 11:26:49 -07:00
Slava Pestov
29f785f09b Sema: Don't emit duplicate diagnostics for members named 'Type' or 'Protocol'
IsFirstPass is going away soon, but in the meantime, the next
patch regresses matters slightly and causes us to emit
duplicate diagnostics in more cases, so let's fix it.
2018-04-02 23:17:59 -07:00
Graydon Hoare
367a1500a3 [Diagnostics] s/may/must/ in 'may not be named' 2017-09-29 16:09:23 -04:00
Jordan Rose
1c8caeb689 Handle implicit member references inside extensions of nested types. (#7241)
Within an extension, references to other members of the extended type
are permitted without qualification. This is intended to work even
when the extended type was a nested type, although members of the
enclosing type are /not/ visible in this case. In order to implement
this, the type checker pre-checks to see if there are /any/ members
with this name and then rewrites the unqualified reference to a
qualified one, based on an unresolved TypeExpr with the name of the
enclosing type. Unfortunately, if the enclosing type is a nested type,
that isn't going to work very well---we find the correct declaration,
but fail to map it into context by virtue of not realizing where it
came from. Fix this by explicitly checking for this case.

https://bugs.swift.org/browse/SR-3847
2017-02-06 14:49:49 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
David Farler
414cfe7487 Minor changes to keyword-as-identifier diagnostics
- Remove stray newline
- Adjust wording when recommending backticks for a keyword identifier
- Provide fix-it when encountering a keyword as an identifier

rdar://problem/25761380
2016-05-10 14:49:21 -07:00
NachoSoto
c97a76fc2b [Serialization] Add failing test creating extension for nested Type type. 2016-01-24 10:20:23 -08:00
Doug Gregor
38c1de69e4 Reinstate "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit ce7b2bcf09, tweaking
a few validation tests appropriately (1 crasher fixed, two -verify
tests that needed updating).
2016-01-14 00:21:48 -08:00
Erik Eckstein
ce7b2bcf09 Revert "[SR-511][Parse] Add 'associatedtype' keyword and fixit"
This reverts commit 2b2e9dc80e.

It broke some compiler crasher tests
2016-01-13 20:42:58 -08:00
gregomni
2b2e9dc80e [SR-511][Parse] Add 'associatedtype' keyword and fixit
Adds an associatedtype keyword to the parser tokens, and accepts either
typealias or associatedtype to create an AssociatedTypeDecl, warning
that the former is deprecated. The ASTPrinter now emits associatedtype
for AssociatedTypeDecls.

Separated AssociatedType from TypeAlias as two different kinds of
CodeCompletionDeclKinds. This part probably doesn’t turn out to be
absolutely necessary currently, but it is nice cleanup from formerly
specifically glomming the two together.

And then many, many changes to tests. The actual new tests for the fixits
is at the end of Generics/associated_types.swift.
2016-01-13 17:54:31 -08:00