Commit Graph

3196 Commits

Author SHA1 Message Date
Arnold Schwaighofer
1719f0cdf1 Serialization: Also serialize the filename for internal storage decls with private accessors
If a value decl is internal hasTestableOrPrivateImport will succeed (or
fail) without looking at the filename. However this breaks when we query
an internal storage decl with private formal access for a private
setter: the query would fail because no filename was serialized for the
decl (we only serialize filenames for private decls). So in the special
case of a internal storage with private accessor also serialize the
filename.

rdar://48516545
2019-03-04 13:12:39 -08:00
Slava Pestov
b9bda84e28 SIL: Fix calls of @_weakLinked functions from serialized SIL
We have to set the SILFunction's 'weakLinked' flag in the defining
module too, so that it can be serialized. Otherwise when we
deserialize it we are not weak linking calls to the function.
2019-02-22 21:10:18 -05:00
Slava Pestov
3bf5a175a3 AST: Check the availability context from Decl::isWeakImported()
Fixes <rdar://problem/46674512>.
2019-02-19 18:58:44 -05:00
Slava Pestov
69d1cafd1c AST: Add AvailabilityContext parameter to Decl::isWeakImported()
For now, it's not used, but we do try to pass the right value down from
our various call sites.

Progress on <rdar://problem/46674512>.
2019-02-19 18:58:44 -05:00
Arnold Schwaighofer
17e64f5e9c Merge pull request #22691 from aschwaighofer/allow_dynamic_replacement_init_non_delegating
Allow dynamic replacement initializers to be non delegating
2019-02-19 08:38:08 -08:00
Arnold Schwaighofer
d5b33ba303 Only allow non resilient non-delegating initializers for now 2019-02-18 15:01:03 -08:00
Slava Pestov
bd6490b391 SIL: Introduce '@_alwaysEmitIntoClient' attribute for use by standard library
This is like '@inlinable', except that the symbol does not have a public
entry point in the generated binary at all; it is deserialized and a copy
is always emitted into the client binary, with shared linkage.

Just like '@inlinable', if you apply this to an internal declaration it
becomes '@usableFromInline' automatically.

This uses the same mechanism as default arguments ever since Swift 4, so
it should work reasonably well, but there are rough edges with diagnostics
and such. Don't use this if you are not the standard library.

Fixes <rdar://problem/33767512>, <https://bugs.swift.org/browse/SR-5646>.
2019-02-18 17:10:57 -05:00
Arnold Schwaighofer
8f0fbd2c75 Allow dynamic replacement initializers to be non delegating
rdar://48125765
2019-02-18 10:26:59 -08:00
Davide Italiano
4d7a4b5d16 Merge pull request #22477 from dcci/not_lldb_fault_anymore_maybe
[Decl] Remove a workaround introduced to appease lldb.
2019-02-12 11:01:40 -08:00
Davide Italiano
8bbb26eb56 [Decl] Remove a workaround introduced to appease lldb.
Probably at some point this was true, but it's not the case
anymore.
2019-02-08 09:51:51 -08:00
Slava Pestov
dffa29fd0d AST: Remove a few uses of FunctionType::Param::getOldType() 2019-02-07 23:46:31 -05:00
Rintaro Ishizaki
6e44205c2f Merge pull request #22411 from johnfairh/assoctype-default-loc
[IDE] Fix sourcerange for assoc types with default values
2019-02-06 12:29:46 -08:00
John Fairhurst
f841d45185 [IDE] Fix sourcerange for assoc types with default values 2019-02-06 18:10:41 +00:00
Doug Gregor
d19d2f2490 [AST] Lazily compute ProtocolDecl::getKnownProtocolKind()
Rather than eagerly doing a bunch of name lookups to establish the known
protocol kind, lazily match the ProtocolDecl to the list of known
protocols as-needed. This eliminates a bunch of up-front unqualified
name lookups when spinning up a type checker.
2019-02-04 21:25:48 -08:00
Rintaro Ishizaki
32ebfa4761 [AST] Comment tweak 2019-01-22 15:38:13 -08:00
Slava Pestov
eef3efbe42 AST: Cache ProtocolDecl::getInheritedProtocols()
Fixes <rdar://problem/47371754>.
2019-01-18 15:36:27 -05:00
Slava Pestov
acb37b2b55 AST: Set ClassDecl's HasDestructor bit in one place 2019-01-18 00:15:41 -05:00
Slava Pestov
a8d1910552 AST: Cache SuperclassDeclRequest
This fixes a significant build time regression since 4.2.

