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
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.
* [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.
* [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.
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
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.
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
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.
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
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
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
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.
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>.
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.