Commit Graph

6423 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
Robert Widmann
2a7eee86fc Merge pull request #8908 from CodaFi/space-engine
Redo Exhaustiveness Analysis
2017-04-28 21:28:31 -04: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
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
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
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
Doug Gregor
7be3a142f9 Merge pull request #9093 from DougGregor/warn-unavailable-witnesses
[Type checker] Warn about unavailable witnesses used to satisfy a requirement
2017-04-28 10:20:59 -07:00
Robert Widmann
39494b2ba2 Rearrange test code for exhaustiveness 2017-04-28 02:06:39 -04: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
Doug Gregor
9ebc4caa41 [Type checker] Warn about unavailable witnesses used to satisfy a requirement. 2017-04-27 22:40:21 -07:00
John Holdsworth
fea17f22aa [Parse] Add support for multiline strings inside interpolations
Adds support for multiline string literals to appear inside of string interpolations. Tests added.
2017-04-27 19:02:23 -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
Maxim Moiseev
41b00c57ab Merge pull request #9044 from moiseev/substring-in
[stdlib] Substring
2017-04-26 19:25:59 -07:00
John McCall
7bb263161a Fix a semantic bug in CSApply's optional-to-optional application.
Implicit conversions from T?? to U?? would map nil to some(nil) instead of nil.
2017-04-26 17:24:17 -04: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
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
John Holdsworth
981e706fd9 An implementation for 0168-multi-line-string-literals.md (#8813)
This adds support for SE-0168, multi-line string literals.

Extend the lexer to recognize the new literals. Test cases added.

There are still areas for future diagnostic improvement, such as fixits and notes as to why a multi-line string literal will be malformed. Multi-line literals are explicitly forbidden inside of string interpolation, though this may be relaxed in the future.
2017-04-25 18:13:03 -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
c0104a26ad [gardening] Remove unused diagnostics 2017-04-25 21:03:42 +02:00
Jacopo Andrea Giola
4c05532090 Change emitted error for @nonobjc invalid usage (#8480) 2017-04-25 10:11:26 -07:00
John McCall
e6d52d8808 LValueToPointerExpr is dead code. RIP LValueToPointerExpr. 2017-04-25 03:01:16 -04: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
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
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
swift-ci
cd262be2c6 Merge pull request #8955 from DougGregor/associated-type-override-hints 2017-04-24 09:11:38 -07:00
Andrew Trick
48ecd6d563 [Exclusivity] Enable SILGen access marker emission by default.
This has no measurable effect on benchmarks and does not affect
standard library compile time.
2017-04-24 08:32:15 -07:00
Doug Gregor
de66b0c25c [GSB] Warn about redeclarations of associated types from inherited protocols.
Introduce a warning about redeclaring the associated types from an
inherited protocol in the protocol being checked:

* If the new declaration is an associated type, note that the
  declaration could be replaced by requirements in the protocol's
  where clause.
* If the new declaration is a typealias, note that it could be
  replaced by a same-type constraint in the protocol's where clause.
2017-04-24 07:55:42 -07:00
Devin Coughlin
9cdff5fe00 [Exclusivity] Improve static enforcement diagnostics
Static diagnostics now refer to the identifier for the variable requiring
exclusive diagnostics. Additionally, when two accesses conflict we now always
emit the main diagnostic on the first modifying access and the note on either
the second modifying access or the read.

The diagnostics also now highlight the source range for the expression
beginning the access.
2017-04-23 11:39:25 -07:00
Slava Pestov
07c189558c Sema: Improve the fixit for 'Self' in invalid places
In an extension of a nested type, the extended type must be
fully qualified.

Also clean up the diagnostic logic a little bit and centralize
it in diagnoseUnknownType().

Fixes <https://bugs.swift.org/browse/SR-4379>.
2017-04-23 01:10:40 -07:00
Slava Pestov
7f3c97bf8b AST: More consistent spelling of 'type alias' in diagnostics
Some messages said 'typealias' and others said 'type alias'.
Change everything to use 'type alias' consistently (except
when it's talking about the keyword itself).
2017-04-23 00:02:30 -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
Joe Groff
3d178be169 Merge pull request #8875 from jckarter/keypaths
Keypaths
2017-04-21 17:51:17 -07:00
Huon Wilson
d0739294ed Merge pull request #8887 from huonw/emit-loaded-module-trace
[Frontend] -frontend -emit-loaded-module-trace.
2017-04-21 13:25:52 -07:00
Jordan Rose
f1902fd719 [Serialization] Drop typealiases whose underlying types have changed. (#8896)
In order to accomplish this, cross-module references to typealiases
are now banned except from within conformances and NameAliasTypes, the
latter of which records the canonical type to determine if the
typealias has changed. For conformances, we don't have a good way to
check if the typealias has changed without trying to map it into
context, but that's all right---the rest of the compiler can already
fall back to the canonical type.
2017-04-21 13:17:12 -07:00
Huon Wilson
87aa3e6935 [Frontend] -frontend -emit-loaded-module-trace.
The -frontend jobs can output a JSON file summarizing the
swiftmodules (etc.) they load during compilation.
2017-04-21 11:14:29 -07:00
Xi Ge
c55b43efc0 [Migrator] Add the simple transformation from global variables to static member variables. (#8865)
This should also handle global string to string enum migration.
2017-04-20 18:36:33 -07:00
practicalswift
8b2a0b693f [gardening] Remove unused diagnostic 2017-04-20 13:47:10 +02:00
Slava Pestov
16b033c111 Merge pull request #8876 from slavapestov/subclass-existentials-sema-casts
Update Sema cast checks for subclass existentials... and more!
2017-04-20 01:28:53 -07:00
swift-ci
0f4ebfd66e Merge pull request #8593 from DougGregor/stdlib-se-0142 2017-04-20 00:49:04 -07:00
Slava Pestov
f4b91cd118 AST: Remove unused 'resolver' argument from TypeBase::getSuperclass() 2017-04-20 00:37:38 -07:00
Doug Gregor
a926beab5b [GSB] Hack to limit recursion in the type graph.
This stops after 5 recurrences of the same associated type. It is a
gross hack and a terrible idea, here as a placeholder to prevent us
from running off the rails in ill-formed code. This will go away when
we get further along the path with recursive protocol constraints.
2017-04-20 00:09:23 -07:00
Joe Groff
595e0e4ede Merge branch 'master' into keypaths 2017-04-19 18:38:24 -07:00
Graydon Hoare
6a94c9fb9e Merge pull request #8735 from graydon/rdar-30959593-operators-defeat-incrementality
Attribute @_implements & deriving enum equality not-named ==
2017-04-19 11:18:55 -07:00
Doug Gregor
e48f4191ca [GSB] Add EquivalenceClass::dump(). NFC 2017-04-19 08:42:05 -07:00
swift-ci
504b6f2a55 Merge pull request #8852 from DougGregor/protocol-conformance-cleanups 2017-04-19 00:05:06 -07:00
Doug Gregor
8584e97408 [AST] Sink ProtocolConformance::getWitness() down into NormalProtocolConformance.
NormalProtocolConformance has the only correct implementation of this
functionality. Instead, providing a safer getWitnessDecl() that
doesn't promise substitutions that are incorrect (and not actually
used by any clients).
2017-04-18 23:35:24 -07:00
Graydon Hoare
e6027eeb4e Derive @_implements(Equatable, ==(_:_:)) _DerivedEnumEquals, not func==. 2017-04-18 23:21:44 -07:00