Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Fix resolution of embedded interfaces in aux files #134

Merged
merged 2 commits into from Dec 6, 2017

Conversation

notbdu
Copy link

@notbdu notbdu commented Nov 28, 2017

Embedded interfaces in aux_files generate unknown embedded interface XXX errors.
See below for example of the problem:

// source
import (
    alias "some.org/package/imported"
)

type Source interface {
    alias.Foreign
}
// some.org/package/imported
type Foreign interface {
    Embedded
}

type Embedded interface {}

Attempting to generate a mock will result in an unknown embedded interface Embedded.
The issue is that the fileParser stores auxInterfaces underneath the package name
explicitly specified in the aux_files flag.

In the parseInterface method, there is an incorrect assumption about an embedded interface
always being in the source file.

case *ast.Ident:
        // Embedded interface in this package.
        ei := p.auxInterfaces[""][v.String()]
        if ei == nil {
                return nil, p.errorf(v.Pos(), "unknown embedded interface %s", v.String())
        }

Test case verifies that the patch fixes the problem described in the bug report.

@pasztorpisti
Copy link
Contributor

pasztorpisti commented Nov 28, 2017

seems to be related to #85 and #10

@notbdu
Copy link
Author

notbdu commented Nov 28, 2017

@pasztorpisti thanks for referencing those issues

@balshetzer balshetzer merged commit 8c3d3c6 into golang:master Dec 6, 2017
@wsong
Copy link

wsong commented Dec 6, 2017

This PR breaks this repo on Windows; aux is not a valid directory name in Windows (https://social.technet.microsoft.com/Forums/Azure/en-US/d1cf7394-a39b-46bf-823d-46f33b2f78d0/unable-to-create-folder-named-aux-anywhere-in-the-disk?forum=w7itprogeneral), so this PR prevents you from checking out this repo on a Windows machine.

@notbdu notbdu mentioned this pull request Dec 6, 2017
@notbdu
Copy link
Author

notbdu commented Dec 6, 2017

@wsong thanks for bringing it up. Opened a second PR w/ aux renamed to faux.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants