summaryrefslogtreecommitdiff
path: root/vendor/github.com/golang/mock/mockgen/tests/aux_imports_embedded_interface/README.md
blob: 63955f6a013e14e70e7754e7ba6951c148a17bd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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())
        }
```