Commit Graph

1002 Commits

Author SHA1 Message Date
Slava Pestov
0c32c54e36 AST: Simplify ModuleDecl::forAllVisibleModules() 2018-04-26 23:37:16 -07:00
Huon Wilson
9b68eb8a80 [AST] Allow unqualified name lookup to return results from outer scopes.
This is necessary for disambiguating calls to functions like `min` and
`max`.
2018-04-19 11:07:48 +10:00
Huon Wilson
fe00f53e48 [AST] Use flags instead of booleans for UnqualifiedLookup. 2018-04-09 10:58:49 +10:00
Slava Pestov
a5579d1cff AST: Plug a hole in access control checking
A protocol extension of a private protocol can define internal
or public members. We should not be able to find these members
from another file or module if an internal or public type
conforms to the protocol.

Fixes <rdar://problem/21380336>.
2018-04-05 23:24:48 -07:00
Slava Pestov
df9e0a76e0 AST: Fix for name lookup not finding initializers in protocols
If a generic parameter has both a class and protocol constraint,
walking up to the class's superclass would cause us to subsequently
ignore any initializer requirements in the protocol.

Fixes <https://bugs.swift.org/browse/SR-1663>, <rdar://problem/22722738>.
2018-03-16 21:49:02 -07:00
Slava Pestov
34fd4ae512 AST: Use DeclBaseName::Kind::Constructor
Fixes <rdar://problem/35852727>, <https://bugs.swift.org/browse/SR-1660>,
<https://bugs.swift.org/browse/SR-6557>.
2018-03-16 00:25:56 -07:00
Graydon Hoare
819275945d [Stats] Replace RecursiveSharedTimer with FrontendStatsTracer. 2018-02-21 14:49:24 -08:00
Joe Groff
d4e03f2ba3 SIL: Add an 'external' KeyPathPatternComponent kind.
This will allow key paths to resiliently reference public properties from other binaries by referencing a descriptor vended by the originating binary. NFC yet, this just provides printing/parsing/verification of the new component.
2018-02-14 10:48:24 -08:00
Doug Gregor
05478455f7 [Name lookup] Fix an issue with lazy named member lookup.
Fix an issue with lazy named member lookup where a sequence of lookups
into a class based on full names (e.g., constraint(equalTo:constant:))
could prevent us from adding candidates with the same based name but
different argument labels.

Fixes SR-6834 / rdar://problem/36851018
2018-02-08 14:33:49 -08:00
Slava Pestov
1ed2cf09df AST: Don't find non-objc members with dynamic lookup
This can come up when we use import-as-member to turn top-level functions
into methods in an @objc class. Previously dynamic lookup would find
these, causing a SILGen crash.

Fixes <rdar://problem/36492980>.
2018-01-18 22:52:54 -08:00
Doug Gregor
8b58b0dbb4 [Type checker] Make redeclaration checking validate fewer declarations.
Redeclaration checking was validating all declarations with the same
base name as the given declaration (and in the same general nominal
type), even when it was trivial to determine that the declarations
could not be conflicting. Separate out the easy structural checks
(based on kind, full name, instance vs. non-instance member, etc.) and
perform those first, before validation.

Fixes SR-6558, a case where redeclaration checking caused some
unnecessary recursion in the type checker.
2017-12-30 23:27:04 -08:00
Doug Gregor
7d4956d37e [Name lookup] Remove debugging cruft 2017-12-16 14:03:28 -08:00
Doug Gregor
8c05278ef3 [Clang importer] Lazily load all named members with a matching base name.
When loading the named members for a given name, we want to load all
of the members with that base name... not only the ones that match the
full name, because the lookup table is indexed by base name and
filtering too early drops candidates.

Fixes rdar://problem/36085994.
2017-12-15 23:54:36 -08:00
David Zarzycki
97541e0d1e [Basic] NFC: Standardize and simplify inline bitfields
Inline bitfields are a common design pattern in LLVM and derived
projects, but the associated boilerplate can be demotivating and
brittle. This new header makes it easier to define and use inline
bitfields in Swift.

