This commit is contained in:
crusader 2018-04-10 23:10:30 +09:00
parent 8c5c5b0311
commit 84645a5b4d

View File

@ -71,10 +71,10 @@ func (cr *defaultComponentRegistry) RegisterType(t reflect.Type) {
log.Panicf("DI: %v", err)
}
if _, ok := cr.definitionByType[td.RealType]; ok {
if _, ok := cr.definitionByType[td.Type]; ok {
log.Panicf("DI: The type[%s] of Component is exist already", td.FullName)
}
cr.definitionByType[td.RealType] = td
cr.definitionByType[td.Type] = td
name := td.TypeName
@ -129,7 +129,7 @@ func (cr *defaultComponentRegistry) GetInstance(t reflect.Type) (interface{}, er
)
rt, _, _ := cur.GetTypeInfo(t)
if td, ok = cr.definitionByType[rt]; !ok {
if td, ok = cr.definitionByType[t]; !ok {
if td, err = cr.buildDefinition(t); nil != err {
return nil, fmt.Errorf("DI: %v", err)
}
@ -253,9 +253,7 @@ func GetMethodAnnotation(instanceType reflect.Type, annotationType reflect.Type,
return registry.GetMethodAnnotation(instanceType, annotationType, methodName)
}
func (cr *defaultComponentRegistry) GetMethodAnnotation(instanceType reflect.Type, annotationType reflect.Type, methodName string) cda.Annotation {
rt, _, _ := cur.GetTypeInfo(instanceType)
def, ok := cr.definitionByType[rt]
def, ok := cr.definitionByType[instanceType]
if !ok {
return nil
}
@ -267,9 +265,7 @@ func GetMethodAnnotations(instanceType reflect.Type, annotationType reflect.Type
return registry.GetMethodAnnotations(instanceType, annotationType)
}
func (cr *defaultComponentRegistry) GetMethodAnnotations(instanceType reflect.Type, annotationType reflect.Type) map[string]cda.Annotation {
rt, _, _ := cur.GetTypeInfo(instanceType)
def, ok := cr.definitionByType[rt]
def, ok := cr.definitionByType[instanceType]
if !ok {
return nil
}