Skip to content

[FixCode] Apply coercion fixit for assignment types' mismatch too #4342

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
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
1 change: 1 addition & 0 deletions lib/Sema/CSDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,7 @@ bool FailureDiagnosis::diagnoseContextualConversionError() {
case CTP_ArrayElement:
case CTP_DictionaryKey:
case CTP_DictionaryValue:
case CTP_AssignSource:
tryRawRepresentableFixIts(diag, CS, exprType, contextualType,
KnownProtocolKind::ExpressibleByIntegerLiteral,
expr) ||
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
import ObjectiveC

Expand All @@ -12,3 +12,12 @@ import ObjectiveC
takeSel(Selector("mySel"))
}
}

func foo(an : Any) {
let a1 : AnyObject
a1 = an
let a2 : AnyObject?
a2 = an
let a3 : AnyObject!
a3 = an
}
23 changes: 23 additions & 0 deletions test/FixCode/fixits-apply-objc.swift.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: not %target-swift-frontend(mock-sdk: %clang-importer-sdk) -disable-objc-attr-requires-foundation-module -parse %s -emit-fixits-path %t.remap
// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
import ObjectiveC

// REQUIRES: objc_interop

@objc class Selectors {
func takeSel(_: Selector) {}
func mySel() {}
func test() {
takeSel(#selector(Selectors.mySel))
takeSel(#selector(Selectors.mySel))
}
}

func foo(an : Any) {
let a1 : AnyObject
a1 = an as AnyObject
let a2 : AnyObject?
a2 = an as AnyObject?
let a3 : AnyObject!
a3 = an as AnyObject!
}
14 changes: 0 additions & 14 deletions test/FixCode/fixits-apply-selector.swift.result

This file was deleted.