resolve

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package resolve rewrites G++ method-syntax uses of generic methods into calls (or closures) over the lowered package-level functions.

It runs a fixpoint: type-check the current shadow texts tolerantly with go/packages overlays, rewrite every call site whose receiver type is known, and repeat — chained calls resolve inside-out, one nesting level per iteration. go/types records the receiver's fully-instantiated type (and addressability) even when the selector itself fails to resolve, which is exactly what each rewrite needs.

Index

Constants

View Source
const RefineCarrier = "//gpp:refine "

RefineCarrier is the carrier comment prefix.

Variables

This section is empty.

Functions

func Backstop

func Backstop(in *Input, maps map[string]*sourcemap.Map) ([]diag.Diagnostic, error)

Backstop type-checks the final emitted texts strictly and returns every error, remapped into .gpp positions where the error lies in a generated file. This is the full go/types safety net behind the targeted resolution pass: anything the lowering got wrong, and any ordinary type error the user wrote, surfaces here exactly once — before anything is written to disk.

Types

type Input

type Input struct {
	Dir          string                        // working directory for package loading
	Patterns     []string                      // package patterns to load
	Texts        map[string][]byte             // abs output path -> current shadow text
	MethodsByDir map[string][]*registry.Method // dir -> generic methods declared there (PkgPath unset)
	EnumsByDir   map[string][]*registry.Enum   // dir -> enums declared there (PkgPath provisional)
	// v0.5.0 typeclasses (PkgPath provisional, cloned on registration).
	ClassesByDir   map[string][]*registry.Class
	InstancesByDir map[string][]*registry.Instance
	TotalsByDir    map[string][]*registry.Total
	DepsByDir      map[string][]*registry.DepFn
}

Input configures a fixpoint run.

type Output

type Output struct {
	Texts map[string][]byte
	Diags []diag.Diagnostic
	// Reg is the fully-populated registry (local + dependency markers);
	// law-test generation consumes it after the fixpoint.
	Reg *registry.Registry
}

Output is the fixpoint result.

func Fixpoint

func Fixpoint(in *Input) (*Output, error)

Fixpoint resolves all method-syntax uses across the loaded packages.

Jump to

Keyboard shortcuts

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