Skip to content

Commit 314a43d

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents 6b42b9c + b191390 commit 314a43d

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ unsigned LocalDiscriminatorsRequest::evaluate(
412412
ParameterList *params = nullptr;
413413
ParamDecl *selfParam = nullptr;
414414
if (auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
415-
node = func->getBody();
415+
if (!func->isBodySkipped())
416+
node = func->getBody();
416417
selfParam = func->getImplicitSelfDecl();
417418
params = func->getParameters();
418419

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t/stats)
2+
3+
// RUN: %target-swift-frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types -module-name Mod -emit-module-path %t/Mod.swiftmodule -stats-output-dir %t/stats %s
4+
// RUN: %{python} %utils/process-stats-dir.py --set-csv-baseline %t/stats.csv %t/stats
5+
// RUN: %FileCheck -input-file %t/stats.csv %s
6+
7+
// The printing implementation differs in asserts and no-asserts builds, it will
8+
// either print `"Parse.NumFunctionsParsed" 0` or not print it at all. Make sure
9+
// we don't output any non-zero value.
10+
// CHECK-NOT: {{"Parse.NumFunctionsParsed" [^0]}}
11+
12+
// Make sure we skip parsing these bodies.
13+
public func foo(x: Int, y: Int) {}
14+
15+
public func bar() {
16+
func baz() {}
17+
}
18+
19+
public struct S {
20+
public func qux() {}
21+
}

test/Parse/issue-74561.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// Make sure we can parse with and without skipping.
4+
// RUN: %target-typecheck-verify-swift
5+
// RUN: not %target-swift-frontend -emit-module -experimental-skip-non-inlinable-function-bodies -module-name Mod -emit-module-path %t/Mod.swiftmodule -diagnostic-style=llvm %s 2>&1 | %FileCheck %s
6+
7+
// https://github.com/swiftlang/swift/issues/74561
8+
// Make sure we can parse this.
9+
#sourceLocation(file: "A", line: 3)
10+
public func foo(_ param: Int) {
11+
#sourceLocation()
12+
}
13+
14+
// FIXME: This should parse correctly.
15+
#sourceLocation(file: "B", line: 3)
16+
@inlinable
17+
public func bar(_ param: Int) {
18+
#sourceLocation()
19+
}
20+
// CHECK: B:6:1: error: parameterless closing #sourceLocation() directive without prior opening #sourceLocation(file:,line:) directive

0 commit comments

Comments
 (0)