mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Sema: Fix regression with -experimental-skip-non-inlinable-function-bodies-without-types
My recent capture analysis refactoring broke a subtle corner case that wasn't exercised by the test suite. If a local inside g() was skipped, but the outer function was not skipped, we would return the empty list of captures for g(). But if the interface type of g() actually involves an outer generic parameter type, then the empty capture list did not record the fact that a generic signature was needed, so we attempted to form a call to the local function without a generic signature.
This commit is contained in:
@@ -627,16 +627,16 @@ public:
|
||||
|
||||
CaptureInfo CaptureInfoRequest::evaluate(Evaluator &evaluator,
|
||||
AbstractFunctionDecl *AFD) const {
|
||||
BraceStmt *body = AFD->getTypecheckedBody();
|
||||
|
||||
auto type = AFD->getInterfaceType();
|
||||
if (type->is<ErrorType>() || body == nullptr)
|
||||
if (type->is<ErrorType>())
|
||||
return CaptureInfo::empty();
|
||||
|
||||
bool isNoEscape = type->castTo<AnyFunctionType>()->isNoEscape();
|
||||
FindCapturedVars finder(AFD->getLoc(), AFD, isNoEscape,
|
||||
AFD->isObjC(), AFD->isGeneric());
|
||||
body->walk(finder);
|
||||
|
||||
if (auto *body = AFD->getTypecheckedBody())
|
||||
body->walk(finder);
|
||||
|
||||
if (!AFD->isObjC()) {
|
||||
finder.checkType(type, AFD->getLoc());
|
||||
|
||||
16
test/SILGen/skip_local_function_bodies.swift
Normal file
16
test/SILGen/skip_local_function_bodies.swift
Normal file
@@ -0,0 +1,16 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types %s -emit-module-path %t/skip_local_function_bodies.swiftmodule
|
||||
|
||||
public protocol P {
|
||||
init()
|
||||
}
|
||||
|
||||
extension P {
|
||||
public func f() {
|
||||
typealias T = Self
|
||||
|
||||
func g(_ x: T) {}
|
||||
g(self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user