// missing returns a list of variants in this sum type that are not in the
// given list of types.
missing returns a list of variants in this sum type that are not in the
given list of types.
// missing returns a list of variants in this sum type that are not in the // given list of types .
func (def *sumTypeDef) missing(tys []types.Type) []types.Object {
	var missing []types.Object
	for _, v := range def.Variants {
		found := false
		varty := indirect(v.Type())
		for _, ty := range tys {
			ty = indirect(ty)
			if types.Identical(varty, ty) {
				found = true
			}
			if iface, ok := ty.Underlying().(*types.Interface); ok {
				if types.Implements(varty, iface) || types.Implements(types.NewPointer(varty), iface) {
					found = true
				}
			}
		}
		if !found {
			missing = append(missing, v)
		}
	}
	return missing
}
func ( def * sumTypeDef ) missing ( tys [ ] types . Type ) [ ] types . Object { var missing [ ] types . Object for _ , v := range def . Variants { found := false varty := indirect ( v . Type ( ) ) for _ , ty := range tys { ty = indirect ( ty ) if types . Identical ( varty , ty ) { found = true } if iface , ok := ty . Underlying ( ) . ( * types . Interface ) ; ok { if types . Implements ( varty , iface ) || types . Implements ( types . NewPointer ( varty ) , iface ) { found = true } } } if ! found { missing = append ( missing , v ) } } return missing }
missing returns a list of variants in this sum type that are not in the
given list of types.
missing returns a list of variants in this sum type that are not in the given list of types .
// TODO(ag): This is O(n^2). Fix that. /shrug