Skip to content

Commit 575eb24

Browse files
authored
Merge pull request github#17735 from github/revert-17709-go/extractor/objecttypes-consistency-generics
Revert "Go: extractor/objecttypes consistency generics"
2 parents d0f73ac + d013c89 commit 575eb24

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

go/extractor/extractor.go

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ func extractMethod(tw *trap.Writer, meth *types.Func) trap.Label {
518518
// For more information on objects, see:
519519
// https://github.com/golang/example/blob/master/gotypes/README.md#objects
520520
func extractObject(tw *trap.Writer, obj types.Object, lbl trap.Label) {
521-
checkObjectNotSpecialized(obj)
522521
name := obj.Name()
523522
isBuiltin := obj.Parent() == types.Universe
524523
var kind int
@@ -1638,7 +1637,7 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
16381637
// Note that methods coming from embedded interfaces can be
16391638
// accessed through `Method(i)`, so there is no need to
16401639
// deal with them separately.
1641-
meth := tp.Method(i).Origin()
1640+
meth := tp.Method(i)
16421641

16431642
// Note that methods do not have a parent scope, so they are
16441643
// not dealt with by `extractScopes`
@@ -1708,15 +1707,15 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
17081707
// ensure all methods have labels - note that methods do not have a
17091708
// parent scope, so they are not dealt with by `extractScopes`
17101709
for i := 0; i < origintp.NumMethods(); i++ {
1711-
meth := origintp.Method(i).Origin()
1710+
meth := origintp.Method(i)
17121711

17131712
extractMethod(tw, meth)
17141713
}
17151714

17161715
// associate all methods of underlying interface with this type
17171716
if underlyingInterface, ok := underlying.(*types.Interface); ok {
17181717
for i := 0; i < underlyingInterface.NumMethods(); i++ {
1719-
methlbl := extractMethod(tw, underlyingInterface.Method(i).Origin())
1718+
methlbl := extractMethod(tw, underlyingInterface.Method(i))
17201719
dbscheme.MethodHostsTable.Emit(tw, methlbl, lbl)
17211720
}
17221721
}
@@ -1788,7 +1787,7 @@ func getTypeLabel(tw *trap.Writer, tp types.Type) (trap.Label, bool) {
17881787
case *types.Interface:
17891788
var b strings.Builder
17901789
for i := 0; i < tp.NumMethods(); i++ {
1791-
meth := tp.Method(i).Origin()
1790+
meth := tp.Method(i)
17921791
methLbl := extractType(tw, meth.Type())
17931792
if i > 0 {
17941793
b.WriteString(",")
@@ -2144,20 +2143,3 @@ func skipExtractingValueForLeftOperand(tw *trap.Writer, be *ast.BinaryExpr) bool
21442143
}
21452144
return true
21462145
}
2147-
2148-
// checkObjectNotSpecialized exits the program if `obj` is specialized. Note
2149-
// that specialization is only possible for function objects and variable
2150-
// objects.
2151-
func checkObjectNotSpecialized(obj types.Object) {
2152-
if funcObj, ok := obj.(*types.Func); ok && funcObj != funcObj.Origin() {
2153-
log.Fatalf("Encountered unexpected specialization %s of generic function object %s", funcObj.FullName(), funcObj.Origin().FullName())
2154-
}
2155-
if varObj, ok := obj.(*types.Var); ok && varObj != varObj.Origin() {
2156-
log.Fatalf("Encountered unexpected specialization %s of generic variable object %s", varObj.String(), varObj.Origin().String())
2157-
}
2158-
if typeNameObj, ok := obj.(*types.TypeName); ok {
2159-
if namedType, ok := typeNameObj.Type().(*types.Named); ok && namedType != namedType.Origin() {
2160-
log.Fatalf("Encountered type object for specialization %s of named type %s", namedType.String(), namedType.Origin().String())
2161-
}
2162-
}
2163-
}

0 commit comments

Comments
 (0)