[Sema] Ignore types with type variables in filterEscapableLifetimeDependencies

If the type still has type variables, avoid trying to check if it's
escapable.

rdar://148749815
This commit is contained in:
Hamish Knight
2025-04-08 14:07:19 +01:00
parent ead547d989
commit 87f9dcb6f8
3 changed files with 33 additions and 1 deletions

View File

@@ -58,7 +58,12 @@ filterEscapableLifetimeDependencies(GenericSignature sig,
for (auto &depInfo : inputs) {
auto targetIndex = depInfo.getTargetIndex();
Type substTy = getSubstTargetType(targetIndex);
// If the type still contains type variables we don't know whether we
// can drop the dependency.
if (substTy->hasTypeVariable())
continue;
// Drop the dependency if the target type is Escapable.
if (sig || !substTy->hasTypeParameter()) {
if (substTy->isEscapable(sig)) {

View File

@@ -0,0 +1,18 @@
// RUN: %batch-code-completion -enable-experimental-feature LifetimeDependence
// REQUIRES: swift_feature_LifetimeDependence
infix operator ^^^
extension Optional where Wrapped: ~Escapable & ~Copyable {
@lifetime(copy self) mutating func foo() -> Self { fatalError() }
}
func ^^^ <T: ~Escapable & ~Copyable> (_ x: Int, _ y: borrowing T?) {}
// https://github.com/swiftlang/swift/issues/80591 - Make sure we don't crash
// here.
func foo() {
_ = 1 ^^^ .#^COMPLETE^#
// COMPLETE: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: foo({#(self): &Optional<~Copyable & ~Escapable>#})[#() -> Optional<~Copyable & ~Escapable>#]; name=foo(:)
}

View File

@@ -0,0 +1,9 @@
// RUN: %batch-code-completion
// https://github.com/apple/swift/issues/80591
// Just make sure we don't crash.
var foo: Bool {
baz == .#^COMPLETE^#
// COMPLETE: Begin completions
}