Commit Graph

1081 Commits

Author SHA1 Message Date
Josh Soref
ebc4e60560 Spelling decl (#42550)
* spelling: adjacent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ambiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: captures

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: effectful

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: nonoverride

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ouroboros

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overridden

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: qualified

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: received

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: refinement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 09:44:52 -07:00
Holly Borla
0e7594a3f9 [Sema] Require any for SE-0309 existential types. 2022-04-21 18:22:27 -07:00
Doug Gregor
c76a99ba02 [SE-0352] Enable implicit opening of existentials by default 2022-04-20 17:51:04 -07:00
Anthony Latsis
934964d49d Use AbstractStorageDecl::isSettableInSwift to prohibit direct writes to optional requirements
Stop pretending that an optional requirement is immutable via the `StorageImplInfo` request.
This approach has lead astray the conformance checker and may have had a negative impact
on other code paths, and it doesn't work for imported declarations because they bypass the
request. Instead, use a forwarding `AbstractStorageDecl::isSettableInSwift` method
that special-cases optional requirements.
2022-04-20 14:27:15 +03:00
Holly Borla
976addcbef [Diagnostics] When replacing an existential parameter type with a type parameter,
insert 'some' instead of an explicit type parameter.

Replacing 'any' with 'some' allows the code to compile without further
changes, such as naming an explicit type parameter, and is future-proofed
for same-type requirements on primary associated types instead of needing
additional logic to add a 'where' clause.
2022-04-15 22:57:56 -07:00
Becca Royal-Gordon
ecdd42f20c Make @preconcurrency import hide sendable variance
When the conformance checker and override checker detect a difference in a function type’s @Sendable attribute that varies in an illegal way, they now check if the protocol/base class was imported with an @preconcurrency import, and either limit the diagnostic or suggest adding @preconcurrency to the import as appropriate.

Completes rdar://91109455.
2022-04-08 13:08:39 -07:00
Becca Royal-Gordon
4caaa3bf24 Merge pull request #42194 from beccadax/witness-accounts-are-only-approximate
Make overloads and witnesses permit @Sendable variance
2022-04-07 22:21:16 -07:00
Doug Gregor
fdc6260bc1 Reimplement conformance isolation checking using the actor reference logic.
Reimplement the final client of ActorIsolationRestriction, conformance
isolation checking, to base it on the new "actor reference" logic.
Centralize the diagnostics emission so we have a single place where we
emit the primary diagnostic (which is heavily customized based on
actor isolation/distributed/etc.) and any relevant notes to make
adjustments to the witness and/or requirement, e.g., adding
'distributed', 'async', 'throws', etc. Improve the diagnostics
slightly by providing Fix-Its when suggesting that we add "async"
and/or "throws".

With the last client of ActorIsolationRestriction gone, remove it
entirely.
2022-04-07 17:10:02 -07:00
Anthony Latsis
15839ffba6 Merge pull request #42049 from AnthonyLatsis/dyn-self-inherit
findGenericParameterReferences: Do better at honoring 'treatNonResultCovarianceAsInvariant' and 'hasCovariantSelfResult'
2022-04-07 09:07:16 +03: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
Becca Royal-Gordon
4ab523378a Warn about incorrect Sendable for witnesses 2022-04-05 16:46:48 -07:00
swift-ci
6af73245c6 Merge pull request #42136 from ktoso/wip-identifiable-synthesis-fix
[Distributed] ID synthesis must be eager, or we run into issues in real projects
2022-04-04 02:51:22 -07:00
Konrad `ktoso` Malawski
bf37e699b3 [Distributed] add protocol test 2022-04-04 12:32:47 +09: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
Konrad `ktoso` Malawski
c88951354f [Distributed] ID synthesis must be eager, or we run into issues in real projects 2022-04-01 18:47:25 +09:00
Slava Pestov
4e89f73e90 RequirementMachine: Allow markConflicting() on already-conflicting frozen rules 2022-04-01 01:05:54 -04:00
Slava Pestov
22f0f40a30 RequirementMachine: Copy over GSB logic where inheritance of JSExport protocol can be re-stated redundantly 2022-04-01 01:04:54 -04:00
Slava Pestov
01fea564fb RequirementMachine: Skip emitting diagnostics containing ErrorTypes 2022-04-01 01:04:54 -04:00
Slava Pestov
b4b873332f Update -requirement-machine-* flags in various tests
- Don't pass 'verify' since it's now the default
- Update tests where diagnostics changed in a correct way to pass 'on' instead
- Delete compiler_scale/explicit_requirements_perf.swift since it's not testing anything with the requirement machine
2022-03-31 15:57:36 -04:00
Anthony Latsis
def23f45a1 findGenericParameterReferences: Do better at honoring 'treatNonResultCovarianceAsInvariant' and 'hasCovariantSelfResult' 2022-03-29 13:10:49 +03:00
Anthony Latsis
ba7f301e83 ConformanceChecker: Always diagnose a conformance failure if the requirement check fails in 'ensureRequirementsAreSatisfied' 2022-03-28 23:22:36 +03:00
Anthony Latsis
f39464bbf3 TypeChecker: Replace calls to the old 'checkGenericArguments' with 'checkGenericArgumentsForDiagnostics' 2022-03-28 22:55:02 +03:00
Anthony Latsis
f37ac3ecec [NFC] Add a test that does not work with experimental associated type inference enabled 2022-03-25 08:59:43 +03:00
Anthony Latsis
38e48ac15d TypeWitnessSystem: Disable by default 2022-03-25 08:45:54 +03:00
Konrad `ktoso` Malawski
8d3e7d91c0 [Distributed] ResultHandler.onReturn must be ad-hoc because SerializationRequirement (#41916)
* [Distributed] Invoke handler.onReturn ad hoc via ast synthesized func

* reformat and cleanup

* remove unused var
2022-03-24 21:44:37 +09:00
Slava Pestov
441fa1679a RequirementMachine: Splitting concrete equivalence classes in protocol requirement signatures 2022-03-22 15:02:06 -04:00
Becca Royal-Gordon
bb29c3589f Merge pull request #41828 from beccadax/a-breach-of-protocol-can-cause-a-conflict
Check protocols for selector conflicts
2022-03-21 14:09:38 -07: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
Konrad `ktoso` Malawski
5a5d1ba2e6 [Distributed] Implement RemoteCallArgument 2022-03-17 22:55:09 +09:00
Konrad `ktoso` Malawski
ea29723466 [Distributed] Add name parameter to recordArgument for better interop 2022-03-17 20:05:31 +09:00
Becca Royal-Gordon
06949a4f4a Check protocols for selector conflicts
Although we have always checked classes to see if their @objc members had the same selectors, it turns out we never did this for protocols. Oops. Keep a table of ObjC selector names for protocols, just as we do for classes, and diagnose any conflicts between them.

Fixes rdar://80990066.
2022-03-16 14:41:55 -07:00
Konrad `ktoso` Malawski
8c13370242 [Distributed] rename _Distributed to underscoreless module 2022-03-16 08:35:35 +09:00
Slava Pestov
df49e112e3 RequirementMachine: Skip 'verify' check if completion failed
We obviously don't have a valid generic signature in this case.
2022-03-14 12:33:18 -04:00
Slava Pestov
965f32dd07 Merge pull request #41773 from slavapestov/rqm-concrete-protocol-typealias-minimization
RequirementMachine: Overhaul handling of protocol typealiases with concrete underlying type
2022-03-12 20:15:24 -05:00
Slava Pestov
1f83cd0b49 RequirementMachine: Don't eliminate a rule via a path involving a protocol typealias rule
If a rule is not a protocol typealias rule, and does not contain any unresolved
symbols, do not attempt to eliminate it via a protocol typealias rule.

This fixes a bunch of cases where the RequirementMachine was overly-eager to
remove rules.
2022-03-11 17:28:01 -05:00
Konrad `ktoso` Malawski
13cc8b3157 [Distributed] Enable no-longer-experimental distributed by default 2022-03-11 22:14:49 +09:00
Konrad `ktoso` Malawski
6d502fc042 [Distributed] Implicit Codable conformance for Dist Actors
[Witness] implement dump() on witness
2022-03-11 18:07:14 +09:00
Holly Borla
d3702bacbb Merge pull request #41664 from hborla/redundant-requirements 2022-03-11 01:03:51 -08:00
Slava Pestov
5bb40ae66e Sema: Fix doesMemberHaveUnfulfillableConstraintsWithExistentialBase() for generic context
We don't want to pass in the outer generic signature here.

The base type's constraint type is written in terms of archetypes,
and we run generic signature queries against it with types appearing
in the protocol member. Since the protocol member has Self at
depth 0, index 0, prepending the outer generic signature to the
opened existential signature would produce incorrect results.
2022-03-09 17:27:06 -05:00
Holly Borla
397684909b [RequirementMachine] Suppress redundancy warnings when an explicit, redundant
rule has a non-explicit, non-redundant rule in its rewrite path.

This fixes bogus redundancy diagnostics in cases where the canonical form
of a redundant rule is not explicit in source, e.g.

protocol Swappable2 {
  associatedtype A
  associatedtype B
  associatedtype Swapped : Swappable2
    where Swapped.B == A,
          Swapped.Swapped == Self
}

in the above case, the canonical rule for `Swapped.B == A` is the rule
[Swappable2:Swapped].[Swappable2:A] => [Swappable2:B], which is not
explicit.
2022-03-09 12:14:58 -08:00
Holly Borla
70197c8557 Merge pull request #41693 from hborla/any-in-diagnositcs
[Diagnostics] Print `any` in diagnostics.
2022-03-06 10:09:12 -08:00
Holly Borla
12459cff80 [Diagnostics] Print 'any' in diagnostic arguments. 2022-03-05 14:26:45 -08:00
swift-ci
92a63b99b2 Merge pull request #41641 from AnthonyLatsis/se-309-vararg
[SE-309] Add tests for covariant variadic parameters
2022-03-04 12:32:12 -08:00
Anthony Latsis
8df964e4cf [SE-309] Add tests for covariant variadic parameters 2022-03-03 13:07:51 +03:00
Slava Pestov
06dabe91ec Merge pull request #41630 from slavapestov/rqm-abstract-signatures-fixes
RequirementMachine: Fix test failures with -requirement-machine-abstract-signatures=verify
2022-03-02 22:13:45 -05:00
Slava Pestov
1a637c62f4 Enable -requirement-machine-abstract-signatures=on in a couple of tests that used to fail 2022-03-02 17:07:33 -05:00
Slava Pestov
38d188b6b9 Sema: Bake in the old broken behavior for protocol overrides
To avoid breaking the ABI of the standard library and possibly other
modules, we can't actually enable the new accurate logic for checking
protocol requirement overrides after all.

Just skip the check if the protocol requirement is generic to get
back the old behavior.
2022-03-02 15:46:58 -05:00
Slava Pestov
345185f32d Sema: Fix isOverrideBasedOnType() to check protocol generic signatures
This avoids feeding invalid type parameters to the Requirement Machine
when a protocol requirement looks similar to a protocol requirement in
the inherited protocol but has an incompatible type.

Fixes https://bugs.swift.org/browse/SR-15826 / rdar://problem/89641535.
2022-03-02 14:18:15 -05:00
swift-ci
c880534e25 Merge pull request #41591 from kavon/or-actor
update diagnostic since actors can have deinits
2022-02-28 18:45:53 -08:00
Kavon Farvardin
c4fc99e71d update diagnostic since actors can have deinits 2022-02-28 16:24:55 -07:00