This also reorders some fields for better code generation.
2017-12-15 14:14:59 -05:00
Graydon Hoare
c51bb7c842 [NamedLazyMemberLoading] Expand logging a little. 2017-12-02 02:19:51 -08:00
Graydon Hoare
c6ce01280d [NamedLazyMemberLoading] Handle partial population from extensions better. 2017-12-02 02:19:29 -08:00
Graydon Hoare
7a9bc26fd9 [NamedLazyMemberLoading] Handle nominals with mix of added/lazy members. 2017-12-01 16:52:26 -08:00
Graydon Hoare
ce28efbf5e [NamedLazyMemberLoading] Tolerate mid-flight getMembers() calls better. 2017-12-01 16:52:25 -08:00
Graydon Hoare
3e76aebee1 [NamedLazyMemberLoading] Support named loading from ObjC categories. 2017-12-01 16:52:25 -08:00
Graydon Hoare
464dc1bcc1 [NamedLazyMemberLoading] Use per-IDC recursion-breaking flag, not sentinel.
The empty sentinel in the lookup table caused recursion-breaking to bottom
out in slightly different order than the old eager code, making certain
order-sensitive tests fail.
2017-12-01 16:52:25 -08:00
Graydon Hoare
a6701a8cce [NamedLazyMemberLoading] Give up trying to break recursion on clang-imported init for now. 2017-12-01 16:52:25 -08:00
Arnold Schwaighofer
eba12a7c3e Revert "Finish and default-enable named lazy member loading" 2017-12-01 07:25:54 -08:00
Graydon Hoare
094ee2fd27 [NamedLazyMemberLoading] Tolerate mid-flight getMembers() calls better. 2017-11-30 22:29:12 -08:00
Graydon Hoare
a967f8c6ea [NamedLazyMemberLoading] Support named loading from ObjC categories. 2017-11-30 22:27:58 -08:00
Graydon Hoare
9e1859469c [NamedLazyMemberLoading] Use per-IDC recursion-breaking flag, not sentinel.
The empty sentinel in the lookup table caused recursion-breaking to bottom
out in slightly different order than the old eager code, making certain
order-sensitive tests fail.
2017-11-30 22:18:25 -08:00
Graydon Hoare
dfc67d6b93 [NamedLazyMemberLoading] Give up trying to break recursion on clang-imported init for now. 2017-11-30 22:02:42 -08:00
Graydon Hoare
bfde4f564c [NamedLazyMemberLoading] Don't self-add extn members to partial tables. 2017-11-10 15:55:34 -08:00
Graydon Hoare
bbeec57182 [NamedLazyMemberLoading] Handle case of source extension on deserialized type. 2017-11-03 00:35:03 -07:00
Graydon Hoare
ed0b43cbce [NamedLazyMemberLoading] Move SerialID to IDC, get extensions working. 2017-11-01 17:35:46 -07:00
Graydon Hoare
f96c0d9b63 [NamedLazyMemberLoading] Address review comments. 2017-11-01 17:35:46 -07:00
Graydon Hoare
e9fbd2ce53 [NamedLazyMemberLoading] Add diagram + comment of IDC + MemberLookupTable. 2017-11-01 17:34:56 -07:00
Graydon Hoare
2d36f5cdae [NamedLazyMemberLoading] Use NominalTypeDecl::LookupTable as proper cache. 2017-11-01 17:34:56 -07:00
Graydon Hoare
30b6fdce83 Merge pull request #12429 from graydon/named-lazy-member-loading
Named lazy member loading 1/N
2017-10-24 14:27:04 -07:00
Slava Pestov
28efca5785 AST: Short-circuit isSetterAccessibleFrom() for ParamDecls 2017-10-22 20:05:00 -07:00
Graydon Hoare
cb1c8526c8 [NamedLazyMemberLoading] Address further review comments. 2017-10-20 22:48:45 -07:00
Graydon Hoare
99cbcde518 [NamedLazyMemberLoading] Debug logging. 2017-10-20 22:48:43 -07:00
Graydon Hoare
125c85f9a1 [NamedLazyMemberLoading] Wire into NominalTypeDecl::lookupDirect. 2017-10-20 22:48:42 -07:00
David Ungar
443ab7d950 git-clang-format 2017-09-26 18:02:35 -07:00
David Ungar
90b456b116 Use if (auto for getting Stats 2017-09-26 17:32:38 -07:00
David Ungar
a41a3c9fa5 compiles using movable guards 2017-09-26 17:22:58 -07:00
David Ungar
2af86f5cac First compiling run, WIP 2017-09-26 16:07:07 -07:00
Slava Pestov
a2e7f363f3 AST: Split off LazyConformanceLoader from LazyMemberLoader 2017-09-11 22:34:43 -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
c3e3d45396 Instrument NominalTypeDecl::lookupDirect
Also implement RecursiveSharedTimer
2017-08-23 14:53:53 -07:00
Rintaro Ishizaki
eb6914ccfc Merge pull request #11346 from rintaro/rip-cfor
Eliminate C-style ForStmt
2017-08-08 07:49:42 -07:00
Slava Pestov
8c98b7a306 AST: Fix a crasher with unqualified lookup
If the DeclContext's Self type-in-context is an ErrorType,
we should still resolve generic parameters to interface types.
2017-08-06 00:21:49 -07:00
Rintaro Ishizaki
a375267e5c [ASTScope] Remove ForStmt support. 2017-08-04 23:27:22 +09:00
Slava Pestov
7db4c9075c AST: Change LookupResultEntry to store a DeclContext instead of a base ValueDecl
Storing a DeclContext allows us to distinguish type
members from extension members just by looking at the
lookup result.
2017-07-18 22:09:55 -07:00