Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
878efac
[Serialization] Force destructor creation for imported class
kateinoigakukun Aug 3, 2020
17c8d27
test: migrate tests to Python3 by default
compnerd Jun 24, 2020
5e3ef64
AST: Fix ASTScopeLookup crash if a PatternBindingEntry's context is n…
slavapestov Aug 25, 2020
b4fb7d0
[IDE] Skip visiting constructor references when the decl is unknown
bnbarham Aug 25, 2020
dd9e1cf
[CS] Don't use TMF_GenerateConstraints in simplifyConstraint
hamishknight Aug 25, 2020
6480bfa
[gardening] Move FuzzyStringMatcher to libIDE
benlangmuir Aug 12, 2020
34de805
[gardening] Move source text printing alongside other completion methods
benlangmuir Aug 25, 2020
cf87ad8
[gardening] Move filter name printing alongside other completion methods
benlangmuir Aug 25, 2020
af78895
[gardening] Sink compiler invocation code into libIDE
benlangmuir Aug 25, 2020
0d42d7d
[gardening] format changed code
benlangmuir Aug 25, 2020
24f1a46
Merge pull request #33624 from slavapestov/ast-scope-crash-with-patte…
slavapestov Aug 25, 2020
8178610
Move adjustClangTriple above its only caller
benlangmuir Aug 25, 2020
696c124
Fix missing dependency
benlangmuir Aug 25, 2020
629f861
Merge remote-tracking branch 'github/master' into HEAD
ainu-bot Aug 25, 2020
6e6de51
[Sema] Improve diagnostics for use of self access kind modifier on ac…
theblixguy Aug 25, 2020
2db2096
Merge remote-tracking branch 'github/master' into HEAD
ainu-bot Aug 25, 2020
ee8ad7b
[AutoDiff] NFC: silence no-asserts unused variable warning. (#33629)
dan-zheng Aug 25, 2020
7353af1
Merge remote-tracking branch 'github/master' into HEAD
ainu-bot Aug 25, 2020
c5b42ac
Move FuzzyStringMatcherTest to IDE unittests
benlangmuir Aug 25, 2020
94b5f76
Revert "[SIL] Add SILFunctionType flag for async."
nate-chandler Aug 25, 2020
5d813f3
Revert "[SIL] Add flag to SILFunctionType::Profile for async."
nate-chandler Aug 25, 2020
78159c8
[Explicit Module Builds] Handle #canImport in the dependency scanner …
artemcm Aug 25, 2020
7815ecf
[CSApply] Handle OptionalForce component when is initial component on…
LucianoPAlmeida Aug 25, 2020
8c56ce8
Merge pull request #33632 from benlangmuir/gardening-libIDE
benlangmuir Aug 25, 2020
86c7857
Merge pull request #33625 from bnbarham/pass-reference-nullptr
bnbarham Aug 25, 2020
8f72547
[test] ABIChecker: add a test for -use-interface-for-module flag
nkcsgexi Aug 25, 2020
d82a767
SIL: Add a SILFunction::Purpose for global init once functions
jckarter Aug 25, 2020
f74a3b4
[SIL] Added async flag to SILExtInfo.
nate-chandler Aug 25, 2020
6d6165a
SILOptimizer: Recognize globalinit once functions using an attribute …
jckarter Aug 26, 2020
48a7bc9
Merge pull request #33631 from hamishknight/what-do-you-mean-youve-se…
hamishknight Aug 26, 2020
79b0a7e
[CSDiagnostics] Emit fix-its to insert requirement stubs for missing …
theblixguy Aug 26, 2020
97609dd
Merge pull request #33623 from LucianoPAlmeida/SR-13442-key-path-unwr…
LucianoPAlmeida Aug 26, 2020
148ba9d
Merge pull request #33636 from nate-chandler/move-flag-to-SILExtInfo
swift-ci Aug 26, 2020
e387b36
Merge pull request #33255 from kateinoigakukun/katei/fix-sib-xref-deinit
MaxDesiatov Aug 26, 2020
a53f363
[IRGen] NFC: Simplify IRGenModule::defineTypeMetadata
davezarzycki Aug 25, 2020
9962f79
[RemoteMirror] Fix potential uninitialized data access in convertChild.
mikeash Aug 26, 2020
bf5fb4d
[CodeCompletion] Don't update VFS content hash map after each completion
rintaro Aug 26, 2020
58604ff
[Runtime] Fix memory ordering on a store in ConcurrentReadableArray.
mikeash Aug 26, 2020
66e2ce6
Remove apparently unnecessary filter for CMO serializing references t…
jckarter Aug 26, 2020
59fe82a
Merge pull request #33638 from nkcsgexi/test-use-interface-for-module
nkcsgexi Aug 26, 2020
b37de4b
Merge pull request #32685 from compnerd/testing-the-future
shahmishal Aug 26, 2020
29c7216
DependenciesScanner: include search path options in PCM building comm…
nkcsgexi Aug 26, 2020
82e870b
build: remove the Python 2 check
compnerd Aug 26, 2020
c059fc2
Merge pull request #33642 from mikeash/fix-remotemirror-uninitialized…
mikeash Aug 26, 2020
0ade99f
Merge pull request #33646 from mikeash/fix-concurrentarray-memory-order
swift-ci Aug 26, 2020
9ee8cd2
Merge pull request #33645 from rintaro/ide-completion-rdar67773257
rintaro Aug 26, 2020
362a25a
[AST] Support SILFunctionType/SILBlockStorageType in ClangTypeConverter.
varungandhi-apple Jan 16, 2020
78ea3de
[AST] Introduce a new type to represent a type hole in constraint system
xedin Aug 26, 2020
48c9767
[CSApply] Make sure that hole type are not propagated to AST
xedin Aug 27, 2020
d039107
[ConstraintSystem] Replace use of `UnresolvedType` with specialized `…
xedin Aug 27, 2020
b4d3237
[CSDiagnostics] Adjust diagnostics to account that type holes in solu…
xedin Aug 27, 2020
d287963
[sil-mode] Change viewcfg integration to specify dot as a renderer.
gottesmm Aug 27, 2020
5b5e30b
Implement implicit member chains
Jumhyn Jul 31, 2020
1069fe2
Fixup diagnostics
Jumhyn Jul 31, 2020
3b5deab
More diagnostic improvements
Jumhyn Jul 31, 2020
788d3f0
Fix missing call diagnostic
Jumhyn Jul 31, 2020
aedde34
[Sema] Move unresolved base tracking into CSGen
Jumhyn Jul 31, 2020
4e9b7b2
[Sema] Inject implicit ParenExpr for unresolved member chains
Jumhyn Jul 31, 2020
f584566
[AST] Introduce UnresolvedMemberChainResultExpr
Jumhyn Jul 31, 2020
d78b59c
[Sema] Prefer LValueType during solution scoring
Jumhyn Aug 1, 2020
e0e3bab
[Sema] Change anchor of unresolved chain result type
Jumhyn Aug 3, 2020
4331e26
[Sema] Move UnresolvedMemberChainResultExpr creation to walkToExprPre
Jumhyn Aug 3, 2020
aade4aa
[Localization] Add new diagnostics to localization file
Jumhyn Aug 3, 2020
5394e6b
[Sema] Use getMetatypeInstanceType instead of casting to MetatypeType
Jumhyn Aug 3, 2020
c33ad11
[Sema] Apply clang-format
Jumhyn Aug 3, 2020
1e27f26
[Sema] Always cache the unresolved chain base
Jumhyn Aug 3, 2020
ed94131
[Sema] Bail out early of solution application for UME
Jumhyn Aug 4, 2020
26f0a80
[Sema] Transfer contextual type info when we inject UnresolvedMemberC…
Jumhyn Aug 4, 2020
74d0040
[Sema] Remove unnecessary impact adjustment
Jumhyn Aug 4, 2020
1892356
[Sema] Move member chain transformation into precheck
Jumhyn Aug 4, 2020
7b05352
[Sema] Improve invalid lvalue diagnostics for UnresolvedMemberExpr
Jumhyn Aug 5, 2020
0055501
[Sema] Add FIXME for Optional binding inference bug
Jumhyn Aug 6, 2020
5de23f5
[Sema] Rebase and address feedback for implicit member chains
Jumhyn Aug 12, 2020
968112e
[Sema] Support code completion for heterogeneous unresolved member ch…
Jumhyn Aug 17, 2020
db33dfa
[IDE] Offer unresolved member completions with non-matching types
Jumhyn Aug 21, 2020
352adc3
Remove Argument from UnresolvedMemberExpr
Jumhyn Aug 24, 2020
30e52be
[AST] Properly initialize FunctionRefKind for UnresolvedMemberExpr
Jumhyn Aug 27, 2020
d8878d2
[Tests] Add IUO tests for implicit member chains
Jumhyn Aug 27, 2020
b6c2f89
[AST] NFC: Fix a typo in the `HasTypeHole` description
xedin Aug 26, 2020
9de7b59
Subsume SWIFT_STDLIB_USE_NONATOMIC_RC into SWIFT_STDLIB_SINGLE_THREAD…
kubamracek Aug 27, 2020
8f2e53c
[AST] Make sure that hole types are always allocated in `ConstraintSo…
xedin Aug 27, 2020
b07ecb9
Merge pull request #33626 from davezarzycki/pr33626
davezarzycki Aug 27, 2020
8905f97
[Tests] Update completions for unresolved enum members
Jumhyn Aug 27, 2020
4cd1b71
[Runtime] Shrink ConcurrentReadableHashMap a bit.
mikeash Aug 26, 2020
1fec2b5
Respect SWIFT_STDLIB_SINGLE_THREADED_RUNTIME and use nonatomic refcou…
kubamracek Aug 27, 2020
102d638
[build] Don't execute dsymutil in parallel (#33654)
edymtt Aug 27, 2020
1a44db3
ABIChecker: exclude decls with the @_alwaysEmitIntoClient attribute
nkcsgexi Aug 27, 2020
524cfae
[Dynamic Casting] Overhauled Runtime (#33561)
tbkka Aug 27, 2020
33fe1ff
Merge pull request #33652 from nkcsgexi/67589328
nkcsgexi Aug 27, 2020
9993875
Merge pull request #33630 from artemcm/ScannerCanImport
artemcm Aug 27, 2020
9665091
[CSBindings] Don't attempt to join types that contain holes
xedin Aug 27, 2020
83b50cd
[AutoDiff] Add missing `withoutDerivative(at:)` fix-its. (#33660)
dan-zheng Aug 27, 2020
103b61c
ABIChecker: rename argument -protocol-requirement-white-list to -prot…
nkcsgexi Aug 27, 2020
80560da
CSGen: Infer generic arguments in explicit closure result types
AnthonyLatsis Aug 27, 2020
61d86d5
[NFC] CSGen: Clean up some flow in inferClosureType
AnthonyLatsis Aug 27, 2020
84c5065
[SR-13461] Relax An Assert
CodaFi Aug 27, 2020
ce2377d
Merge pull request #33651 from compnerd/complete
compnerd Aug 27, 2020
c890cdd
[AST] Add functionality for computing Clang types for SIL functions.
varungandhi-apple Jul 28, 2020
1807412
[Serialization] Allow different Clang types in deserialization.
varungandhi-apple Aug 18, 2020
eaac23f
[NFC] Remove ASTExtInfo::assertIsFunctionType in favor of checkInvari…
varungandhi-apple Aug 18, 2020
8da4d53
[NFC] Use ClangTypeInfo's implicit null state instead of an extra Opt…
varungandhi-apple Aug 18, 2020
eead4ae
[NFC] Remove unused function parameter.
varungandhi-apple Aug 18, 2020
eeec16f
[NFC] Remove redundant ExtInfo parameter for getBridgedFunctionType.
varungandhi-apple Aug 20, 2020
fdbcd12
[NFC] Bridge based on SILFunctionLanguage instead of Representation.
varungandhi-apple Aug 21, 2020
f86aad9
[NFC] Extract computation of SILExtInfoBuilder bits into new method.
varungandhi-apple Aug 21, 2020
c4ad840
[NFC] Reuse SILExtInfoBuilder's main constructor in default constructor.
varungandhi-apple Aug 21, 2020
863bca8
[Dependency Scanner] Prefix Clang dependency scanner search path argu…
artemcm Aug 27, 2020
4847ec9
[AST/TypeChecker] Add more asserts to make sure types don't get into AST
xedin Aug 27, 2020
41ea927
Merge pull request #33666 from nkcsgexi/67883661
nkcsgexi Aug 27, 2020
0bef4a6
Give global once symbols stabler manglings.
jckarter Aug 27, 2020
4b921c3
[Sema] Improve diagnostics for key path root type inferred as option …
LucianoPAlmeida Aug 23, 2020
4c7ccf5
[NFC] Clean Up FrontendTool
CodaFi Aug 25, 2020
fe7444f
Add doesActionRequireSwiftStandardLibrary
CodaFi Aug 27, 2020
4c56c95
Define doesActionRequireInputs
CodaFi Aug 27, 2020
e013ebd
[CodeCompletion] Ensure all ExtensionDecl's extended nominal are comp…
rintaro Aug 27, 2020
5faedbd
Merge pull request #33667 from nkcsgexi/allow-list-rename
nkcsgexi Aug 27, 2020
16876fb
[Clang importer] Drop unused parameter from getParamOptionality().
DougGregor Aug 24, 2020
12dd83d
Merge pull request #33670 from artemcm/ClangScannerPathPrefixes
artemcm Aug 28, 2020
6e8ee7c
[docs] Fix small mistake in DynamicCasting.md (#33641)
ole Aug 28, 2020
5afbddb
[Dependency Scanner] Ensure that Clang dependency scanner instances i…
artemcm Aug 28, 2020
82fc202
Merge pull request #33603 from LucianoPAlmeida/SR-13079-improve-kp-op…
LucianoPAlmeida Aug 28, 2020
b1db77a
Fix ConnectionGraph verification for calls to no return functions. (#…
meg-gupta Aug 28, 2020
f3cebd2
Merge pull request #33669 from rintaro/ide-completion-rdar67102794
rintaro Aug 28, 2020
1e5d30f
[Concurrency] Import Objective-C methods with completion handlers as …
DougGregor Aug 26, 2020
1132cda
[ownership] Move SemanticARCOpts into a separate folder in preparatio…
gottesmm Aug 28, 2020
109b7b8
Disable LLDB tests in nightly package preset (67923799)
shahmishal Aug 28, 2020
f588f2f
Merge pull request #33650 from jckarter/global_init_mangling
jckarter Aug 28, 2020
c98d895
Expanded discussion of protocol types (#33621)
tbkka Aug 28, 2020
7b50374
Merge pull request #33679 from apple/disable-lldb-test-package-bot
shahmishal Aug 28, 2020
02513b1
Merge pull request #33671 from artemcm/BatchScannerTargetExtract
artemcm Aug 28, 2020
a6c3e6f
Merge pull request #33658 from xedin/introduce-hole-type
xedin Aug 28, 2020
c48a676
Merge pull request #31679 from Jumhyn/implicit-member-chains-differen…
rintaro Aug 28, 2020
fd6922f
Add error reporting when looking up types by demangled name.
mikeash Aug 19, 2020
0990fa9
Merge pull request #33647 from mikeash/shrink-concurrentreadablehashmap
mikeash Aug 28, 2020
539b241
Fallback to building Cmake from source on all platforms, not just Lin…
tbkka Aug 28, 2020
6ad2757
[Concurrency] Use completion/completionHandler parameter names for as…
DougGregor Aug 28, 2020
7c8041a
Merge pull request #33672 from CodaFi/ceci-nest-pas-une-pipeline
CodaFi Aug 28, 2020
592d427
Merge pull request #33668 from CodaFi/field-day
CodaFi Aug 28, 2020
8df8315
Merge pull request #33541 from varungandhi-apple/vg-clang-types-in-si…
varungandhi-apple Aug 28, 2020
50ea66d
Merge pull request #33585 from mikeash/type-lookup-error-reporting
mikeash Aug 28, 2020
c4f0505
[Parse] Don't drop throws containing a code completion expression.
Aug 14, 2020
00994f1
[Parse] Stop early exiting when parsing catch statements and ObjCSele…
Aug 27, 2020
3e0500d
[Parse][IDE] Don't drop default argument init exprs containing code c…
Aug 24, 2020
8980356
[Parse] Perform the single expression function body transform for del…
Aug 26, 2020
c03d762
[ConstraintSystem] NFC: Clarify why upward propagation of literal con…
xedin Aug 29, 2020
ebc03a1
[CSBindings] NFC: Remove dead condition leftover from Swift version 3…
xedin Aug 29, 2020
5525a78
Merge pull request #33663 from AnthonyLatsis/unbound-closure-retty
AnthonyLatsis Aug 29, 2020
172c4be
[Sema] Diagnose use of ambiguous property wrappers (#33688)
theblixguy Aug 29, 2020
8c1be69
Merge pull request #33677 from gottesmm/pr-0c62e0beda3a13e79c75b24764…
gottesmm Aug 29, 2020
11eac12
Merge pull request #33659 from gottesmm/pr-84ac4140f366657db17f220c96…
swift-ci Aug 29, 2020
10fa19b
Merge pull request #33674 from DougGregor/concurrency-objc-import-async
DougGregor Aug 29, 2020
7a6f84d
When building standalone stdlib, explicitly use C/C++ compilers from …
kubamracek Aug 29, 2020
73f4273
Mark Reflection_jit.swift as UNSUPPORTED for standalone stdlib builds…
kubamracek Aug 29, 2020
dbd16d2
swift_build_sdk_interfaces.py: adjust output directory path to an SDK…
nkcsgexi Aug 29, 2020
3e8278a
Merge pull request #33676 from nathawes/parser-completion-fixes
Aug 29, 2020
8573c99
Merge pull request #33690 from xedin/csbindings-protocol-propagation
xedin Aug 29, 2020
db0a6f7
Merge pull request #33691 from nkcsgexi/fix-67951012
nkcsgexi Aug 29, 2020
c34212a
Turn on Verbose Output For Test
CodaFi Aug 29, 2020
a412e48
Revert "Add A Reproducer For rdar://48443680"
CodaFi Aug 29, 2020
a0cdeb5
Merge pull request #33693 from CodaFi/testify
CodaFi Aug 29, 2020
49d43e8
Merge remote-tracking branch 'github/master' into HEAD
dan-zheng Aug 30, 2020
fa74676
[TF] Update AutoDiff test.
dan-zheng Aug 30, 2020
9216b35
update-checkout-config.json: adjust for tensorflow merge
shabalind Sep 2, 2020
1fa9a63
Merge branch 'tensorflow' into tensorflow-merge
shabalind Sep 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
endif()
endif()

find_package(Python2 COMPONENTS Interpreter REQUIRED)
find_package(Python3 COMPONENTS Interpreter REQUIRED)

#
Expand Down
5 changes: 5 additions & 0 deletions docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ Globals
global ::= global 'MJ' // noncanonical specialized generic type metadata instantiation cache associated with global
global ::= global 'MN' // noncanonical specialized generic type metadata for global

#if SWIFT_RUNTIME_VERSION >= 5.4
global ::= context (decl-name '_')+ 'WZ' // global variable one-time initialization function
global ::= context (decl-name '_')+ 'Wz' // global variable one-time initialization token
#endif

A direct symbol resolves directly to the address of an object. An
indirect symbol resolves to the address of a pointer to the object.
They are distinct manglings to make a certain class of bugs
Expand Down
19 changes: 12 additions & 7 deletions docs/DynamicCasting.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Implementation Note: `AnyObject` is represented in memory as a pointer to a refc
### Objective-C Interactions

Note the invariant above cannot be an equality because Objective-C bridging allows libraries to introduce new relationships that can alter the behavior of seemingly-unrelated casts.
One example of this is Foundation's `Number` (or `NSNumber`) type which conditionally bridges to several Swift numeric types.
One example of this is Foundation's `NSNumber` type which conditionally bridges to several Swift numeric types.
As a result, when Foundation is in scope, `Int(7) is Double == false` but `(Int(7) as! AnyObject) is Double == true`.
In general, the ability to add new bridging behaviors from a single type to several distinct types implies that Swift casting cannot be transitive.

Expand Down Expand Up @@ -407,9 +407,10 @@ S.self.svar // 2
```

Invariants
* If `T` conforms to `P` and `t` is an instance of `T`, then `t is P`, and `T.self is P.Type`
* If `T` conforms to `P` and `t` is an instance of `T`, then `t is P` and `T.self is P.Type`
* If `P` is a sub-protocol of `P1` and `T` is any type, then `T.self is P.Type` implies that `T.self is P1.Type`
* Since every type `T` conforms to `Any`, `T.self is Any.Type` is always true
* `Any` self-conforms: `Any.self is Any.Type == true`
* Since every class type `C` conforms to `AnyObject`, `C.self is AnyObject.Type` is always true (this includes Objective-C class types)

### Note: "Self conforming" protocols

Expand Down Expand Up @@ -439,10 +440,14 @@ let b : MyGenericType(a)
As above, since `a` has type `P`, this code is instantiating `MyGenericType` with `T = P`, which is only valid if `P` conforms to `P`.

Note that any protocol that specifies static methods, static properties, associated types, or initializers cannot possibly be self-conforming.
As of Swift 5.3, there are only three kinds of self-conforming protocols:
* `Any` must be self-conforming since every `T.self` is an instance of `Any.Type`
* `Error` is a self-conforming protocol
* Objective-C protocols that have no static requirements are self-conforming
As of Swift 5.3, the only self-conforming protocols are `Any`, `Error`, and Objective-C protocols that have no static requirements.

Invariants
* `Any` self-conforms: `Any.self is Any.Type == true`
* `Error` self-conforms: `Error.self is Error.Type == true`
* If `P` self-conforms and is a sub-protocol of `P1`, then `P.self is P1.Type == true`

For example, the last invariant here implies that for any Objective-C protocol `OP` that has no static requirements, `OP.self is AnyObject.Type`. This follows from the fact that `OP` self-conforms and that every Objective-C protocol has `AnyObject` as an implicit parent protocol.

## CoreFoundation types

Expand Down
13 changes: 13 additions & 0 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace swift {
class BoundGenericType;
class ClangModuleLoader;
class ClangNode;
class ClangTypeConverter;
class ConcreteDeclRef;
class ConstructorDecl;
class Decl;
Expand Down Expand Up @@ -618,6 +619,10 @@ class ASTContext final {
Type getBridgedToObjC(const DeclContext *dc, Type type,
Type *bridgedValueType = nullptr) const;

private:
ClangTypeConverter &getClangTypeConverter();

public:
/// Get the Clang type corresponding to a Swift function type.
///
/// \param params The function parameters.
Expand All @@ -627,6 +632,14 @@ class ASTContext final {
getClangFunctionType(ArrayRef<AnyFunctionType::Param> params, Type resultTy,
FunctionTypeRepresentation trueRep);

/// Get the canonical Clang type corresponding to a SIL function type.
///
/// SIL analog of \c ASTContext::getClangFunctionType .
const clang::Type *
getCanonicalClangFunctionType(
ArrayRef<SILParameterInfo> params, Optional<SILResultInfo> result,
SILFunctionType::Representation trueRep);

/// Get the Swift declaration that a Clang declaration was exported from,
/// if applicable.
const Decl *getSwiftDeclForExportedClangDecl(const clang::Decl *decl);
Expand Down
3 changes: 2 additions & 1 deletion include/swift/AST/ASTMangler.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class ASTMangler : public Mangler {

std::string mangleGlobalVariableFull(const VarDecl *decl);

std::string mangleGlobalInit(const VarDecl *decl, int counter,
std::string mangleGlobalInit(const PatternBindingDecl *decl,
unsigned entry,
bool isInitFunc);

std::string mangleReabstractionThunkHelper(CanSILFunctionType ThunkType,
Expand Down
14 changes: 12 additions & 2 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace swift {
class Type;
class Expr;
class DeclRefExpr;
class ForeignAsyncConvention;
class ForeignErrorConvention;
class LiteralExpr;
class BraceStmt;
Expand Down Expand Up @@ -6171,7 +6172,15 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// being dropped altogether. `None` is returned for a normal function
/// or method.
Optional<int> getForeignFunctionAsMethodSelfParameterIndex() const;


/// Set information about the foreign async convention used by this
/// declaration.
void setForeignAsyncConvention(const ForeignAsyncConvention &convention);

/// Get information about the foreign async convention used by this
/// declaration, given that it is @objc and 'async'.
Optional<ForeignAsyncConvention> getForeignAsyncConvention() const;

static bool classof(const Decl *D) {
return D->getKind() >= DeclKind::First_AbstractFunctionDecl &&
D->getKind() <= DeclKind::Last_AbstractFunctionDecl;
Expand Down Expand Up @@ -6300,7 +6309,8 @@ class FuncDecl : public AbstractFunctionDecl {
DeclContext *Parent);

static FuncDecl *createImported(ASTContext &Context, SourceLoc FuncLoc,
DeclName Name, SourceLoc NameLoc, bool Throws,
DeclName Name, SourceLoc NameLoc,
bool Async, bool Throws,
ParameterList *BodyParams, Type FnRetType,
DeclContext *Parent, ClangNode ClangN);

Expand Down
14 changes: 14 additions & 0 deletions include/swift/AST/DiagnosticsCommon.def
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,19 @@ ERROR(scanner_find_cycle, none,
ERROR(scanner_arguments_invalid, none,
"dependencies scanner cannot be configured with arguments: '%0'", (StringRef))

//------------------------------------------------------------------------------
// MARK: custom attribute diagnostics
//------------------------------------------------------------------------------

ERROR(ambiguous_custom_attribute_ref,none,
"ambiguous use of attribute %0", (Identifier))
NOTE(ambiguous_custom_attribute_ref_fix,none,
"use '%0.' to reference the attribute %1 in module %2",
(StringRef, Identifier, Identifier))
NOTE(found_attribute_candidate,none,
"found this attribute", ())
ERROR(unknown_attribute,none,
"unknown attribute '%0'", (StringRef))

#define UNDEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,6 @@ ERROR(replace_equal_with_colon_for_value,none,
"'=' has been replaced with ':' in attribute arguments", ())
ERROR(expected_attribute_name,none,
"expected an attribute name", ())
ERROR(unknown_attribute,none,
"unknown attribute '%0'", (StringRef))
ERROR(unexpected_lparen_in_attribute,none,
"unexpected '(' in attribute '%0'", (StringRef))
ERROR(duplicate_attribute,none,
Expand Down
21 changes: 19 additions & 2 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ ERROR(expected_argument_in_contextual_member,none,
"member %0 expects argument of type %1", (DeclName, Type))
ERROR(expected_parens_in_contextual_member,none,
"member %0 is a function; did you mean to call it?", (DeclName))
ERROR(expected_parens_in_contextual_member_type,none,
"member %0 is a function that produces expected type %1; did you mean to "
"call it?", (DeclName, Type))

ERROR(expected_result_in_contextual_member,none,
"member %0 in %2 produces result of type %1, but context expects %2",
Expand Down Expand Up @@ -453,6 +456,10 @@ ERROR(cannot_convert_closure_result_nil,none,
ERROR(cannot_convert_parent_type,none,
"cannot convert parent type %0 to expected type %1",
(Type, Type))
ERROR(cannot_convert_chain_result_type,none,
"member chain produces result of type %0 but contextual base was "
"inferred as %1",
(Type, Type))

NOTE(generic_argument_mismatch,none,
"arguments to generic parameter %0 (%1 and %2) are expected to be equal",
Expand Down Expand Up @@ -1082,13 +1089,22 @@ NOTE(unwrap_with_guard,none,
ERROR(optional_base_not_unwrapped,none,
"value of optional type %0 must be unwrapped to refer to member %1 of "
"wrapped base type %2", (Type, DeclNameRef, Type))
ERROR(invalid_optional_infered_keypath_root, none,
"key path root inferred as optional type %0 must be unwrapped to refer to member %1 "
"of unwrapped type %2", (Type, DeclNameRef, Type))
NOTE(optional_base_chain,none,
"chain the optional using '?' to access member %0 only for non-'nil' "
"base values", (DeclNameRef))
NOTE(optional_base_remove_optional_for_keypath_root, none,
"use unwrapped type %0 as key path root", (Type))
NOTE(optional_keypath_application_base, none,
"use '?' to access key path subscript only for non-'nil' base values", ())
NOTE(optional_key_path_root_base_chain, none,
"chain the optional using '?.' to access unwrapped type member %0",
(DeclNameRef))
NOTE(optional_key_path_root_base_unwrap, none,
"unwrap the optional using '!.' to access unwrapped type member %0",
(DeclNameRef))

ERROR(missing_unwrap_optional_try,none,
"value of optional type %0 not unwrapped; did you mean to use 'try!' "
Expand Down Expand Up @@ -1295,8 +1311,9 @@ ERROR(nominal_type_not_attribute,none,

ERROR(mutating_invalid_global_scope,none, "%0 is only valid on methods",
(SelfAccessKind))
ERROR(mutating_invalid_classes,none, "%0 isn't valid on methods in "
"classes or class-bound protocols", (SelfAccessKind))
ERROR(mutating_invalid_classes,none, "%0 is not valid on %1s in "
"%select{classes|class-bound protocols}2",
(SelfAccessKind, DescriptiveDeclKind, bool))

ERROR(functions_mutating_and_not,none,
"method must not be declared both %0 and %1",
Expand Down
118 changes: 56 additions & 62 deletions include/swift/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,8 @@ class alignas(8) Expr {
NumArgLabels : 16
);

SWIFT_INLINE_BITFIELD_FULL(UnresolvedMemberExpr, Expr, 1+1+1+16,
/// Whether the UnresolvedMemberExpr has arguments.
HasArguments : 1,
/// Whether the UnresolvedMemberExpr also has source locations for the
/// argument label.
HasArgLabelLocs : 1,
/// Whether the last argument is a trailing closure.
HasTrailingClosure : 1,
: NumPadBits,
/// # of argument labels stored after the UnresolvedMemberExpr.
NumArgLabels : 16
SWIFT_INLINE_BITFIELD_FULL(UnresolvedMemberExpr, Expr, 2,
FunctionRefKind : 2
);

SWIFT_INLINE_BITFIELD(OverloadSetRefExpr, Expr, 2,
Expand Down Expand Up @@ -1841,71 +1832,49 @@ class DynamicSubscriptExpr final
/// member, which is to be resolved with context sensitive type information into
/// bar.foo. These always have unresolved type.
class UnresolvedMemberExpr final
: public Expr,
public TrailingCallArguments<UnresolvedMemberExpr> {
: public Expr {
SourceLoc DotLoc;
DeclNameLoc NameLoc;
DeclNameRef Name;
Expr *Argument;

UnresolvedMemberExpr(SourceLoc dotLoc, DeclNameLoc nameLoc,
DeclNameRef name, Expr *argument,
ArrayRef<Identifier> argLabels,
ArrayRef<SourceLoc> argLabelLocs,
bool hasTrailingClosure,
bool implicit);

public:
/// Create a new unresolved member expression with no arguments.
static UnresolvedMemberExpr *create(ASTContext &ctx, SourceLoc dotLoc,
DeclNameLoc nameLoc, DeclNameRef name,
bool implicit);

/// Create a new unresolved member expression.
static UnresolvedMemberExpr *create(ASTContext &ctx, SourceLoc dotLoc,
DeclNameLoc nameLoc, DeclNameRef name,
SourceLoc lParenLoc,
ArrayRef<Expr *> args,
ArrayRef<Identifier> argLabels,
ArrayRef<SourceLoc> argLabelLocs,
SourceLoc rParenLoc,
ArrayRef<TrailingClosure> trailingClosures,
bool implicit);
UnresolvedMemberExpr(SourceLoc dotLoc, DeclNameLoc nameLoc, DeclNameRef name,
bool implicit)
: Expr(ExprKind::UnresolvedMember, implicit), DotLoc(dotLoc),
NameLoc(nameLoc), Name(name) {
// FIXME: Really, we should be setting this to `FunctionRefKind::Compound`
// if `NameLoc` is compound, but this would be a source break for cases like
// ```
// struct S {
// static func makeS(_: Int) -> S! { S() }
// }
//
// let s: S = .makeS(_:)(0)
// ```
// Instead, we should store compound-ness as a separate bit from applied/
// unapplied.
Bits.UnresolvedMemberExpr.FunctionRefKind =
static_cast<unsigned>(FunctionRefKind::Unapplied);
}

DeclNameRef getName() const { return Name; }
DeclNameLoc getNameLoc() const { return NameLoc; }
SourceLoc getDotLoc() const { return DotLoc; }
Expr *getArgument() const { return Argument; }
void setArgument(Expr *argument) { Argument = argument; }

/// Whether this reference has arguments.
bool hasArguments() const {
return Bits.UnresolvedMemberExpr.HasArguments;
}

unsigned getNumArguments() const {
return Bits.UnresolvedMemberExpr.NumArgLabels;
}

bool hasArgumentLabelLocs() const {
return Bits.UnresolvedMemberExpr.HasArgLabelLocs;
}
SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }

/// Whether this call with written with a trailing closure.
bool hasTrailingClosure() const {
return Bits.UnresolvedMemberExpr.HasTrailingClosure;
}
SourceLoc getStartLoc() const { return DotLoc; }
SourceLoc getEndLoc() const { return NameLoc.getSourceRange().End; }

/// Return the index of the unlabeled trailing closure argument.
Optional<unsigned> getUnlabeledTrailingClosureIndex() const {
return getArgument()->getUnlabeledTrailingClosureIndexOfPackedArgument();
/// Retrieve the kind of function reference.
FunctionRefKind getFunctionRefKind() const {
return static_cast<FunctionRefKind>(
Bits.UnresolvedMemberExpr.FunctionRefKind);
}

SourceLoc getLoc() const { return NameLoc.getBaseNameLoc(); }

SourceLoc getStartLoc() const { return DotLoc; }
SourceLoc getEndLoc() const {
return (Argument ? Argument->getEndLoc() : NameLoc.getSourceRange().End);
/// Set the kind of function reference.
void setFunctionRefKind(FunctionRefKind refKind) {
Bits.UnresolvedMemberExpr.FunctionRefKind = static_cast<unsigned>(refKind);
}

static bool classof(const Expr *E) {
Expand Down Expand Up @@ -2088,6 +2057,31 @@ class ParenExpr : public IdentityExpr {

static bool classof(const Expr *E) { return E->getKind() == ExprKind::Paren; }
};

/// Represents the result of a chain of accesses or calls hanging off of an
/// \c UnresolvedMemberExpr at the root. This is only used during type checking
/// to give the result type of such a chain representation in the AST. This
/// expression type is always implicit.
class UnresolvedMemberChainResultExpr : public IdentityExpr {
/// The base of this chain of member accesses.
UnresolvedMemberExpr *ChainBase;
public:
UnresolvedMemberChainResultExpr(Expr *subExpr, UnresolvedMemberExpr *base,
Type ty = Type())
: IdentityExpr(ExprKind::UnresolvedMemberChainResult, subExpr, ty,
/*isImplicit=*/true),
ChainBase(base) {
assert(base);
}

UnresolvedMemberExpr *getChainBase() const { return ChainBase; }

SWIFT_FORWARD_SOURCE_LOCS_TO(getSubExpr())

static bool classof(const Expr *E) {
return E->getKind() == ExprKind::UnresolvedMemberChainResult;
}
};

/// AwaitExpr - An 'await' surrounding an expression, marking that the
/// expression contains code which is a coroutine that may block.
Expand Down
3 changes: 2 additions & 1 deletion include/swift/AST/ExprNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ ABSTRACT_EXPR(Identity, Expr)
EXPR(Paren, IdentityExpr)
EXPR(DotSelf, IdentityExpr)
EXPR(Await, IdentityExpr)
EXPR_RANGE(Identity, Paren, Await)
EXPR(UnresolvedMemberChainResult, IdentityExpr)
EXPR_RANGE(Identity, Paren, UnresolvedMemberChainResult)
ABSTRACT_EXPR(AnyTry, Expr)
EXPR(Try, AnyTryExpr)
EXPR(ForceTry, AnyTryExpr)
Expand Down
Loading