Skip to content

Incorrect "impossible type assertion" on interfaces that include unexported methods #1025

@theclapp

Description

@theclapp

I'm trying to interpret this code:

if e, ok := e.(widget.SubmitEvent); ok {

I get this:

impossible type assertion: gioui.org/widget.SubmitEvent does not implement
gioui.org/widget.EditorEvent (missing isEditorEvent method)

Well, widget.SubmitEvent does actually implement isEditorEvent.

widget is this, e is a widget.EditorEvent (here) which looks like this:

type EditorEvent interface {
	isEditorEvent()
}

widget.ChangeEvent, SubmitEvent, and SelectEvent all implement isEditorEvent() (here):

func (s ChangeEvent) isEditorEvent() {}
func (s SubmitEvent) isEditorEvent() {}
func (s SelectEvent) isEditorEvent() {}

This works in the regular compiled code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions