-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/analysis/passes/composite: update for generics
Warn about unkeyed composite literals via literals of type parameter type. Updates golang/go#48704 Change-Id: Ia75139b56cb73288c133bd547d71664464015813 Reviewed-on: https://go-review.googlesource.com/c/tools/+/357756 Trust: Robert Findley <[email protected]> Run-TryBot: Robert Findley <[email protected]> gopls-CI: kokoro <[email protected]> Reviewed-by: Tim King <[email protected]> TryBot-Result: Go Bot <[email protected]>
- Loading branch information
Showing
6 changed files
with
137 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
go/analysis/passes/composite/testdata/src/typeparams/lib/lib.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package lib | ||
|
||
type Struct struct{ F int } | ||
type Slice []int | ||
type Map map[int]int |
27 changes: 27 additions & 0 deletions
27
go/analysis/passes/composite/testdata/src/typeparams/typeparams.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package typeparams | ||
|
||
import "typeparams/lib" | ||
|
||
type localStruct struct { F int } | ||
|
||
func F[ | ||
T1 ~struct{ f int }, | ||
T2a localStruct, | ||
T2b lib.Struct, | ||
T3 ~[]int, | ||
T4 lib.Slice, | ||
T5 ~map[int]int, | ||
T6 lib.Map, | ||
]() { | ||
_ = T1{2} | ||
_ = T2a{2} | ||
_ = T2b{2} // want "unkeyed fields" | ||
_ = T3{1,2} | ||
_ = T4{1,2} | ||
_ = T5{1:2} | ||
_ = T6{1:2} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters