File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 23
23
#include " swift/AST/TypeWalker.h"
24
24
#include " swift/AST/Types.h"
25
25
#include " swift/Basic/Platform.h"
26
+ #include " swift/ClangImporter/ClangModule.h"
26
27
#include < map>
27
28
28
29
using namespace swift ;
@@ -312,7 +313,7 @@ bool Decl::isAvailableDuringLowering() const {
312
313
UnavailableDeclOptimization::Complete)
313
314
return true ;
314
315
315
- if (hasClangNode ( ))
316
+ if (isa<ClangModuleUnit>( getDeclContext ()-> getModuleScopeContext () ))
316
317
return true ;
317
318
318
319
return !isUnconditionallyUnavailable (this );
@@ -325,6 +326,9 @@ bool Decl::requiresUnavailableDeclABICompatibilityStubs() const {
325
326
UnavailableDeclOptimization::Stub)
326
327
return false ;
327
328
329
+ if (isa<ClangModuleUnit>(getDeclContext ()->getModuleScopeContext ()))
330
+ return false ;
331
+
328
332
return isUnconditionallyUnavailable (this );
329
333
}
330
334
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: split-file %s %t
3
+ // RUN: %target-swift-emit-silgen %t/Overlay.swift -I %t -import-objc-header %t/MyOptions.h -unavailable-decl-optimization=none | %FileCheck %t/Overlay.swift
4
+ // RUN: %target-swift-emit-silgen %t/Overlay.swift -I %t -import-objc-header %t/MyOptions.h -unavailable-decl-optimization=stub | %FileCheck %t/Overlay.swift
5
+ // RUN: %target-swift-emit-silgen %t/Overlay.swift -I %t -import-objc-header %t/MyOptions.h -unavailable-decl-optimization=complete | %FileCheck %t/Overlay.swift
6
+
7
+ //--- MyOptions.h
8
+
9
+ __attribute__ ( ( availability ( swift, unavailable, message= " Unavailable in Swift " ) ) )
10
+ typedef enum : int {
11
+ SomeOption,
12
+ } MyOptions;
13
+
14
+ typedef MyOptions MyOptionsTypedef;
15
+
16
+ //--- Overlay.swift
17
+
18
+ // This really shouldn't be allowed, but it is.
19
+ let _ = MyOptionsTypedef ( rawValue: 1 )
20
+
21
+ // CHECK-LABEL: sil shared [transparent] [serialized]{{.*}} @$sSo9MyOptionsa8rawValueABs5Int32V_tcfC : $@convention(method) (Int32, @thin MyOptions.Type) -> MyOptions {
22
+ // CHECK-NOT: ss31_diagnoseUnavailableCodeReacheds5NeverOyFTwb
23
+ // CHECK: } // end sil function '$sSo9MyOptionsa8rawValueABs5Int32V_tcfC'
You can’t perform that action at this time.
0 commit comments