-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
account for anonymous interface in type params
Previously the typeparams logic did not account for anonymous interfaces in type paramters. Fix this, and add tests. A bit of housekeeping to ease debugging: The types and funcs in the testdata typeparams package are moved to separate files. This should ease debugging. To debug a problematic test case in isolation, the single function for the test case can be added to a separate new file (say funcs_debug.go), and the existing funcs in funcs.go can be disabled altogether by setting build constraint in funcs.go to "go118 && never", such that it isn't included. Also, move the check for same basic kind-ness to once at the end.
- Loading branch information
Showing
3 changed files
with
155 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//go:build go1.18 | ||
// +build go1.18 | ||
|
||
package typeparam | ||
|
||
type Stringer interface { | ||
String() string | ||
} | ||
|
||
type M uint8 // want M:"^A,B$" | ||
const ( | ||
_ M = iota * 100 | ||
A | ||
B | ||
) | ||
|
||
func (M) String() string { return "" } | ||
|
||
type N uint8 // want N:"^C,D$" | ||
const ( | ||
_ N = iota * 100 | ||
C | ||
D | ||
) | ||
|
||
type O byte // want O:"^E1,E2$" | ||
const ( | ||
E1 O = 'h' | ||
E2 O = 'e' | ||
) | ||
|
||
type P float32 // want P:"^F$" | ||
const ( | ||
F P = 1.1234 | ||
) | ||
|
||
type Q string // want Q:"^G$" | ||
const ( | ||
G Q = "world" | ||
) | ||
|
||
type NotEnumType uint8 | ||
|
||
type II interface{ N | JJ } | ||
type JJ interface{ O } | ||
type KK interface { | ||
M | ||
Stringer | ||
error | ||
comparable | ||
} | ||
type LL interface { | ||
M | NotEnumType | ||
Stringer | ||
error | ||
} | ||
type MM interface { | ||
M | ||
} | ||
type Anon interface { | ||
interface{ M } | interface{ N } | ||
} | ||
type QQ interface { | ||
Q | ||
} |