Skip to content

Commit ac67317

Browse files
authored
Merge pull request #17871 from slavapestov/fix-coerce-existential-crash-4.2
Sema: Fix crash with UnresolvedType in coerceExistential() [4.2]
2 parents 104c96a + 3c18462 commit ac67317

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

lib/Sema/CSApply.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5543,9 +5543,11 @@ Expr *ExprRewriter::coerceExistential(Expr *expr, Type toType,
55435543
Type toInstanceType = toType;
55445544

55455545
// Look through metatypes
5546-
while (fromInstanceType->is<AnyMetatypeType>() &&
5546+
while ((fromInstanceType->is<UnresolvedType>() ||
5547+
fromInstanceType->is<AnyMetatypeType>()) &&
55475548
toInstanceType->is<ExistentialMetatypeType>()) {
5548-
fromInstanceType = fromInstanceType->castTo<AnyMetatypeType>()->getInstanceType();
5549+
if (!fromInstanceType->is<UnresolvedType>())
5550+
fromInstanceType = fromInstanceType->castTo<AnyMetatypeType>()->getInstanceType();
55495551
toInstanceType = toInstanceType->castTo<ExistentialMetatypeType>()->getInstanceType();
55505552
}
55515553

test/Constraints/diagnostics.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,3 +1187,9 @@ func badTypes() {
11871187
// expected-error@-1 {{type of expression is ambiguous without more context}}
11881188
// FIXME: terrible diagnostic
11891189
}
1190+
1191+
// rdar://34357545
1192+
func unresolvedTypeExistential() -> Bool {
1193+
return (Int.self==_{})
1194+
// expected-error@-1 {{ambiguous reference to member '=='}}
1195+
}

validation-test/compiler_crashers/28739-unreachable-executed-at-swift-lib-ast-type-cpp-229.swift renamed to validation-test/compiler_crashers_fixed/28739-unreachable-executed-at-swift-lib-ast-type-cpp-229.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
(Int==_{

0 commit comments

Comments
 (0)