Skip to content

Commit 2210ad3

Browse files
authored
Merge pull request #590 from visualfc/typesalias
remove internal/typesalias
2 parents 1d5ab8b + f7fb685 commit 2210ad3

25 files changed

Lines changed: 230 additions & 523 deletions

.github/workflows/go.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,3 @@ jobs:
3434
with:
3535
token: ${{ secrets.CODECOV_TOKEN }}
3636

37-
Test_Alias:
38-
strategy:
39-
matrix:
40-
go-version: [1.23.x, 1.24.x, 1.25.x]
41-
os: [ubuntu-latest, windows-latest, macos-latest]
42-
runs-on: ${{ matrix.os }}
43-
steps:
44-
- uses: actions/checkout@v6
45-
46-
- name: Set up Go
47-
uses: actions/setup-go@v6
48-
with:
49-
go-version: ${{ matrix.go-version }}
50-
51-
- name: Set types alias env
52-
run: echo "GODEBUG=gotypesalias=1" >> $GITHUB_ENV
53-
54-
- name: Build
55-
run: go build -v ./...
56-
57-
- name: Test
58-
run: go test -race -v -coverprofile="coverage.txt" -covermode=atomic ./...
59-
60-
- name: Codecov
61-
uses: codecov/codecov-action@v5
62-
with:
63-
token: ${{ secrets.CODECOV_TOKEN }}

ast.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"strings"
2828

2929
"github.com/goplus/gogen/internal"
30-
"github.com/goplus/gogen/internal/typesalias"
3130
)
3231

3332
var (
@@ -149,7 +148,7 @@ func embedName(typ types.Type) string {
149148
return t.Name()
150149
case *types.Named:
151150
return t.Obj().Name()
152-
case *typesalias.Alias:
151+
case *types.Alias:
153152
return t.Obj().Name()
154153
}
155154
return ""
@@ -188,7 +187,7 @@ retry:
188187
return toObjectExpr(pkg, t.Obj())
189188
case *Union:
190189
return toUnionType(pkg, t)
191-
case *typesalias.Alias:
190+
case *types.Alias:
192191
return toAliasType(pkg, t)
193192
}
194193
log.Panicln("TODO: toType -", reflect.TypeOf(typ))
@@ -502,8 +501,8 @@ retry:
502501
case *types.Named:
503502
typ = t.Underlying()
504503
goto retry
505-
case *typesalias.Alias:
506-
typ = typesalias.Unalias(t)
504+
case *types.Alias:
505+
typ = types.Unalias(t)
507506
goto retry
508507
}
509508
return false
@@ -538,8 +537,8 @@ retry:
538537
case *types.Named:
539538
argType = cb.getUnderlying(t)
540539
goto retry
541-
case *typesalias.Alias:
542-
argType = typesalias.Unalias(t)
540+
case *types.Alias:
541+
argType = types.Unalias(t)
543542
goto retry
544543
}
545544
return false
@@ -1351,8 +1350,8 @@ func matchType(pkg *Package, arg *internal.Elem, param types.Type, at interface{
13511350
case *types.Named:
13521351
typ = t.Underlying()
13531352
goto retry
1354-
case *typesalias.Alias:
1355-
typ = typesalias.Unalias(t)
1353+
case *types.Alias:
1354+
typ = types.Unalias(t)
13561355
goto retry
13571356
}
13581357
}

ast_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"go/token"
1919
"go/types"
2020
"testing"
21-
22-
"github.com/goplus/gogen/internal/typesalias"
2321
)
2422

