Skip to content

Commit 9ddfc9e

Browse files
committed
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.
1 parent e4887c7 commit 9ddfc9e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5676,6 +5676,7 @@ NeverNullType TypeResolver::resolveTupleType(TupleTypeRepr *repr,
56765676
inStage(TypeResolutionStage::Interface) &&
56775677
!moveOnlyElementIndex.has_value() &&
56785678
!ty->hasUnboundGenericType() &&
5679+
!ty->hasTypeVariable() &&
56795680
!isa<TupleTypeRepr>(tyR)) {
56805681
auto contextTy = GenericEnvironment::mapTypeIntoContext(
56815682
resolution.getGenericSignature().getGenericEnvironment(), ty);

test/Constraints/issue-77315.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
func foo<T>(_: () -> (Optional<T>, Int)) -> T { fatalError() }
4+
5+
let x: Int = foo { () -> (Optional, Int) in fatalError() }

0 commit comments

Comments
 (0)