Commit Graph

5778 Commits

Author SHA1 Message Date
swift-ci
f15cad3609 Merge remote-tracking branch 'origin/master' into master-next 2017-04-28 20:08:31 -07:00
Doug Gregor
447dce6c1f Merge pull request #9004 from itaiferber/swift-archival-serialization
Swift Archival & Serialization API
2017-04-28 20:02:33 -07:00
swift-ci
9ee70173bc Merge remote-tracking branch 'origin/master' into master-next 2017-04-28 18:48:32 -07:00
Robert Widmann
2a7eee86fc Merge pull request #8908 from CodaFi/space-engine
Redo Exhaustiveness Analysis
2017-04-28 21:28:31 -04:00
swift-ci
09e110f874 Merge remote-tracking branch 'origin/master' into master-next 2017-04-28 17:48:31 -07:00
swift-ci
b8fda57cb9 Merge pull request #9114 from eeckstein/fix-tuple-mangling 2017-04-28 17:47:39 -07:00
Doug Gregor
ebd34ec597 Merge pull request #9106 from DougGregor/sub-map-concrete-generic-params
[Substitution Map] Handle substitutions of generic parameters made concrete
2017-04-28 17:39:50 -07:00
swift-ci
e0d9eeb4bb Merge remote-tracking branch 'origin/master' into master-next 2017-04-28 17:08:36 -07:00
Graydon Hoare
cd48479d14 Merge pull request #9110 from graydon/grab-bag-of-metrics
Add an assortment of new "always-on" metrics.
2017-04-28 16:59:09 -07:00
Erik Eckstein
ae49b6939b Mangling: fix mangling of functions with a single empty tuple argument
For example:
	func testit(_ x: ()) -> Int
2017-04-28 16:51:34 -07:00
Doug Gregor
6ef76a92f4 [AST] Use flat array storage for SubstitutionMap's replacement types.
The replacement types in a SubstitutionMap correspond with the generic
parameters of its generic signature, so replace the DenseMap storage
with a flat array of Types, one element for each generic parameter.
2017-04-28 16:22:07 -07:00
Doug Gregor
93435d17d6 [Substitution Map] Handle substitutions of generic parameters made concrete.
If SubstitutionMap is asked to form a substitution for a generic
parameter that has been made concrete by the generic signature,
substitute into the concrete type. This allows us to better deal with
non-canonical types.
2017-04-28 16:22:07 -07:00
swift-ci
32094e9d34 Merge remote-tracking branch 'origin/master' into master-next 2017-04-28 14:48:32 -07:00
Graydon Hoare
b5292f04f8 Add an assortment of new "always-on" metrics. 2017-04-28 13:56:13 -07:00
Slava Pestov
3130c3cbd7 AST: Remove an overload of GenericSignature::getSubstitutions() 2017-04-28 13:26:02 -07:00
Robert Widmann
42c59554a0 Introduce the Space Engine
Implement exhaustiveness checking in Sema with rich error messages.  The
algorithm used is a variant of the one described in Fengyun Liu's paper
"A Generic Algorithm for Checking Exhaustivity of Pattern Matching"
published in the EPFL conference, and Luc Maranget's seminal paper
"Warnings for Pattern Matching"

The Space Engine views pattern matching as a problem of projecting the
scrutinee of a pattern-match into a "Space", then iteratively
constructing a Space from the cases.  Taking the difference of this
master space and the covered spaces yields the "holes" left over or
reveals a completely covered space.

The algorithm also extends trivially to redundancy checks in patterns,
but that check is already implemented in SILGen and this algorithm does
not improve upon it.
2017-04-28 02:06:39 -04:00
swift-ci
cdde06ac25 Merge remote-tracking branch 'origin/master' into master-next 2017-04-27 15:56:02 -07:00
Itai Ferber
bdfa92703d Fix crash in AST printing
Extensions need not have nominal types, e.g.

    extension Int : Codable { ... }

where

    typealias Codable = Encodable & Decodable
