Skip to content

analyze_types: better support for type aliases #23

@pohly

Description

@pohly

The recently merged semantic analysis has one drawback when dealing with type aliases: they always get replaced with the underlying type. Example:

package somepkg

import "example.com/anotherpkg"

type SomeType = anotherpkg.AnotherType

A pattern somepkg.SomeType.ForbiddenMethod does not match because SomeType is an alias. What works is anotherpkg.AnotherType.ForbiddenMethod.

This is a) unexpected and b) can cause a pattern that works with a version of a package where the type is not an alias to stop working when the packages switches to a type alias.

It would be better if forbidigo matched against both the underlying type (anotherpkg.AnotherType) and the alias (somepkg.SomeType).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions