Skip to content

Commit 6017cbc

Browse files
authored
Merge pull request #22176 from jketema/jketema/go-dead
Go: Remove dead extractor code
2 parents a142121 + 559f9f3 commit 6017cbc

2 files changed

Lines changed: 9 additions & 48 deletions

File tree

go/extractor/extractor.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,12 +1529,6 @@ func extractSpec(tw *trap.Writer, spec ast.Spec, parent trap.Label, idx int) {
15291529
extractNodeLocation(tw, spec, lbl)
15301530
}
15311531

1532-
// Determines whether the given type is an alias.
1533-
func isAlias(tp types.Type) bool {
1534-
_, ok := tp.(*types.Alias)
1535-
return ok
1536-
}
1537-
15381532
// extractType extracts type information for `tp` and returns its associated label;
15391533
// types are only extracted once, so the second time `extractType` is invoked it simply returns the label
15401534
func extractType(tw *trap.Writer, tp types.Type) trap.Label {
@@ -1644,7 +1638,6 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
16441638
dbscheme.TypeNameTable.Emit(tw, lbl, origintp.Obj().Name())
16451639
underlying := origintp.Underlying()
16461640
extractUnderlyingType(tw, lbl, underlying)
1647-
trackInstantiatedStructFields(tw, tp, origintp)
16481641

16491642
entitylbl, exists := tw.Labeler.LookupObjectID(origintp.Obj(), lbl)
16501643
if entitylbl == trap.InvalidLabel {
@@ -2035,36 +2028,6 @@ func getObjectBeingUsed(tw *trap.Writer, ident *ast.Ident) types.Object {
20352028
}
20362029
}
20372030

2038-
// trackInstantiatedStructFields tries to give the fields of an instantiated
2039-
// struct type underlying `tp` the same labels as the corresponding fields of
2040-
// the generic struct type. This is so that when we come across the
2041-
// instantiated field in `tw.Package.TypesInfo.Uses` we will get the label for
2042-
// the generic field instead.
2043-
func trackInstantiatedStructFields(tw *trap.Writer, tp, origintp *types.Named) {
2044-
if tp == origintp {
2045-
return
2046-
}
2047-
2048-
if instantiatedStruct, ok := tp.Underlying().(*types.Struct); ok {
2049-
genericStruct, ok2 := origintp.Underlying().(*types.Struct)
2050-
if !ok2 {
2051-
log.Fatalf(
2052-
"Error: underlying type of instantiated type is a struct but underlying type of generic type is %s",
2053-
origintp.Underlying())
2054-
}
2055-
2056-
if instantiatedStruct.NumFields() != genericStruct.NumFields() {
2057-
log.Fatalf(
2058-
"Error: instantiated struct %s has different number of fields than the generic version %s (%d != %d)",
2059-
instantiatedStruct, genericStruct, instantiatedStruct.NumFields(), genericStruct.NumFields())
2060-
}
2061-
2062-
for i := 0; i < instantiatedStruct.NumFields(); i++ {
2063-
tw.ObjectsOverride[instantiatedStruct.Field(i)] = genericStruct.Field(i)
2064-
}
2065-
}
2066-
}
2067-
20682031
func getTypeParamParentLabel(tw *trap.Writer, tp *types.TypeParam) trap.Label {
20692032
parent, exists := typeParamParent[tp]
20702033
if !exists {

go/extractor/trap/trapwriter.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@ import (
1717

1818
// A Writer provides methods for writing data to a TRAP file
1919
type Writer struct {
20-
zip *gzip.Writer
21-
wzip *bufio.Writer
22-
wfile *bufio.Writer
23-
file *os.File
24-
Labeler *Labeler
25-
path string
26-
trapFilePath string
27-
Package *packages.Package
28-
TypesOverride map[ast.Expr]types.Type
29-
ObjectsOverride map[types.Object]types.Object
20+
zip *gzip.Writer
21+
wzip *bufio.Writer
22+
wfile *bufio.Writer
23+
file *os.File
24+
Labeler *Labeler
25+
path string
26+
trapFilePath string
27+
Package *packages.Package
28+
TypesOverride map[ast.Expr]types.Type
3029
}
3130

3231
func FileFor(path string) (string, error) {
@@ -67,7 +66,6 @@ func NewWriter(path string, pkg *packages.Package) (*Writer, error) {
6766
trapFilePath,
6867
pkg,
6968
make(map[ast.Expr]types.Type),
70-
make(map[types.Object]types.Object),
7169
}
7270
tw.Labeler = newLabeler(tw)
7371
return tw, nil

0 commit comments

Comments
 (0)