2017-04-27 12:42:13 -07:00
Jordan Rose
888894c5ba Merge pull request #8987 from jrose-apple/canonicalize-on-swift-4
[ClangImporter] Always import types under their Swift 4 name.
2017-04-27 10:14:02 -07:00
Erik Eckstein
76eca003bb ArrayElementValuePropagation: explicitly reserve space for new elements when doing the array-content-of optimization
When Array.append(contentOf:) is replaced by individual Array.append(element) calls, an explicit reserveCapacityForAppend is inserted.
2017-04-27 09:06:56 -07:00
swift-ci
b2d71ecc14 Merge pull request #9064 from DougGregor/typealias-infer-same-type-requirements 2017-04-26 22:44:29 -07:00
Maxim Moiseev
41b00c57ab Merge pull request #9044 from moiseev/substring-in
[stdlib] Substring
2017-04-26 19:25:59 -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
John McCall
338825e73d Fix the emission of r-value pointer conversions to delay the
conversions and extend lifetimes over the call.

Apply this logic to string-to-pointer conversions as well as
array-to-pointer conversions.

Fix the AST verifier to not blow up on optional pointer conversions,
and make sure we SILGen them correctly.  There's still an AST bug
here, but I'll fix that in a follow-up patch.
2017-04-26 14:15:44 -04:00
Itai Ferber
c515b53fcc Remove unnecessary enum case check 2017-04-26 11:06:38 -07:00
practicalswift
ab5aaeb359 Merge pull request #9001 from practicalswift/gardening-20170425
[gardening] Unused variables. Unused diagnostics. Namespace comments. Typos.
2017-04-26 09:28:24 +02:00
Jordan Rose
4b87bd93f9 Tweak DiagnosticEngine's 'aka' logic to only kick in for typealiases. (#9010)
Previously we had more ad hoc logic that tried to decide if it was
worth desugaring a type based on its structure. Now we instead look
for a typealias that might actually benefit from desugaring, and if
we don't find one we won't show the 'aka' note.
2017-04-25 19:37:22 -07:00
Doug Gregor
e858c553cb [GSB] Start inferring same-type requirements from inherited type declarations.
Infer same-type requirements among same-named associated
types/typealiases within inherited protocols. This is more staging; it
doesn't really have teeth until we stop wiring together these types as
part of lookup.
2017-04-25 16:13:48 -07:00
Max Moiseev
42703c9978 Making compiler recognize Substring and allow _ObjectiveCBridgeable conformance 2017-04-25 15:02:51 -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
practicalswift
ff827e0455 [gardening] Fix recently introduced typos 2017-04-25 21:03:44 +02:00
practicalswift
4ef5c6d840 [gardening] Remove unused variables 2017-04-25 21:03:41 +02:00
John McCall
e6d52d8808 LValueToPointerExpr is dead code. RIP LValueToPointerExpr. 2017-04-25 03:01:16 -04:00
Argyrios Kyrtzidis
9b9c84a708 Merge pull request #8972 from akyrtzi/index-external-symbol-namespacing
[index] Use a #pragma to apply module namespacing for exported ObjC header and match Swift namespaced USRs with the clang side
2017-04-24 21:13:12 -07:00
Michael Gottesman
a89752f77a [gardening] Eliminate unused variable warnings from non-asserts build. 2017-04-24 16:08:06 -07:00
Slava Pestov
0290c2d5d8 AST: Make GenericSignature and GenericEnvironment SubstitutionMaps interchangable
SubstitutionMap::lookupConformance() would map archetypes out
of context to compute a conformance path. Do the same thing
in SubstitutionMap::lookupSubstitution().

The DenseMap of replacement types in a SubstitutionMap now
always has GenericTypeParamTypes as keys.

