Skip to content

Commit

Permalink
validate we can use aliases with type arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
reillywatson committed Aug 24, 2024
1 parent c7f4a31 commit c110da7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/moq/testpackages/typealias/typealias.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

type Example interface {

Check failure on line 7 in pkg/moq/testpackages/typealias/typealias.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported type Example should have comment or be unexported

Check failure on line 7 in pkg/moq/testpackages/typealias/typealias.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported type Example should have comment or be unexported
Do(a typealiastwo.AliasType) error
Do(a typealiastwo.AliasType, b typealiastwo.GenericAliasType) error
}
14 changes: 10 additions & 4 deletions pkg/moq/testpackages/typealias/typealias_moq.golden.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package typealiasinternal

// we shouldn't be able to import this type directly, you need to use the alias in the parent package
// we shouldn't be able to import these types directly, you need to use the alias in the parent package

Check failure on line 3 in pkg/moq/testpackages/typealiastwo/internal/typealiasinternal/typealiasinternal.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

comment on exported type MyInternalType should be of the form "MyInternalType ..." (with optional leading article)

Check failure on line 3 in pkg/moq/testpackages/typealiastwo/internal/typealiasinternal/typealiasinternal.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

comment on exported type MyInternalType should be of the form "MyInternalType ..." (with optional leading article)
type MyInternalType struct {
Foo int
}

type MyGenericType[T any] struct {

Check failure on line 8 in pkg/moq/testpackages/typealiastwo/internal/typealiasinternal/typealiasinternal.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported type MyGenericType should have comment or be unexported

Check failure on line 8 in pkg/moq/testpackages/typealiastwo/internal/typealiasinternal/typealiasinternal.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported type MyGenericType should have comment or be unexported
A T
}
2 changes: 2 additions & 0 deletions pkg/moq/testpackages/typealiastwo/typealiastwo.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ package typealiastwo
import "github.com/matryer/moq/pkg/moq/testpackages/typealiastwo/internal/typealiasinternal"

type AliasType = typealiasinternal.MyInternalType

Check failure on line 5 in pkg/moq/testpackages/typealiastwo/typealiastwo.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported type AliasType should have comment or be unexported

Check failure on line 5 in pkg/moq/testpackages/typealiastwo/typealiastwo.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported type AliasType should have comment or be unexported

type GenericAliasType = typealiasinternal.MyGenericType[int]

Check failure on line 7 in pkg/moq/testpackages/typealiastwo/typealiastwo.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, oldstable)

exported type GenericAliasType should have comment or be unexported

Check failure on line 7 in pkg/moq/testpackages/typealiastwo/typealiastwo.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, stable)

exported type GenericAliasType should have comment or be unexported

0 comments on commit c110da7

Please sign in to comment.