Skip to content

Commit 0a0b9f7

Browse files
author
Nathan Hawes
authored
Merge pull request #31352 from nathawes/fix-assertion-hit-in-getUnwrappedCurryThunkExpr
[AST] Fix assertion hit in AutoClosureExpr::getUnwrappedCurryThunkExpr()
2 parents 1882c40 + f78c930 commit 0a0b9f7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/AST/Expr.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1897,6 +1897,8 @@ Expr *AutoClosureExpr::getUnwrappedCurryThunkExpr() const {
18971897

18981898
if (auto *openExistential = dyn_cast<OpenExistentialExpr>(innerBody)) {
18991899
innerBody = openExistential->getSubExpr();
1900+
if (auto *ICE = dyn_cast<ImplicitConversionExpr>(innerBody))
1901+
innerBody = ICE->getSyntacticSubExpr();
19001902
}
19011903

19021904
if (auto *outerCall = dyn_cast<ApplyExpr>(innerBody)) {

test/Index/roles.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,14 @@ func useDefaultInits() {
520520
// CHECK: [[@LINE-1]]:15 | instance-property/Swift | y | s:14swift_ide_test7BStructV1ySbvp | Ref,RelCont
521521
// CHECK: [[@LINE-2]]:7 | constructor/Swift | init(x:y:z:) | s:14swift_ide_test7BStructV1x1y1zACSi_SbSStcfc | Ref,Call,RelCall,RelCont | rel: 1
522522
}
523+
524+
internal protocol FromInt {
525+
init(_ uint64: Int)
526+
}
527+
extension Int: FromInt { }
528+
func test<M>(_: M, value: Int?) {
529+
if let idType = M.self as? FromInt.Type {
530+
_ = value.flatMap(idType.init) as? M
531+
// CHECK: [[@LINE-1]]:34 | constructor/Swift | init(_:) | s:14swift_ide_test7FromIntPyxSicfc | Ref,RelCont | rel: 1
532+
}
533+
}

0 commit comments

Comments
 (0)