mirror of
https://github.com/hanzoai/yaegi.git
synced 2026-10-01 00:49:47 +00:00
The type.val field was always pointing to the final underlying type for aliased types, defeating a possible match if a method was attached to a type in between. Now the complete chain of aliases is always preserved. We have added an underlying() itype method which returns the underlying type of a defined type (aliasT), even in the presence of multiple indirections. We have added a definedType function which checks if type t1 is defined from type t2 or t2 defined from t1, required when checking assignability of aliasT types. Fixes #1411. PS: this is the 2nd attempt, as the first version #1412 wasn't passing _test/issue-1408.go as well. This PR does pass and supersedes #1412.
17 lines
200 B
Go
17 lines
200 B
Go
package main
|
|
|
|
type Number int32
|
|
|
|
func (n Number) IsValid() bool { return true }
|
|
|
|
type Number1 = Number
|
|
|
|
type Number2 = Number1
|
|
|
|
func main() {
|
|
a := Number2(5)
|
|
println(a.IsValid())
|
|
}
|
|
|
|
// Output: true
|