Skip to content

Commit be22bb5

Browse files
authored
Merge bb3889f into e9d0aa5
2 parents e9d0aa5 + bb3889f commit be22bb5

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

packages.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -506,13 +506,6 @@ func (pkgDefs *PackagesDefinitions) findPackagePathFromImports(pkg string, file
506506
}
507507

508508
func (pkgDefs *PackagesDefinitions) findTypeSpecFromPackagePaths(matchedPkgPaths, externalPkgPaths []string, name string) (typeDef *TypeSpecDef) {
509-
for _, pkgPath := range matchedPkgPaths {
510-
typeDef = pkgDefs.findTypeSpec(pkgPath, name)
511-
if typeDef != nil {
512-
return typeDef
513-
}
514-
}
515-
516509
if pkgDefs.parseDependency > 0 {
517510
for _, pkgPath := range externalPkgPaths {
518511
if err := pkgDefs.loadExternalPackage(pkgPath); err == nil {
@@ -524,6 +517,13 @@ func (pkgDefs *PackagesDefinitions) findTypeSpecFromPackagePaths(matchedPkgPaths
524517
}
525518
}
526519

520+
for _, pkgPath := range matchedPkgPaths {
521+
typeDef = pkgDefs.findTypeSpec(pkgPath, name)
522+
if typeDef != nil {
523+
return typeDef
524+
}
525+
}
526+
527527
return typeDef
528528
}
529529

@@ -542,13 +542,14 @@ func (pkgDefs *PackagesDefinitions) FindTypeSpec(typeName string, file *ast.File
542542

543543
parts := strings.Split(strings.Split(typeName, "[")[0], ".")
544544
if len(parts) > 1 {
545-
typeDef, ok := pkgDefs.uniqueDefinitions[typeName]
546-
if ok {
547-
return typeDef
548-
}
549-
550545
pkgPaths, externalPkgPaths := pkgDefs.findPackagePathFromImports(parts[0], file)
551-
typeDef = pkgDefs.findTypeSpecFromPackagePaths(pkgPaths, externalPkgPaths, parts[1])
546+
if len(externalPkgPaths) == 0 || pkgDefs.parseDependency == ParseNone {
547+
typeDef, ok := pkgDefs.uniqueDefinitions[typeName]
548+
if ok {
549+
return typeDef
550+
}
551+
}
552+
typeDef := pkgDefs.findTypeSpecFromPackagePaths(pkgPaths, externalPkgPaths, parts[1])
552553
return pkgDefs.parametrizeGenericType(file, typeDef, typeName)
553554
}
554555

0 commit comments

Comments
 (0)