Commit Graph

7734 Commits

Author SHA1 Message Date
Jordan Rose
a17dbfbf29 Merge pull request #18778 from jrose-apple/towards-stability
[ModuleInterface] More changes to printing and parsing .swiftinterface files
2018-08-17 09:10:57 -07:00
Jordan Rose
f061dff9b7 [ModuleInterface] Don't print typealiases that match generic params
These are synthesized to satisfy associated type requirements, but
they're not needed in source, and they look like self-referential
definitions (`typealias X = X`).
2018-08-16 17:59:24 -07:00
Jordan Rose
d6c8ca016b Constify PrintOptions in ShouldPrintChecker::shouldPrint
No functionality change.
2018-08-16 17:59:24 -07:00
Jordan Rose
5a8cbe4503 [AST] Never print access levels on protocol requirements
We might allow this at some point in the future, but for now we should
stick to the syntax that people write in source.

rdar://problem/26746605
2018-08-16 16:00:49 -07:00
Jordan Rose
6526f11400 [ModuleInterface] Don't print access on extensions
This ends up meaning "don't print access attributes, then print access
uniformly on ValueDecls if you're not printing access attributes".
2018-08-16 16:00:42 -07:00
Harlan
9b29e8dc91 Merge pull request #18454 from harlanhaskins/requests-ive-had-a-few
Remove SimpleRequest::breakCycle
2018-08-16 11:03:22 -07:00
Ben Cohen
428c580158 Fix unused variable warnings in release builds. (#18755) 2018-08-16 11:46:45 -06:00
Jordan Rose
1958d7aea3 [AST] Add an AccessScope::dump helper (#18756)
And factor an existing getAccessLevelString out into a
generally-available swift::getAccessLevelSpelling.
2018-08-16 10:30:30 -07:00
Jordan Rose
53e0fad181 Assume it's okay for decls in a cross-module extension to be public (#18741)
...even if the base decl isn't.

This isn't normally possible, but it can come up when an imported type
is import-as-member'd onto an internal Swift declaration. This isn't
even such an unreasonable thing to do, since internal Swift
declarations are exposed in the generated header for an app.

rdar://problem/43312660
2018-08-16 10:06:54 -07:00
John McCall
5d8252b8c6 Pass around whether storage is mutable as an enum instead of a bool. 2018-08-16 02:13:54 -04:00
Doug Gregor
fa183b3639 [GenericSignatureBuilder] Rewrite sanity check to avoid warning in no-asserts builds. 2018-08-15 13:08:50 -07:00
Harlan Haskins
c31d7f808a Rebase on master and resolve conflicts 2018-08-15 11:22:09 -07:00
Harlan Haskins
5a6985f39e Remove SimpleRequest::breakCycle
This patch removes the need for Request objects to provide a default
cycle-breaking value, instead opting to return llvm::Expected so clients
must handle a cycle failure explicitly.

Currently, all clients do the 'default' behavior, but this opens the
possibility for future requests to handle failures explicitly.
2018-08-15 11:01:12 -07:00
swift-ci
be0e1643d6 Merge pull request #18720 from DougGregor/kill-type-resolver-context-generic-signature 2018-08-15 10:55:08 -07:00
Jordan Rose
6dfff66a83 Merge pull request #18617 from jrose-apple/any-requestions
Request evaluator: Cut down on the cost of AnyRequest in two ways
2018-08-15 10:09:23 -07:00
Doug Gregor
876738fabe Merge pull request #18718 from DougGregor/cleanup-type-lookup
[Name lookup] Clean up qualified and type lookup
2018-08-15 10:03:41 -07:00
Doug Gregor
50763fc641 [AST] Re-establish assertion about inheritance relationship in getSuperclassForDecl()
When we fail to find a particular superclass type of a type in ill-formed
code, make sure that we were right to look here at all. This re-establishes
a check I had recently weakened.
2018-08-15 09:27:36 -07:00
Doug Gregor
7f759145c7 [GSB] Make requirement-signature computation more robust for nested protocols.
Add all of the generic parameters from outer contexts as well. This only
occurs in ill-formed code, but maintains a GenericSignatureBuilder
invariant that it knows about all of the generic parameters in play.
2018-08-15 09:26:23 -07:00
Doug Gregor
955fab8d10 [Name lookup] Fix typo in comment. NFC 2018-08-15 08:19:39 -07:00
Doug Gregor
92d622ab41 [Type checker] Eliminate TypeResolverContext::GenericSignature.
The name-lookup behavior that avoids looking for members of a nominal type
or extension therefore when resolving the inheritance clause is now
handled by UnqualifiedLookup, so remove it from the type checker itself.

Fixes rdar://problem/39130543.
2018-08-14 23:17:57 -07:00
Doug Gregor
0480f18ec3 [Name lookup] Generalize member lookup check for extensions as well.
We only look for members within the extension’s type when we are in the
body or a protocol extension’s where clause.
2018-08-14 23:17:57 -07:00
Doug Gregor
afefae337e [Name lookup] Factor out the check controlling member lookup into a nominal. 2018-08-14 23:17:57 -07:00
Jordan Rose
8b83291750 [AST] Don't look at a type's members when checking inherited types
Without this, we were firing off way more InheritedDeclsReferenced-
Requests than were actually needed. This drops it way down in the
profile, for what I /think/ is minor wins in type-checking the
stdlib...but it's hard to tell, since the time varies from run to run.
2018-08-14 23:17:57 -07:00
Jordan Rose
a5f84ec2f6 [AST] Drop redundant ProtocolDecl::TrailingWhereClause
There's already a field for this in GenericContext, which ProtocolDecl
indirectly inherits. Protocols may have slightly different treatment
of their where-clauses, but not enough to justify a separate field.

No functionality change.
2018-08-14 23:17:57 -07:00
Doug Gregor
8a81ea45fb [Name lookup] Teach lookupQualified() to accept TypeDecls.
Rather than require clients of lookupQualified() to resolve
their type declarations to nominal type declarations (and
separately cope with modules), have lookupQualified() accept
an array of TypeDecls and handle the resolution to nominal
type declarations (where it can look directly) and module
declarations, combining the results.
2018-08-14 14:40:51 -07:00
Jordan Rose
910894a970 Merge pull request #18597 from jrose-apple/well-worn-path
Cache ConformanceAccessPaths in GSB::EquivalenceClass for big wins
2018-08-14 11:42:15 -07:00
Doug Gregor
b08a6f56b4 [AST] Drop resilience expansion from TypeBase::getReferenceCounting().
We’re not using this parameter, and don’t expect to do so in the future,
so remove it. Also fold away TypeBase::usesNativeReferenceCounting()
and irgen::getReferenceCountingForType(), both of which are trivial.
2018-08-14 09:10:49 -07:00
Doug Gregor
36dc43a97d [AST] Use ProtocolDecl::createGenericParamsIfMissing() where appropriate.
Thanks to @slavapestov for noticing that I hard-coded this, badly.
2018-08-14 08:47:14 -07:00
Doug Gregor
0a26e333bb Switch two simple callers over to decl-based lookupQualified. 2018-08-14 02:39:24 -07:00
Doug Gregor
5e0a7fdab9 [Name lookup] Teach shadowing to avoid validating decls until needed.
Rather than validating the signature of any declaration found by
name lookup, first check whether there is a collision on the full name
of the declaration. This should result in fewer declaration validations.
2018-08-14 02:19:13 -07:00
Doug Gregor
6384d080b1 Merge pull request #18539 from DougGregor/unqualified-lookup-via-decls
[Name lookup] Use decl-based name lookup more regularly
2018-08-14 05:18:59 -04:00
Doug Gregor
d1a43617cc [Conformance lookup table] Drop unnecessary LazyResolver parameters.
There is no point in threading LazyResolver parameters through this
data structure; we can recover the resolver in the one place it is 
needed.
2018-08-14 01:05:42 -07:00
Doug Gregor
5fbd7567af [Type checker] Don’t form a cycle when printing a request on an extension. 2018-08-13 22:31:09 -07:00
Doug Gregor
0e81b40ae0 [AST Verifier] Remove verifyProtocolList().
The property that we are checking for here isn’t really local to the
nominal type or extension declaration, and triggers semantic queries
that aren’t needed elsewhere. Remove it, because it’s not adding value.
2018-08-13 22:31:09 -07:00
Slava Pestov
c0e33277f3 AST: Convert builtins to use AnyFunctionType::Param 2018-08-13 21:13:10 -07:00
Slava Pestov
d31d35a788 AST: Remove a few usages of TypeBase::getInOutObjectType() 2018-08-13 21:13:10 -07:00
Slava Pestov
31a570d53c AST: Replace TypeBase::getRValueInstanceType() with getMetatypeInstanceType()
That is, don't look through InOutType anymore, and update callers to
call getInOutObjectType() as well (or not, where it was obvious to me
that InOutType could not appear).

This surfaces more remaining uses of getInOutObjectType() directly.
2018-08-13 21:13:10 -07:00
Doug Gregor
5b6b0b6ab1 [Name lookup] Turn the "Self bounds of a where clause" query into a request.
Name lookup within a protocol extension also looks into protocols and
superclasses on the right-hand side of Self constraints in the where
clause, e.g., "Self: Foo". Turn that function into a request to avoid
infinite recursion on invalid code.
2018-08-13 19:03:35 -07:00
Doug Gregor
ba93ed25db [Conformance lookup table] Delete unnecessary call to bindExtension(). 2018-08-13 19:03:35 -07:00
Doug Gregor
09c46ad101 [AST] Eliminate the unused by ComputingInheritedProtocols in ProtocolDecl. 2018-08-13 19:03:35 -07:00
Doug Gregor
064652693b Remove LazyResolver::resolveExtensionForConformanceConstruction().
This is no longer used. NFC
2018-08-13 19:03:35 -07:00
Doug Gregor
cc9ac43f22 [AST] Use declaration-based name lookup in the conformance lookup table.
This avoids a call into the lazy resolver simply to figure out which
protocols a type conforms to.
2018-08-13 19:03:35 -07:00
Doug Gregor
a1fe426866 [Name lookup] Use decl-based name lookup for unqualified lookup.
Within unqualified name lookup, replace uses of Type-based lookup
(formed from calls to getSelfTypeInContext()) with declaration-based
name lookup, so that name lookup doesn't depend directly on the type
checker.

The main oddity here is that we need to consider "Self: Foo"
requirements within a protocol extension during name lookup, so that
we will also look into "Foo". This is handled via the basic
name-lookup facilities that allow us to resolve TypeReprs to
declarations without going through the type checker.
2018-08-13 19:03:35 -07:00
Slava Pestov
80a7ae100b SIL: Treat __shared and __owned just like inout when lowering function types
Even with an opaque abstraction pattern, we must explode a
parameter list containing __shared and __owned elements.

Otherwise, we produce invalid lowered SIL types.

Note that this is already an issue, because the stdlib has a
handful of declarations using __owned.
2018-08-12 01:09:45 -07:00
Slava Pestov
432924018c Sema: Remove TupleType::getVarArgsBaseType()
Or, actually, now that there's only one usage left move it to CSDiag.
Hopefully, both vararg tuple types and CSDiag are going away
eventually.
2018-08-11 22:28:36 -07:00
Slava Pestov
f2ae23a2ab AST: Remove TupleType::getElementForScalarInit()
This is a legacy holdover from when tuple types had default
arguments, and also the constraint solver's matching of function
types pre-SE-0110.

Well, move the last live usage to CSDiag, where it can die a slow
painful death over time. The other usages were not doing anything.
2018-08-11 22:26:44 -07:00
Slava Pestov
f44ff38db4 AST: Remove unused ParamDecl::getParameterFlags() 2018-08-11 03:29:16 -07:00
Slava Pestov
471f10f0bc AST: Remove tuple-forming methods on ParameterList 2018-08-11 03:29:16 -07:00
Slava Pestov
d48c8ab67a AST: Convert computeType() methods to use ParameterList::getParams()
This is mostly NFC; the output of the api-digester test changed because
the interface type of an enum element now has parentheses around the
'Self' parameter type. This is more consistent with everything else
(and in the future, all function types will have "parentheses").
2018-08-11 03:29:16 -07:00
Slava Pestov
6f0a062bb7 AST: Introduce ParameterList::getParams()
This converts a list of ParameterDecls into a list of
AnyFunctionType::Params; it will eventually replace
these methods on ParameterList:

- getType() (both overloads)
- getInterfaceType()
- getFullInterfaceType()
2018-08-11 03:29:16 -07:00