Fixes <rdar://problem/47305605>.
2019-01-15 23:24:36 -05:00
Pavel Yaskevich
b78ffa77e8 [AST] If access control is disabled adjust declaration access to maximum openness
This is a follow-up to https://github.com/apple/swift/pull/21783
which made `is{Setter}AccessibleFrom` respect `-disable-access-control`
flag. Now it's `getAdjustedFormalAccess` turn to do the same.
2019-01-14 21:26:11 -08:00
Pavel Yaskevich
69c622fc06 Merge pull request #21783 from xedin/rdar-30933988
[AST] `Decl::is*AccessibleFrom` methods should respect access control…
2019-01-14 14:06:44 -08:00
Rintaro Ishizaki
b446d6b051 Merge pull request #21377 from rintaro/ide-contextinfo
[SourceKit][IDE] New SourceKit request to retrieve context type information
2019-01-15 01:54:16 +09:00
Pavel Yaskevich
da8f384b22 [AST] Move get{Setter}FormalAccess' calls into checkAccess from is*AccessibleFrom` 2019-01-11 17:51:15 -08:00
Pavel Yaskevich
ddc2fa415e [AST] NFC: introduce ASTContext::isAccessControlDisabled 2019-01-11 17:30:10 -08:00
Pavel Yaskevich
5426e0df9e [AST] Decl::is*AccessibleFrom methods should respect access control flag
Otherwise integrated REPL and other tools like LLDB would produce
incorrect results or crash.

Resolves: rdar://problem/30933988
2019-01-11 17:30:10 -08:00
Rintaro Ishizaki
d17bb78a0b [AST] Add shouldHideFromEditor() method
This replaces shouldHideDeclFromCompletionResults() in IDE.
2019-01-10 17:52:36 +09:00
Parker Schuh
f5859ff46e Rename NameAliasType to TypeAliasType. 2019-01-09 16:47:13 -08:00
Slava Pestov
716ac81b3e AST: Cache protocol generic signature in GenericContext::getGenericSignature()
The generic signature of a protocol is simple enough that we can
build it directly when asked. However, be sure to cache it for
future use.
2019-01-08 22:58:12 -05:00
Nathan Hawes
c3723fd4d7 [sourcekitd][AST] Fix CursorInfo crash on method with unresolved default value
When printing its annotated decl, we would would assume the param's default
value is present if the default value kind was "Normal". The type checker
explicitly sets the default value to nullptr if it doesn't type check though, so
we were crashing for that case. Added the check.

Resolves rdar://problem/46694149
2018-12-21 18:13:53 -08:00
Slava Pestov
bfcf24ee4e AST: Rework @objcMembers inheritance to not depend on validation order
Sema would directly check for the presence of the @objcMembers attribute,
and inherit it from the immediate superclass in validateDecl().

We don't want validateDecl() to have side effects like this and this was
already a problem, because it would not inherit the attribute transitively
in some cases.

Instead, add a ClassDecl::hasObjCMembers() method that walks over all
ancestors and caches the result.

<rdar://problem/46420252>
2018-12-12 15:12:38 -05:00
Slava Pestov
bc4aa75b35 AST: Simplify GenericSignatureBuilder::computeRequirementSignature() 2018-12-11 23:55:41 -05:00
Slava Pestov
544e0a02d5 AST: Don't link together GenericParamLists of nested generic types
GenericParamList::OuterParameters would mirror the nesting structure
of generic DeclContexts. This resulted in redundant code and caused
unnecessary complications for extensions and protocols, whose
GenericParamLists are constructed after parse time.

