Hi,

I notice Go's compiler examines the interface signature somewhat 
superficially. It is best to explain the situation using code:

Given in Package a, 

package a

type Arg interface{
   DoSomething()
}

type Worker interface{ 
   Work(arg Arg) 
}

func NewWorker() Worker{
   //...
}

Then Package a is consumed in Package b,

package b

type Arg interface{
   DoSomething()
}

type Worker interface{ 
   Work(arg Arg) 
}

func SomewhereInB(){
   var worker Worker
   worker = a.NewWorker() //compile failure: worker does not implement 
Work(b.Arg)
   //...
}


I believe the compiler should be able to deduce that a.Arg and b.Arg are 
identical and therefore Work(a.Arg) and Work(b.Arg) should also be 
identical. Thus, a.Worker and b.Worker are identical. The compiler fails to 
recognize this. Is this a bug?

Thanks.

Henry





-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to