Commit Graph

4105 Commits

Author SHA1 Message Date
Holly Borla
268f6e25d1 [Diagnostics] Improve the diagnostics for invalid associatedtype or
typealias access on existential types by mentioning the base type in
the error message.
2022-08-19 22:22:43 -04:00
Robert Widmann
4a9a932dce Ban @objcMembers Without Importing Foundation
rdar://98734024
2022-08-17 16:30:02 -07:00
Artem Chikin
256c0ff04a [Explicit Modules] On an explicit interface build, early exit if the expected output is up-to-date. 2022-08-16 18:31:13 -07:00
Luciano Almeida
1b8330778d Merge pull request #60479 from LucianoPAlmeida/dictionary-literal
[Sema] Warn about dictionary literal of dictionary type about duplicated keys
2022-08-16 08:30:49 -03:00
Luciano Almeida
ee20fec382 [Sema] Warn about dictionary literal of dictionary type about duplicated keys 2022-08-15 22:54:55 -03:00
Allan Shortlidge
1739528f6c Sema: Diagnose inconsistent use of @_weakLinked on import declarations. 2022-08-12 09:45:49 -07:00
Slava Pestov
9339443e79 RequirementMachine: Diagnose recursive requirements
Note the test cases in abstract_type_witnesses used to pass but are now
rejected. This is fine, because doing anything more complicated used to
crash, and the GSB would crash or misbehave with these examples.
2022-08-11 14:12:06 -04:00
Suyash Srijan
b30cc9dc1c [Sema] Diagnose 'nonisolated' attribute on wrapped properties (#60475)
* [Sema] Diagnose 'nonisolated' attribute on wrapped properties

* [AST] Update diagnostic wording for nonisolated_wrapped_property
2022-08-10 20:51:49 +01:00
Michael Gottesman
7da2c92358 [move-function] Ban move being passed non-declref expr values.
I did this by requiring this in the typechecker. This will ensure that when we
emit a move, we are guaranteed to have a value decl ref that we can evaluate. It also ensures that we can't _move fields.

auto
2022-08-08 12:50:42 -07:00
Slava Pestov
d222ac5f6e Sema: New syntax for @opened archetypes in textual SIL
The old syntax was

    @opened("UUID") constraintType

Where constraintType was the right hand side of a conformance requirement.

This would always create an archetype where the interface type was `Self`,
so it couldn't cope with member types of opened existential types.

Member types of opened existential types is now a thing with SE-0309, so
this lack of support prevented writing SIL test cases using this feature.

The new syntax is

    @opened("UUID", constraintType) interfaceType

The interfaceType is a type parameter rooted in an implicit `Self`
generic parameter, which is understood to be the underlying type of the
existential.

Fixes rdar://problem/93771238.
2022-08-07 19:03:46 -04:00
Slava Pestov
2944374f79 Merge pull request #60364 from slavapestov/extension-of-inferred-type-alias
Sema: Improved check for failure to bind an extension
2022-08-05 07:20:17 -04:00
Suyash Srijan
b2593ee5e3 [CSDiagnostics] Optional closure diagnostic improvement (#60321)
* [NFC] Add a getOptionalityDepth method to return the number of optionals a type has

* [NFC] Use getOptionalityDepth to remove existing code

* [AST] Add a new diagnostic note for suggesting optional chaining

* [CSDiagnostics] Tweak MissingOptionalUnwrapFailure to suggest using optional chaining on closure

* [Test] Add a couple of test cases for perform_optional_chain_on_closure

* [CSDiagnostics] Change DeclRefExpr casts to isa checks

* [AST] Update diagnostic phrasing

* [Sema] Use new diagnostic identifier and update comment

* [Test] Add a new test case for function type

* [Test] Update cfuncs_parse.swift tests to check for new diagnostic note
2022-08-04 21:40:17 +01: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
Allan Shortlidge
1b9d53941d Sema: Diagnose when typealiases used in public declarations would desugar to types from non-public imports.
Resolves rdar://91447971
2022-07-31 11:59:02 -07:00
Pavel Yaskevich
0457a72fdf Merge pull request #60222 from xedin/rdar-97396399
[ConstraintSystem] Retrieve contextual type from a solution for ambiguities
2022-07-28 09:28:09 -07:00
Hamish Knight
5418e8d934 [AST] Remove ArgumentList::composeTupleOrParenType
Remove a redundant bit of diagnostic logic now
that we better diagnose cases where an uncallable
variable is in an overload set for a mismatched
apply. Tweak another bit of diagnostic logic to
only apply to a single arg/param case, as that
seems to be what it's meant for.
2022-07-26 12:51:54 +01:00
Pavel Yaskevich
399d3490d4 [ConstraintSystem] Add a tailored ambiguity diagnostic for non-conforming result type 2022-07-25 10:45:45 -07:00
Michael Gottesman
afd8accb75 [move-only] Add a move only request to lookup if a ValueDecl is a "move only type".
I also created a SILType::isMoveOnly() helper that returns true if a type is
a move only wrapped type or a first class move only type. The verifier check
that move only types aren't copied in canonical SIL was rewired to use that as well.
2022-07-21 15:33:17 -07:00
Cal Stephens
778a2fc1f5 Merge branch 'main' into cal--implicit-weak-self 2022-07-18 10:00:23 -07:00
Slava Pestov
5c412b4b55 Sema: Don't allow opaque return types to reference DynamicSelfType
This cannot be represented in the ABI because we expect that the
opaque return type can be instantiated from the generic arguments
of its declaring context. Reconstructing type metadata for the
DynamicSelfType would require opaque return type instantiation
to also take the self *value*.

Fixes rdar://72407668 / https://github.com/apple/swift/issues/56367
2022-07-14 11:07:52 -04:00
Alexis Laferrière
33a987faca Merge pull request #60008 from xymus/implicit-import-conformances
[Sema] Report exported uses of conformances that are implicitly imported
2022-07-12 10:01:46 -07:00
Alexis Laferrière
f459eb3564 [Sema] Report exported uses of conformances that are implicitly imported
Diagnose uses of conformances in API when the conformance declaration
isn't imported by the local file. This uses the existing logic checking
for conformance availability combined with the implicit import check.
Report it as a warning until Swift 6 where it will be an error.

rdar://96437311
2022-07-11 14:37:10 -07:00
nate-chandler
aff4e799d9 Merge pull request #59726 from nate-chandler/freestanding/task-to-thread-model
[Freestanding] Disable unstructured tasks.
2022-07-11 07:40:31 -07:00
Robert Widmann
f51b4a30b1 Improve Diagnostics for Over-Constrained Protocol Types
Upgrade the diagnostic from one that mentions the restriction to one
that

1) Mentions primary associated types at all
2) Removes the constraints
3) Points at the declaration of the protocol type so the user can fix it
2022-07-08 09:39:14 -07:00
Evan Wilde
8f6d22ce3c Merge pull request #59919 from etcwilde/ewilde/improve-main-error
Adding actionable note to @main error
2022-07-06 12:51:40 -07:00
Nate Chandler
68eea8adec [TaskToThread] No unstructured tasks.
In this mode, the following are disabled:

