Skip to content

Commit d24ab5e

Browse files
authored
Merge pull request #22042 from github/jketema/go-1.27
Go: Update to 1.27
2 parents 87c77cc + 072b298 commit d24ab5e

15 files changed

Lines changed: 73 additions & 12 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ use_repo(
302302
)
303303

304304
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
305-
go_sdk.download(version = "1.26.6")
305+
go_sdk.download(version = "1.27.0")
306306

307307
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
308308
go_deps.from_file(go_mod = "//go/extractor:go.mod")

docs/codeql/reusables/supported-versions-compilers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
.NET 5, .NET 6, .NET 7, .NET 8, .NET 9, .NET 10","``.sln``, ``.slnx``, ``.csproj``, ``.cs``, ``.cshtml``, ``.xaml``"
1919
GitHub Actions,"Not applicable",Not applicable,"``.github/workflows/*.yml``, ``.github/workflows/*.yaml``, ``**/action.yml``, ``**/action.yaml``"
20-
Go (aka Golang), "Go up to 1.26", "Go 1.11 or more recent", ``.go``
20+
Go (aka Golang), "Go up to 1.27", "Go 1.11 or more recent", ``.go``
2121
Java,"Java 7 to 26 [5]_","javac (OpenJDK and Oracle JDK),
2222

2323
Eclipse compiler for Java (ECJ) [6]_",``.java``

go/actions/test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ inputs:
44
go-test-version:
55
description: Which Go version to use for running the tests
66
required: false
7-
default: "~1.26.6"
7+
default: "~1.27.0"
88
run-code-checks:
99
description: Whether to run qhelp generation checks
1010
required: false

go/extractor/autobuilder/build-environment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
var minGoVersion = util.NewSemVer("1.11")
15-
var maxGoVersion = util.NewSemVer("1.26")
15+
var maxGoVersion = util.NewSemVer("1.27")
1616

1717
type versionInfo struct {
1818
goModVersion util.SemVer // The version of Go found in the go directive in the `go.mod` file.

go/extractor/extractor.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,8 +1657,30 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
16571657
// parent scope, so they are not dealt with by `extractScopes`
16581658
for i := 0; i < origintp.NumMethods(); i++ {
16591659
meth := origintp.Method(i).Origin()
1660-
16611660
extractMethod(tw, meth)
1661+
1662+
// Consider a generic struct and a generic method:
1663+
//
1664+
// type S[P any] struct{}
1665+
// func (*S[P]) m[Q any](x Q) {}
1666+
//
1667+
// If we have a variable 's' of type 'S[int]' and the expression
1668+
// 's.m[string]("")', then the type of the selector expression 's.m'
1669+
// is ' func(Q)'. The method 'm' here is an instantiation of the
1670+
// declaration, which has its own type with type parameter 'Q'.
1671+
// As we do not extract method instantiations, 'populateTypeParamParents'
1672+
// does not automatically get called for the type parameter 'Q'
1673+
// from the instantiation of 'm'. To compensate, we add the type
1674+
// parameters here.
1675+
//
1676+
// As a parent we use the origin method. This suffices, as the name
1677+
// and index of the type parameter in the instantiation will be
1678+
// identical to those of the uninstantiated method, and as only
1679+
// these two properties will be extracted for a type parameter.
1680+
if tp.Method(i) != meth {
1681+
signature := tp.Method(i).Type().(*types.Signature)
1682+
populateTypeParamParents(signature.TypeParams(), meth, false)
1683+
}
16621684
}
16631685

16641686
underlyingInterface, underlyingIsInterface := underlying.(*types.Interface)

go/extractor/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module github.com/github/codeql-go/extractor
22

3-
go 1.26
3+
go 1.27
44

5-
toolchain go1.26.6
5+
toolchain go1.27.0
66

77
// when updating this, run
88
// bazel run @rules_go//go -- mod tidy

go/extractor/toolchain/toolchain_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88

99
func TestParseGoVersion(t *testing.T) {
1010
tests := map[string]string{
11-
"go version go1.18.9 linux/amd64": "go1.18.9",
12-
"go version go1.26.3-X:nodwarf5 linux/amd64": "go1.26.3",
13-
"go version go1.26.3rc1 linux/amd64": "go1.26.3rc1",
11+
"go version go1.18.9 linux/amd64": "go1.18.9",
12+
"go version go1.26.3-X:nodwarf5 linux/amd64": "go1.26.3",
13+
"go version go1.26.3rc1 linux/amd64": "go1.26.3rc1",
1414
"warning: GOPATH set to GOROOT (/usr/local/go) has no effect\ngo version go1.18.9 linux/amd64": "go1.18.9",
1515
}
1616
for input, expected := range tests {

go/extractor/trap/labels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func findMethodOnTypeWithGivenReceiver(tp types.Type, object types.Object) *type
187187
if definedType, ok := tp.(*types.Named); ok {
188188
for i := 0; i < definedType.NumMethods(); i++ {
189189
meth := definedType.Method(i)
190-
if object == meth.Type().(*types.Signature).Recv() {
190+
if object == meth.Type().(*types.Signature).Recv().Origin() {
191191
return meth
192192
}
193193
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: majorAnalysis
3+
---
4+
* Go 1.27 is now supported.

go/ql/test/library-tests/semmle/go/Function/GenericFunctionInstantiationExpr.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
| genericFunctions.go:45:6:45:50 | generic function instantiation expression | genericFunctions.go:45:6:45:33 | GenericFunctionTwoTypeParams | 1 | genericFunctions.go:45:43:45:49 | float64 |
77
| genericFunctions.go:141:6:141:41 | generic function instantiation expression | genericFunctions.go:141:6:141:33 | GenericFunctionInAnotherFile | 0 | genericFunctions.go:141:35:141:40 | string |
88
| genericFunctions.go:146:6:146:55 | generic function instantiation expression | genericFunctions.go:146:6:146:47 | selection of GenericFunctionInAnotherPackage | 0 | genericFunctions.go:146:49:146:54 | string |
9+
| genericMethods.go:13:2:13:23 | generic function instantiation expression | genericMethods.go:13:2:13:18 | selection of GenericMethod1 | 0 | genericMethods.go:13:20:13:22 | int |
10+
| genericMethods.go:14:2:14:26 | generic function instantiation expression | genericMethods.go:14:2:14:18 | selection of GenericMethod2 | 0 | genericMethods.go:14:20:14:25 | string |

0 commit comments

Comments
 (0)