@@ -119,64 +119,6 @@ var UnusedImportAnalyzer = (func() *analysis.Analyzer {
119119 }
120120 },
121121 )
122- // TODO: Remove the below section once https://github.com/onflow/cadence/issues/4470 is fixed.
123- // The Walk methods for composite, interface, and attachment declarations
124- // do not recurse into conformance lists, attachment base types, or
125- // entitlement access specifiers, so the inspector never visits the
126- // NominalType nodes there. Check those positions explicitly.
127-
128- markNominalTypeUsed := func (t * ast.NominalType ) {
129- name := t .Identifier .Identifier
130- if _ , isImported := importedNames [name ]; isImported {
131- usedImports [name ] = struct {}{}
132- }
133- }
134-
135- markEntitlementAccessUsed := func (access ast.Access ) {
136- entAccess , ok := access .(ast.EntitlementAccess )
137- if ! ok {
138- return
139- }
140- for _ , e := range entAccess .EntitlementSet .Entitlements () {
141- markNominalTypeUsed (e )
142- }
143- }
144-
145- inspector .Preorder (
146- []ast.Element {
147- (* ast .CompositeDeclaration )(nil ),
148- (* ast .InterfaceDeclaration )(nil ),
149- (* ast .AttachmentDeclaration )(nil ),
150- (* ast .FunctionDeclaration )(nil ),
151- (* ast .FieldDeclaration )(nil ),
152- },
153- func (element ast.Element ) {
154- switch decl := element .(type ) {
155- case * ast.CompositeDeclaration :
156- markEntitlementAccessUsed (decl .Access )
157- for _ , c := range decl .Conformances {
158- markNominalTypeUsed (c )
159- }
160- case * ast.InterfaceDeclaration :
161- markEntitlementAccessUsed (decl .Access )
162- for _ , c := range decl .Conformances {
163- markNominalTypeUsed (c )
164- }
165- case * ast.AttachmentDeclaration :
166- markEntitlementAccessUsed (decl .Access )
167- if decl .BaseType != nil {
168- markNominalTypeUsed (decl .BaseType )
169- }
170- for _ , c := range decl .Conformances {
171- markNominalTypeUsed (c )
172- }
173- case * ast.FunctionDeclaration :
174- markEntitlementAccessUsed (decl .Access )
175- case * ast.FieldDeclaration :
176- markEntitlementAccessUsed (decl .Access )
177- }
178- },
179- )
180122
181123 // Collect unused imports.
182124 // For implicit imports, we only report if ALL imports from that declaration are unused
0 commit comments