mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ASTGen] Wrap optional binding pattern with type annotation
This commit is contained in:
@@ -161,6 +161,14 @@ extension ASTGenVisitor {
|
||||
// I'm not sure this should really be implicit.
|
||||
pat.setImplicit()
|
||||
|
||||
if let typeAnnotation = node.typeAnnotation {
|
||||
pat = BridgedTypedPattern.createParsed(
|
||||
self.ctx,
|
||||
pattern: pat,
|
||||
type: self.generate(type: typeAnnotation.type)
|
||||
).asPattern
|
||||
}
|
||||
|
||||
let initializer: BridgedExpr
|
||||
if let initNode = node.initializer {
|
||||
initializer = self.generate(expr: initNode.value)
|
||||
|
||||
@@ -116,6 +116,17 @@ func testThen() {
|
||||
}
|
||||
}
|
||||
|
||||
func intOrString() -> Int? { 1 }
|
||||
func intOrString() -> String? { "" }
|
||||
func testIf() {
|
||||
if
|
||||
let i: Int = intOrString(),
|
||||
case let str? = intOrString() as String?
|
||||
{
|
||||
_ = (i, str)
|
||||
}
|
||||
}
|
||||
|
||||
struct GenericTypeWithYields<T> {
|
||||
var storedProperty: T?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user