Skip to content

Add support for handling Interface in reflect.Type.AssignableTo() #4277

Description

@fxamacker

Some packages like fxamacker/cbor require Type.AssignableTo to support Interface.

There was some prior discussion at fxamacker/cbor#295 (comment).

Projects using packages that require Interface support can encounter panics from the following code.

tinygo/src/reflect/type.go

Lines 956 to 969 in 6384eca

func (t *rawType) AssignableTo(u Type) bool {
if t == u.(*rawType) {
return true
}
if u.Kind() == Interface && u.NumMethod() == 0 {
return true
}
if u.Kind() == Interface {
panic("reflect: unimplemented: AssignableTo with interface")
}
return false
}

If a solution becomes available, I can use some existing tests in fxamacker/cbor to help test it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    reflectionNeeds further work on reflection

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions