Commit Graph

1018 Commits

Author SHA1 Message Date
Angela Laar
dffafdb96b [test] fix tests 2022-09-21 12:02:48 -07:00
Angela Laar
4f3dff43f2 [Sema] Create Opaque Decls from Composition Types 2022-09-20 15:25:09 -07:00
Angela Laar
a7171c00f0 [AST] Add new ASTWalker actions to opaque type repr walker 2022-09-20 15:25:09 -07:00
Angela Laar
410fa12248 [AST] Create opaque type from tuple type repr 2022-09-20 15:25:09 -07:00
Angela Laar
4240b005b2 [Sema] Support GenericIdentTypeReprs as opaque parameters and return type 2022-09-20 15:25:09 -07:00
Angela Laar
ae2c6a18d8 [Sema] Resolve ident type to opaque result type
This is just more work to get type resolution to understand
how to derive an opaque type from an IdentTypeRepr during
OpaqueResultTypeRequest
2022-09-20 15:25:09 -07:00
Angela Laar
b12ecdb7ce [AST] Ignore existential types when building opaque parameter list 2022-09-20 15:25:09 -07:00
Angela Laar
22bbb012f4 [AST] Preserve type constraint for identifier type
Type contraints need to be passed when creating
generic parameters from identifier types.
2022-09-20 15:25:09 -07:00
Angela Laar
3b3e5a2c94 Avoid walking the nested type reprs for types reprs marked with 'some' keyword 2022-09-20 15:25:09 -07:00
Angela Laar
9458072467 [AST] Verify identifier type representations are protocols
Now that GenericParamListRequest and OpaqueResultTypeRequest know
to check for IdentTypeReprs when scanning for opaque parameters,
the requests need to know it should only create Generic Paramters
and Opaque Type Decls for IdentTypeReprs that are protocols.
We should add a function to the swift namespace to check.
2022-09-20 15:25:09 -07:00
Angela Laar
5f3191c74e [AST] Teach GenericParamList amd OpaqueReturnType Request to use plain protocols
Originally protocols prefixed with 'some' keyword are considered an opaue return
type representation. In order to understand plain protocols, the GenericParamList
Request must understand how to build a generic parameter list using alternative
type representations: identifier and composition.
2022-09-20 15:25:09 -07:00
Cal Stephens
03322bf716 Move implicit self lookup from resolveDeclRefExpr into ASTScope::unqualifiedLookup implementation 2022-09-20 07:06:54 -07:00
Slava Pestov
de0fd63f75 AST: Teach qualified lookup to find members of tuples 2022-09-10 00:26:42 -04:00
Slava Pestov
c1b8690401 AST: Introduce special Builtin.TheTupleType singleton 2022-09-10 00:26:42 -04:00
Doug Gregor
d2f6107946 Merge pull request #60982 from DougGregor/objc-async-alternative-cycle
Break dependency cycle between `@objc` checking and and "renamed" availability
2022-09-07 16:58:32 -07:00
Doug Gregor
97bd500f5b Break dependency cycle between @objc checking and and "renamed" availability.
The filtering used to allow `@objc` protocols to have both an `async` and a
completion-handler version of the same method was dependent on the
resolution of the "renamed" declaration (for `@available(..., renamed: "")`),
which in tern was dependent on whether the declaration is `@objc`... causing
a cycle. Break the cycle by moving the filtering later.

Fixes rdar://99618060.
2022-09-07 12:55:31 -07:00
Slava Pestov
79ed990728 AST: Replace TupleTypeRepr's ellipsis with PackExpansionTypeRepr 2022-09-07 12:35:54 -04:00
Slava Pestov
db4b4c9fa2 AST: Introduce PackExpansionTypeRepr 2022-09-07 12:35:53 -04:00
Robert Widmann
a8b5e14d9d [NFC] Remove An Unused Vector of Protocols 2022-08-26 17:46:58 -07:00
Slava Pestov
d9a3f2e5ce AST: Stop calling getAllConformances() on protocols 2022-08-23 00:03:36 -04:00
Becca Royal-Gordon
68c52937c5 Merge pull request #60394 from beccadax/private-defective
Allow extensions to define private module methods
2022-08-05 13:31:39 -07:00
Becca Royal-Gordon
600ced19e3 Allow extensions to define private module methods
Expands the unofficial “feature” that allows extensions to define @objc methods declared in headers for the same module to also allow this for methods in the private clang module.

Fixes rdar://97810819.
2022-08-04 11:01:17 -07:00
Slava Pestov
2338c43fc9 AST: Fix extension binding for @_specializedExtension hack 2022-08-02 23:12:24 -04:00
Hamish Knight
fe7c1f4b9b Refactor callable lookup
Move off `Type` based requests and onto `Decl`
based requests, utilizing name lookup's
`extractDirectlyReferencedNominalTypes` utility.
This allows us to better cache the results, and
avoids the need to guard against type variable
inputs when deciding whether or not to cache.
2022-07-25 22:03:55 +01:00
Becca Royal-Gordon
e90876639c Further loosen selector conflict checks
Some mixed-language projects import Objective-C headers through their umbrella or bridging header that declare things that are actually implemented in Swift. This isn’t something we really supported or had tests for, but it happens in practice and we can’t break them.

Carve out a second exception to method conflict checking for when all of the conflicting methods are imported ObjC methods in either the same module or a bridging header.

Fixes rdar://96470068.
2022-07-19 15:41:49 -07:00
Becca Royal-Gordon
9b5f89963b [NFC] Serialize ObjC selectors for protocols
The ObjCMethodLookupTable for protocols was not being serialized and rebuilt on load, so NominalTypeDecl::lookupDirect() on selectors was not working correctly for deserialized types. Correct this oversight.
2022-06-16 14:07:49 -07:00
Becca Royal-Gordon
dc4162fddb Allow same-selector async/completion requirements
An @objc protocol can now explicitly declare both the `async` and completion handler signatures of a method as long as the completion handler one is marked with `@available(*, renamed:)`.

This is not yet handled correctly in PrintAsClang.
2022-06-16 14:06:47 -07:00
Becca Royal-Gordon
6de808e824 [NFC] Make ObjCMethodConflicts a set
This allows us to stop using `vec.size() == 1` to prevent duplicate conflicts from being diagnosed, which will become untenable in the next commit.
2022-06-16 14:06:47 -07:00
Pavel Yaskevich
b7860ea055 [TypeChecker] Split for-in sequence into parsed and type-checked versions 2022-05-30 23:17:41 -07:00
Richard Wei
11154e5ff6 [Sema] Allow code to shadow definitions in implicit _StringProcessing module.
Treat _StringProcessing decls as if it were declared in the Swift module, just like how _Concurrency is treated (#34642).
2022-05-02 16:31:52 -07:00
Rintaro Ishizaki
eade9b7bc9 [LookupVisibleDecls] Implement shadowing for unqualified lookups
Tweaked usable check:
  * Local type/func decls are usable even before declaration
  * Outer nominal Instance member are not usable
  * Type context cannot close over values in outer type contexts

Added shadowing rule by the base name:
  * Type members don't shadow each other as long as they are in the
    same type context.
  * Local values shadow everything in outer scope
    * Except that 'func' decl doesn't shadow 'var' decl if they are in the
      same scope.

rdar://86285396
2022-04-28 16:36:54 -07:00
Slava Pestov
f4a5f85797 Merge pull request #42293 from hank121314/main
[Sema] SR-15807: Associated Type Inference fails across module boundaries
2022-04-20 17:35:16 -04:00
Rintaro Ishizaki
4e621408aa [CodeCompletion] Ensure synthesized members are available before lookup
In ExprContextAnalyzer, when looking up members, some implicit
members weren't populated. Ensure all implicit members available by
force synthesizing them.

rdar://89773376
2022-04-15 11:47:36 -07:00
hank121314
1dabc67b5f [Sema] TypeCheckProtocolInference: using trailingWhereClause to get self bounds in source file. 2022-04-12 22:57:47 +08:00
John McCall
5519749ade [NFC] Collect protocol decls, not type, in ExistentialLayout
Another thing that will be necessary for correctness with
compositions of parameterized protocols.
2022-04-11 22:15:16 -04:00
hank121314
ad00118d9a [Sema] TypeCheckProtoclInference: Using generic signature to check conformance instead of trailingWhereClause 2022-04-11 09:26:08 +08: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
Becca Royal-Gordon
974fbc1167 [NFC] Move ObjC method support to NominalTypeDecl
This prepares us to generalize ObjC selector collision diagnostics to also include protocols. NFC in this commit because, even though Sema and ClangImporter now try to record ObjC methods on non-`ClassDecl`s, `NominalTypeDecl::createObjCMethodLookup()` still doesn’t create ObjC method tables for them, so the calls are no-ops.
2022-03-16 14:41:55 -07:00
Allan Shortlidge
1be8913c9b NFC: Fix a number of warnings emitted when building swift-frontend. 2022-03-04 16:15:33 -08:00
Doug Gregor
27056a0ed7 Enable SE-0341 "Opaque Parameter Declarations" by default.
This proposal has been accepted, so enable it by default and update
some diagnostics to stop implying that this feature cannot be used.
2022-02-17 13:57:45 -08:00
Slava Pestov
a1c03db381 AST: Generalize ProtocolDecl::getRequirementSignature() to a new RequirementSignature type
The RequirementSignature generalizes the old ArrayRef<Requirement>
which stores the minimal requirements that a conforming type's
witnesses must satisfy, to also record the protocol typealiases
defined in the protocol.
2022-02-13 00:24:23 -05:00
Nuri Amari
3762ca1fa7 Attach Lazy ClangImporter Diagnostics as Notes
Clang importer diagnostics that are produced as a result of a reference
in Swift code are attached to as notes to the Sema produced diagnostic
that indicates the declaration is unavailable.

Ex: Notes about why a C function import failed are attached to
the error explaining that the symbol could not be found in scope.
2022-01-29 14:32:42 -05:00
Rintaro Ishizaki
94a7e16a1a Merge pull request #41040 from rintaro/ide-completion-rdar86050684
[CodeCompletion] Let FindLocalVal walk into ExprPattern
2022-01-28 09:42:11 -08:00
Konrad `ktoso` Malawski
89b0a4ce89 Merge pull request #41036 from ktoso/wip-distributed-remove-dynamic-sil-remotecall-squashed
[Distributed] Remove @_dynamic replacements; impl remoteCall ad-hoc reqs
2022-01-28 11:13:34 +09:00
Rintaro Ishizaki
db48ace197 [CodeCompletion] Let FindLocalVal walk into ExprPattern
Some conditions in control flow statements are parsed as expression
patterns, then resolved to "pattern"s later in Sema. In code completion,
they might not be type checked at all. Previously, when collecting
visible declarations for completion candidates, it didn't walk into
`ExprPattern`, and thus it didn't find the variables inside. Use
standard `Pattern::forEachVariable()` that looks into `ExprPattern`
instead of using its custom recursive logic.

rdar://86050684
2022-01-27 12:56:23 -08:00
Konrad `ktoso` Malawski
4bf2a92bda [Distributed] Remove @_dynamic replacements; impl remoteCall ad-hoc reqs
Squashed commit of the following:

commit e5a05ffe44
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 17:45:31 2022 +0900

    cleanup

commit 1f751cea5a
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 14:50:33 2022 +0900

    cleanups

commit c632f3215d
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 14:01:09 2022 +0900

    add test for generic from actor decl

commit 09b8bd50a7
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 14:00:58 2022 +0900

    cleanups

commit 31f4d0cffd
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 27 11:40:51 2022 +0900

    fix test

commit ad4db2fb6c
Merge: 97227edcca 07e2dfda56
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 26 23:31:41 2022 +0900

    Merge branch 'main' into wip-zzz

commit 97227edcca
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 26 21:01:25 2022 +0900

    remove @_dynamic methods!

    fix tests

commit 1c79344dbb
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 19 12:51:09 2022 +0900

    cleanup

    wip

    stuck

    fixed the stack cleanups

    cleanups pretty good now

    weird load

    rki

    works

    remove hack

    add take + throw + return

    fix test

    more tests fixed

    more tests fixed

    more tests fixed

commit 3ed494c175
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Jan 18 21:09:28 2022 +0900

    stack issues in SIL verification

commit 5cf43a7f86
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Jan 18 09:19:51 2022 +0900

    about to call the remoteCall

    goot to return, but missing subs

commit df8e47122a
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 13 14:09:49 2022 +0900

    [Distributed] Refactor Invocation to Decoder/Encoder

    getting there

    done-recording

    working on the string init

    stuck trying to get String initializer SILFunction

    created the remote call target

commit fc7bd62f32
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 23:01:14 2022 +0900

    [Distributed] Pass arguments from Invocation to HBuffer

commit cafc2cc058
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 22:08:47 2022 +0900

    works

commit a7d01837ff
Author: Pavel Yaskevich <pyaskevich@apple.com>
Date:   Tue Jan 11 15:48:58 2022 -0800

    [Distributed] Adjust interface of `swift_distributed_execute_target`

    Since this is a special function, `calleeContext` doesn't point to
    a direct parent but instead both parent context (uninitialized)
    and resume function are passed as last arguments which means that
    `callContext` has to act as an intermediate context in call to accessor.

commit c1f830be27
Author: Pavel Yaskevich <pyaskevich@apple.com>
Date:   Tue Jan 11 17:00:08 2022 -0800

    [Distributed] Drop optionality from result buffer in `_executeDistributedTarget`

    `RawPointer?` is lowered into a two arguments since it's a struct,
    to make it easy let's just allocate an empty pointer for `Void` result.

commit c83c2c37b6
Author: Pavel Yaskevich <pyaskevich@apple.com>
Date:   Tue Jan 11 17:02:45 2022 -0800

    [Distributed] NFC: Update _remoteCall test-case to check multiple different result types

commit 29e7cf50e4
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 21:32:37 2022 +0900

    wip

commit 9128ecc6f8
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 20:46:20 2022 +0900

    wip

commit a6b2a62a67
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 20:38:22 2022 +0900

    wip

commit 8b188f0d43
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 16:55:10 2022 +0900

    wip

commit 3796bec2b9
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Jan 12 16:55:02 2022 +0900

    wip

commit 0ffc68b5ef
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Jan 11 21:44:58 2022 +0900

    [Distributed] Implementing ad-hoc protocol requirements

commit 78862575e4
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 6 18:03:54 2022 +0900

    cleanup

commit 5f4ab89e25
Merge: 24a628e7c0 fdda6f2ee4
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 6 15:51:39 2022 +0900

    Merge branch 'main' into wip-impl-execute-swift

commit 24a628e7c0
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Thu Jan 6 15:33:21 2022 +0900

    wip

commit 69e7fed09d
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Dec 22 06:36:45 2021 +0900

    [Distributed] comment out distributed_actor_remoteCall for now

commit 376733a9f6
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Tue Dec 21 16:00:06 2021 +0900

    reimplement distributed get type info impls

commit 74ab47886a
Author: Konrad `ktoso` Malawski <konrad_malawski@apple.com>
Date:   Wed Dec 15 21:37:08 2021 +0900

    [Distributed] Implement func metadata and executeDistributedTarget

    dont expose new entrypoints

    able to get all the way to calling _execute
2022-01-27 17:51:43 +09:00
Doug Gregor
49bc1edbd7 Allow opaque parameters in structural positions 2022-01-26 21:52:38 -08:00
Doug Gregor
4c9bca9c53 Implement basic support for opaque parameters.
Implement function parameters of the form `some P` be synthesizing an
implicit generic parameter whose requirements come from the opaque
type. We then map the opaque type back to the generic parameter, and
print as the opaque type. This allows us to write functions with
implicit generic parameters:

```swift
func f(_: some Collection) { }
```

which is equivalent to:

```swift
func f<T: Collection>(_: some T) { }
```

where `T` is an otherwise-unused generic parameter name.

All of this is behind the experimental frontend flag
`-enable-experimental-opaque-parameters`.
2022-01-26 14:47:12 -08:00
Doug Gregor
0416ec708b Augment GenericTypeParamDecl with bits indicating they came from opaque types 2022-01-26 14:47:11 -08:00
Doug Gregor
e2a49f4d3b Rework the storage of generic parameter lists in generic contexts.
In generic contexts, rework the storage for generic parameter lists
to make it more explicit when we have parsed vs. synthesized vs.
parsed-and-type-checked generic parameter lists.
2022-01-20 17:15:35 -08:00