From 8b7e376e71cbd23a0644ff50cc4e75ce47cd9723 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 3 Mar 2025 15:11:47 -0800 Subject: go/types, types2: factor out single commonUnder function Combine commonUnder and commonUnderOrChan: - Provide an optional cond(ition) function argument to commonUnder to establish additional type set conditions. - Instead of a *Checker and *string argument for error reporting, return an error cause that is only allocated in the presence of an error. - Streamline some error messages. Replace all calls to coreType with calls to commonUnder. Change-Id: I81ac86d0d532cddc09164309acced61d90718b44 Reviewed-on: https://go-review.googlesource.com/c/go/+/654455 LUCI-TryBot-Result: Go LUCI Auto-Submit: Robert Griesemer Reviewed-by: Robert Griesemer Reviewed-by: Robert Findley --- src/internal/types/testdata/fixedbugs/issue43671.go | 8 ++++---- src/internal/types/testdata/fixedbugs/issue47115.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/internal') diff --git a/src/internal/types/testdata/fixedbugs/issue43671.go b/src/internal/types/testdata/fixedbugs/issue43671.go index 19da7e0ccc..5b44682a7a 100644 --- a/src/internal/types/testdata/fixedbugs/issue43671.go +++ b/src/internal/types/testdata/fixedbugs/issue43671.go @@ -12,11 +12,11 @@ type C4 interface{ chan int | chan<- int } type C5[T any] interface{ ~chan T | <-chan T } func _[T any](ch T) { - <-ch // ERRORx `cannot receive from ch .*: type set contains no specific channel type` + <-ch // ERRORx `cannot receive from ch .*: no specific channel type` } func _[T C0](ch T) { - <-ch // ERRORx `cannot receive from ch .*: type set contains non-channel int` + <-ch // ERRORx `cannot receive from ch .*: non-channel int` } func _[T C1](ch T) { @@ -28,11 +28,11 @@ func _[T C2](ch T) { } func _[T C3](ch T) { - <-ch // ERRORx `cannot receive from ch .*: type set contains channels with different element types int and float32` + <-ch // ERRORx `cannot receive from ch .*: channels chan int and chan float32 have different element types` } func _[T C4](ch T) { - <-ch // ERRORx `cannot receive from ch .*: type set contains send-only channel chan<- int` + <-ch // ERRORx `cannot receive from ch .*: send-only channel chan<- int` } func _[T C5[X], X any](ch T, x X) { diff --git a/src/internal/types/testdata/fixedbugs/issue47115.go b/src/internal/types/testdata/fixedbugs/issue47115.go index 1de85b3791..58b668ce4f 100644 --- a/src/internal/types/testdata/fixedbugs/issue47115.go +++ b/src/internal/types/testdata/fixedbugs/issue47115.go @@ -12,11 +12,11 @@ type C4 interface{ chan int | chan<- int } type C5[T any] interface{ ~chan T | chan<- T } func _[T any](ch T) { - ch <- /* ERRORx `cannot send to ch .*: type set contains no specific channel type` */ 0 + ch <- /* ERRORx `cannot send to ch .*: no specific channel type` */ 0 } func _[T C0](ch T) { - ch <- /* ERRORx `cannot send to ch .*: type set contains non-channel int` */ 0 + ch <- /* ERRORx `cannot send to ch .*: non-channel int` */ 0 } func _[T C1](ch T) { @@ -24,11 +24,11 @@ func _[T C1](ch T) { } func _[T C2](ch T) { - ch <- /* ERRORx `cannot send to ch .*: type set contains receive-only channel <-chan int` */ 0 + ch <- /* ERRORx `cannot send to ch .*: receive-only channel <-chan int` */ 0 } func _[T C3](ch T) { - ch <- /* ERRORx `cannot send to ch .*: type set contains channels with different element types` */ 0 + ch <- /* ERRORx `cannot send to ch .*: channels chan int and chan float32 have different element types` */ 0 } func _[T C4](ch T) { -- cgit v1.3-5-g9baa