subst

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package subst provides type substitution operations for generics.

These operations replace type parameters with concrete types, used during generic instantiation and Self type resolution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandInstantiated

func ExpandInstantiated(t typ.Type) typ.Type

ExpandInstantiated expands generic instantiations to their structural form.

For Instantiated{Generic: Array<T>, TypeArgs: [number]}, returns the Array body with T replaced by number. This enables structural comparison and field/method lookup on instantiated generics.

Does not enforce generic constraints; use subtype checking for that.

func Params

func Params(t typ.Type, params []*typ.TypeParam, args []typ.Type) typ.Type

Params replaces type parameters with corresponding type arguments.

func Self

func Self(t typ.Type, selfType typ.Type) typ.Type

Self replaces Self type references with a concrete type. Does not recurse into Interface types because Self inside an Interface is a separate binding that refers to that Interface's implementor.

func Substitute

func Substitute(t typ.Type, subs map[string]typ.Type) typ.Type

Substitute replaces type parameters with concrete types throughout a type.

Used during generic instantiation to replace TypeParam references with the corresponding type arguments. The subs map keys are type parameter names.

Types

This section is empty.

Jump to

Keyboard shortcuts

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