mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CSBindings] Revert changes in BindingSet::isViable
This change although correct cases performance issues in some scenarios.
This commit is contained in:
@@ -1208,19 +1208,7 @@ bool BindingSet::isViable(PotentialBinding &binding, bool isTransitive) {
|
||||
if (!existingNTD || NTD != existingNTD)
|
||||
continue;
|
||||
|
||||
// What is going on here needs to be thoroughly re-evaluated,
|
||||
// but at least for now, let's not filter bindings of different
|
||||
// kinds so if we have a situation like: `Array<$T0> conv $T1`
|
||||
// and `$T1 conv Array<(String, Int)>` we can't lose `Array<$T0>`
|
||||
// as a binding because `$T0` could be inferred to
|
||||
// `(key: String, value: Int)` and binding `$T1` to `Array<(String, Int)>`
|
||||
// eagerly would be incorrect.
|
||||
if (existing->Kind != binding.Kind) {
|
||||
// Array, Set and Dictionary allow conversions, everything else
|
||||
// requires their generic arguments to match exactly.
|
||||
if (existingType->isKnownStdlibCollectionType())
|
||||
continue;
|
||||
}
|
||||
// FIXME: What is going on here needs to be thoroughly re-evaluated.
|
||||
|
||||
// If new type has a type variable it shouldn't
|
||||
// be considered viable.
|
||||
|
||||
37
test/Constraints/rdar139812024.swift
Normal file
37
test/Constraints/rdar139812024.swift
Normal file
@@ -0,0 +1,37 @@
|
||||
// RUN: %target-typecheck-verify-swift %clang-importer-sdk
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// rdar://139812024 - error: cannot convert return expression of type 'NSObject' to return type 'NSImage'
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc
|
||||
final class Image: NSObject {
|
||||
}
|
||||
|
||||
@available(*, unavailable)
|
||||
extension Image: Sendable {} // expected-note {{explicitly marked unavailable here}}
|
||||
|
||||
class Lock<State> {
|
||||
func withLock<R: Sendable>(_: @Sendable (inout State) -> R) -> R {
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
extension Lock where State == Void {
|
||||
func withLock<R: Sendable>(_: @Sendable () -> R) -> R {
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
var images: [Int: Image] = [:]
|
||||
|
||||
func fetchImage(lock: Lock<Void>, id: Int) -> Image? {
|
||||
if let existingImage = lock.withLock({ return images[id] }) { // expected-warning {{unavailable}}
|
||||
return existingImage
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user