Skip to content

Commit c21568b

Browse files
author
Nathan Hawes
committed
[AST] Fix assertion hit in AutoClosureExpr::getUnwrappedCurryThunkExpr()
For DoubleCurryThunk cases it’s expecting an ApplyExpr directly within the OpenExistentialExpr, but in some cases it contains an ErasureExpr (implicit conversion) that wraps the ApplyExpr. This updates the method to look through implicit conversions. Resolves rdar://problem/61885996
1 parent a0a432e commit c21568b

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)