mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Add check for specialized objects
This commit is contained in:
@@ -518,6 +518,7 @@ func extractMethod(tw *trap.Writer, meth *types.Func) trap.Label {
|
||||
// For more information on objects, see:
|
||||
// https://github.com/golang/example/blob/master/gotypes/README.md#objects
|
||||
func extractObject(tw *trap.Writer, obj types.Object, lbl trap.Label) {
|
||||
checkObjectNotSpecialized(obj)
|
||||
name := obj.Name()
|
||||
isBuiltin := obj.Parent() == types.Universe
|
||||
var kind int
|
||||
@@ -2143,3 +2144,15 @@ func skipExtractingValueForLeftOperand(tw *trap.Writer, be *ast.BinaryExpr) bool
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// checkObjectNotSpecialized exits the program if `obj` is specialized. Note
|
||||
// that specialization is only possible for function objects and variable
|
||||
// objects.
|
||||
func checkObjectNotSpecialized(obj types.Object) {
|
||||
if funcObj, ok := obj.(*types.Func); ok && funcObj != funcObj.Origin() {
|
||||
log.Fatalf("Encountered unexpected specialization %s of generic function object %s", funcObj.FullName(), funcObj.Origin().FullName())
|
||||
}
|
||||
if varObj, ok := obj.(*types.Var); ok && varObj != varObj.Origin() {
|
||||
log.Fatalf("Encountered unexpected specialization %s of generic variable object %s", varObj.String(), varObj.Origin().String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user