Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4b8c13dc
Commit
4b8c13dc
authored
Apr 14, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not create interfaces containing interfaces
R=r DELTA=16 (14 added, 0 deleted, 2 changed) OCL=27464 CL=27466
parent
ff73221d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
2 deletions
+16
-2
src/lib/reflect/all_test.go
src/lib/reflect/all_test.go
+6
-0
src/lib/reflect/value.go
src/lib/reflect/value.go
+5
-2
src/runtime/iface.c
src/runtime/iface.c
+5
-0
No files found.
src/lib/reflect/all_test.go
View file @
4b8c13dc
...
...
@@ -310,6 +310,12 @@ func TestInterfaceValue(t *testing.T) {
assert
(
v2
.
Type
()
.
String
(),
"interface { }"
);
v3
:=
v2
.
(
reflect
.
InterfaceValue
)
.
Value
();
assert
(
v3
.
Type
()
.
String
(),
"float"
);
i3
:=
v2
.
Interface
();
if
f
,
ok
:=
i3
.
(
float
);
!
ok
{
a
,
typ
,
c
:=
sys
.
Reflect
(
i3
);
t
.
Error
(
"v2.Interface() did not return float, got "
,
typ
);
}
}
func
TestFunctionValue
(
t
*
testing
.
T
)
{
...
...
src/lib/reflect/value.go
View file @
4b8c13dc
...
...
@@ -58,9 +58,12 @@ func (c *commonValue) Addr() Addr {
func
(
c
*
commonValue
)
Interface
()
interface
{}
{
var
i
interface
{};
if
c
.
typ
.
Size
()
>
8
{
// TODO(rsc): how do we know it is 8?
switch
{
case
c
.
typ
.
Kind
()
==
InterfaceKind
:
i
=
*
(
*
interface
{})(
c
.
addr
);
case
c
.
typ
.
Size
()
>
8
:
// TODO(rsc): how do we know it is 8?
i
=
sys
.
Unreflect
(
uint64
(
uintptr
(
c
.
addr
)),
c
.
typ
.
String
(),
true
);
}
else
{
default
:
if
uintptr
(
c
.
addr
)
==
0
{
panicln
(
"reflect: address 0 for"
,
c
.
typ
.
String
());
}
...
...
src/runtime/iface.c
View file @
4b8c13dc
...
...
@@ -766,6 +766,11 @@ sys·Unreflect(uint64 it, String type, bool indir, Iface ret)
if
(
cmpstring
(
type
,
emptystring
)
==
0
)
goto
out
;
if
(
type
.
len
>
10
&&
mcmp
(
type
.
str
,
(
byte
*
)
"interface "
,
10
)
==
0
)
{
printf
(
"sys.Unreflect: cannot put %S in interface
\n
"
,
type
);
throw
(
"sys.Unreflect"
);
}
// if we think the type should be indirect
// and caller does not, play it safe, return nil.
sigt
=
findtype
(
type
,
indir
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment