File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -1889,7 +1889,10 @@ class PatternBindingEntry {
1889
1889
void setPattern (Pattern *P) { PatternAndFlags.setPointer (P); }
1890
1890
1891
1891
// / Whether the given pattern binding entry is initialized.
1892
- bool isInitialized () const ;
1892
+ // /
1893
+ // / \param onlyExplicit Only consider explicit initializations (rather
1894
+ // / than implicitly-generated ones).
1895
+ bool isInitialized (bool onlyExplicit = false ) const ;
1893
1896
1894
1897
Expr *getInit () const {
1895
1898
if (PatternAndFlags.getInt ().contains (Flags::Removed) ||
Original file line number Diff line number Diff line change @@ -1539,9 +1539,9 @@ void PatternBindingEntry::setOriginalInit(Expr *E) {
1539
1539
PatternFlags::IsText);
1540
1540
}
1541
1541
1542
- bool PatternBindingEntry::isInitialized () const {
1542
+ bool PatternBindingEntry::isInitialized (bool onlyExplicit ) const {
1543
1543
// Directly initialized.
1544
- if (getInit ())
1544
+ if (getInit () && (!onlyExplicit || getEqualLoc (). isValid ()) )
1545
1545
return true ;
1546
1546
1547
1547
// Initialized via a property wrapper.
@@ -1833,7 +1833,7 @@ bool PatternBindingDecl::isComputingPatternBindingEntry(
1833
1833
1834
1834
bool PatternBindingDecl::isExplicitlyInitialized (unsigned i) const {
1835
1835
const auto &entry = getPatternList ()[i];
1836
- return entry.isInitialized () && entry. getEqualLoc (). isValid ( );
1836
+ return entry.isInitialized (/* onlyExplicit= */ true );
1837
1837
}
1838
1838
1839
1839
SourceLoc PatternBindingDecl::getEqualLoc (unsigned i) const {
Original file line number Diff line number Diff line change @@ -1809,3 +1809,25 @@ func test_rdar56350060() {
1809
1809
}
1810
1810
}
1811
1811
}
1812
+
1813
+ // rdar://problem/57411331 - crash due to incorrectly synthesized "nil" default
1814
+ // argument.
1815
+ @propertyWrapper
1816
+ struct Blah < Value> {
1817
+ init ( blah _: Int ) { }
1818
+
1819
+ var wrappedValue : Value {
1820
+ let val : Value ? = nil
1821
+ return val!
1822
+ }
1823
+ }
1824
+
1825
+ struct UseRdar57411331 {
1826
+ let x = Rdar57411331 ( other: 5 )
1827
+ }
1828
+
1829
+ struct Rdar57411331 {
1830
+ @Blah ( blah: 17 ) var something : Int ?
1831
+
1832
+ var other : Int
1833
+ }
You can’t perform that action at this time.
0 commit comments