Commit Graph

214 Commits

Author SHA1 Message Date
David Ungar
f64033a2d2 Manual rebase with master 2019-08-06 22:13:20 -07:00
David Ungar
3a3145c0f4 Alternate SelfDC computation, fixes, and cleanups.
ASTScopeLookup by default
Create empty fn bodies for IDE tests.
Include initializer source range for property wrappers.
Add -disable-astscope-lookup
2019-06-23 09:17:09 -07:00
David Ungar
69f6b41a13 Use unique_ptr for Scope, getScope returns a reference 2019-06-12 07:29:00 -07:00
David Ungar
ad77af1b87 Catch top-level dependency for use under pattern.
var x = 3
_ = x
2019-06-03 21:13:25 -07:00
David Ungar
005e259247 compiles, unfmt 2019-05-31 21:02:19 -07:00
David Ungar
8814390225 ifndef NDEBUG nify 2019-05-28 14:40:10 -07:00
David Ungar
6942344ad4 Review cleanups. 2019-05-28 12:35:29 -07:00
David Ungar
663760e3b7 ASTOOScope ontology 2019-05-28 10:48:22 -07:00
Ben Langmuir
34da079aa6 Pass DynamicLookupInfo through VisibleDeclConsumers NFC
This commit adds a new type DynamicLookupInfo that provides information
about how a dynamic member lookup found a particular Decl. This is
needed to correctly handle KeyPath dynamic member lookups, but for now
just plumb it through everywhere.
2019-05-06 10:02:39 -07:00
Gogul Balakrishnan
1fa3846224 Add more hooks for overriding name lookup in the DebuggerClient (#23031) 2019-04-08 15:19:31 -07:00
David Ungar
6982e66ddf Refactor filterForDiscriminator and call of addLocalVariableResults. 2019-02-22 12:41:03 -07:00
David Ungar
c9576ca068 Move LegacyUnqualifiedLookup out of header 2019-02-20 16:16:16 -07:00
David Ungar
306cfd8a4f Constification 2019-02-20 15:32:49 -07:00
David Ungar
cd48cd6eb3 Format 2019-02-20 14:35:52 -07:00
David Ungar
1595efe5e2 Split the file, unfmt 2019-02-20 14:34:11 -07:00
David Ungar
edaec2aea5 Move searchPlacesToSearch into PlacesToSearch 2019-02-19 11:24:51 -07:00
David Ungar
ef9f99e37c Rename ExpUnqalifiedLookup to UnqualifiedLookup, UnqualifiedLookup to LegacyUnqualifiedLookup 2019-02-19 10:55:44 -07:00
David Ungar
0aee0dba4b 1st cut finish redo, unfmt 2019-02-18 15:30:18 -07:00
David Ungar
977b0db93d Nonfmt cut down on DC 2019-02-16 23:35:25 -07:00
David Ungar
3c295f8228 Group lookupDecls etc into PlacesToSearch 2019-02-16 22:43:10 -07:00
David Ungar
8ece21459b Push GenericParamList check into function case. 2019-02-16 11:55:41 -07:00
David Ungar
3b7131cf0b Factor each variant into a separate function. Facter out Decl dispatch. 2019-02-16 11:49:07 -07:00
David Ungar
e9298a1ee0 Renamed shouldReturnBasedOnResults to isFinishedWithLookupNowThatIsAboutToLookForOuterResults 2019-02-16 11:34:43 -07:00
David Ungar
04ef0daeb8 Add ExpUnqualifiedLookup, cross-check 2019-02-16 11:31:16 -07:00
Argyrios Kyrtzidis
75ab0a5f36 [AST] Break dependency cycle between swiftAST and swiftSema
AST/LookupVisibleDecls.cpp has a dependency on swiftSema by having doGlobalExtensionLookup call into swift::isExtensionApplied,
and doGlobalExtensionLookup is ultimately used by the other global functions in that file.
Break the cycle by moving the file into the swiftSema library.
2018-12-06 22:52:38 -08: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
36c8d94238 AST: Refactor SelfBoundsFromWhereClause to support ProtocolDecls 2018-10-12 03:06:52 -07:00
Doug Gregor
6556926cba [AST] Switch ProtocolDecl::requiresClass() over to decl-based resolution.
Resolving whether a protocol is class-bound only requires declaration-based
resolution (not the full type checker), so switch over to those APIs.
2018-08-06 10:07:16 -07:00
Doug Gregor
971a6e3cd3 [Name lookup] Use decl-based name lookup for the conformance lookup table.
Add API to get all of the nominal types directly referenced from the
inheritance clause of a given declaration. Use that to find the protocols
to enter into the conformance lookup table based on a given declaration,
without going through the type checker [*].

[*] Except for unqualified lookup still needing to use the type checker.
2018-08-06 09:15:57 -07:00
Doug Gregor
b07dd059a6 [Type Checker] Remove TypeChecker/LazyResolver parameters from name lookup.
Make the TypeChecker’s name-lookup routines static, so they don’t depend
on the TypeCheck instance… except for one pesky place where we jump back
into protocol conformance checking. This is part of teasing apart the type
checker.
2018-07-18 14:50:38 -07:00
Slava Pestov
19de53f6cf Sema: Remove dead code from access level computation rework 2018-07-06 23:50:36 -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
Doug Gregor
cd3c63cbfd [AST] Stop including GenericSignature.h in other headers.
Except GenericEnvironment.h, because you can't meaningfully use a
GenericEnvironment without its signature. Lots less depends on
GenericSignature.h now. NFC
2017-10-12 14:23:46 -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
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
Slava Pestov
fb9d410350 AST: Rename UnqualifiedLookupResult => LookupResultEntry
There's a similar LookupResult::Result type in Sema, and I'd like
to combine the two.
2017-07-18 22:09:02 -07:00
Doug Gregor
ac8e8aa1b3 [GSB] Stop creating unresolved potential archetypes; rework typo correction.
The small-but-significant change to the generic signature builder is
to refuse to create unresolved potential archetypes. Instead, delay
any requirement that depends on such type, to be reprocessed once
we've seen all of the other requirements. If the type can be resolved
later, it will be; Otherwise, the type checker will complain when it
sees an unresolvable type. By itself, this fixes the crash in SR-2796.

Doing this by itself regresses diagnostics because typo correction in
the generic signature builder no longer kicks in. Therefore, implement
typo correction for these cases in the type checker proper, using its
existing facilities for typo correction. The result is more consistent
code with a better result.

Fixes SR-2796 / rdar://problem/28544316.
2017-06-29 16:52:46 -07:00
Xi Ge
55bdc6d1a6 Documentation: Add some documentation explaining what is Base in UnqualifiedLookupResult. 2017-04-06 15:50:23 -07:00
Brian Gesiak
663b92ece9 [AST] Completely replace Module with ModuleDecl
The typedef `swift::Module` was a temporary solution that allowed
`swift::Module` to be renamed to `swift::ModuleDecl` without requiring
every single callsite to be modified.

Modify all the callsites, and get rid of the typedef.
2017-01-08 00:36:08 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Jordan Rose
9eaaf5d3b8 Add "IgnoreAccessControl" to UnqualifiedLookup.
...and use it when top-level type lookup fails, to produce better
diagnostics.

Really this should be using an option set, or setting flags on the
UnqualifiedLookup instance or something, but I want to cherry-pick
this to the swift-3.0-branch without major disturbances.

More rdar://problem/27663403
2016-09-22 15:09:27 -07:00
Alex Hoppen
232fe59b54 [Sema] Don't issue warnings when accessing enum elements as instance members
This removes the logic which issued warnings when accessing enum
elements as instance members (SE-0036), making room for a new
implementation that will issue errors instead.

This reverts commit ae1058a39a.
2016-07-20 16:25:57 +02:00
Alex Hoppen
ae1058a39a [Sema] Provide warnings when accessing enum elements as instance members as a preparation for SE-0036 2016-07-08 11:17:46 +02:00
Slava Pestov
3127264376 AST: When performing qualified lookup of a member type, filter out non-types earlier
With the previous resolveTypeInContext() patch, a few compiler
crashers regressed with this problem, presumably because we were now
performing lookups in more contexts than before.

This is a class of problems where we would attempt a recursive
validation:

1) Generic signature validation begins for type T
2) Name lookup in type context finds a non-type declaration D nested in T
3) Generic signature validation begins for D
4) The outer generic context of D is T, but T doesn't have a generic
   signature yet

