@@ -446,6 +446,7 @@ func typeCheck(ctx context.Context, snapshot *snapshot, m *metadata, mode source
446
446
typesinternal .SetUsesCgo (cfg )
447
447
448
448
check := types .NewChecker (cfg , fset , pkg .types , pkg .typesInfo )
449
+
449
450
// Type checking errors are handled via the config, so ignore them here.
450
451
_ = check .Files (files )
451
452
// If the context was cancelled, we may have returned a ton of transient
@@ -454,12 +455,6 @@ func typeCheck(ctx context.Context, snapshot *snapshot, m *metadata, mode source
454
455
return nil , ctx .Err ()
455
456
}
456
457
457
- // staticcheck requires full type information. Reduce memory usage for
458
- // everyone else.
459
- if ! snapshot .view .Options ().Staticcheck {
460
- trimTypesInfo (files , pkg .typesInfo )
461
- }
462
-
463
458
// We don't care about a package's errors unless we have parsed it in full.
464
459
if mode != source .ParseFull {
465
460
return pkg , nil
@@ -800,33 +795,3 @@ func isValidImport(pkgPath, importPkgPath packagePath) bool {
800
795
type importerFunc func (path string ) (* types.Package , error )
801
796
802
797
func (f importerFunc ) Import (path string ) (* types.Package , error ) { return f (path ) }
803
-
804
- func trimTypesInfo (files []* ast.File , info * types.Info ) {
805
- for _ , file := range files {
806
- ast .Inspect (file , func (n ast.Node ) bool {
807
- if n == nil {
808
- return false
809
- }
810
- cl , ok := n .(* ast.CompositeLit )
811
- if ! ok {
812
- return true
813
- }
814
-
815
- // types.Info.Types for long slice/array literals are particularly
816
- // expensive. Try to clear them out.
817
- if _ , ok := cl .Type .(* ast.ArrayType ); ! ok {
818
- return true
819
- }
820
-
821
- for _ , elt := range cl .Elts {
822
- // Only delete information for basic literals; other elements,
823
- // like constants and function calls, could still be relevant.
824
- if _ , ok := elt .(* ast.BasicLit ); ok {
825
- delete (info .Types , elt )
826
- }
827
- }
828
-
829
- return true
830
- })
831
- }
832
- }
0 commit comments