Commit Graph

1137 Commits

Author SHA1 Message Date
Doug Gregor
447dce6c1f Merge pull request #9004 from itaiferber/swift-archival-serialization
Swift Archival & Serialization API
2017-04-28 20:02:33 -07:00
Graydon Hoare
b5292f04f8 Add an assortment of new "always-on" metrics. 2017-04-28 13:56:13 -07:00
Jordan Rose
dbc148bfb3 [ClangImporter] Tag compatibility aliases as such...
...so we can avoid showing an 'aka' for them...unless they are
themselves typealiases.
2017-04-26 13:07:03 -07:00
Itai Ferber
c515b53fcc Remove unnecessary enum case check 2017-04-26 11:06:38 -07:00
Itai Ferber
e2318392be Add CodingKey and *codable derived conformance
* Allow CodingKey conformance to be automatically derived for enums
  which have no raw type (with no associated values) and which have
  a raw type of String or Int.
* Allow Encodable and Decodable conformance to be automatically derived
  for classes and structs with Encodable/Decodable properties
* Add initial unit tests for verifying derived conformance
2017-04-25 13:13:35 -07:00
Jordan Rose
7397340ca8 Don't inherit convenience inits if a designated init is missing. (#8708)
(which can happen if an imported class has un-importable initializers)

Our initializer model guarantees that it's safe to inherit convenience
initializers when a subclass has implemented all designated
initializers, since each convenience initializer will be implemented
by calling one of the designated initializers. If one of the
designated initializers /can't/ be implemented in Swift, however,
then inheriting the convenience initializer would not be safe.

This is potentially a source-breaking change, so the importer will
only actually record that it failed to import something in when
compiling in Swift 4 mode.

rdar://problem/31563662
2017-04-24 11:47:54 -07:00
Doug Gregor
facf1996b1 [Clang importer] Don't transfer IBAction attributes that don't make sense.
Fixes an error emitted on declarations imported from Objective-C,
rdar://problem/31776315.
2017-04-22 21:38:23 -07:00
Graydon Hoare
c25210f6eb Move IsUserAccessible bit from VarDecl up to ValueDecl (and adjust bits). 2017-04-18 23:21:43 -07:00
Graydon Hoare
3a79d83233 Forward declare TypeRepr in TypeLoc.h, adjust other code to compensate. 2017-04-18 11:12:53 -07:00
Huon Wilson
53b4e7044f Merge pull request #8822 from huonw/symbol-list-5
Yet more TBDGen work: mostly classes.
2017-04-18 11:04:57 -07:00
Doug Gregor
17846e2be1 [GSB] Cope with recursive requirements by delaying them.
Rather than detecting recursion and bailing early, delay requirements
that would form recursive types. Note that we aren't actually
processing them later.
2017-04-17 23:13:21 -07:00
Huon Wilson
5ce7289db8 [AST] No redundant clang node check for metaclass ObjC-ness.
It seems that any type that has a clang node will have a non-NonObjC
ObjCClassKind, so this Or expression was essentially `foo() || true`.
2017-04-17 17:15:16 -07:00
Huon Wilson
d26c9791e5 [AST] Classes know their appropriate metaclass. 2017-04-17 11:28:55 -07:00
Doug Gregor
faa0401598 [GSB] Allow requirement inference for synthesized requirements. 2017-04-14 17:19:02 -07:00
practicalswift
7684e73388 Merge pull request #8706 from practicalswift/excess-logic
[gardening] Remove redundant logic
2017-04-12 09:51:49 +02:00
Robert Widmann
5b3c4b6844 [NFC] Use the presence of an argument type to check for associated values (#8679)
* Use the presence of an argument type to check for associated values

hasOnlyCasesWithoutAssociatedValues returns true for any serialized
enum declaration whether or not it has cases.  This never really came
up because it's mostly relevant to Sema's proto-deriving mechanism.  Fix
this by using the presence of the case's argument type instead.

* Separate checks for presence of cases and enum simplicity

Necessary because the old behavior was an artifact of the
implementation.
2017-04-11 20:13:17 -04:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
Slava Pestov
ad417c96ad AST: Update ProtocolCompositionType::requiresClass() for subclass existentials
Whether a protocol composition requires a class is no longer
solely a property of what protocols it contains; now, a
protocol composition consisting of a non-class constrained
protocol and a superclass should return true from requiresClass().

This is done by looking at the ExistentialLayout, instead of
walking the members directly.
2017-04-10 17:05:43 -07:00
Slava Pestov
37491e63ac AST: Refactor existential type accessors on TypeBase and CanType 2017-04-03 23:14:25 -07:00
Slava Pestov
9a3f0fc527 Sema: Fix for SourceKit crash in inheritsSuperclassInitializers()
Two problems:

1) We were tearing down the type checker too early, before all
   relevant decls in other files had been type checked, so there
   was no LazyResolver available for use in the ASTContext.

   This might explain the crashes coming through
   diagnoseUnintendedObjCMethodOverrides().

2) When a lazy resolver was set in the ASTContext, we were not
   using it in the case where nullptr was passed in as the
   'resolver' parameter to inheritsSuperclassInitializers().

   This might fix the crashes where we were coming in from other
   code paths, but I'm less confident about this case.

Possibly fixes <rdar://problem/29043074>, <rdar://problem/30976765>,
<rdar://problem/31122590>, and <rdar://problem/31286627>, and the
many other similar-looking dupes.
2017-03-31 00:04:17 -07:00
Xi Ge
75e191f5ac AST: Summarize a commonly used call chain in AbstractFunctionDecl. NFC (#8424) 2017-03-30 10:51:10 -07:00
Slava Pestov
a79ef97c32 AST: Repent for my sins by adding new assertions
Since the previous fix is essentially a hack to dodge an
assertion, I'm adding stronger assertions to
AbstractTypeParamDecl::getSuperclass() and
getConformingProtocols().
2017-03-30 02:03:53 -07:00
Slava Pestov
91b980b94d SILGen: Dynamic, curry, foreign thunks should be serializable
This fixes a crash when referencing partially-applied methods
from @_inlineable functions.

Also, curry thunks for private methods do not need shared
linkage; private is sufficient.
2017-03-29 21:35:25 -07:00
Slava Pestov
53759f7126 Use ValueDecl::isDynamic() instead of getAttrs().hasAttribute<DynamicAttr>() 2017-03-29 00:46:43 -07:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
David Hart
ecdcac5aa2 Resolve crasher 28704 (#8158)
This crash happens because shouldAddSelfFixit (a check for the expected_self_before_reference diagnotic) performs name lookup inside the parser, which causes a search for extensions, which triggers the mangler, which can get confused if we are in an unfinished declaration (a PatternBindingInitilizer in this case).

A cleaner fix would be to move that logic inside Sema, but it would require much more refactoring that I don’t feel comfortable doing. Instead, this band-aid checks if the innermost type is inside a local context. If that’s the case, we can ignore the search for extensions.
2017-03-17 18:43:23 -07:00
Huon Wilson
ca3a398b4a Merge pull request #8021 from huonw/protocol-where-clause
Parse/typecheck/print where clauses on protocols
2017-03-15 11:00:46 -07:00
Slava Pestov
f0e3459068 AST: Fix compiler_crasher regression from associated type where clause work
New GenericTypeParamDecls should always be created with an
InvalidDepth, to prevent canonicalization before the generic
parameter list has been type checked.
2017-03-14 00:10:43 -07:00
Slava Pestov
aaa995a626 AST: Remove unnecessary AllocateCopy() calls
A GenericSignature stores parameters and requirements inside its own
allocation, so there's no need to copy them.
2017-03-14 00:10:43 -07:00
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
Alex Hoppen
dd1c661c16 Merge pull request #8015 from ahoppen/isOperator-gardening
[Gardening] Change calls of getName().isOperator() to isOperator()
2017-03-10 21:10:33 +00:00
Alex Hoppen
1b7055db5a [Gardening] Change calls of getName().isOperator() to isOperator() 2017-03-10 09:06:20 +00:00
Huon Wilson
54f247693c [AST]/[Parse] parse where clauses on protocol declarations. 2017-03-09 16:08:16 -08:00
Slava Pestov
df81e51f36 AST: Add TypeBase::getRootGenericParam() utility method 2017-03-08 13:54:29 -08:00
Doug Gregor
dbf5782d56 [GSB] Provide a root potential archetype for requirement-signature sources. 2017-02-28 09:42:06 -08:00
Doug Gregor
40a813bc8d [GenericSigBuilder] Sink RequirementSource into GenericSignatureBuilder. 2017-02-28 09:41:23 -08:00
Doug Gregor
5c2fe3496f Merge pull request #7740 from huonw/parse-assoc-type-where
(Mostly) Type-check where clauses on associated types
2017-02-27 22:06:51 -08:00
Doug Gregor
fafb244ee4 [AST] Add ProtocolDecl::walkInheritedProtocols.
Use this in ProtocolDecl::requiresClassSlow(), and hope its presence
discourages more potentially-infinitely-recursive walks of the
inherited-protocols lists.
2017-02-27 15:57:18 -08:00
Doug Gregor
09a5807c30 [AST] Teach ProtocolDecl::requiresClassSlow() to tolerate recursive protocol inheritance.
Recursive protocol inheritance is ill-formed, but we should
nonetheless tolerate it within the AST rather than infinitely recursing.
2017-02-27 15:24:01 -08:00
Huon Wilson
644f6df424 [AST] getInterfaceType never returns null, so guard it.
There's no point testing for null on the next line after just calling
getInterfaceType(), because that function asserts that the interface
type exists.
2017-02-24 22:00:59 -08:00
Huon Wilson
5e1bb40298 [AST] Compute the (trivial) generic signature of a protocol on demand. 2017-02-24 19:24:13 -08:00
Huon Wilson
84e0a109a2 [AST] Explicitly track the validation state of Decls.
Previously some decls (TypeAliasDecl and ExtensionDecl) had bits
explicitly marking whether they've been validated, while other decls
just deduced this from hasInterfaceType. The doing the latter doesn't
work when the interface type can be computed before doing full
validation (such as protocols and associatedtypes, which have trivial
interface types), and so an explicit bit is adopted for all decls.
2017-02-24 19:21:33 -08:00
Huon Wilson
8423018057 [Parse] Parse trailing where clauses on associated types. 2017-02-24 19:21:32 -08:00
Slava Pestov
fdb0a18647 AST: Add a GenericParamList::clone() method
This will be immediately needed for generic subscripts, and also
for fixing the remaining cases where initializer inheritance
doesn't work.
2017-02-23 20:57:15 -08:00
Slava Pestov
ecda075792 AST: Fix signature of GenericParamList::create() 2017-02-23 20:57:14 -08:00
Xi Ge
2e447dc812 NameTranslation: ensure that preferred names are preferred to implicit names in @objc(). rdar://30658589 (#7692)
Implicit names in @objc() are essentially cached auto-translated Swift names. This patch ensures that we don't mistake them for explicitly specified objc selectors.
2017-02-22 14:48:19 -08:00
Nathan Hawes
444775f58a Merge pull request #7670 from nathawes/rdar16271632
Use clang-style USRs for swift decls that are exposed to Objective C
2017-02-21 17:00:28 -08:00
Nathan Hawes
0dc0985f45 Move SwiftNameTranslation implementation out of Decl.cpp and into its own file.
Also fix code formatting issues and simplify the code in USRGeneration.cpp based on review comments in PR #7670.
2017-02-21 14:54:31 -08:00
Nathan Hawes
c9758c2c0f Use clang-style USRs for swift decls that are exposed to Objective C 2017-02-21 09:42:33 -08:00
Slava Pestov
a79fd9eff1 Merge pull request #7639 from slavapestov/sourcekit-indexing-protocol-typealias
SourceKit: Fix indexing crash with protocol typealiases
2017-02-20 12:07:37 -08:00