Index: trunk/abdev/BasicCompiler_Common/ParamImpl.cpp
===================================================================
--- trunk/abdev/BasicCompiler_Common/ParamImpl.cpp	(revision 364)
+++ trunk/abdev/BasicCompiler_Common/ParamImpl.cpp	(revision 424)
@@ -107,5 +107,5 @@
 }
 
-bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, bool &isErrored ){
+bool ParamImpl::EvaluateOverloadScore( int level, const Parameters &targetParms, const Type &targetResultType, const Type &leftType, const UserProc &userProc, bool &isErrored ){
 	//パラメータを識別してオーバーロードを解決
 
@@ -124,4 +124,7 @@
 	for(int i=0;i<max;i++){
 		Parameter &param = *targetParms[i];
+
+		Type paramType( param );
+		ResolveFormalGenericTypeParameter( paramType, leftType, &userProc );
 
 		if( i >= ParmsNum ){
@@ -140,5 +143,5 @@
 
 			if( !NumOpe_GetType(Parms[i],
-				( level <= OVERLOAD_LEVEL3 )? nullParam : param,
+				( level <= OVERLOAD_LEVEL3 )? nullParam : paramType,
 				argType) )
 			{
@@ -151,10 +154,31 @@
 		}
 
-		if(argType.GetBasicType()!=param.GetBasicType()){
+		if( ( argType.IsObject() && paramType.IsObject() ) || argType.GetBasicType() == paramType.GetBasicType() )
+		{
+			if( argType.IsStruct() ){
+				if(argType.GetIndex()!=paramType.GetIndex()){
+					return false;
+				}
+			}
+			else if( argType.IsObject() ){
+				if( level == OVERLOAD_LEVEL0 ){
+					if( !paramType.GetClass().IsEquals( &argType.GetClass() ) ){
+						return false;
+					}
+				}
+				else{
+					if( !paramType.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){
+						return false;
+					}
+				}
+			}
+		}
+		else
+		{
 			if( level == OVERLOAD_LEVEL0 || level == OVERLOAD_LEVEL1 || level==OVERLOAD_LEVEL4 ){
 				return false;
 			}
 			else if( level == OVERLOAD_LEVEL2 ){
-				if( !(argType.IsWhole() && param.IsWhole() && argType.GetBasicSize() == param.GetBasicSize() ) ){
+				if( !(argType.IsWhole() && paramType.IsWhole() && argType.GetBasicSize() == paramType.GetBasicSize() ) ){
 					// サイズ違い
 					return false;
@@ -163,10 +187,10 @@
 			else if( level == OVERLOAD_LEVEL3 || level==OVERLOAD_LEVEL5){
 				if(!(
-					argType.IsWhole()&&param.IsWhole()||
-					argType.IsReal()&&param.IsReal()
+					argType.IsWhole()&&paramType.IsWhole()||
+					argType.IsReal()&&paramType.IsReal()
 					)){
 						return false;
 				}
-				if( argType.IsPointer() || param.IsPointer() )
+				if( argType.IsPointer() || paramType.IsPointer() )
 				{
 					// ポインタ型の不整合は認めない
@@ -175,24 +199,5 @@
 			}
 			else if(level==OVERLOAD_LEVEL6){
-				if(argType.IsObject()||param.IsObject()) return false;
-			}
-		}
-		else{
-			if( NATURAL_TYPE(argType.GetBasicType())==DEF_STRUCT){
-				if(argType.GetIndex()!=param.GetIndex()){
-					return false;
-				}
-			}
-			else if( NATURAL_TYPE(argType.GetBasicType())==DEF_OBJECT ){
-				if( level == OVERLOAD_LEVEL0 ){
-					if( !param.GetClass().IsEquals( &argType.GetClass() ) ){
-						return false;
-					}
-				}
-				else{
-					if( !param.GetClass().IsEqualsOrSubClass( &argType.GetClass() ) ){
-						return false;
-					}
-				}
+				if(argType.IsObject()||paramType.IsObject()) return false;
 			}
 		}
@@ -209,5 +214,5 @@
 }
 
-const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){
+const UserProc *ParamImpl::_OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType ){
 	const UserProc *pUserProc = NULL;
 
@@ -218,5 +223,5 @@
 			bool isErrored = false;
 			bool isHit = false;
-			isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), isErrored );
+			isHit = EvaluateOverloadScore( level, pTempUserProc->Params(), isEnabledReturnType?pTempUserProc->ReturnType():Type(), leftType, *pTempUserProc, isErrored );
 			if( isErrored )
 			{
@@ -239,5 +244,5 @@
 						trace_for_overload( "戻り値も比較するモードに切り替えてオーバーロード解決を試みる" );
 
-						return OverloadSolution(name,subs, true);
+						return OverloadSolution( name, subs, leftType, true);
 					}
 				}
@@ -278,10 +283,10 @@
 	return pUserProc;
 }
-const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, bool isEnabledReturnType ){
+const UserProc *ParamImpl::OverloadSolution( const char *name, std::vector<const UserProc *> &subs, const Type &leftType, bool isEnabledReturnType ){
 	trace_for_overload( "" );
 	trace_for_overload( "■■■■■■■■■■■■■■■■■■" );
 	trace_for_overload( "■■■ オーバーロード解決(" << name << ")" );
 
-	const UserProc *result = _OverloadSolution( name, subs, isEnabledReturnType );
+	const UserProc *result = _OverloadSolution( name, subs, leftType, isEnabledReturnType );
 
 	trace_for_overload( "■■■ ここまで" );