This simplifies some code and brings us one step closer to
a more efficient representation of SubstitutionMaps.
2017-04-24 14:12:36 -07:00
Argyrios Kyrtzidis
093e826f92 [index] Use a #pragma to apply module namespacing for exported ObjC header and match Swift namespaced USRs with the clang side 2017-04-24 14:02:16 -07:00
swift-ci
33ffab28b0 Merge pull request #8967 from DougGregor/ast-verifier-partially-checked 2017-04-24 12:49:02 -07:00
swift-ci
b0ff277c2a Merge remote-tracking branch 'origin/master' into master-next 2017-04-24 11:48:41 -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
swift-ci
771cdb8a82 Merge remote-tracking branch 'origin/master' into master-next 2017-04-24 11:08:52 -07:00
Jordan Rose
d123794829 Merge pull request #8849 from jrose-apple/error-structs-are-an-illusion
[ClangImporter] Error structs from enums are not imported decls
2017-04-24 10:52:19 -07:00
swift-ci
23e9881528 Merge remote-tracking branch 'origin/master' into master-next 2017-04-24 10:28:40 -07:00
swift-ci
febd996c35 Merge pull request #8960 from DougGregor/lookupconformance-use-after-scope 2017-04-24 10:10:40 -07:00
Jordan Rose
e575d2d5ba [ClangImporter] Error structs from enums are not imported decls.
Enums with the ns_error_domain attribute represent codes for NSError,
which means Swift developers will expect to interact with them in
terms of Error. SE-0112 improved bridging for these enums to generate
a struct with the following form:

    struct MyError: Error {
      @objc enum Code: RawRepresentable {
        case outOfMemory
        case fileNotFound
      }
      var userInfo: [NSObject: AnyObject] { get }
      static var outOfMemory: Code { get }
      static var fileNotFound: Code { get }
    }

where MyError.Code corresponds to the original MyError enum defined in
Objective-C. Until recently, both the enum and the synthesized struct
were marked as having the original enum as their "Clang node", but
that leads to problems: the struct isn't really ObjC-compatible, and
the two decls have the same USR. (The latter had already been worked
around.)

This commit changes the struct to be merely considered a synthesized
"external definition", with no associated Clang node. This meant
auditing everywhere that's looking for a Clang node and seeing which
ones applied to external definitions in general.

There is one regression in quality here: the generated struct is no
longer printed as part of the Swift interface for a header file, since
it's not actually a decl with a corresponding Clang node. The previous
change to AST printing mitigates this a little by at least indicating
that the enum has become a nested "Code" type.
2017-04-24 09:57:41 -07:00
Jordan Rose
129fd372d5 ASTPrinter: Qualify names when printing nested declarations.
That is, if you have this declaration:

    struct Outer {
      struct Inner {
        // ...
      }
    }

and you're just printing 'Inner', print it like this:

    struct Outer.Inner {
      // ...
    }

This comes up with the ClangImporter's import-as-member feature, and
is also about to affect how error code enums are imported as well.

This is currently only enabled in certain contexts: always when
printing interfaces, and for types (but not other members) when
printing declarations for Quick Help.

rdar://problem/28208090
2017-04-24 09:57:40 -07:00
Jordan Rose
25985cb764 [Mangling] Uniformly use "So" for imported decls.
...and repurpose "SC" for (C)lang-importer-synthesized decls, instead
of just decls that are C-like instead of ObjC-like. (See next commits.)
2017-04-24 09:57:30 -07:00
Doug Gregor
2c32f72303 [AST Verifier] Tolerate partially-validated ASTs.
We can get partially-validated ASTs when they are created by the Clang
importer, but not otherwise needed or after new code can be
introduced. Avoid doing the "checked" verification on such ASTs, to
make assertions-enabled builds more useful for testing.

This is the wrong long-term solution: the AST verifier should tolerate
partially-type-checked ASTs at a finer granularity, but doing so is a
larger project than I can take on at the moment.
2017-04-24 09:46:18 -07:00
swift-ci
70b8773fb5 Merge remote-tracking branch 'origin/master' into master-next 2017-04-24 09:28:38 -07:00
swift-ci
cd262be2c6 Merge pull request #8955 from DougGregor/associated-type-override-hints 2017-04-24 09:11:38 -07:00