From 84645a5b4d81dc611de27a7f3c830f232150f947 Mon Sep 17 00:00:00 2001 From: crusader Date: Tue, 10 Apr 2018 23:10:30 +0900 Subject: [PATCH] ing --- registry/registry.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/registry/registry.go b/registry/registry.go index bc477c9..e88b93d 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -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 }