-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inferencegenericsIssue is related to genericsIssue is related to generics
Milestone
Description
What version of Go are you using (go version
)?
$ go version go version go1.19.3 darwin/arm64
Does this issue reproduce with the latest release?
Yes, tested on playground.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/*/Library/Caches/go-build" GOENV="/Users/*/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/*/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/*/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/opt/homebrew/Cellar/go/1.19.3/libexec" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/homebrew/Cellar/go/1.19.3/libexec/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.19.3" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/cl/x9ccznh92fbc0_57g_7nk2gc0000gn/T/go-build3394357358=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Given GenericInterface1[T any]
, GenericInterface2[T any] { GenericInterface1[T] }
, and a function func F[T any](GI1 GenericInterface1[T]()
, T
is not inferred if we pass to F
a GenericInterface2
.
https://go.dev/play/p/dsZOHq2Y1Au
What did you expect to see?
Type inference to work since GenericInterface2
is also GenericInterface1
, and since passing to F
a declared variable of type GenericInterface1[T]
works (if it's not explicitly declared, then type inference cannot infer T even for GenericInterface1
).
What did you see instead?
Compilation failure.
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.Feedback is required from experts, contributors, and/or the community before a change can be made.TypeInferenceIssue is related to generic type inferenceIssue is related to generic type inferencegenericsIssue is related to genericsIssue is related to generics