For example, "golang.org/x/net/context".Context now aliases "context".Context. I expected the Lookup call for the "go/types".Scope for the "go/types".Package for "context" to give me the "go/types".Type for the "golang.org/x/net/context".Context declaration, but it gave me the one for the "context".Context declaration, so the result of "go/types".Named.Obj().IsAlias() for that type is false when I expected true. Is there another way you're supposed to look up the type of a package's alias declaration by name, such that IsAlias returns true? If not, is there a workaround?
This is working as expected and you have a bug in your code: You are calling the IsAlias() method on the original type name rather than the aliased type name. Keep in mind that a Type is never an alias, it's a TypeName that may be an alias (names can be aliases, types are never aliases).
Or in other words, the Type of a TypeName object is always the actual (non-alias) type, no matter if the TypeName is an alias or not. In your code
you are getting the Type of the Context object, which is the original (std lib) named Context Type. Then you look up it's TypeName Object, which is (std lib) context.Context, and of course that's not an alias.
On the other hand, if you check if the looked up Context object is an an alias, you will get the expected result: