in lib/coverage.go [54:78]
func (c *Coverage) ProgramOption() cel.ProgramOption {
return cel.CustomDecorator(func(i interpreter.Interpretable) (interpreter.Interpretable, error) {
c.decorator.all[i.ID()] = true
switch i := i.(type) {
case interpreter.InterpretableAttribute:
return coverageAttribute{InterpretableAttribute: i, cov: c.decorator.cov}, nil
case interpreter.InterpretableCall:
return coverageCall{InterpretableCall: i, cov: c.decorator.cov}, nil
case interpreter.InterpretableConst:
return coverageConst{InterpretableConst: i, cov: c.decorator.cov}, nil
case interpreter.InterpretableConstructor:
return coverageConstructor{InterpretableConstructor: i, cov: c.decorator.cov}, nil
default:
// Check that we do not have more methods on the original
// type than the base interpreter.Interpretable type. In
// the case that we hit this, the program will probably
// run, but may give unexpected results.
var ii interpreter.Interpretable
if exportedMethods(reflect.TypeOf(i)) > exportedMethods(reflect.TypeOf(&ii).Elem()) {
return nil, fmt.Errorf("unsupported interpretable type: %T", i)
}
return coverage{Interpretable: i, cov: c.decorator.cov}, nil
}
})
}