Skip to content

Commit fcbd255

Browse files
committed
feat:ZeroLit for alias
1 parent ba6f4f0 commit fcbd255

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: codebuild.go

+3
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,9 @@ retry:
768768
case *types.Named:
769769
typ = p.getUnderlying(t)
770770
goto retry
771+
case *typesutil.Alias:
772+
typ = typesutil.Unalias(t)
773+
goto retry
771774
}
772775
ret := &ast.CompositeLit{}
773776
switch t := typ.(type) {

Diff for: package_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,22 @@ func main() {
667667
`)
668668
}
669669

670+
func TestZeroLitAlias(t *testing.T) {
671+
pkg := newPackage("main", true)
672+
bar := pkg.AliasType("bar", types.Typ[types.Float64])
673+
results := types.NewTuple(types.NewVar(token.NoPos, pkg.Types, "", bar))
674+
pkg.NewFunc(nil, "main", nil, results, false).BodyStart(pkg).
675+
ZeroLit(bar).Return(1).End()
676+
domTest(t, pkg, `package main
677+
678+
type bar = float64
679+
680+
func main() bar {
681+
return 0
682+
}
683+
`)
684+
}
685+
670686
func TestZeroLitAllTypes(t *testing.T) {
671687
pkg := newMainPackage()
672688
tyString := types.Typ[types.String]

0 commit comments

Comments
 (0)