mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When re-typechecking an expression during diagnostics, we begin by erasing all the types in the expression. However, any expressions created as part of applying the solution will remain. CSGen was doing the wrong thing when it encountered EnumIsCaseExpr, which can only appear in already-type checked ASTs. Returning expr->getType() is not correct, because the type is not yet set; returning a null type is intended to signal that a diagnostic was already emitted, which causes Sema to stop type checking. The end result is that certain combinations of invalid code with an 'is' cast nested inside would crash either the AST verifier (with asserts on) or in SILGen (with asserts off), because we would stop trying to diagnose the issue prematurely, and possibly not emit a diagnostic at all. Fixes <https://bugs.swift.org/browse/SR-5050> and <rdar://problem/32487948>.
13 lines
187 B
Swift
13 lines
187 B
Swift
// RUN: not %target-swift-frontend %s -typecheck
|
|
// REQUIRES: asserts
|
|
|
|
protocol P {}
|
|
|
|
func bar(p: P?) {
|
|
foo(p is String)
|
|
}
|
|
|
|
func foo<T>(_: T, _: T) {}
|
|
func foo<T>(_: T?, _: T?) {}
|
|
|