The right way to break such cycles is to implement the iterative
decl checker design. However when the recursion is via name lookup,
we can try to avoid the problem in the first place by not validating
non-type declarations if the client requested a type-only lookup.

Note that there is a small semantic change here, where programs that
were previously rejected as invalid because of name clashes are
now valid. It is arguable if we want to allow stuff like this or not:

class A {
  func A(a: A) {}
}

or

class Case {}
enum Foo {
  case Case(Case)
}

However at the very least, the new behavior is better because it
gives us an opportunity to add a diagnostic in the right place
later. The old diagnostics were not very good, for example the
second example just yields "use of undeclared type 'Case'".
In other examples, the undeclared type diagnostic would come up
multiple times, or we would generate a cryptic "type 'A' used within
its own definition".

As far as I understand, this should not change behavior of any existing
valid code.
2016-06-11 16:27:43 -07:00
John McCall
3fc2291733 Add basic typo correction for unqualified lookup.
There's a lot of room for better QoI / performance here.
2016-05-20 11:04:58 -07:00
Alex Hoppen
a0a74aeb46 SE-0064 / SR-1239: Code completion for #selector of property getters/setters.
Implement basic code completion support for #selector with property
getters/setters. The vast majority of this implementation comes from
Alex Hoppen (@ahoppen), with only a handful of my own tweaks. Alex has
more interesting ideas on improving this that I wasn't quite ready to
commit to, so this is more basic than the overall goal.
2016-05-11 23:03:37 -07:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
db13bcb22e Fix typos. 2015-12-26 14:11:42 +01:00