Commit Graph

1862 Commits

Author SHA1 Message Date
Slava Pestov
a6b5824dac AST: Correctly set parent DeclContext of ParamDecls in EnumElementDecls
When an EnumElementDecl is parsed, we create the parameter list before
creating the EnumElementDecl itself, so we have to re-parent those
ParamDecls just like we do for functions and subscripts.
2019-10-08 18:39:00 -04:00
Varun Gandhi
04ce7bf779 Merge pull request #27557 from varungandhi-apple/vg-fix-selector-names
Use the accessor names as written in Objective-C.
2019-10-08 10:08:13 -07:00
Slava Pestov
64224cadcc Merge pull request #27553 from slavapestov/circular-validation-cleanups-4
Circular validation cleanups, part 4
2019-10-08 10:46:42 -04:00
Slava Pestov
fac36f95b0 Sema: Always use interface types in typeCheckParameterList() 2019-10-08 01:37:09 -04:00
Slava Pestov
a260d0a445 AST: getInterfaceType() returns ErrorType instead of Type() on circularity 2019-10-08 01:37:09 -04:00
Hamish Knight
91a792b393 Merge branch 'master' into id-like-to-request-a-table 2019-10-07 22:05:30 -07:00
Slava Pestov
52cf3659b5 Sema: Simplify validateDecl()
Remove the early return in the case where one of our parent contexts was
being validated, and replace it with a simpler check that is only
performed in some callers related to associated type inference; we want
to bail out in one specific case only, which is that the declaration
is inside an extension whose generic signature is in the process of
being computed.
2019-10-07 22:20:18 -04:00
Slava Pestov
1d809801e1 AST: Add ValueDecl::isRecursiveValidation()
This will be used as a transitional aid in refactoring getInterfaceType()
to always return a valid type, instead of silently returning Type() when
there is circularity.
2019-10-07 22:20:18 -04:00
Slava Pestov
6bfe518344 AST: Compute FuncDecl::isStatic() using a request 2019-10-07 22:20:18 -04:00
Varun Gandhi
0d727d06a7 [NFC] Replace new getAccessor calls with getOpaqueAccessor calls.
It is fine if we synthesize the accessors a bit more than usual as
PrintAsObjC isn't performance-sensitive and IRGen needs the accessors
anyways.
2019-10-07 18:37:52 -07:00
Varun Gandhi
3b9dbd57c4 [AST] Get the ObjC accessor name, not the one parsed from Swift.
Fixes rdar://problem/55519276.
2019-10-06 06:57:50 -07:00
Slava Pestov
e334e5d66f AST: Convert ValueDecl::getOpaqueResultTypeDecl() into a request
Instead of depending on a prior call to setOpaqueResultTypeDecl(),
we can instead just build the decl if we need one.
2019-10-04 22:11:07 -04:00
Hamish Knight
c1a1ddd458 Requestify needsNewVTableEntry
This commit introduces `NeedsNewVTableEntryRequest`,
which checks whether a class method needs a new
vtable entry.
2019-10-03 19:13:39 -07:00
Hamish Knight
013c4f1540 Requestify whether a decl is an ABI compatible override (#27524)
Requestify whether a decl is an ABI compatible override
2019-10-03 19:09:11 -07:00
Slava Pestov
6702d38d87 Sema: Remove most calls to Decl::setValidationToChecked() 2019-10-03 17:11:45 -04:00
Hamish Knight
934d4d1d87 Requestify whether a decl is an ABI compatible override
This commit adds `IsABICompatibleOverrideRequest`,
which checks if the decl is an override, and if
so whether it's ABI compatible with the base
This is then usedto replace the logic for
computing  `isValidKeyPathComponent` in addition
to being used in `requiresNewVTableEntry`.
2019-10-02 21:06:22 -07:00
Robert Widmann
2fe3ce8af8 Requestify the Raw Value Accessor
Make getRawValueExpr() return a checked value.

This entails a strange kind of request that effectively acts like
a cache warmer.  In order to properly check the raw value expression for
a single case, we actually need all the other cases for the
autoincrementing synthesis logic.  The strategy is therefore to have the
request act at the level of the parent EnumDecl and check all the values
at once.  We also cache at the level of the EnumDecl so the cache
"warms" for all enum elements simultaneously.

The request also abuses TypeResolutionStage to act as an indicator for
how much information to compute.  In the minimal case, we will return
a complete accounting of (auto-incremented) raw values.  In the maximal
case we will also check and record types and emit diagnostics.  The
minimal case is uncached to support repeated evaluation.

Note that computing the interface type of an @objc enum decl *must*
force this request.  The enum's raw values are part of the ABI, and we
should not get all the way to IRGen before discovering that we cannot
possibly lay out the enum.  In the future, we might want to consider
moving this check earlier or have IRGen tolerate broken cases but for
now we will maintain the status quo and not have IRGen emit
diagnostics.
2019-10-02 16:09:25 -07:00
Brent Royal-Gordon
6456b39660 Fix StringInterpolationProtocol validation crasher
Some old circularity-breaking code caused an unexpected null type, which led to crashes in the decl checker when trying to check that an `appendInterpolation` method in a different file would satisfy the informal requirement for one in a StringInterpolationProtocol conformer. This code appears to now be unnecessary, so this commit removes it. Fixes rdar://problem/55864759.
2019-10-01 17:43:42 -07:00
Mishal Shah
2f86d67500 Merge pull request #27396 from shahmishal/master-rebranch
Update master to support apple/stable/20190619 branch for LLVM projects
2019-10-01 10:50:49 -07:00
Robert Widmann
75670c1727 Merge pull request #27436 from CodaFi/signed-sealed-delivered
[NFC] Adopt TypeBase-isms for GenericSignature
2019-09-30 15:50:42 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
swift-ci
26a8bf8e75 Merge remote-tracking branch 'origin/master' into master-rebranch 2019-09-30 08:43:50 -07:00
David Ungar
ea81fdc7d8 Merge pull request #27313 from davidungar/generic-request-or-extended-nominal-assertion
Fail early if getExtendedNominal is called before extension has been bound.
2019-09-30 08:37:33 -07:00
David Ungar
4bc4030338 Catch failures earlier caused by premature requests for extended nominal 2019-09-28 15:19:32 -07:00
adrian-prantl
00c64e7959 Merge pull request #27345 from adrian-prantl/16042546
Debug Info: Encode let-bindings using DW_TAG_const_type.
2019-09-27 14:39:56 -07:00
Xi Ge
4069172a40 AST: refactor getLoc() of decls to have a single entry point for all decl kinds, NFC
After we start to serialize the result of getLoc() in the
.swiftsourceinfo file, getLoc() needs a single entry point to look up via
USRs in the serialized format.
2019-09-26 17:47:44 -07:00
Robert Widmann
c5a27efe56 Merge pull request #27351 from CodaFi/not-a-good-start-boris
Requestify Operator Precedence Groups and Precedence Group Lookup
2019-09-25 13:30:18 -07:00
Adrian Prantl
ff22da20c3 Debug Info: Encode let-bindings using DW_TAG_const_type.
This allows the debugger to distinguish constant "let" values from
mutable "var" variables.

rdar://problem/16042546
2019-09-25 08:51:05 -07:00
Slava Pestov
98aa47c078 Merge pull request #27357 from slavapestov/circular-validation-cleanups
Circular validation cleanups, part 1
2019-09-25 09:40:03 -04:00
Doug Gregor
9b20012ee1 Merge pull request #27322 from DougGregor/property-wrapper-composition-di
[DI] Support definite initialization for composed property wrappers.
2019-09-24 21:22:43 -07:00
Slava Pestov
040be292e5 AST: TypeDecl::getDeclaredInterfaceType() always returns a non-empty Type
In the case of circular type aliases, this now returns ErrorType
instead of Type().
2019-09-24 22:38:59 -04:00
Slava Pestov
645fc20df7 AST: TypeAliasDecl::get{Structural,Underlying}Type() always return non-empty Type
Return an ErrorType on circularity instead of Type().
2019-09-24 22:38:59 -04:00
Robert Widmann
5964ce47b0 Use OperatorPrecedenceGroupRequest to clean up InfixOperatorDecl a bit 2019-09-24 17:45:50 -07:00
Slava Pestov
6a9b566517 AST: Fix parent type of protocol type alias types
To preserve correct behavior under substitution, the parent type
of a protocol type alias must be the 'Self' generic parameter and
not the protocol's existential type.
2019-09-24 17:39:53 -04:00
Doug Gregor
ab5d161c05 [SILGen] Separate the initialization of a wrapped property from a wrapped value
Teach SILGen to emit a separate SIL function to capture the
initialization of the backing storage type for a wrapped property
based on the wrapped value. This eliminates manual code expansion at
every use site.
2019-09-24 09:11:53 -07:00
Robert Widmann
ed18f47d05 Port getInterfaceType() patterns in libAST 2019-09-23 16:49:09 -07:00
Robert Widmann
8d9629ec43 Requestify getInterfaceType() in Name Only
Make getInterfaceType() call validateDecl on behalf of its clients.  In effect, this makes the interface type behave like a request.  It also means that its clients no longer need to perform a number of undesirable anti-patterns in order to sidestep the bizarre API contract validateDecl has at the moment

In particular, the following things are no longer necessary:

- Checking for a missing interface type then validating
- Validating the interface type then retrieving it
- Validating the interface type then retrieving a derived value

These anti-patterns will be removed in follow-up commits
2019-09-23 16:48:35 -07:00
Robert Widmann
b135928125 Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless.  All of the callers intended to ask "hasInterfaceType" anyways.
2019-09-20 22:22:49 -07:00
Robert Widmann
e7fccde40c Directly detect the cyclic case while computing conditional requirement
The general class of cycle here is when validation asks for the generic signature which triggers requirement checking which forces us to ask for the generic signature of the extension again.  We should look into a more principled solution.

See rdar://55263708
2019-09-20 20:38:38 -07:00
Robert Widmann
38bde33067 Merge pull request #27172 from CodaFi/aliasing-artifacts-and-noise-reduction-techniques
Kill validateDeclForNameLookup Harder
2019-09-18 15:00:51 -07:00
Slava Pestov
67c668200a Sema: Compute and store captures for default argument expressions 2019-09-18 14:26:01 -04:00
Jordan Rose
8d7f1b7c5d [AST] Separate SourceFile from FileUnit.h
Like the last commit, SourceFile is used a lot by Parse and Sema, but
less so by the ClangImporter and (de)Serialization. Split it out to
cut down on recompilation times when something changes.

This commit does /not/ split the implementation of SourceFile out of
Module.cpp, which is where most of it lives. That might also be a
reasonable change, but the reason I was reluctant to is because a
number of SourceFile members correspond to the entry points in
ModuleDecl. Someone else can pick this up later if they decide it's a
good idea.

No functionality change.
2019-09-17 17:54:41 -07:00
Jordan Rose
853caa66d4 [AST] Split FileUnit and its subclasses out of Module.h
Most of AST, Parse, and Sema deal with FileUnits regularly, but SIL
and IRGen certainly don't. Split FileUnit out into its own header to
cut down on recompilation times when something changes.

No functionality change.
2019-09-17 17:54:41 -07:00
Suyash Srijan
c99facb48b Merge pull request #27057 from theblixguy/unrevert/SR-11298
Unrevert "[Sema] Setter has incorrect mutating-ness inside class-constrained protocol extension"
2019-09-18 01:15:07 +01:00
Suyash Srijan
d9c8ae4ce8 [AST] Remove isTypeContext() check from hasValueSemantics() and move the responsibility to the caller 2019-09-17 18:38:01 +01:00
Robert Widmann
c254f4d2f8 Setting the underlying type should set the structural type too
This avoids making the structural type dependent on whether the interface type has been computed and neatly avoids special-casing non-parsed declarations which set their underlying type up front.
2019-09-17 08:49:03 -07:00
Robert Widmann
5e34169aca Separate computing interface types and underlying types
Computing the interface type of a typealias used to push validation forward and recompute the interface type on the fly.  This was fragile and inconsistent with the way interface types are computed in the rest of the decls.  Separate these two notions, and plumb through explicit interface type computations with the same "computeType" idiom.  This will better allow us to identify the places where we have to force an interface type computation.

Also remove access to the underlying type loc.  It's now just a cache location the underlying type request will use.  Push a type repr accessor to the places that need it, and push the underlying type accessor for everywhere else.  Getting the structural type is still preferred for pre-validated computations.

This required the resetting of a number of places where we were - in many cases tacitly - asking the question "does the interface type exist".  This enables the removal of validateDeclForNameLookup
2019-09-17 08:20:55 -07:00
Robert Widmann
d097c8186d Requestify generic signatures
Define a request that provides the generic signature for a given generic context.  This unblocks a ton of cleanup and will allow us to remove validateExtension, validateDeclForNameLookup, and a lot of the surrounding infrastructure.

Being more honest about which declarations actually have a generic signature computed has naturally introduced more cycles in requests.  hasComputedGenericSignature() now acts as a recursion breaker.  In the future, we should purge any uses of this accessor that specifically head-off cycles as the cycle itself is probably part of a larger structural problem.
2019-09-16 11:41:53 -07:00
Sasha Krassovsky
1e414f7fb6 Fix warnings in AST 2019-09-13 09:57:48 -07:00
Suyash Srijan
29ca8b0b38 [AST] Adds 'hasValueSemantics()' to DeclContext and uses 'getSelfTypeInContext()' instead 2019-09-09 21:17:27 +01:00