Skip to content

[FixCode] Apply coercion fixits on return statement and initialization. #4379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4040,6 +4040,8 @@ bool FailureDiagnosis::diagnoseContextualConversionError() {
case CTP_DictionaryKey:
case CTP_DictionaryValue:
case CTP_AssignSource:
case CTP_Initialization:
case CTP_ReturnStmt:
tryRawRepresentableFixIts(diag, CS, exprType, contextualType,
KnownProtocolKind::ExpressibleByIntegerLiteral,
expr) ||
Expand Down
8 changes: 8 additions & 0 deletions test/FixCode/fixits-apply-objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ func foo(an : Any) {
let a3 : AnyObject!
a3 = an
}

func foo1(_ an : Any) {
let obj: AnyObject = an
}

func foo2(_ messageData: Any?) -> AnyObject? {
return messageData
}
8 changes: 8 additions & 0 deletions test/FixCode/fixits-apply-objc.swift.result
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ func foo(an : Any) {
let a3 : AnyObject!
a3 = an as AnyObject!
}

func foo1(_ an : Any) {
let obj: AnyObject = an as AnyObject
}

func foo2(_ messageData: Any?) -> AnyObject? {
return messageData as AnyObject?
}
2 changes: 1 addition & 1 deletion test/FixCode/fixits-apply.swift.result
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct MyMask : OptionSet {
}

func supported() -> MyMask {
return MyMask.Bingo
return MyMask(rawValue: UInt(MyMask.Bingo))
}

struct MyEventMask2 : OptionSet {
Expand Down