Skip to content

Commit 6633b8f

Browse files
authored
Merge pull request #11000 from rjmccall/keep-openings-opaque
2 parents 6d3cb14 + b4c10bd commit 6633b8f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/SILGen/SILGenExpr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,11 @@ static BridgingConversion getBridgingConversion(Expr *E) {
593593
return { E, kind, 0 };
594594
}
595595

596+
// If we peeked through an opening, and we didn't recognize a specific
597+
// pattern above involving the opaque value, make sure we use the opening
598+
// as the final expression instead of accidentally look through it.
599+
if (open) return { open, None, 0 };
600+
596601
return { E, None, 0 };
597602
}
598603

test/SILGen/objc_bridging_peephole.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,13 @@ func testNullproneSubscriptSet(object: NullproneSubscript, index: AnyObject) {
472472
// CHECK: end_borrow [[SELF]] from %0
473473
object[index] = makeOptNS() as String?
474474
}
475+
476+
/*** Bugfixes ***************************************************************/
477+
478+
protocol P {
479+
var title : String { get }
480+
}
481+
482+
func foo(p: P) {
483+
DummyClass().takeNullableString(p.title)
484+
}

0 commit comments

Comments
 (0)