diff options
Diffstat (limited to 'libgo/go/reflect')
-rw-r--r-- | libgo/go/reflect/all_test.go | 5 | ||||
-rw-r--r-- | libgo/go/reflect/type.go | 17 |
2 files changed, 15 insertions, 7 deletions
diff --git a/libgo/go/reflect/all_test.go b/libgo/go/reflect/all_test.go index 599ab27..9452255 100644 --- a/libgo/go/reflect/all_test.go +++ b/libgo/go/reflect/all_test.go @@ -4136,7 +4136,6 @@ func TestArrayOfGenericAlg(t *testing.T) { } func TestArrayOfDirectIface(t *testing.T) { - t.Skip("skipping test because gccgo uses a different directiface value") { type T [1]*byte i1 := Zero(TypeOf(T{})).Interface() @@ -4775,9 +4774,6 @@ func TestStructOfGenericAlg(t *testing.T) { } } -/* -gccgo does not use the same directiface settings as gc. - func TestStructOfDirectIface(t *testing.T) { { type T struct{ X [1]*byte } @@ -4826,7 +4822,6 @@ func TestStructOfDirectIface(t *testing.T) { } } } -*/ type StructI int diff --git a/libgo/go/reflect/type.go b/libgo/go/reflect/type.go index ea97b7d9..fb2e5d4 100644 --- a/libgo/go/reflect/type.go +++ b/libgo/go/reflect/type.go @@ -2204,7 +2204,14 @@ func StructOf(fields []StructField) Type { typ.equalfn = nil } - typ.kind &^= kindDirectIface + switch { + case len(fs) == 1 && !ifaceIndir(fs[0].typ): + // structs of 1 direct iface type can be direct + typ.kind |= kindDirectIface + default: + typ.kind &^= kindDirectIface + } + typ.uncommonType = nil typ.ptrToThis = nil @@ -2405,7 +2412,13 @@ func ArrayOf(count int, elem Type) Type { array.ptrdata = array.size // overestimate but ok; must match program } - array.kind &^= kindDirectIface + switch { + case count == 1 && !ifaceIndir(typ): + // array of 1 direct iface type can be direct + array.kind |= kindDirectIface + default: + array.kind &^= kindDirectIface + } esize := typ.size |