@@ -553,7 +553,7 @@ func convert(n *node) {
553
553
if c .isNil () { // convert nil to type
554
554
// TODO(mpl): Try to completely remove, as maybe frameType already does the job for interfaces.
555
555
if isInterfaceSrc (n .child [0 ].typ ) && ! isEmptyInterface (n .child [0 ].typ ) {
556
- typ = reflect . TypeOf (( * valueInterface )( nil )). Elem ()
556
+ typ = valueInterfaceType
557
557
}
558
558
n .exec = func (f * frame ) bltn {
559
559
dest (f ).Set (reflect .New (typ ).Elem ())
@@ -713,7 +713,7 @@ func assign(n *node) {
713
713
case isFuncSrc (typ ):
714
714
t = reflect .TypeOf ((* node )(nil ))
715
715
case isInterfaceSrc (typ ):
716
- t = reflect . TypeOf (( * valueInterface )( nil )). Elem ()
716
+ t = valueInterfaceType
717
717
default :
718
718
t = typ .TypeOf ()
719
719
}
@@ -1007,7 +1007,7 @@ func genFunctionWrapper(n *node) func(*frame) reflect.Value {
1007
1007
}
1008
1008
typ := def .typ .arg [i ]
1009
1009
switch {
1010
- case isEmptyInterface (typ ):
1010
+ case isEmptyInterface (typ ) || typ . TypeOf () == valueInterfaceType :
1011
1011
d [i ].Set (arg )
1012
1012
case isInterfaceSrc (typ ):
1013
1013
d [i ].Set (reflect .ValueOf (valueInterface {value : arg .Elem ()}))
@@ -1560,12 +1560,9 @@ func callBin(n *node) {
1560
1560
case isInterfaceSrc (c .typ ):
1561
1561
values = append (values , genValueInterfaceValue (c ))
1562
1562
case c .typ .cat == arrayT || c .typ .cat == variadicT :
1563
- switch {
1564
- case isEmptyInterface (c .typ .val ):
1563
+ if isEmptyInterface (c .typ .val ) {
1565
1564
values = append (values , genValueArray (c ))
1566
- case isInterfaceSrc (c .typ .val ):
1567
- values = append (values , genValueInterfaceArray (c ))
1568
- default :
1565
+ } else {
1569
1566
values = append (values , genInterfaceWrapper (c , defType ))
1570
1567
}
1571
1568
case isPtrSrc (c .typ ):
@@ -2703,8 +2700,6 @@ func doComposite(n *node, hasType bool, keyed bool) {
2703
2700
values [fieldIndex ] = func (* frame ) reflect.Value { return reflect .New (rft ).Elem () }
2704
2701
case isFuncSrc (val .typ ):
2705
2702
values [fieldIndex ] = genValueAsFunctionWrapper (val )
2706
- case isArray (val .typ ) && val .typ .val != nil && isInterfaceSrc (val .typ .val ) && ! isEmptyInterface (val .typ .val ):
2707
- values [fieldIndex ] = genValueInterfaceArray (val )
2708
2703
case isInterfaceSrc (ft ) && (! isEmptyInterface (ft ) || len (val .typ .method ) > 0 ):
2709
2704
values [fieldIndex ] = genValueInterface (val )
2710
2705
case isInterface (ft ):
@@ -3585,7 +3580,7 @@ func convertLiteralValue(n *node, t reflect.Type) {
3585
3580
case n .typ .cat == nilT :
3586
3581
// Create a zero value of target type.
3587
3582
n .rval = reflect .New (t ).Elem ()
3588
- case ! (n .kind == basicLit || n .rval .IsValid ()) || t == nil || t .Kind () == reflect .Interface || t .Kind () == reflect .Slice && t .Elem ().Kind () == reflect .Interface :
3583
+ case ! (n .kind == basicLit || n .rval .IsValid ()) || t == nil || t .Kind () == reflect .Interface || t == valueInterfaceType || t .Kind () == reflect .Slice && t .Elem ().Kind () == reflect .Interface :
3589
3584
// Skip non-constant values, undefined target type or interface target type.
3590
3585
case n .rval .IsValid ():
3591
3586
// Convert constant value to target type.
@@ -3946,7 +3941,7 @@ func isNotNil(n *node) {
3946
3941
dest := genValue (n )
3947
3942
3948
3943
if n .fnext == nil {
3949
- if isInterfaceSrc (c0 .typ ) {
3944
+ if isInterfaceSrc (c0 .typ ) && c0 . typ . TypeOf () != valueInterfaceType {
3950
3945
if isInterface {
3951
3946
n .exec = func (f * frame ) bltn {
3952
3947
dest (f ).Set (reflect .ValueOf (! value (f ).IsNil ()).Convert (typ ))
@@ -3991,7 +3986,7 @@ func isNotNil(n *node) {
3991
3986
3992
3987
fnext := getExec (n .fnext )
3993
3988
3994
- if isInterfaceSrc (c0 .typ ) {
3989
+ if isInterfaceSrc (c0 .typ ) && c0 . typ . TypeOf () != valueInterfaceType {
3995
3990
n .exec = func (f * frame ) bltn {
3996
3991
if value (f ).IsNil () {
3997
3992
dest (f ).SetBool (false )
0 commit comments