File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -785,6 +785,10 @@ AvailabilityContext Decl::getAvailabilityForLinkage() const {
785
785
if (auto *accessor = dyn_cast<AccessorDecl>(this ))
786
786
return accessor->getStorage ()->getAvailabilityForLinkage ();
787
787
788
+ if (auto *ext = dyn_cast<ExtensionDecl>(this ))
789
+ if (auto *nominal = ext->getExtendedNominal ())
790
+ return nominal->getAvailabilityForLinkage ();
791
+
788
792
auto *dc = getDeclContext ();
789
793
if (auto *ext = dyn_cast<ExtensionDecl>(dc))
790
794
return ext->getAvailabilityForLinkage ();
@@ -806,6 +810,10 @@ bool Decl::isAlwaysWeakImported() const {
806
810
if (auto *accessor = dyn_cast<AccessorDecl>(this ))
807
811
return accessor->getStorage ()->isAlwaysWeakImported ();
808
812
813
+ if (auto *ext = dyn_cast<ExtensionDecl>(this ))
814
+ if (auto *nominal = ext->getExtendedNominal ())
815
+ return nominal->isAlwaysWeakImported ();
816
+
809
817
auto *dc = getDeclContext ();
810
818
if (auto *ext = dyn_cast<ExtensionDecl>(dc))
811
819
return ext->isAlwaysWeakImported ();
Original file line number Diff line number Diff line change
1
+ @available ( macOS 10 . 60 , * )
2
+ public struct Foo {
3
+ public init ( ) { }
4
+ }
5
+
6
+ extension Foo {
7
+ public func extensionMethod( ) { }
8
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ //
3
+ // RUN: %target-swift-frontend -enable-library-evolution -emit-module -target x86_64-apple-macosx10.60 -emit-module-path %t/weak_import_extension_helper.swiftmodule -parse-as-library %S/Inputs/weak_import_extension_helper.swift
4
+ // RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target x86_64-apple-macosx10.50 | %FileCheck %s --check-prefix=CHECK-OLD
5
+ // RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -target x86_64-apple-macosx10.60 | %FileCheck %s --check-prefix=CHECK-NEW
6
+ //
7
+ // REQUIRES: OS=macosx
8
+
9
+ import weak_import_extension_helper
10
+
11
+ @available ( macOS 10 . 60 , * )
12
+ public func callsExtensionMethod( ) {
13
+ Foo ( ) . extensionMethod ( )
14
+ }
15
+
16
+ // CHECK-OLD: declare extern_weak swiftcc %swift.metadata_response @"$s28weak_import_extension_helper3FooVMa"
17
+ // CHECK-OLD: declare extern_weak swiftcc void @"$s28weak_import_extension_helper3FooVACycfC"
18
+ // CHECK-OLD: declare extern_weak swiftcc void @"$s28weak_import_extension_helper3FooV0C6MethodyyF"
19
+
20
+ // CHECK-NEW: declare swiftcc %swift.metadata_response @"$s28weak_import_extension_helper3FooVMa"
21
+ // CHECK-NEW: declare swiftcc void @"$s28weak_import_extension_helper3FooVACycfC"
22
+ // CHECK-NEW: declare swiftcc void @"$s28weak_import_extension_helper3FooV0C6MethodyyF"
You can’t perform that action at this time.
0 commit comments