2523
func TestToVariadic(t *testing.T) {
@@ -44,7 +42,7 @@ func TestToType(t *testing.T) {
4442

4543
func TestToTypeAlias(t *testing.T) {
4644
pkg := NewPackage("", "foo", gblConf)
47-
alias := typesalias.NewAlias(types.NewTypeName(token.NoPos, nil, "Int", nil), types.Typ[types.Int])
45+
alias := types.NewAlias(types.NewTypeName(token.NoPos, nil, "Int", nil), types.Typ[types.Int])
4846
expr := toType(pkg, alias)
4947
if ident, ok := expr.(*ast.Ident); !ok || ident.Name != "Int" {
5048
t.Fatalf("bad alias %#v", expr)
@@ -75,12 +73,12 @@ func Test_embedName(t *testing.T) {
7573
},
7674
{
7775
name: "alias type",
78-
typ: typesalias.NewAlias(types.NewTypeName(0, nil, "MyInt", nil), types.Typ[types.Int]),
76+
typ: types.NewAlias(types.NewTypeName(0, nil, "MyInt", nil), types.Typ[types.Int]),
7977
want: "MyInt",
8078
},
8179
{
8280
name: "pointer to alias type",
83-
typ: types.NewPointer(typesalias.NewAlias(types.NewTypeName(0, nil, "MyInt", nil), types.Typ[types.Int])),
81+
typ: types.NewPointer(types.NewAlias(types.NewTypeName(0, nil, "MyInt", nil), types.Typ[types.Int])),
8482
want: "MyInt",
8583
},
8684
{

builtin.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"strings"
2525
"syscall"
2626

27-
"github.com/goplus/gogen/internal/typesalias"
2827
"github.com/goplus/gogen/typeutil"
2928
)
3029

@@ -694,8 +693,8 @@ retry:
694693
case *types.Named:
695694
typ = cb.getUnderlying(t)
696695
goto retry
697-
case *typesalias.Alias:
698-
typ = typesalias.Unalias(t)
696+
case *types.Alias:
697+
typ = types.Unalias(t)
699698
goto retry
700699
}
701700
return false
@@ -727,8 +726,8 @@ retry:
727726
case *types.Named:
728727
t0 = pkg.cb.getUnderlying(t)
729728
goto retry
730-
case *typesalias.Alias:
731-
t0 = typesalias.Unalias(t)
729+
case *types.Alias:
730+
t0 = types.Unalias(t)
732731
goto retry
733732
}
734733
panic("TODO: <-ch not a chan type")
@@ -928,8 +927,8 @@ retry:
928927
case *types.Named:
929928
typ = pkg.cb.getUnderlying(t)
930929
goto retry
931-
case *typesalias.Alias:
932-
typ = typesalias.Unalias(t)
930+
case *types.Alias:
931+
typ = types.Unalias(t)
933932
goto retry
934933
}
935934
return nil
@@ -952,11 +951,11 @@ func offsetof(pkg *Package, typ types.Type, index []int, recv ast.Node, sel stri
952951
var indirectType int
953952
for n, i := range index {
954953
if n > 0 {
955-
if t, ok := typesalias.Unalias(typ).(*types.Pointer); ok {
954+
if t, ok := types.Unalias(typ).(*types.Pointer); ok {
956955
typ = t.Elem()
957956
indirectType = n
958957
}
959-
if t, ok := typesalias.Unalias(typ).(*types.Named); ok {
958+
if t, ok := types.Unalias(typ).(*types.Named); ok {
960959
typList = append(typList, t.Obj().Name())
961960
typ = t.Underlying()
962961
}
@@ -1111,8 +1110,8 @@ retry:
11111110
case *types.Named:
11121111
typ = pkg.cb.getUnderlying(t)
11131112
goto retry
1114-
case *typesalias.Alias:
1115-
typ = typesalias.Unalias(t)
1113+
case *types.Alias:
1114+
typ = types.Unalias(t)
11161115
goto retry
11171116
}
11181117
return false
@@ -1166,8 +1165,8 @@ retry:
11661165
case *types.Named:
11671166
typ = pkg.cb.getUnderlying(t)
11681167
goto retry
1169-
case *typesalias.Alias:
1170-
typ = typesalias.Unalias(t)
1168+
case *types.Alias:
1169+
typ = types.Unalias(t)
11711170
goto retry
11721171
case *types.Slice: // slice/map/func is very special
11731172
return false
@@ -1227,8 +1226,8 @@ retry:
12271226
case *types.Named:
12281227
typ = pkg.cb.getUnderlying(t)
12291228
goto retry
1230-
case *typesalias.Alias:
1231-
typ = typesalias.Unalias(t)
1229+
case *types.Alias:
1230+
typ = types.Unalias(t)
12321231
goto retry
12331232
}
12341233
return false
@@ -1256,8 +1255,8 @@ retry:
12561255
case *types.Named:
12571256
typ = pkg.cb.getUnderlying(t)
12581257
goto retry
1259-
case *typesalias.Alias:
1260-
typ = typesalias.Unalias(t)
1258+
case *types.Alias:
1259+
typ = types.Unalias(t)
12611260
goto retry
12621261
}
12631262
return capable.Match(pkg, typ)
@@ -1285,8 +1284,8 @@ retry:
12851284
case *types.Named:
12861285
typ = pkg.cb.getUnderlying(t)
12871286
goto retry
1288-
case *typesalias.Alias:
1289-
typ = typesalias.Unalias(t)
1287+
case *types.Alias:
1288+
typ = types.Unalias(t)
12901289
goto retry
12911290
}
12921291
return false
@@ -1321,8 +1320,8 @@ retry:
13211320
}
13221321
}
13231322
}
1324-
case *typesalias.Alias:
1325-
typ = typesalias.Unalias(t)
1323+
case *types.Alias:
1324+
typ = types.Unalias(t)
13261325
goto retry
13271326
}
13281327
c := &basicContract{kinds: kindsAddable}
@@ -1409,8 +1408,8 @@ retry:
14091408
case *types.Named:
14101409
typ = pkg.cb.getUnderlying(t)
14111410
goto retry
1412-
case *typesalias.Alias:
1413-
typ = typesalias.Unalias(t)
1411+
case *types.Alias:
1412+
typ = types.Unalias(t)
14141413
goto retry
14151414
}
14161415
return false

