[SE-0111 SILGen] Dropping labels can make TupleTypes disappear; deal with it.
diff --git a/lib/SILGen/SILGenPoly.cpp b/lib/SILGen/SILGenPoly.cpp
index c72b4b0..769fd41 100644
--- a/lib/SILGen/SILGenPoly.cpp
+++ b/lib/SILGen/SILGenPoly.cpp
@@ -812,7 +812,10 @@
if (outputOrigType.isTuple() &&
outputOrigType.getNumTupleElements() == 1) {
outputOrigType = outputOrigType.getTupleElementType(0);
- outputSubstType = cast<TupleType>(outputSubstType).getElementType(0);
+ if (auto outputSubstTuple = dyn_cast<TupleType>(outputSubstType)) {
+ if (outputSubstTuple->getNumElements() > 0)
+ outputSubstType = outputSubstTuple.getElementType(0);
+ }
return translate(inputOrigType, inputSubstType,
outputOrigType, outputSubstType);
}
diff --git a/test/SILGen/generic_closures.swift b/test/SILGen/generic_closures.swift
index e2c2c6d..12621c8 100644
--- a/test/SILGen/generic_closures.swift
+++ b/test/SILGen/generic_closures.swift
@@ -1,4 +1,5 @@
// RUN: %target-swift-frontend -parse-stdlib -emit-silgen %s | FileCheck %s
+// RUN: %target-swift-frontend -parse-stdlib -emit-silgen -suppress-argument-labels-in-types %s | FileCheck %s
import Swift
diff --git a/test/SILGen/partial_apply_init.swift b/test/SILGen/partial_apply_init.swift
index 403178b..66aaf46 100644
--- a/test/SILGen/partial_apply_init.swift
+++ b/test/SILGen/partial_apply_init.swift
@@ -1,4 +1,5 @@
// RUN: %target-swift-frontend -emit-silgen %s | FileCheck %s
+// RUN: %target-swift-frontend -emit-silgen -suppress-argument-labels-in-types %s | FileCheck %s
class C {
init(x: Int) {}