Commit Graph

3561 Commits

Author SHA1 Message Date
Xi Ge
560b08c171 SyntaxModel: simplify the collecting of contextual keywords in PrecedenceGroup.NFC (#11819) 2017-09-08 12:38:44 -07:00
Jordan Rose
f8b7db4e76 Excise the terms "blacklist" and "whitelist" from Swift source. (#11687)
The etymology of these terms isn't about race, but "black" = "blocked"
and "white" = "allowed" isn't really a good look these days. In most
cases we weren't using these terms particularly precisely anyway, so
the rephrasing is actually an improvement.
2017-08-30 09:28:00 -07:00
Jordan Rose
449cd98997 Excise "Accessibility" from the compiler (3/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

Rename AccessibilityAttr to AccessControlAttr and
SetterAccessibilityAttr to SetterAccessAttr, then track down the last
few uses of "accessibility" that don't have to do with
NSAccessibility. (I left the SourceKit XPC API alone because that's
supposed to be more stable.)
2017-08-28 13:27:59 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
David Ungar
5662c4b5dc Remove redundant getMembers
Also make LazyMemberLoader abstract
Add "final" to (Class|Protocol|Enum|Struct)Decl classes
2017-08-18 20:09:20 -07:00
Slava Pestov
ef87a5bbfb Sema: Fix crash with invalid 'let' property in protocol
Fixes <rdar://problem/25185722>.
2017-08-16 18:17:38 -04:00
Tony Allevato
a3db968057 Move derivesProtocolConformances from AST to Sema 2017-08-08 18:30:22 -07:00
Tony Allevato
425de49454 [Sema] Synthesize Eq/Hash for enums with payloads, structs 2017-08-08 18:20:58 -07:00
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