Commit Graph

3502 Commits

Author SHA1 Message Date
Tony Allevato
4777f9d8b7 [AST] Enable derived Equatable/Hashable for structs 2017-08-08 18:20:58 -07:00
Xi Ge
6573a5fe41 SourceKit: Report the signature length for subscript declarations. SR-5626 (#11376) 2017-08-07 14:11:52 -07:00
swift-ci
e506bb3134 Merge remote-tracking branch 'origin/master' into master-next 2017-08-01 08:08:52 -07:00
Alex Hoppen
ebd701c4b7 Represent the name of destructors by a special DeclBaseName
No longer use the known identifier `deinit` for destructors. This allows
classes to have functions called `deinit`.
2017-07-28 19:20:02 +02:00
swift-ci
f4563eef5b Merge remote-tracking branch 'origin/master' into master-next 2017-07-24 16:09:01 -07:00
Robert Widmann
771ea8365c Shared parameters do not need a load 2017-07-24 14:32:09 -07:00
swift-ci
c9469bf34e Merge remote-tracking branch 'origin/master' into master-next 2017-07-24 10:31:29 -07:00
Robert Widmann
35851263b1 Merge pull request #11074 from CodaFi/the-sharing-economy
Staging for __shared and __owned
2017-07-24 10:13:06 -07:00
swift-ci
211d8c7c18 Merge remote-tracking branch 'origin/master' into master-next 2017-07-24 00:09:13 -07:00
swift-ci
43a428c277 Merge pull request #11126 from CodaFi/param-a-rama 2017-07-23 23:49:03 -07:00
swift-ci
9c336638be Merge remote-tracking branch 'origin/master' into master-next 2017-07-23 22:48:57 -07:00
Robert Widmann
b77f2c147c Parse Shared
Add parser support for __shared and __owned as type attributes.  Also, extend parser diagnostics and tests to account for the new type attributes.
2017-07-23 21:47:25 -07:00
Robert Widmann
e5918f70e8 [NFC] Refactor self type computation to return a Param
Remove a user of InOutType::get and flip a few users of
FunctionType::get to pass Params instead of naked input
types.
2017-07-23 21:36:16 -07:00
Slava Pestov
1221bd8f60 Sema/AST: Fix a couple of protocol typealias validation order bugs
We break name lookup circularities by special-casing validation of
type aliases, resolving the underlying type of the type alias before
building the generic environment of the protocol that contains the
type alias.

However doing this gives the type alias an underlying type written
in terms of unresolved DependentMemberTypes which do not map to
associated types.

Attempting to substitute such a type fails.

We worked around this by re-validating type alias members of
protocols when we finally got around to building the protocol's
generic environment. Force this to happen earlier in
substMemberTypeWithBase(), because we need the fully resolved
underlying type in order to perform the substitution.

Also, fix TypeAliasDecl::setUnderlyingType() to only create a new
NameAliasType the first time it is called. In this special case
where it can be called twice with a resolved underlying type the
second time, we should not be creating a new NameAliasType.

There are better fixes possible here, requiring various levels
of refactoring. I'll investigate this soon, but for now this narrow
fix should address the problem with minimal risk.

Fixes <rdar://problem/33189068>.
2017-07-23 17:34:38 -07:00
swift-ci
d9f0e3cedb Merge remote-tracking branch 'origin/master' into master-next 2017-07-19 13:28:52 -07:00
Robert Widmann
8cdddef2f8 Refactor Params to use flags
Also, begin to pass around base types instead of raw InOutType types.  Ideally, only Sema needs to deal with them, but this means that a bunch of callers need to unwrap any inouts that might still be lying around before forming these types.

Multiple parts of the compiler were slicing, dicing, or just dropping these flags.  Because I intend to use them for the new function type representation, I need them to be preserved all across the compiler.  As a first pass, this stubs in what will eventually be structural rules as asserts and tracks down all callers of consequence to conform to the new invariants.

This is temporary.
2017-07-19 09:49:32 -07:00
Robert Widmann
1a0b777275 Add parameter flags to Decl 2017-07-19 09:49:32 -07:00
swift-ci
2dc84ee365 Merge remote-tracking branch 'origin/master' into master-next 2017-07-05 15:28:50 -07:00
Robert Widmann
4da853e7cb Rename Specifier::None to Specifier::Owned 2017-07-05 14:02:26 -07:00
swift-ci
8b7b1866d7 Merge remote-tracking branch 'origin/master' into master-next 2017-06-30 22:28:39 -07:00
swift-ci
cb38983f86 Merge pull request #10742 from DougGregor/gsb-no-longer-gross 2017-06-30 22:12:29 -07:00
Michael Gottesman
78713ce07f Merge pull request #10519 from jrose-apple/ModuleMacro-master-next
WIP getting master-next up and running with clang::ModuleMacro
2017-06-30 14:52:09 -07:00
swift-ci
3e31e8c2cd Merge pull request #10721 from CodaFi/parampa-tha-rappa 2017-06-30 10:50:08 -07:00
Robert Widmann
4411223156 [NFC] Switch some more of the frontend to params 2017-06-30 10:24:52 -07:00
Doug Gregor
ae5091b09a [GSB] Clean up and audit uses of ArchetypeResolutionKind.
Use ArchetypeResolutionKind::CompleteWellFormed whenever we need to
ask questions about the potential archetype, and
ArchetypeResolutionKind::WellFormed when we need only evaluate whether
there is a legitimate type with that name (and possibly get a handle
to it).
2017-06-30 10:05:12 -07:00
Robert Widmann
679584d8d8 Merge pull request #10695 from CodaFi/all-specd-out
[NFC] Use a meaningful representation of parameter specifiers
2017-06-29 20:00:14 -07:00
Robert Widmann
ac5594dabe Use a meaningful representation of parameter specifiers
In anticipation of future attributes, and perhaps the ability to
declare lvalues with specifiers other than 'let' and 'var', expand
the "isLet" bit into a more general "specifier" field.
2017-06-29 16:03:49 -07:00
swift-ci
97f2f8bf2b Merge pull request #10711 from DougGregor/requirement-signature-improvements 2017-06-29 15:00:40 -07:00
Doug Gregor
5bacc08288 [AST] Represent requirement signature as a flat set of requirements.
The outside representation already went to a flat set of requirements;
make the internal representation match so we aren't tempted to use the
requirement signature as inputs to a generic signature.
2017-06-29 14:36:33 -07:00
Doug Gregor
623d72db3c [AST] Make the "requirement signature" of a protocol a flat array.
Rather than pretend that the requirement signature of a protocol is a
full, well-formed generic signature that one can meaningfully query,
treat it as a flat set of requirements. Nearly all clients already did
this, but make it official. NFC
2017-06-29 14:01:49 -07:00
Robert Widmann
43f29399f3 Remove an old diagnostic for 'var' in param position
Using the attribute in this position is a relic from the Swift 2
days, and fixing it required letting invalid code fall through to
Sema instead of being diagnosed in Parse proper.  Treat 'var'
in this position like 'let' by simply offering to remove it
instead of extracting it into a separate variable.
2017-06-29 13:35:59 -07:00
Doug Gregor
c2539eaa75 [AST] Simplify ProtocolDecl::computeRequirementSignature().
It doesn't need to depend on the generic signature, and the
early-exit-on-invalid isn't doing anything. NFC
2017-06-28 13:31:43 -07:00
Alex Hoppen
949968a182 Adjust printing to take into account special DeclNames
Print DeclBaseNames using a new userFacingStr() method to prepare for
DeclBaseNames that are not backed by Identifiers
2017-06-24 11:39:09 +02:00
Jordan Rose
c3d6be64ab WIP Update to use clang::ModuleMacro instead of clang::MacroInfo.
Untested and still missing a few pieces.
2017-06-23 16:04:24 -07:00
Doug Gregor
1693b38ea8 [AST] Adopt AnyFunctionType::getParams() when computing overloading signatures. 2017-06-23 13:41:20 -07:00
Huon Wilson
406e72d6d5 Merge pull request #9983 from huonw/symbol-list-9
More TBD work
2017-06-19 16:50:45 -07:00
Jordan Rose
77de3dc1f2 [AST] Bring 'mutating' and 'inout self' in sync. (#10375)
- A mutating method or accessor always has 'inout self'.
- A nonmutating method or accessor never has 'inout self'.
- Only instance members can be mutating.
- Addressors are still addressors even when on static members.

Came up after reviewing another patch that confused the two as
possibly distinct concepts.
2017-06-19 16:16:47 -07:00
Huon Wilson
8d455a4991 [TBDGen] Explicitly walk members of stored static vars.
Unlike some other vars, these members are not also listed at the top
level, adjacent to the VarDecl.
2017-06-19 14:53:21 -07:00
Slava Pestov
8541811edf AST: Fix ProtocolDecl::getInheritedProtocols() for protocols that inherit from compositions
We allow protocols to inherit from protocol compositions
defined via a typealias, eg,

typealias PQ = P & Q

protocol R : PQ {}

Sometimes, ProtocolDecl::getInheritedProtocols() is called before
the protocol's requirement signature has been computed. In this
case, we walk the inheritance clause of the protocol directly.
This walk was only looking at ProtocolType members of the
inheritance clause, ignoring ProtocolCompositionTypes.

As a result, name lookup could fail with an assertion because of
not being able to "see" members inherited via the protocol
composition.

Fixes <rdar://problem/32595988>.
2017-06-17 00:27:45 -07:00
Slava Pestov
89dc5afa57 Sema: Targeted fix for bad interaction between resilience checks and -enable-testing
The -enable-testing flag makes ValueDecl::getEffectiveAccess()
say that internal declarations are public.

This would lead us to emit spurious diagnostics if a default
argument of an internal function referenced a private symbol,
for example, which is something we actually want to allow.

This is a second revision of the patch -- instead of changing
getEffectiveAccess() to take an extra parameter, this changes
getFormalAccessScope() instead.

Fixes <rdar://problem/32592973>.
2017-06-08 01:35:44 -07:00
Slava Pestov
7cfa34952a Revert "Sema: Targeted fix for bad interaction between resilience checks and -enable-testing"
This reverts commit 66173a9b97.
2017-06-07 22:06:54 -07:00
Slava Pestov
66173a9b97 Sema: Targeted fix for bad interaction between resilience checks and -enable-testing
The -enable-testing flag makes ValueDecl::getEffectiveAccess()
say that internal declarations are public.

This would lead us to emit spurious diagnostics if a default
argument of an internal function referenced a private symbol,
for example, which is something we actually want to allow.

Hack around this by adding a new 'forLinkage' parameter to
getEffectiveAccess(). When this is false, we ignore the
-enable-testing flag, and only look for the @_versioned
attribute.

I'm not very happy with the fix, because it only compliates
the subtle behaviors of getFormalAccess(), getEffectiveAccess()
and getFormalAccessScope() further. But refactoring this is
a bigger change than I'm willing to put into swift-4.0-branch.

Fixes <rdar://problem/32592973>.
2017-06-07 21:43:37 -07:00
Jordan Rose
485ebefba7 Merge pull request #10083 from jrose-apple/nscoding-diags-take-2
Update and re-enable the diagnostics for unstable runtime names
2017-06-05 19:51:01 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
swift-ci
5d395d9ee4 Merge pull request #10049 from DougGregor/gsb-superclass 2017-06-01 23:07:42 -07:00
Joe Groff
2c0873a997 Correct getAccessStrategy for class extension storage decls.
Class extension methods are non-polymorphic unless @objc. Fixes rdar://problem/32434652.
2017-06-01 16:38:03 -07:00
Doug Gregor
899e68ef09 [GSB] Generalize potential archetype from "typealias" to all concrete types.
Potential archetypes can resolve to either an associated type or a
typealias. Generalize the latter to "any concrete type", both because
the current implementation is unnecessarily narrow (typealiases aren't
actually special in this regard) and to get us closer to handling
lookups via superclass constraints when resolving these types.
2017-06-01 13:52:39 -07:00
Doug Gregor
5628580ffb [AST] Introduce TypeDecl::compare() to provide an ordering for type declarations.
Generalizes ProtocolType::compareProtocols() for more general use.
2017-06-01 08:26:26 -07:00
Jordan Rose
325a96983e [AST] Preparations for removal of getName on ValueDecl (#9969)
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:04:19 -07:00
Jordan Rose
c0ccdb1626 Change getBaseName to return DeclBaseName instead of Identifier (#9968)
This changes `getBaseName()` on `DeclName` to return a `DeclBaseName`
instead of an `Identifier`. All places that will continue to be
expecting an `Identifier` are changed to call `getBaseIdentifier` which
will later assert that the `DeclName` is actually backed by an
identifier and not a special name.

For transitional purposes, a conversion operator from `DeclBaseName` to
`Identifier` has been added that will be removed again once migration
to DeclBaseName has been completed in other parts of the compiler.

Unify approach to printing declaration names

Printing a declaration's name using `<<` and `getBaseName()` is be
independent of the return type of `getBaseName()` which will change in
the future from `Identifier` to `DeclBaseName`
2017-05-28 17:55:03 -07:00