Commit Graph

76 Commits

Author SHA1 Message Date
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Timur Islamgulov
56d1d6bbd3 Sema: Add a fix-it for integer literal to option set conversion. (#13899)
If expression type is IntegerLiteralExpr and value is equal to '0',
suggest '[]' as a replacement.

Resolves: rdar://problem/20704317 / SR-6716.
2018-01-12 13:34:49 -08:00
Max Moiseev
a167238d1d Fixing more tests 2017-01-12 15:54:56 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Robin Kunde
71364d0d09 fix SR-3168: add fix-it for "'optional' can only be applied to protocol members" (#5717) 2016-11-11 14:00:45 +09:00
practicalswift
c4a6c054b1 Merge pull request #4855 from practicalswift/spacing-consistency
[gardening] Increase consistency with regards to spacing after colons
2016-09-23 11:20:23 +02:00
Jordan Rose
b9e1d4c21c Don't use construction to convert literals in rawValue fix-it. (#4934)
Input:  panel.styleMask = 8345
Old output:  panel.styleMask = NSWindowStyleMask(rawValue: UInt(8345))
New output:  panel.styleMask = NSWindowStyleMask(rawValue: 8345)

rdar://problem/26681232
2016-09-22 17:36:41 -07:00
practicalswift
ef8e43b519 [gardening] Increase consistency with regards to spacing after colons 2016-09-22 16:28:57 +02:00
Jordan Rose
821cdf368d Merge pull request #4910 from jrose-apple/fix-it-swift_newtype-rawValue
Use the existing '.rawValue' fix-it to handle unwrapping objects too.

rdar://problem/26678862
2016-09-21 18:28:40 -07:00
Jordan Rose
693fd9d455 Use the existing '.rawValue' fix-it to handle unwrapping objects too.
We could probably make this even more general, but this specifically
avoids trying to insert an "as AnyObject" fix-it, which will now work
but probably produce an incorrect result. This comes up when working
with swift_newtype wrappers of CF types being passed to CFTypeRef
parameters.

rdar://problem/26678862
2016-09-21 17:16:26 -07:00
Jordan Rose
fea7878806 Auto-apply the new generic parameter fix-it during migration.
Last bit of rdar://problem/27087345.
2016-09-21 18:04:14 -06:00
Jordan Rose
1d7ad9e38a Better generic fix-its for types as well as construction and casts.
Slava pointed out that we have an existing version of the code from
the previous commit that's only used when checking types. Replace it
with the new code, which handles more cases.
2016-09-21 18:04:14 -06:00
Xi Ge
1f6670f113 [Parser] Correct the fixit for protocol composition's syntax change (#4483)
* [Parser] Correct a fixit to preserve the trailing content after replacing Protocol<A, B>. rdar://27992964

When migrating, we found our fixit to replace the old protocol composition syntax, namely "Protocol<A, B>",
to the new syntax, "A & B", does not preserve the trailing content after '>'. For instance, we replace "Protocol<A, B>?"
with "A & B". This patch fixes the issue by inserting whatever after '>' in the old syntax to the new
replacement string. I consider this as a hack; the root-cause fix should be in the lexer to smartly separate
'>' and '?' as two tokens instead of one.

* [test] Update existing test.
2016-08-24 16:16:11 -07:00
Xi Ge
52273554f4 [FixCode] Add diagnosis/fixit to help users deal with BooleanType's removal (#4392)
* [FixCode] Add diagnosis/fixit to help users deal with BooleanType's removal.

Due to migration reasons, types used to conform to BooleanType, which
must contain a member var 'boolValue', now does not convert to Bool. This patch
adds a specific diagnosis/fixit to explicitly invoke 'boolValue' to please the
context types.

* Address Jordan's code review comments.
2016-08-19 08:29:42 -07:00
Ben Langmuir
a8534530b2 [FixCode] Move AnyObject bits into an objc-interop test
Keep the main test portable by moving the objc_interop bits into their
own test, combined with the existing selector tests.
2016-08-16 18:56:38 -07:00
Argyrios Kyrtzidis
af15fff58b [test] Mark 'test/FixCode/fixits-apply.swift' as requiring 'objc_interop'.
This is because it depends on using AnyObject.
2016-08-16 16:23:23 -07:00
Xi Ge
b620d3ebfe [FixCode] Apply coercion fixit for assignment types' mismatch too. rdar://27681428 2016-08-16 14:28:18 -07:00
Jordan Rose
3d005f3ad9 [Parse] Add fix-its for empty Swift 2 operator decl braces. (#4309)
And improve the error message for non-empty braces; if we're going to
ignore the contents, we should at least point you in the right
direction for Swift 3.

rdar://problem/27576922
2016-08-15 14:43:09 -07:00
Argyrios Kyrtzidis
895dc90513 [FixCode] Disable a migrating fixit that interacts badly with the migrator.
For such code:
  func test(p: Int, _: String) {}
  test(0, "")

the compiler bizarrely suggests to change order of arguments in the call site.
2016-08-12 13:33:46 -07:00
Argyrios Kyrtzidis
0cd8ca56dc [FixCode] Accept the fixit for the warning that @warn_unused_result is the default now.
rdar://27516354
2016-08-12 11:47:14 -07:00
Argyrios Kyrtzidis
72ac89325f Merge pull request #4240 from akyrtzi/typealias-print
[ASTPrinter] Fix printing of nested typealias types and make it consistent with printing of nominal types.
2016-08-11 16:49:00 -07:00
Ben Langmuir
8b42212543 Merge remote-tracking branch 'benlangmuir/fixit-protocol-comp'
Conflicts:
	lib/FrontendTool/FrontendTool.cpp
	test/FixCode/fixits-apply.swift
	test/FixCode/fixits-apply.swift.result
2016-08-11 12:55:21 -07:00
Ben Langmuir
008a57f7e5 Merge pull request #4205 from benlangmuir/fixit-anyobject
[fixcode] Add ( as AnyObject) fixit to the whitelist
2016-08-11 12:52:39 -07:00
Argyrios Kyrtzidis
69918a966d [ASTPrinter] Fix printing of nested typealias types and make it consistent with printing of nominal types.
This fixes several issues:
- By default parent types of alias types are not printed which results in
	- Erroneous fixits, for example when casting to 'Notification.Name' from a string, which ends up adding erroneous cast
	  as "Name(rawValue: ...)"
	- Hard to understand types in code-completion results and diagnostics
- When printing with 'fully-qualified' option typealias types are printed erroneously like this "<PARENT>.Type.<TYPEALIAS>"

The change make typealias printing same as nominal types and addresses the above.
2016-08-11 12:15:15 -07:00
Ben Langmuir
ec539d6abf [fixcode] Enabled protocol<...> fixits
The old syntax is deprecated in swift 3, and these fixits seem quite
safe, so apply them for migration.

rdar://problem/27794981
2016-08-11 10:28:18 -07:00
Argyrios Kyrtzidis
9bd3e48b21 [AST] Fix the source range for InterpolatedStringLiteralExpr.
This allows fixits to be correctly applied when wrapping such an expression.
2016-08-10 15:22:03 -07:00
Ben Langmuir
454ee8a8d9 [fixcode] Add ( as AnyObject) fixit to the whitelist
This fixit comes from a note, but is very useful for migration of code
that has changed from AnyObject to Any but wants to do AnyObject
dispatch.

rdar://problem/27793389
2016-08-10 14:51:59 -07:00
Xi Ge
398f483557 [FixCode] Blacklist the fixit for enum case renames to avoid reverting migrator's change. rdar://27776887 (#4199)
We added the fixit to help users manually migrate enum case references after the declaration
has been renamed; however, when interacting with the migrator, the fixit may revert migrator's
correct changes, when the migrator updates references before updating the declaration. This patch
blacklists the fixit in migrator's pass, so we leave it to users' manually application if necessary.
2016-08-10 13:52:25 -07:00
Michael Ilseman
f48471ebd4 [noescape by default] purge tests of needless @noescape 2016-08-04 16:14:27 -07:00
Argyrios Kyrtzidis
92c0980a88 [FixCode] Make sure to accept the fixit in warning about 'where' syntax change. 2016-08-02 13:00:45 -07:00
Argyrios Kyrtzidis
c04aadb1a8 [FixCode] Make sure to accept the fixit in note about adding '@escaping'. 2016-08-02 10:04:40 -07:00
Michael Ilseman
c37751ae96 [noescape by defaul] make noescape the default
This flips the switch to have @noescape be the default semantics for
function types in argument positions, for everything except property
setters. Property setters are naturally escaping, so they keep their
escaping-by-default behavior.

Adds contentual printing, and updates the test cases.

There is some further (non-source-breaking) work to be done for
SE-0103:

- We need the withoutActuallyEscaping function
- Improve diagnostics and QoI to at least @noescape's standards
- Deprecate / drop @noescape, right now we allow it
- Update internal code completion printing to be contextual
- Add more tests to explore tricky corner cases
- Small regressions in fixits in attr/attr_availability.swift
2016-07-29 13:49:08 -07:00
Doug Gregor
823c24b355 [SE-0112] Rename ErrorProtocol to Error.
This is bullet (5) of the proposed solution in SE-0112, and the last
major piece to be implemented.
2016-07-12 10:53:52 -07:00
Ben Langmuir
e50c232f4b [FixCode] Add another case of inserting ';' to the ban list
We missed one of the fixits that insert ; separators.

rdar://problem/26681061
2016-07-06 17:08:08 -07:00
Ben Langmuir
3f026bea27 [FixCode] Don't add .dynamicType
Adding .dynamicType interacts poorly with the swift migrator by
invalidating some inits with type errors.

rdar://problem/26642062
2016-07-05 09:46:38 -07:00
Ben Langmuir
d5d48f38b6 [FixCode] Apply @* is now an attribute on a parameter type fixits 2016-07-05 09:46:38 -07:00
Ben Langmuir
338f40296b [FixCode] Avoid removing @IB* attributes
If there are type-checking issues, these interact poorly with the
migrator and may remove @IB* attributes unnecessarily.

rdar://problem/26886636
2016-07-05 09:46:37 -07:00
Argyrios Kyrtzidis
7d6f11d217 [sema] Follow-up on the raw-representable casting fixits, produce a fixit for optional source types as well.
For optional source types we use the form "expr.map{ T(rawValue: $0) }".
2016-06-05 18:06:14 -07:00
Ben Langmuir
24988f8c42 [fixits] Don't fixit-remove generic arguments on ModuleType
Seeing Module<Args> is more likely to indicate some catastrophic
failure, for instance a missing type with the same name as the module,
than that we should remove the generic arguments.

rdar://problem/26639477
2016-06-04 18:22:18 -07:00
Argyrios Kyrtzidis
3334a82974 [test] Add an extra test case for f60567e7ba, per feedback by BenL. 2016-06-04 12:18:51 -07:00
Argyrios Kyrtzidis
f60567e7ba [sema] Follow-up on the raw-representable casting fixits, produce the fixit for optional destination types as well. 2016-06-04 11:22:39 -07:00
Ben Langmuir
73f09176e1 [FixCode] Don't accept fixit that inserts commas; they break placeholders
These fixits interact poorly with code that has <#editor placeholder#>s
in it, inserting commas inside the placeholder.

rdar://problem/26623964
2016-06-03 10:47:13 -07:00
Argyrios Kyrtzidis
c1953e0f17 [sema] Add a fixit for missing generic arguments.
When the unbound generic type is missing type arguments try to add a fixit that
infers a generic type list to pass.

rdar://26623703
2016-06-03 09:59:50 -07:00
Argyrios Kyrtzidis
792ab3c8ed [sema] Add compiler fixit for the case where a raw-representable type is constructed from an argument with the same type.
Like this:

  MyEnumType(MyEnumType.foo)

This is missing 'rawValue:' label, but that won't actually fix this. A better fix is to just remove the unnecessary constructor call:

  MyEnumType(MyEnumType.foo)
-->
  MyEnumType.foo
2016-06-03 07:44:50 -07:00
Ben Langmuir
d3b40aa483 [FixCode] Pick up fixit for let->var change
This is an important fixit, but was lost because it is on the note
instead of the error.

rdar://problem/26593117
2016-06-02 10:19:45 -07:00
Argyrios Kyrtzidis
f36cc94f51 [FixCode] Add fix-its for mismatched integer types.
Adds fixits for:
 - Passing an integer with the right type but which is getting wrapped with a
   different integer type unnecessarily. The fixit removes the cast.

 - Passing an integer but expecting different integer type. The fixit adds
   a wrapping cast.
2016-05-31 22:29:28 -07:00
Slava Pestov
4558b5018c Sema: New fix-its for RawRepresentable conversions
If the expression type is RawRepresentable with an associated
RawValue type of T, and the contextual type is T, suggest adding
a '.rawValue' accessor call.

Also, suggest inserting the fixit in a few more cases, such as
dictionary keys.

This improves upon a previous patch which added a fix-it for the
other direction:

<55bf215feb>

Fixes <rdar://problem/26470490>.
2016-05-27 00:26:21 -07:00
Argyrios Kyrtzidis
146be88a6e [FixCode] When picking-up fixits for migration ignore the fixits for adding @objc(selector).
These interact badly with the swift migrator, they are triggered by label mismatches in pre-migrated code.

We also don't generally need them since we do inference for the most common cases.
2016-05-26 17:15:19 -07:00
Argyrios Kyrtzidis
48a063e853 [FixCode] Follow-up for b4a2b53739, ignore another diagnostic fixit that is messing with argument labels. 2016-05-26 17:15:19 -07:00
Argyrios Kyrtzidis
55bf215feb [sema] When the error is "cannot convert value of type <integer> to expected argument type <RawRepresentable>" add a fixit.
The fixit constructs the raw-representable type from the value. This helps with SDK changes.
2016-05-25 07:23:57 -07:00