- task creation
- global actors
- MainActor
- custom executors
2022-07-06 11:51:16 -07:00
Evan Wilde
aba6b9294e Adding actionable note to @main error
The compiler enters "script" mode if there is a file called
`main.swift`, or if there is only one file. Parsing files as a script
means that anything in the file is interpreted as top-level code, which
is incompatible with a valid @main-annotated struct, so an error is
emitted.

Unfortunately, it is intentional in many cases, and the diagnostic
didn't provide anything actionable to indicate that the explicit main
function is intentional and that the file being passed in is not
actually a top-level context.

The new note indicates that passing `-parse-as-library` to the compiler
invocation will fix it if the explicit main function is intentional.
2022-07-06 09:27:54 -07:00
Holly Borla
dbc8307b64 Merge pull request #59829 from hborla/enable-bound-generic-extensions
[SE-0361] Enable bound generic extensions.
2022-07-05 17:38:59 -07:00
Konrad `ktoso` Malawski
6b8642cdf2 [Distributed] Prevent overloading on async in distributed methods, for wire compat 2022-07-05 18:49:42 +09:00
Konrad `ktoso` Malawski
728c007fb9 [Distributed] Implement witnesses for sync or non-throw dist reqs
[Distributed] generic and inner test; without one edge case

[Distributed] fix distributed_thunk test; unsure about those extra hops, could remove later

[Distributed] Remove type pretending in getSILFunctionType; it is not needed

It seems our constant replacement in the earlier phases is enough, and
we don't need this trick at all.

[Distributed] Use thunk when calling cross-actor on DA protocols
2022-07-04 19:02:11 +09:00
Alexis Laferrière
2bc2021c8a Merge pull request #59799 from xymus/report-export-of-implicitly-imported
[Sema] Report use of implicitly imported decls in inlinable code
2022-07-01 13:27:18 -07:00
Holly Borla
01d46340e1 [SE-0361] Remove the feature flag for bound generic extensions. 2022-06-30 17:24:38 -07:00
Kavon Farvardin
e288db42f0 prevent extensions from having designated inits for actors
When I began removing `convenience` from actor inits, I thought it would
be ok for an actor's extensions to be non-delegating. But that's wrong,
because the actor could be in a resilient module and still have its
properties change between stored and computed, meaning that there isn't
a practical way to allow this, unless if the extension and the actor
are in the same file.

