Skip to content

Commit 00b9514

Browse files
committed
Fix CatchMatches
Signed-off-by: James Hamlin <jfhamlin@gmail.com>
1 parent 21b6052 commit 00b9514

1 file changed

Lines changed: 3 additions & 18 deletions

File tree

pkg/lang/catch.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,7 @@ func CatchMatches(r, expect any) bool {
1616
return false
1717
}
1818

19-
// Special case: the symbol "any" catches everything (for go/any)
20-
if sym, ok := expect.(*Symbol); ok && sym.Name() == "any" {
21-
return true
22-
}
23-
24-
// If expect is an error type, check if r is an instance of it
19+
// if expect is an error type, check if r is an instance of it
2520
if rErr, ok := r.(error); ok {
2621
if expectTyp, ok := expect.(reflect.Type); ok && expectTyp.Implements(errorType) {
2722
expectVal := reflect.New(expectTyp).Elem().Interface().(error)
@@ -31,15 +26,5 @@ func CatchMatches(r, expect any) bool {
3126
}
3227
}
3328

34-
// General type check
35-
if expectTyp, ok := expect.(reflect.Type); ok {
36-
return reflect.TypeOf(r).AssignableTo(expectTyp)
37-
}
38-
39-
// For interface{} type (go/any), catch everything
40-
if expectTyp, ok := expect.(reflect.Type); ok && expectTyp.Kind() == reflect.Interface && expectTyp.NumMethod() == 0 {
41-
return true
42-
}
43-
44-
return false
45-
}
29+
return reflect.TypeOf(r).AssignableTo(expect.(reflect.Type))
30+
}

0 commit comments

Comments
 (0)