this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: use reflect.TypeAssert in three more places

Others still use reflect.Value.Interface,
but these are the ones that map to reflect.TypeAssert directly.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I7ac2bc7b9e1b689e21e4b68331f26fac74bf2784
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1231001
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+4 -4
+2 -1
cue/decode.go
··· 385 385 kt := t.Key() 386 386 if reflect.PointerTo(kt).Implements(textUnmarshalerType) { 387 387 kv = reflect.New(kt) 388 - err := kv.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(key)) 388 + u, _ := reflect.TypeAssert[encoding.TextUnmarshaler](kv) 389 + err := u.UnmarshalText([]byte(key)) 389 390 d.addErr(err) 390 391 kv = kv.Elem() 391 392 } else {
+2 -3
internal/astinternal/debug.go
··· 104 104 return 105 105 } 106 106 if k == reflect.Pointer { 107 - if n, ok := v.Interface().(ast.Node); ok { 107 + if n, ok := reflect.TypeAssert[ast.Node](v); ok { 108 108 ptrVal = v.Pointer() 109 109 if id, ok := d.nodeRefs[n]; ok { 110 110 refName = refIDToName(id) ··· 259 259 d.truncate(elemStart) 260 260 } 261 261 } 262 - val := v.Addr().Interface() 263 - if val, ok := val.(ast.Node); ok { 262 + if val, ok := reflect.TypeAssert[ast.Node](v.Addr()); ok { 264 263 // Comments attached to a node aren't a regular field, but are still useful. 265 264 // The majority of nodes won't have comments, so skip them when empty. 266 265 if comments := ast.Comments(val); len(comments) > 0 {