satisfy

package
v0.0.0-...-478cd7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package satisfy inspects the type-checked ASTs of Go packages and reports the set of discovered type constraints of the form (lhs, rhs Type) where lhs is a non-trivial interface, rhs satisfies this interface, and this fact is necessary for the package to be well-typed.

THIS PACKAGE IS EXPERIMENTAL AND MAY CHANGE AT ANY TIME.

It is provided only for the gorename tool. Ideally this functionality will become part of the type-checker in due course, since it is computing it anyway, and it is robust for ill-typed inputs, which this package is not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constraint

type Constraint struct {
	LHS, RHS types.Type
}

A Constraint records the fact that the RHS type does and must satisfy the LHS type, which is an interface. The names are suggestive of an assignment statement LHS = RHS.

type Finder

type Finder struct {
	Result map[Constraint]bool
	// contains filtered or unexported fields
}

A Finder inspects the type-checked ASTs of Go packages and accumulates the set of type constraints (x, y) such that x is assignable to y, y is an interface, and both x and y have methods.

In other words, it returns the subset of the "implements" relation that is checked during compilation of a package. Refactoring tools will need to preserve at least this part of the relation to ensure continued compilation.

func (*Finder) Find

func (f *Finder) Find(info *types.Info, files []*ast.File)

Find inspects a single package, populating Result with its pairs of constrained types.

The result is non-canonical and thus may contain duplicates (but this tends to preserves names of interface types better).

The package must be free of type errors, and info.{Defs,Uses,Selections,Types} must have been populated by the type-checker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL