add a test with generic code
This ensures that we support obfuscating builds containing the use of type parameters, the new feature in Go 1.18. The test is small for now, but we can extend it over time. There was just one bug that kept the code from obfuscating properly; that has been fixed in https://go.dev/cl/405194, and we update x/tools to the latest master version to include it. Fixes #414.pull/534/head
parent
22e3d30216
commit
61bd95bb89
@ -0,0 +1,38 @@
|
||||
env GOGARBLE=*
|
||||
|
||||
garble build
|
||||
! binsubstr main$exe ${WORK} 'garble_main.go' 'GenericFunc' 'GenericVector' 'PredeclaredSignedInteger' 'StringableSignedInteger' 'CombineEmbeds' 'GenericParam'
|
||||
|
||||
-- go.mod --
|
||||
module test/main
|
||||
|
||||
go 1.18
|
||||
|
||||
-- garble_main.go --
|
||||
package main
|
||||
|
||||
func main() {
|
||||
//var _ GenericVector[int]
|
||||
GenericFunc[int, int](1, 2)
|
||||
}
|
||||
|
||||
func GenericFunc[GenericParamA, B any](x GenericParamA, y B) {}
|
||||
|
||||
type GenericVector[GenericParamT any] []GenericParamT
|
||||
|
||||
type PredeclaredSignedInteger interface {
|
||||
int | int8 | int16 | int32 | int64
|
||||
}
|
||||
|
||||
type StringableSignedInteger interface {
|
||||
~int | ~int8 | ~int16 | ~int32 | ~int64
|
||||
|
||||
String() string
|
||||
}
|
||||
|
||||
type CombineEmbeds interface {
|
||||
string | int
|
||||
|
||||
interface { EmbeddedMethod() }
|
||||
RegularMethod()
|
||||
}
|
Loading…
Reference in New Issue