aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/quasilyte
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2024-09-10 12:16:33 +0200
committerTaras Madan <tarasmadan@google.com>2024-09-10 14:05:26 +0000
commitc97c816133b42257d0bcf1ee4bd178bb2a7a2b9e (patch)
tree0bcbc2e540bbf8f62f6c17887cdd53b8c2cee637 /vendor/github.com/quasilyte
parent54e657429ab892ad06c90cd7c1a4eb33ba93a3dc (diff)
vendor: update
Diffstat (limited to 'vendor/github.com/quasilyte')
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/LICENSE29
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/bundle.go19
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/do.go19
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/dsl.go361
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/filter.go24
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/internal.go6
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/types/ext.go21
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/types/type_impl.go17
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/dsl/types/types.go68
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/internal/xtypes/xtypes.go4
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/ruleguard/irconv/irconv.go3
-rw-r--r--vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/compile.go7
12 files changed, 573 insertions, 5 deletions
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/LICENSE b/vendor/github.com/quasilyte/go-ruleguard/dsl/LICENSE
new file mode 100644
index 000000000..558f81ff2
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/LICENSE
@@ -0,0 +1,29 @@
+BSD 3-Clause License
+
+Copyright (c) 2022, Iskander (Alex) Sharipov / quasilyte
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holder nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/bundle.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/bundle.go
new file mode 100644
index 000000000..45a9455d8
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/bundle.go
@@ -0,0 +1,19 @@
+package dsl
+
+// Bundle is a rules file export manifest.
+type Bundle struct {
+ // TODO: figure out which fields we might want to add here.
+}
+
+// ImportRules imports all rules from the bundle and prefixes them with a specified string.
+//
+// Empty string prefix is something like "dot import" in Go.
+// Group name collisions will result in an error.
+//
+// Only packages that have an exported Bundle variable can be imported.
+//
+// Note: right now imported bundle can't import other bundles.
+// This is not a fundamental limitation but rather a precaution
+// measure before we understand how it should work better.
+// If you need this feature, please open an issue at github.com/quasilyte/go-ruleguard.
+func ImportRules(prefix string, bundle Bundle) {}
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/do.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/do.go
new file mode 100644
index 000000000..86bc163a7
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/do.go
@@ -0,0 +1,19 @@
+package dsl
+
+import (
+ "github.com/quasilyte/go-ruleguard/dsl/types"
+)
+
+type DoContext struct{}
+
+func (*DoContext) Var(varname string) *DoVar { return nil }
+
+func (*DoContext) SetReport(report string) {}
+
+func (*DoContext) SetSuggest(suggest string) {}
+
+type DoVar struct{}
+
+func (*DoVar) Text() string { return "" }
+
+func (*DoVar) Type() types.Type { return nil }
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/dsl.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/dsl.go
new file mode 100644
index 000000000..d3c73bddd
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/dsl.go
@@ -0,0 +1,361 @@
+package dsl
+
+// Matcher is a main API group-level entry point.
+// It's used to define and configure the group rules.
+// It also represents a map of all rule-local variables.
+type Matcher map[string]Var
+
+// Import loads given package path into a rule group imports table.
+//
+// That table is used during the rules compilation.
+//
+// The table has the following effect on the rules:
+// * For type expressions, it's used to resolve the
+// full package paths of qualified types, like `foo.Bar`.
+// If Import(`a/b/foo`) is called, `foo.Bar` will match
+// `a/b/foo.Bar` type during the pattern execution.
+func (m Matcher) Import(pkgPath string) {}
+
+// Match specifies a set of patterns that match a rule being defined.
+// Pattern matching succeeds if at least 1 pattern matches.
+//
+// If none of the given patterns matched, rule execution stops.
+func (m Matcher) Match(pattern string, alternatives ...string) Matcher {
+ return m
+}
+
+// MatchComment is like Match, but handles only comments and uses regexp patterns.
+//
+// Multi-line /**/ comments are passed as a single string.
+// Single-line // comments are passed line-by-line.
+//
+// Hint: if you want to match a plain text and don't want to do meta char escaping,
+// prepend `\Q` to your pattern. `\Qf(x)` will match `f(x)` as a plain text
+// and there is no need to escape the `(` and `)` chars.
+//
+// Named regexp capture groups can be accessed using the usual indexing notation.
+//
+// Given this pattern:
+//
+// `(?P<first>\d+)\.(\d+).(?P<second>\d+)`
+//
+// And this input comment: `// 14.6.600`
+//
+// We'll get these submatches:
+//
+// m["$$"] => `14.6.600`
+// m["first"] => `14`
+// m["second"] => `600`
+//
+// All usual filters can be applied:
+//
+// Where(!m["first"].Text.Matches(`foo`))
+//
+// You can use this to reject some matches (allow-list behavior).
+func (m Matcher) MatchComment(pattern string, alternatives ...string) Matcher {
+ return m
+}
+
+// Where applies additional constraint to a match.
+// If a given cond is not satisfied, a match is rejected and
+// rule execution stops.
+func (m Matcher) Where(cond bool) Matcher {
+ return m
+}
+
+// Report prints a message if associated rule match is successful.
+//
+// A message is a string that can contain interpolated expressions.
+// For every matched variable it's possible to interpolate
+// their printed representation into the message text with $<name>.
+// An entire match can be addressed with $$.
+func (m Matcher) Report(message string) Matcher {
+ return m
+}
+
+// Suggest assigns a quickfix suggestion for the matched code.
+func (m Matcher) Suggest(suggestion string) Matcher {
+ return m
+}
+
+func (m Matcher) Do(fn func(*DoContext)) Matcher {
+ return m
+}
+
+// At binds the reported node to a named submatch.
+// If no explicit location is given, the outermost node ($$) is used.
+func (m Matcher) At(v Var) Matcher {
+ return m
+}
+
+// File returns the current file context.
+func (m Matcher) File() File { return File{} }
+
+// GoVersion returns the analyzer associated target Go language version.
+func (m Matcher) GoVersion() GoVersion { return GoVersion{} }
+
+// Deadcode reports whether this match is contained inside a dead code path.
+func (m Matcher) Deadcode() bool { return boolResult }
+
+// Var is a pattern variable that describes a named submatch.
+type Var struct {
+ // Pure reports whether expr matched by var is side-effect-free.
+ Pure bool
+
+ // Const reports whether expr matched by var is a constant value.
+ Const bool
+
+ // ConstSlice reports whether expr matched by var is a slice literal
+ // consisting of contant elements.
+ //
+ // We need a separate Const-like predicate here because Go doesn't
+ // treat slices of const elements as constants, so including
+ // them in Const would be incorrect.
+ // Use `m["x"].Const || m["x"].ConstSlice` when you need
+ // to have extended definition of "constant value".
+ //
+ // Some examples:
+ // []byte("foo") -- constant byte slice
+ // []byte{'f', 'o', 'o'} -- same constant byte slice
+ // []int{1, 2} -- constant int slice
+ ConstSlice bool
+
+ // Value is a compile-time computable value of the expression.
+ Value ExprValue
+
+ // Addressable reports whether the corresponding expression is addressable.
+ // See https://golang.org/ref/spec#Address_operators.
+ Addressable bool
+
+ // Comparable reports whether the corresponding expression value is comparable.
+ // See https://pkg.go.dev/go/types#Comparable.
+ Comparable bool
+
+ // Type is a type of a matched expr.
+ //
+ // For function call expressions, a type is a function result type,
+ // but for a function expression itself it's a *types.Signature.
+ //
+ // Suppose we have a `a.b()` expression:
+ // `$x()` m["x"].Type is `a.b` function type
+ // `$x` m["x"].Type is `a.b()` function call result type
+ Type ExprType
+
+ SinkType SinkType
+
+ // Object is an associated "go/types" Object.
+ Object TypesObject
+
+ // Text is a captured node text as in the source code.
+ Text MatchedText
+
+ // Node is a captured AST node.
+ Node MatchedNode
+
+ // Line is a source code line number that contains this match.
+ // If this match is multi-line, this is the first line number.
+ Line int
+}
+
+// Filter applies a custom predicate function on a submatch.
+//
+// The callback function should use VarFilterContext to access the
+// information that is usually accessed through Var.
+// For example, `VarFilterContext.Type` is mapped to `Var.Type`.
+func (Var) Filter(pred func(*VarFilterContext) bool) bool { return boolResult }
+
+// Contains runs a sub-search from a given pattern using the captured
+// vars from the original pattern match.
+//
+// For example, given the Match(`$lhs = append($lhs, $x)`) pattern,
+// we can do m["lhs"].Contains(`$x`) and learn whether $lhs contains
+// $x as its sub-expression.
+//
+// Experimental: this function is not part of the stable API.
+func (Var) Contains(pattern string) bool { return boolResult }
+
+// MatchedNode represents an AST node associated with a named submatch.
+type MatchedNode struct{}
+
+// Is reports whether a matched node AST type is compatible with the specified type.
+// A valid argument is a ast.Node implementing type name from the "go/ast" package.
+// Examples: "BasicLit", "Expr", "Stmt", "Ident", "ParenExpr".
+// See https://golang.org/pkg/go/ast/.
+func (MatchedNode) Is(typ string) bool { return boolResult }
+
+// Parent returns a matched node parent.
+func (MatchedNode) Parent() Node { return Node{} }
+
+// Node represents an AST node somewhere inside a match.
+// Unlike MatchedNode, it doesn't have to be associated with a named submatch.
+type Node struct{}
+
+// Is reports whether a node AST type is compatible with the specified type.
+// See `MatchedNode.Is` for the full reference.
+func (Node) Is(typ string) bool { return boolResult }
+
+// ExprValue describes a compile-time computable value of a matched expr.
+type ExprValue struct{}
+
+// Int returns compile-time computable int value of the expression.
+// If value can't be computed, condition will fail.
+func (ExprValue) Int() int { return intResult }
+
+// TypesObject is a types.Object mapping.
+type TypesObject struct{}
+
+// Is reports whether an associated types.Object is compatible with the specified type.
+// A valid argument is a types.Object type name from the "go/types" package.
+// Examples: "Func", "Var", "Const", "TypeName", "Label", "PkgName", "Builtin", "Nil"
+// See https://golang.org/pkg/go/types/.
+func (TypesObject) Is(typ string) bool { return boolResult }
+
+// IsGlobal reports whether an associated types.Object is defined in global scope.
+func (TypesObject) IsGlobal() bool { return boolResult }
+
+// IsVariadicParam reports whether this object represents a function variadic param.
+// This property is not propagated between the assignments.
+func (TypesObject) IsVariadicParam() bool { return boolResult }
+
+type SinkType struct{}
+
+// Is reports whether a type is identical to a given type.
+// Works like ExprType.Is method.
+func (SinkType) Is(typ string) bool { return boolResult }
+
+// ExprType describes a type of a matcher expr.
+type ExprType struct {
+ // Size represents expression type size in bytes.
+ //
+ // For expressions of unknown size, like type params in generics,
+ // any filter using this operand will fail.
+ Size int
+}
+
+// IdenticalTo applies types.Identical(this, v.Type) operation.
+// See https://golang.org/pkg/go/types/#Identical function documentation.
+//
+// Experimental: this function is not part of the stable API.
+func (ExprType) IdenticalTo(v Var) bool { return boolResult }
+
+// Underlying returns expression type underlying type.
+// See https://golang.org/pkg/go/types/#Type Underlying() method documentation.
+// Read https://golang.org/ref/spec#Types section to learn more about underlying types.
+func (ExprType) Underlying() ExprType { return underlyingType }
+
+// AssignableTo reports whether a type is assign-compatible with a given type.
+// See https://golang.org/pkg/go/types/#AssignableTo.
+func (ExprType) AssignableTo(typ string) bool { return boolResult }
+
+// ConvertibleTo reports whether a type is conversible to a given type.
+// See https://golang.org/pkg/go/types/#ConvertibleTo.
+func (ExprType) ConvertibleTo(typ string) bool { return boolResult }
+
+// Implements reports whether a type implements a given interface.
+// See https://golang.org/pkg/go/types/#Implements.
+func (ExprType) Implements(typ typeName) bool { return boolResult }
+
+// HasMethod reports whether a type has a given method.
+// Unlike Implements(), it will work for both value and pointer types.
+//
+// fn argument is a function signature, like `WriteString(string) (int, error)`.
+// It can also be in form of a method reference for importable types: `io.StringWriter.WriteString`.
+//
+// To avoid confusion with Implements() method, here is a hint when to use which:
+//
+// - To check if it's possible to call F on x, use HasMethod(F)
+// - To check if x can be passed as I interface, use Implements(I)
+func (ExprType) HasMethod(fn string) bool { return boolResult }
+
+// Is reports whether a type is identical to a given type.
+func (ExprType) Is(typ string) bool { return boolResult }
+
+// HasPointers reports whether a type contains at least one pointer.
+//
+// We try to be as close to the Go sense of pointer-free objects as possible,
+// therefore string type is not considered to be a pointer-free type.
+//
+// This function may return "true" for some complicated cases as a
+// conservative result. It never returns "false" for a type that
+// actually contains a pointer.
+//
+// So this function is mostly useful for !HasPointers() form.
+func (ExprType) HasPointers() bool { return boolResult }
+
+// OfKind reports whether a matched expr type is compatible with the specified kind.
+//
+// Only a few "kinds" are recognized, the list is provided below.
+//
+// "integer" -- typ is *types.Basic, where typ.Info()&types.Integer != 0
+// "unsigned" -- typ is *types.Basic, where typ.Info()&types.Unsigned != 0
+// "float" -- typ is *types.Basic, where typ.Info()&types.Float != 0
+// "complex" -- typ is *types.Basic, where typ.Info()&types.Complex != 0
+// "untyped" -- typ is *types.Basic, where typ.Info()&types.Untyped != 0
+// "numeric" -- typ is *types.Basic, where typ.Info()&types.Numeric != 0
+// "signed" -- identical to `OfKind("integer") && !OfKind("unsigned")`
+// "int" -- int, int8, int16, int32, int64
+// "uint" -- uint, uint8, uint16, uint32, uint64
+//
+// Note: "int" will include "rune" as well, as it's an alias.
+// In the same manner, "uint" includes the "byte" type.
+//
+// Using OfKind("unsigned") is more efficient (and concise) than using a set
+// of or-conditions with Is("uint8"), Is("uint16") and so on.
+func (ExprType) OfKind(kind string) bool { return boolResult }
+
+// MatchedText represents a source text associated with a matched node.
+type MatchedText string
+
+// Matches reports whether the text matches the given regexp pattern.
+func (MatchedText) Matches(pattern string) bool { return boolResult }
+
+// String represents an arbitrary string-typed data.
+type String string
+
+// Matches reports whether a string matches the given regexp pattern.
+func (String) Matches(pattern string) bool { return boolResult }
+
+// File represents the current Go source file.
+type File struct {
+ // Name is a file base name.
+ Name String
+
+ // PkgPath is a file package path.
+ // Examples: "io/ioutil", "strings", "github.com/quasilyte/go-ruleguard/dsl".
+ PkgPath String
+}
+
+// Imports reports whether the current file imports the given path.
+func (File) Imports(path string) bool { return boolResult }
+
+// GoVersion is an analysis target go language version.
+// It can be compared to Go versions like "1.10", "1.16" using
+// the associated methods.
+type GoVersion struct{}
+
+// Eq asserts that target Go version is equal to (==) specified version.
+func (GoVersion) Eq(version string) bool { return boolResult }
+
+// GreaterEqThan asserts that target Go version is greater or equal than (>=) specified version.
+func (GoVersion) GreaterEqThan(version string) bool { return boolResult }
+
+// GreaterThan asserts that target Go version is greater than (>) specified version.
+func (GoVersion) GreaterThan(version string) bool { return boolResult }
+
+// LessThan asserts that target Go version is less than (<) specified version.
+func (GoVersion) LessThan(version string) bool { return boolResult }
+
+// LessEqThan asserts that target Go version is less or equal than (<=) specified version.
+func (GoVersion) LessEqThan(version string) bool { return boolResult }
+
+// typeName is a helper type used to document function params better.
+//
+// A type name can be:
+// - builtin type name: `error`, `string`, etc.
+// - qualified name from a standard library: `io.Reader`, etc.
+// - fully-qualified type name, like `github.com/username/pkgname.TypeName`
+//
+// typeName is also affected by a local import table, which can override
+// how qualified names are interpreted.
+// See `Matcher.Import` for more info.
+type typeName = string
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/filter.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/filter.go
new file mode 100644
index 000000000..cef880098
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/filter.go
@@ -0,0 +1,24 @@
+package dsl
+
+import (
+ "github.com/quasilyte/go-ruleguard/dsl/types"
+)
+
+// VarFilterContext carries Var and environment information into the filter function.
+// It's an input parameter type for the Var.Filter function callback.
+type VarFilterContext struct {
+ // Type is mapped to Var.Type field.
+ Type types.Type
+}
+
+// SizeOf returns the size of the given type.
+// It uses the ruleguard.Context.Sizes to calculate the result.
+func (*VarFilterContext) SizeOf(x types.Type) int { return 0 }
+
+// GetType finds a type value by a given name.
+// If a type can't be found (or a name is malformed), this function panics.
+func (*VarFilterContext) GetType(name typeName) types.Type { return nil }
+
+// GetInterface finds a type value that represents an interface by a given name.
+// Works like `types.AsInterface(ctx.GetType(name))`.
+func (*VarFilterContext) GetInterface(name typeName) *types.Interface { return nil }
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/internal.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/internal.go
new file mode 100644
index 000000000..3bb6d85dc
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/internal.go
@@ -0,0 +1,6 @@
+package dsl
+
+var boolResult bool
+var intResult int
+
+var underlyingType ExprType
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/types/ext.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/types/ext.go
new file mode 100644
index 000000000..82595ff30
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/types/ext.go
@@ -0,0 +1,21 @@
+package types
+
+// AsArray is a type-assert like operation, x.(*Array), but never panics.
+// Returns nil if type is not an array.
+func AsArray(x Type) *Array { return nil }
+
+// AsSlice is a type-assert like operation, x.(*Slice), but never panics.
+// Returns nil if type is not an array.
+func AsSlice(x Type) *Slice { return nil }
+
+// AsPointer is a type-assert like operation, x.(*Pointer), but never panics.
+// Returns nil if type is not a pointer.
+func AsPointer(x Type) *Pointer { return nil }
+
+// AsStruct is a type-assert like operation, x.(*Struct), but never panics.
+// Returns nil if type is not a struct.
+func AsStruct(x Type) *Struct { return nil }
+
+// AsInterface is a type-assert like operation, x.(*Interface), but never panics.
+// Returns nil if type is not an interface.
+func AsInterface(x Type) *Interface { return nil }
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/types/type_impl.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/types/type_impl.go
new file mode 100644
index 000000000..9fc71d753
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/types/type_impl.go
@@ -0,0 +1,17 @@
+package types
+
+// Method stubs to make various types implement Type interface.
+//
+// Nothing interesting here, hence it's moved to a separate file.
+
+func (*Array) String() string { return "" }
+func (*Slice) String() string { return "" }
+func (*Pointer) String() string { return "" }
+func (*Interface) String() string { return "" }
+func (*Struct) String() string { return "" }
+
+func (*Array) Underlying() Type { return nil }
+func (*Slice) Underlying() Type { return nil }
+func (*Pointer) Underlying() Type { return nil }
+func (*Interface) Underlying() Type { return nil }
+func (*Struct) Underlying() Type { return nil }
diff --git a/vendor/github.com/quasilyte/go-ruleguard/dsl/types/types.go b/vendor/github.com/quasilyte/go-ruleguard/dsl/types/types.go
new file mode 100644
index 000000000..b6be7cc35
--- /dev/null
+++ b/vendor/github.com/quasilyte/go-ruleguard/dsl/types/types.go
@@ -0,0 +1,68 @@
+// Package types mimics the https://golang.org/pkg/go/types/ package.
+// It also contains some extra utility functions, they're defined in ext.go file.
+package types
+
+// Implements reports whether a given type implements the specified interface.
+func Implements(typ Type, iface *Interface) bool { return false }
+
+// Identical reports whether x and y are identical types. Receivers of Signature types are ignored.
+func Identical(x, y Type) bool { return false }
+
+// A Type represents a type of Go. All types implement the Type interface.
+type Type interface {
+ // Underlying returns the underlying type of a type.
+ Underlying() Type
+
+ // String returns a string representation of a type.
+ String() string
+}
+
+type (
+ // An Array represents an array type.
+ Array struct{}
+
+ // A Slice represents a slice type.
+ Slice struct{}
+
+ // A Pointer represents a pointer type.
+ Pointer struct{}
+
+ // An Interface represents an interface type.
+ Interface struct{}
+
+ // A struct represents a struct type.
+ Struct struct{}
+)
+
+// NewArray returns a new array type for the given element type and length.
+// A negative length indicates an unknown length.
+func NewArray(elem Type, len int) *Array { return nil }
+
+// Elem returns element type of array.
+func (*Array) Elem() Type { return nil }
+
+// NewSlice returns a new slice type for the given element type.
+func NewSlice(elem Type) *Slice { return nil }
+
+// Elem returns element type of slice.
+func (*Slice) Elem() Type { return nil }
+
+// Len returns the length of array.
+// A negative result indicates an unknown length.
+func (*Array) Len() int { return 0 }
+
+// NewPointer returns a new pointer type for the given element (base) type.
+func NewPointer(elem Type) *Pointer { return nil }
+
+// Elem returns the element type for the given pointer.
+func (*Pointer) Elem() Type { return nil }
+
+func (*Struct) NumFields() int { return 0 }
+
+func (*Struct) Field(i int) *Var { return nil }
+
+type Var struct{}
+
+func (*Var) Embedded() bool { return false }
+
+func (*Var) Type() Type { return nil }
diff --git a/vendor/github.com/quasilyte/go-ruleguard/internal/xtypes/xtypes.go b/vendor/github.com/quasilyte/go-ruleguard/internal/xtypes/xtypes.go
index 4c5c2a2ab..d29573a6f 100644
--- a/vendor/github.com/quasilyte/go-ruleguard/internal/xtypes/xtypes.go
+++ b/vendor/github.com/quasilyte/go-ruleguard/internal/xtypes/xtypes.go
@@ -221,6 +221,10 @@ func typeIdentical(x, y types.Type, p *ifacePair) bool {
case *typeparams.TypeParam:
// nothing to do (x and y being equal is caught in the very beginning of this function)
+ case *types.Alias:
+ // an alias type is identical if the type it's an alias of is identical to it.
+ return typeIdentical(types.Unalias(x), y, p)
+
case nil:
// avoid a crash in case of nil type
diff --git a/vendor/github.com/quasilyte/go-ruleguard/ruleguard/irconv/irconv.go b/vendor/github.com/quasilyte/go-ruleguard/ruleguard/irconv/irconv.go
index 4eb90d51b..cc40506af 100644
--- a/vendor/github.com/quasilyte/go-ruleguard/ruleguard/irconv/irconv.go
+++ b/vendor/github.com/quasilyte/go-ruleguard/ruleguard/irconv/irconv.go
@@ -618,8 +618,7 @@ func (conv *converter) convertFilterExprImpl(e ast.Expr) ir.FilterExpr {
case *ast.UnaryExpr:
x := conv.convertFilterExpr(e.X)
args := []ir.FilterExpr{x}
- switch e.Op {
- case token.NOT:
+ if e.Op == token.NOT {
return ir.FilterExpr{Op: ir.FilterNotOp, Args: args}
}
diff --git a/vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/compile.go b/vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/compile.go
index b81fb8f1d..95ca9297e 100644
--- a/vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/compile.go
+++ b/vendor/github.com/quasilyte/go-ruleguard/ruleguard/quasigo/compile.go
@@ -605,11 +605,12 @@ func (cl *compiler) compileCall(key funcKey, sig *types.Signature, args []ast.Ex
}
var op opcode
- if sig.Results().Len() == 0 {
+ switch {
+ case sig.Results().Len() == 0:
op = opVoidCall
- } else if typeIsInt(sig.Results().At(0).Type()) {
+ case typeIsInt(sig.Results().At(0).Type()):
op = opIntCall
- } else {
+ default:
op = opCall
}