@@ -77,27 +77,42 @@ bool TypeChecker::diagnoseInlineableDeclRef(SourceLoc loc,
77
77
const ValueDecl *D,
78
78
const DeclContext *DC) {
79
79
auto expansion = DC->getResilienceExpansion ();
80
- if (expansion == ResilienceExpansion::Minimal) {
81
- if (!isa<GenericTypeParamDecl>(D) &&
82
- // Protocol requirements are not versioned because there's no
83
- // global entry point
84
- !(isa<ProtocolDecl>(D->getDeclContext ()) && isRequirement (D)) &&
85
- // FIXME: Figure out what to do with typealiases
86
- !isa<TypeAliasDecl>(D) &&
87
- !D->getDeclContext ()->isLocalContext () &&
88
- D->hasAccessibility ()) {
89
- if (D->getEffectiveAccess () < Accessibility::Public) {
90
- diagnose (loc, diag::resilience_decl_unavailable,
91
- D->getDescriptiveKind (), D->getFullName (),
92
- D->getFormalAccess (), getFragileFunctionKind (DC));
93
- diagnose (D, diag::resilience_decl_declared_here,
94
- D->getDescriptiveKind (), D->getFullName ());
95
- return true ;
96
- }
97
- }
98
- }
99
80
100
- return false ;
81
+ // Internal declarations referenced from non-inlineable contexts are OK.
82
+ if (expansion == ResilienceExpansion::Maximal)
83
+ return false ;
84
+
85
+ // Local declarations are OK.
86
+ if (D->getDeclContext ()->isLocalContext ())
87
+ return false ;
88
+
89
+ // Type parameters are OK.
90
+ if (isa<AbstractTypeParamDecl>(D))
91
+ return false ;
92
+
93
+ // Public declarations are OK.
94
+ if (D->getEffectiveAccess () >= Accessibility::Public)
95
+ return false ;
96
+
97
+ // Enum cases are handled as part of their containing enum.
98
+ if (isa<EnumElementDecl>(D))
99
+ return false ;
100
+
101
+ // Protocol requirements are not versioned because there's no
102
+ // global entry point.
103
+ if (isa<ProtocolDecl>(D->getDeclContext ()) && isRequirement (D))
104
+ return false ;
105
+
106
+ // FIXME: Figure out what to do with typealiases
107
+ if (isa<TypeAliasDecl>(D))
108
+ return false ;
109
+
110
+ diagnose (loc, diag::resilience_decl_unavailable,
111
+ D->getDescriptiveKind (), D->getFullName (),
112
+ D->getFormalAccess (), getFragileFunctionKind (DC));
113
+ diagnose (D, diag::resilience_decl_declared_here,
114
+ D->getDescriptiveKind (), D->getFullName ());
115
+ return true ;
101
116
}
102
117
103
118
void TypeChecker::diagnoseResilientValueConstructor (ConstructorDecl *ctor) {
0 commit comments