• Matthew Dempsky's avatar
    cmd/compile: don't apply -lang=go1.X restrictions to imported packages · b7d097a4
    Matthew Dempsky authored
    Previously langSupported applied -lang as though it's a global
    restriction, but it's actually a per-package restriction. This CL
    fixes langSupported to take a *types.Pkg parameter to reflect this and
    updates its callers accordingly.
    
    This is relevant for signed shifts (added in Go 1.12), because they
    can be inlined into a Go 1.11 package; and for overlapping interfaces
    (added in Go 1.13), because they can be exported as part of the
    package's API.
    
    Today we require all Go packages to be compiled with the same
    toolchain, and all uses of langSupported are for controlling
    backwards-compatible features. So we can simply assume that since the
    imported packages type-checked successfully, they must have been
    compiled with an appropriate -lang setting.
    
    In the future if we ever want to use langSupported to control
    backwards-incompatible language changes, we might need to record the
    -lang flag used for compiling a package in its export data.
    
    Fixes #35437.
    Fixes #35442.
    
    Change-Id: Ifdf6a62ee80cd5fb4366cbf12933152506d1b36e
    Reviewed-on: https://go-review.googlesource.com/c/go/+/205977Reviewed-by: default avatarBryan C. Mills <bcmills@google.com>
    Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
    b7d097a4
typecheck.go 87.1 KB