Instead, lets only use OuterParameters to link together the multiple
parameter lists of a single extension, or parameter lists in SIL
functions.
2018-12-11 23:55:41 -05:00
Slava Pestov
c0bfaaf30f AST: Merge ProtocolDecl::createGenericParams() into createGenericParamsIfMissing() 2018-12-11 23:55:41 -05:00
Slava Pestov
7a038ff817 AST: Refactor ExtensionDecl::createGenericParamsIfMissing()
Let's use the same code path for protocol and non-protocol extensions;
we still have to do something special for protocol extensions though.
2018-12-11 23:22:18 -05:00
Slava Pestov
78e56079ed AST: Introduce ExtensionDecl::createGenericParamsIfMissing()
For now Sema still calls it manually, but soon we could make
getGenericParams() lazy, calling this automatically, since
there's really no reason to create the generic parameters
upfront when binding the extension.
2018-12-11 17:48:52 -05:00
Slava Pestov
1ca81c42b4 AST: Factor out GenericParamList::configureGenericParamDepth() 2018-12-11 17:48:52 -05:00
Slava Pestov
aa747dcd81 Remove property behaviors 2018-12-07 20:38:33 -05:00
Slava Pestov
e160b85f8f Merge pull request #21117 from slavapestov/accessor-synthesis-cleanup
Accessor synthesis cleanup (NFC)
2018-12-07 19:53:26 -05:00
Harlan Haskins
c829506aca Merge pull request #21033 from harlanhaskins/trouble-at-the-roller-rink
[Sema] Diagnose internal(set) from @inlinable functions
2018-12-07 15:33:18 -08:00
Slava Pestov
6d1b866cc1 AST: Fix FuncDecl::getSourceRange() to do the right thing for accessors with synthesized bodies 2018-12-07 17:10:08 -05:00
Harlan Haskins
d30a3da32a [Sema] Non-requirement protocol members should inherit @usableFromInline
Previously, members of protocols that were not protocol requirements,
like accessors and typealiases, did not inherit @usableFromInline from
the parent protocol. Change this so they do.
2018-12-07 12:45:32 -08:00
John McCall
8112f68b96 Merge pull request #20629 from rjmccall/error-self-conformance
Allow Error to conform to itself
2018-12-05 19:58:08 -05:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Slava Pestov
473a2cb38c AST: Members of @_weakLinked types are implicitly @_weakLinked 2018-12-03 20:36:03 -05:00
Slava Pestov
4289f76064 AST: Introduce ClassDecl::hasResilientMetadata() 2018-11-29 23:20:02 -05:00
Slava Pestov
fcb52172fc AST: Change isResilient() to do the cheaper check first 2018-11-29 23:20:02 -05:00
Pavel Yaskevich
e18d390d18 Merge pull request #20663 from hamishknight/packing-up-the-flags
[AST] NFC: Pack @autoclosure parameter decl flag with the default value
2018-11-17 12:27:16 -08:00
Slava Pestov
e8e1f4f80d Merge pull request #20593 from slavapestov/keypath-resilience-fixes
Fix key paths for resilience and @inlinable
2018-11-17 13:13:53 -05:00
Hamish Knight
bec9a8c9cb [AST] NFC: Pack @autoclosure parameter decl flag with the default value 2018-11-17 13:31:40 +00:00
David Zarzycki
e4fb140355 Merge pull request #20501 from davezarzycki/fix_28870_crasher
[AST] NFC: Add reentrancy check to associated type anchor walk
2018-11-17 07:26:37 -05:00
John McCall
49ba9c59d1 Allow Error to conform to itself.
Most of the foundation for this was laid in earlier patches.
2018-11-17 02:51:45 -05:00