Skip to content

Commit 2109051

Browse files
committed
Frontend: Allow -emit-module-interface with -resolve-imports
Experimental mode for generating module interfaces without running primary file type-checking. The idea is that the ASTPrinter triggers requests to only do the minimum amount of type checking work possible while printing the interface for a module's public declarations. These requests may emit diagnostics, but the ASTPrinter should in theory already be robust against invalid code.
1 parent 2fcfa7e commit 2109051

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Frontend/FrontendOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ bool FrontendOptions::canActionEmitInterface(ActionType action) {
705705
switch (action) {
706706
case ActionType::NoneAction:
707707
case ActionType::Parse:
708-
case ActionType::ResolveImports:
709708
case ActionType::DumpParse:
710709
case ActionType::DumpInterfaceHash:
711710
case ActionType::DumpAST:
@@ -727,6 +726,7 @@ bool FrontendOptions::canActionEmitInterface(ActionType action) {
727726
case ActionType::ScanDependencies:
728727
case ActionType::PrintFeature:
729728
return false;
729+
case ActionType::ResolveImports:
730730
case ActionType::Typecheck:
731731
case ActionType::MergeModules:
732732
case ActionType::EmitModuleOnly:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -resolve-imports %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
4+
// RUN: %FileCheck %s < %t/main.swiftinterface
5+
6+
// CHECK: import Swift
7+
8+
// CHECK: public func f() -> Swift.Int
9+
public func f() -> Int {}
10+
11+
// Deliberate semantic errors to ensure private and internal declarations don't
12+
// get type checked.
13+
private func bad1(_: NotAThing) -> DoesNotExist {}
14+
15+
internal typealias Bad1 = NotEvenReal.DefinitelyNot

0 commit comments

Comments
 (0)