Skip to content

Commit 05354fc

Browse files
griesemergopherbot
authored andcommitted
go/types, types2: remove remaining references to coreType in literals.go
For now, use commonUnder (formerly called sharedUnder) and update error messages and comments. We can provide better error messages in individual cases eventually. For #70128. Change-Id: I906ba9a0c768f6499c1683dc9be3ad27da8007a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/653156 Reviewed-by: Robert Griesemer <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 26ba61d commit 05354fc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/cmd/compile/internal/types2/literals.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
129129
typ = hint
130130
base = typ
131131
// *T implies &T{}
132-
if b, ok := deref(coreType(base)); ok {
132+
if b, ok := deref(commonUnder(check, base, nil)); ok {
133133
base = b
134134
}
135135
isElem = true
@@ -142,7 +142,7 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
142142
base = typ
143143
}
144144

145-
switch utyp := coreType(base).(type) {
145+
switch utyp := commonUnder(check, base, nil).(type) {
146146
case *Struct:
147147
// Prevent crash if the struct referred to is not yet set up.
148148
// See analogous comment for *Array.
@@ -330,7 +330,7 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
330330
}
331331
var cause string
332332
if utyp == nil {
333-
cause = " (no core type)"
333+
cause = " (no common underlying type)"
334334
}
335335
check.errorf(e, InvalidLit, "invalid composite literal%s type %s%s", qualifier, typ, cause)
336336
x.mode = invalid

src/go/types/literals.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/internal/types/testdata/fixedbugs/issue51335.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ type S1 struct{}
88
type S2 struct{}
99

1010
func _[P *S1|*S2]() {
11-
_= []P{{ /* ERROR "invalid composite literal element type P (no core type)" */ }}
11+
_= []P{{ /* ERROR "invalid composite literal element type P (no common underlying type)" */ }}
1212
}
1313

1414
func _[P *S1|S1]() {
15-
_= []P{{ /* ERROR "invalid composite literal element type P (no core type)" */ }}
15+
_= []P{{ /* ERROR "invalid composite literal element type P (no common underlying type)" */ }}
1616
}

0 commit comments

Comments
 (0)