@@ -115,22 +115,12 @@ func convlit1(n ir.Node, t *types.Type, explicit bool, context func() string) ir
115
115
return n
116
116
}
117
117
118
- if n .Op () == ir .OLITERAL || n .Op () == ir .ONIL {
119
- // Can't always set n.Type directly on OLITERAL nodes.
120
- // See discussion on CL 20813.
121
- old := n
122
- n = ir .Copy (old )
123
- if old .Op () == ir .OLITERAL {
124
- // Keep untyped constants in their original untyped syntax for error messages.
125
- n .(ir.OrigNode ).SetOrig (old )
126
- }
127
- }
128
-
129
118
// Nil is technically not a constant, so handle it specially.
130
119
if n .Type ().Kind () == types .TNIL {
131
120
if n .Op () != ir .ONIL {
132
121
base .Fatalf ("unexpected op: %v (%v)" , n , n .Op ())
133
122
}
123
+ n = ir .Copy (n )
134
124
if t == nil {
135
125
base .Errorf ("use of untyped nil" )
136
126
n .SetDiag (true )
@@ -158,10 +148,11 @@ func convlit1(n ir.Node, t *types.Type, explicit bool, context func() string) ir
158
148
case ir .OLITERAL :
159
149
v := convertVal (n .Val (), t , explicit )
160
150
if v .Kind () == constant .Unknown {
151
+ n = ir .NewConstExpr (n .Val (), n )
161
152
break
162
153
}
154
+ n = ir .NewConstExpr (v , n )
163
155
n .SetType (t )
164
- n .SetVal (v )
165
156
return n
166
157
167
158
case ir .OPLUS , ir .ONEG , ir .OBITNOT , ir .ONOT , ir .OREAL , ir .OIMAG :
@@ -541,8 +532,9 @@ func evalConst(n ir.Node) ir.Node {
541
532
i2 ++
542
533
}
543
534
544
- nl := origConst (s [i ], constant .MakeString (strings .Join (strs , "" )))
545
- nl .(ir.OrigNode ).SetOrig (nl ) // it's bigger than just s[i]
535
+ nl := ir .Copy (n )
536
+ nl .PtrList ().Set (s [i :i2 ])
537
+ nl = origConst (nl , constant .MakeString (strings .Join (strs , "" )))
546
538
newList = append (newList , nl )
547
539
i = i2 - 1
548
540
} else {
@@ -645,12 +637,7 @@ func origConst(n ir.Node, v constant.Value) ir.Node {
645
637
return n
646
638
}
647
639
648
- orig := n
649
- n = ir .NodAt (orig .Pos (), ir .OLITERAL , nil , nil )
650
- n .(ir.OrigNode ).SetOrig (orig )
651
- n .SetType (orig .Type ())
652
- n .SetVal (v )
653
- return n
640
+ return ir .NewConstExpr (v , n )
654
641
}
655
642
656
643
func origBoolConst (n ir.Node , v bool ) ir.Node {
0 commit comments