Skip to content

Commit

Permalink
speedup typecheck on large project with compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jirfag committed Jan 20, 2019
1 parent 2b7ea84 commit 2216387
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/packages/util.go
Expand Up @@ -10,7 +10,7 @@ import (

//nolint:gocyclo
func ExtractErrors(pkg *packages.Package, astCache *astcache.Cache) []packages.Error {
errors := extractErrorsImpl(pkg)
errors := extractErrorsImpl(pkg, map[*packages.Package]bool{})
if len(errors) == 0 {
return errors
}
Expand Down Expand Up @@ -48,7 +48,12 @@ func ExtractErrors(pkg *packages.Package, astCache *astcache.Cache) []packages.E
return uniqErrors
}

func extractErrorsImpl(pkg *packages.Package) []packages.Error {
func extractErrorsImpl(pkg *packages.Package, seenPackages map[*packages.Package]bool) []packages.Error {
if seenPackages[pkg] {
return nil
}
seenPackages[pkg] = true

if !pkg.IllTyped { // otherwise it may take hours to traverse all deps many times
return nil
}
Expand All @@ -59,7 +64,7 @@ func extractErrorsImpl(pkg *packages.Package) []packages.Error {

var errors []packages.Error
for _, iPkg := range pkg.Imports {
iPkgErrors := extractErrorsImpl(iPkg)
iPkgErrors := extractErrorsImpl(iPkg, seenPackages)
if iPkgErrors != nil {
errors = append(errors, iPkgErrors...)
}
Expand Down

0 comments on commit 2216387

Please sign in to comment.