blob: 3f137a516c2a6740d73391c6d88d44d2715e02d5 [file] [log] [blame]
package reflecttypefor
import (
"io"
"reflect"
"time"
)
var (
x any
_ = reflect.TypeOf(x) // nope (dynamic)
_ = reflect.TypeFor[int]() // want "reflect.TypeOf call can be simplified using TypeFor"
_ = reflect.TypeFor[uint]() // want "reflect.TypeOf call can be simplified using TypeFor"
_ = reflect.TypeOf(error(nil)) // nope (likely a mistake)
_ = reflect.TypeFor[*error]() // want "reflect.TypeOf call can be simplified using TypeFor"
_ = reflect.TypeOf(io.Reader(nil)) // nope (likely a mistake)
_ = reflect.TypeFor[*io.Reader]() // want "reflect.TypeOf call can be simplified using TypeFor"
_ = reflect.TypeOf(*new(time.Time)) // nope (false negative of noEffects)
_ = reflect.TypeFor[time.Time]() // want "reflect.TypeOf call can be simplified using TypeFor"
_ = reflect.TypeFor[time.Duration]() // want "reflect.TypeOf call can be simplified using TypeFor"
)
// Eliminate local var if we deleted its last use.
func _() {
_ = reflect.TypeFor[string]() // want "reflect.TypeOf call can be simplified using TypeFor"
var z2 string
_ = reflect.TypeFor[string]() // want "reflect.TypeOf call can be simplified using TypeFor"
_ = z2 // z2 has multiple uses
}