For now, just re-ban this behavior before anybody notices :)
2022-06-30 15:52:15 -07:00
swift-ci
9aa2de4137 Merge pull request #41083 from kavon/inconvenienced-actors
[SE-327] Remove need for `convenience` for delegating initializers of an actor.
2022-06-30 14:56:32 -07:00
Alexis Laferrière
8fc80f96d5 [Sema] Make "not-imported" diagnostic more direct 2022-06-30 12:56:45 -07:00
Konrad `ktoso` Malawski
ef525424f6 Merge pull request #59700 from xedin/distributed-computed-properties-via-accessor-thunk
[Distributed] Implement distributed computed properties via special accessor
2022-06-30 16:04:36 +09:00
Alexis Laferrière
9127f90d8d [Sema] Report uses of implicitly imported decls in inlinable code
Implicitly imported decls may end up in inlinable code and break the
module API. This have been known to lead to deserialization crash and
could in theory break the generated swiftinterfaces files. Let's
explicitly check for such a case, keeping it to a warning until Swift 6
where we can make it an error.

rdar://95816286
2022-06-29 16:09:42 -07:00
Alexis Laferrière
4d9c8ee5eb [Sema] Generalize the downgraded warning for exportability check
This warning will be used more generally so let's make bring back the
diagnostic in line with the error version.
2022-06-29 16:09:42 -07:00
Konrad `ktoso` Malawski
febfef97d4 [Distributed] Skeleton implementation of distributed computed properties 2022-06-29 14:49:04 -07:00
Hamish Knight
c56ea461b6 [Sema] Add fix-it to import RegexBuilder
For code such as the following:

```
let r = Regex {
  /abc/
}
```

If RegexBuilder has not been imported, emit a
specialized diagnostic and fix-it to add
`import RegexBuilder` to the file.

Unfortunately we're currently prevented from
emitting the specialized diagnostic in cases where
the builder contains references to RegexBuilder
types, such as:

```
let r = Regex {
  Capture {
    /abc/
  }
}
```

This is due to the fact that we bail from CSGen
due to the reference to `Capture` being turned
into an `ErrorExpr`. We ought to be able to
handle solving in the presence of such errors, but
for now I'm leaving it as future work.

rdar://93176036
2022-06-28 11:38:41 +01:00
Kavon Farvardin
41134ea8a0 Remove the need for convenience on actor inits to delegate.
This is possible because actors do not support inheritance. There
is one specific exception to that rule, which is that an actor
can inherit from `NSObject` just to support ObjC interop.

This means an actor is effectively a final class.

resolves rdar://87568153
2022-06-27 16:01:08 -07:00
Konrad `ktoso` Malawski
22b20afce6 [Distributed] make witness be the distributed thunk 2022-06-27 17:08:55 +09:00
Konrad `ktoso` Malawski
6a2778645f Revert "Merge pull request #59481 from xedin/distributed-computed-properties"
This reverts commit 8125a85a8f, reversing
changes made to 728971c5b7.
2022-06-25 08:49:00 +09:00
Konrad `ktoso` Malawski
53168355f0 [Distributed] Explicitly ban a class extending AnyActor as well 2022-06-22 09:21:55 +09:00
Anthony Latsis
d76e74391f Merge pull request #59526 from AnthonyLatsis/closure_result_mismatch_diagQoI
Sema, DiagQoI: Fix and tailor diagnosis of explicit closure result type conflicts
2022-06-21 00:19:52 +03:00
Anthony Latsis
a07f2b4889 Sema, DiagQoI: Fix and tailor diagnosis of explicit closure result type conflicts 2022-06-20 22:20:32 +03:00
Pavel Yaskevich
fa2e64c1fd [Distributed] Sema: Add a new distributed-thunk attribute
The attribute comes handy during solution application to
determine whether the call is using a distributed thunk.
2022-06-17 12:35:54 -07:00
Konrad `ktoso` Malawski
079bbcf517 wip 2022-06-17 12:12:16 -07:00
Pavel Yaskevich
a38fc3dc6c Merge pull request #59415 from xedin/issue-59390
[Diagnostics] Diagnose a mismatch between result builder result and r…
2022-06-17 12:01:32 -07:00
swift-ci
f75590445b Merge pull request #59205 from etcwilde/ewilde/no-async-ibactions
Disallow async IBAction methods
2022-06-16 15:34:59 -07:00