Skip to content

Commit 8b4bde5

Browse files
authored
Merge pull request swiftlang#35855 from CodaFi/i-spi
Fix a Simple Crash-On-Invalid For @_spi
2 parents fb47182 + 013127a commit 8b4bde5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ static void maybeAddMemberwiseDefaultArg(ParamDecl *arg, VarDecl *var,
147147
if (var->isLet())
148148
return;
149149

150+
// If there's no parent pattern there's not enough structure to even perform
151+
// this analysis. Just bail.
152+
if (!var->getParentPattern())
153+
return;
154+
150155
// We can only provide default values for patterns binding a single variable.
151156
// i.e. var (a, b) = getSomeTuple() is not allowed.
152157
if (!var->getParentPattern()->getSingleVar())
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
3+
public struct PeakMemoryUsage {
4+
public let rawValue: UInt64
5+
6+
@_spi( init(rawValue: UInt64) {
7+
self.rawValue = rawValue
8+
}
9+
}

0 commit comments

Comments
 (0)