File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -518,6 +518,7 @@ 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
520520func extractObject (tw * trap.Writer , obj types.Object , lbl trap.Label ) {
521+ checkObjectNotSpecialized (obj )
521522 name := obj .Name ()
522523 isBuiltin := obj .Parent () == types .Universe
523524 var kind int
@@ -2143,3 +2144,15 @@ func skipExtractingValueForLeftOperand(tw *trap.Writer, be *ast.BinaryExpr) bool
21432144 }
21442145 return true
21452146}
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+ }
You can’t perform that action at this time.
0 commit comments