Sema: Fix crash in type resolution when tuple type contains type variables

This can happen when we're generating constraints and resolving the
type annotations written in a closure expression. Just skip the
non-copyable check in this case.

Fixes rdar://problem/143031466.
This commit is contained in:
Slava Pestov
2025-01-24 16:58:52 -05:00
parent e4887c7193
commit 9ddfc9e47b
2 changed files with 6 additions and 0 deletions

View File

@@ -5676,6 +5676,7 @@ NeverNullType TypeResolver::resolveTupleType(TupleTypeRepr *repr,
inStage(TypeResolutionStage::Interface) &&
!moveOnlyElementIndex.has_value() &&
!ty->hasUnboundGenericType() &&
!ty->hasTypeVariable() &&
!isa<TupleTypeRepr>(tyR)) {
auto contextTy = GenericEnvironment::mapTypeIntoContext(
resolution.getGenericSignature().getGenericEnvironment(), ty);

View File

@@ -0,0 +1,5 @@
// RUN: %target-typecheck-verify-swift
func foo<T>(_: () -> (Optional<T>, Int)) -> T { fatalError() }
let x: Int = foo { () -> (Optional, Int) in fatalError() }