Commit Graph

12 Commits

Author SHA1 Message Date
Mark Lacey
01ae11769c [Migrator] Re-enable wrap_optional.swift test.
This had to be reworked a bit to deal with the fact that IUOs are no
longer a distinct type and there were uses of IUOs that are not
supported after SE-0054.

Fixes: rdar://problem/37040141
2018-05-31 14:43:11 -07:00
Mark Lacey
e43ff7164c Merge pull request #14299 from rudkx/iuo-remove-the-type
IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>
2018-02-01 21:58:37 -08:00
David Ungar
c6b4e8bc2b Change tests to specify same number of -o's as primary inputs. 2018-02-01 13:41:00 -08:00
Mark Lacey
f08823757a IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>.
Stop creating ImplicitlyUnwrappedOptional<T> so that we can remove it
from the type system.

Enable the code that generates disjunctions for Optional<T> and
rewrites expressions based on the original declared type being 'T!'.

Most of the changes supporting this were previously merged to master,
but some things were difficult to merge to master without actually
removing IUOs from the type system:
- Dynamic member lookup and dynamic subscripting
- Changes to ensure the bridging peephole still works

Past commits have attempted to retain as much fidelity with how we
were printing things as possible. There are some cases where we still
are not printing things the same way:
- In diagnostics we will print '?' rather than '!'
- Some SourceKit and Code Completion output where we print a Type
  rather than Decl.

Things like module printing via swift-ide-test attempt to print '!'
any place that we now have Optional types that were declared as IUOs.

There are some diagnostics regressions related to the fact that we can
no longer "look through" IUOs. For the same reason some output and
functionality changes in Code Completion. I have an idea of how we can
restore these, and have opened a bug to investigate doing so.

There are some small source compatibility breaks that result from
this change:
- Results of dynamic lookup that are themselves declared IUO can in
  rare circumstances be inferred differently. This shows up in
  test/ClangImporter/objc_parse.swift, where we have
    var optStr = obj.nsstringProperty
  Rather than inferring optStr to be 'String!?', we now infer this to
  be 'String??', which is in line with the expectations of SE-0054.
  The fact that we were only inferring the outermost IUO to be an
  Optional in Swift 4 was a result of the incomplete implementation of
  SE-0054 as opposed to a particular design. This should rarely cause
  problems since in the common-case of actually using the property rather
  than just assigning it to a value with inferred type, we will behave
  the same way.
- Overloading functions with inout parameters strictly by a difference
  in optionality (i.e. Optional<T> vs. ImplicitlyUnwrappedOptional<T>)
  will result in an error rather than the diagnostic that was added
  in Swift 4.1.
- Any place where '!' was being used where it wasn't supposed to be
  allowed by SE-0054 will now treat the '!' as if it were '?'.
  Swift 4.1 generates warnings for these saying that putting '!'
  in that location is deprecated. These locations include for example
  typealiases or any place where '!' is nested in another type like
  `Int!?` or `[Int!]`.

This commit effectively means ImplicitlyUnwrappedOptional<T> is no
longer part of the type system, although I haven't actually removed
all of the code dealing with it yet.

ImplicitlyUnwrappedOptional<T> is is dead, long live implicitly
unwrapped Optional<T>!

Resolves rdar://problem/33272674.
2018-01-31 12:15:58 -08:00
Robert Widmann
71bf312a25 Migrate the rest of the tests to %empty-directory 2017-06-04 11:08:39 -07:00
Xi Ge
fa78d9259e migrator/test: move all API diff data files to Inputs directory. NFC (#10074) 2017-06-02 14:20:35 -07:00
Ben Langmuir
257c1a6caf [migrator] Fix cities vs. Cities case consistency in tests 2017-05-19 10:41:15 -07:00
Nathan Hawes
0410f17c1b [Migrator] Fix optional types not being updated correctly in some cases
If the replacement type was a function type or protocol-constrained type (e.g.  'Class & Proto) and the existing type had a postfix ? or !, we weren't wrapping the replacement in parens. This would result in an incorrect/ambiguous new type. This patch wraps the replacement in parens if it contains an & or ->, the existing type has a trailing ? or !.

Resolves rdar://problem/32082269.
2017-05-09 12:08:13 -07:00
Nathan Hawes
0d97d55eae [migrator] Don't walk into user-specified (and possibly generic) type aliases when applying API type changes 2017-05-02 16:23:58 -07:00
David Farler
bf52ff032a [Migrator] Conservative and Minimal @objc inference workflows
Based on recommendations in SE-0160, there are two migration workflows:

- Conservative: Maintain @objc visibility that was inferred in Swift 3
  by adding @objc to all declarations that were implicitily visible to
  the Objective-C runtime. This is invoked in the migrator by adding the
  -migrate-keep-objc-visibility flag.
- Minimal: Only declarations that must be visible to Objective-C based
  on their uses (or in cases like dynamic vars) are migrated.

rdar://problem/31876357
2017-04-28 18:28:34 -07:00
Nathan Hawes
76dc4210c4 Change %swift -> %target-swift-frontend 2017-04-28 16:08:41 -07:00
Nathan Hawes
8ad6aa4e0d [migrator] Add pass for API type changes
This handles optionality changes and type rewrites in function param and return types and constructor param and failability types.
Resolves rdar://problem/31766010
2017-04-27 22:19:52 -07:00