builtin_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,23 +1713,23 @@ func TestAliasTypeMethod(t *testing.T) {
17131713
}
17141714

17151715
func TestAliasCheckInterface(t *testing.T) {
1716-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1716+
pkg := NewPackage("", "foo", nil)
17171717
alias := pkg.AliasType("Any", types.NewInterfaceType(nil, nil))
17181718
if typ, ok := pkg.cb.checkInterface(alias); typ == nil || !ok {
17191719
t.Fatal("TestAliasCheckInterface failed:", typ, ok)
17201720
}
17211721
}
17221722

17231723
func TestAliasUnsigned(t *testing.T) {
1724-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1724+
pkg := NewPackage("", "foo", nil)
17251725
typ := pkg.AliasType("Int", types.Typ[types.Uint8])
17261726
if !isUnsigned(typ) {
17271727
t.Fatal("TestAliasUnsigned failed:", typ)
17281728
}
17291729
}
17301730

17311731
func TestAliasContract(t *testing.T) {
1732-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1732+
pkg := NewPackage("", "foo", nil)
17331733
at := types.NewPackage("foo", "foo")
17341734
foo := pkg.Import("github.com/goplus/gogen/internal/foo")
17351735
tfoo := foo.Ref("Foo").Type()
@@ -1760,7 +1760,7 @@ func TestAliasContract(t *testing.T) {
17601760
}
17611761

17621762
func TestAliasIsNumeric(t *testing.T) {
1763-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1763+
pkg := NewPackage("", "foo", nil)
17641764
typ := types.NewNamed(types.NewTypeName(token.NoPos, pkg.Types, "MyInt", nil), types.Typ[types.Int], nil)
17651765
if !isNumeric(&pkg.cb, typ) {
17661766
t.Fatal("TestAliasIsNumeric: MyInt not isNumeric?")
@@ -1772,7 +1772,7 @@ func TestAliasIsNumeric(t *testing.T) {
17721772
}
17731773

17741774
func TestAliasGetStruct(t *testing.T) {
1775-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1775+
pkg := NewPackage("", "foo", nil)
17761776
st := types.NewStruct(
17771777
[]*types.Var{types.NewField(token.NoPos, pkg.Types, "F", types.Typ[types.Int], false)},
17781778
nil,
@@ -1784,7 +1784,7 @@ func TestAliasGetStruct(t *testing.T) {
17841784
}
17851785

17861786
func TestAliasRecv(t *testing.T) {
1787-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1787+
pkg := NewPackage("", "foo", nil)
17881788
var instr recvInstr
17891789
elem := &Element{
17901790
Type: pkg.AliasType("MyChan", types.NewChan(types.SendRecv, types.Typ[types.Int])),
@@ -1797,7 +1797,7 @@ func TestAliasRecv(t *testing.T) {
17971797
}
17981798

17991799
func TestAliasOffsetof(t *testing.T) {
1800-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1800+
pkg := NewPackage("", "foo", nil)
18011801
var instr unsafeOffsetofInstr
18021802
typ := types.NewNamed(
18031803
types.NewTypeName(token.NoPos, pkg.Types, "Point", nil),
@@ -1831,7 +1831,7 @@ func TestAliasOffsetof(t *testing.T) {
18311831
}
18321832

18331833
func TestAliasBasic(t *testing.T) {
1834-
pkg := NewPackage("", "foo", &Config{EnableTypesalias: true})
1834+
pkg := NewPackage("", "foo", nil)
18351835
aliasType := pkg.AliasType("MyInt", types.Typ[types.Int])
18361836
elem := &Element{
18371837
Type: aliasType,

0 commit comments

Comments
 (0)