Index: trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h	(revision 727)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/include/LexicalAnalyzer.h	(revision 728)
@@ -35,7 +35,7 @@
 	static Member *CreateMember( const CClass &_class, Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine );
 	static void AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
-		bool isVirtual, bool isOverride, const char *interfaceName, bool isAutoGeneration, int nowLine);
+		bool isVirtual, bool isOverride, bool isEnableOverrideCheck, const char *interfaceName, bool isAutoGeneration, int nowLine);
 	static bool Inherits( CClass &_class, const char *inheritNames, int nowLine );
-	static void Implements( CClass &_class, Interface *pInterface, std::vector<DynamicMethod::OverrideResult> &overrideResults );
+	static void Implements( CClass &_class, Interface *pInterface );
 	static bool Implements( CClass &_class, const char *interfaceNames, int nowLine );
 	static void LookaheadClass( const std::string &className, Classes &classes );
@@ -44,4 +44,5 @@
 
 	// テンプレート展開
+	static Type LexicalAnalyzer::TemplateExpand_ResolveType( const Type &baseType, const Types &actualTypes );
 	static void TemplateExpand_ResolveMethod( const CMethod *pBaseMethod, const Types &actualTypes, CClass *pNewClass );
 	static const CClass *TemplateExpand( CClass &_class, const Types &actualTypes );
Index: trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp
===================================================================
--- trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp	(revision 727)
+++ trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp	(revision 728)
@@ -278,5 +278,5 @@
 
 void LexicalAnalyzer::AddMethod(CClass *pobj_c, UserProc *pUserProc, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,
-	bool isVirtual, bool isOverride, const char *interfaceName, bool isAutoGeneration, int nowLine)
+	bool isVirtual, bool isOverride, bool isEnableOverrideCheck, const char *interfaceName, bool isAutoGeneration, int nowLine)
 {
 	if( isAutoGeneration )
@@ -353,5 +353,5 @@
 	{
 		DynamicMethod::OverrideResult result;
-		result.enumType = pMethodForOverride->Override( pUserProc, accessibility, isOverride );
+		result.enumType = pMethodForOverride->Override( pUserProc, accessibility, isEnableOverrideCheck ? isOverride : true );
 		result.pMethod = pMethodForOverride;
 		OverrideErrorCheck( result );
@@ -514,6 +514,16 @@
 }
 
-void LexicalAnalyzer::Implements( CClass &_class, Interface *pInterface, std::vector<DynamicMethod::OverrideResult> &overrideResults )
+void LexicalAnalyzer::Implements( CClass &_class, Interface *pInterface )
 {
+	// まずは継承されたインターフェイスを実装する
+	BOOST_FOREACH( ::Interface *pInheritsInterface, pInterface->GetClass().GetInterfaces() )
+	{
+		// TODO: actualTypeParametersの引渡し
+		Implements(
+			_class,
+			new ::Interface( &pInheritsInterface->GetClass(), pInterface->GetActualTypeParameters() )
+		);
+	}
+
 	_class.AddInterface( pInterface );
 
@@ -530,5 +540,6 @@
 			result.enumType = pMethodForOverride->Override( &pMethod->GetUserProc(), pMethod->GetAccessibility(), false );
 			result.pMethod = pMethod;
-			overrideResults.push_back( result );
+
+			OverrideErrorCheck( result );
 
 			// 実装元になるメソッドは呼び出し不可にしておく（オーバーロードの解決から除外する）
@@ -588,4 +599,5 @@
 			false,			// isVirtual
 			false,			// isOverride
+			true,			// Override修飾子チェック
 			"",
 			true,			// isAutoGeneration
@@ -633,16 +645,10 @@
 		if( pInterfaceClass->IsInterface() || pInterfaceClass->IsComInterface() )
 		{
-			// インターフェイスを継承する
-			std::vector<DynamicMethod::OverrideResult> overrideResults;
-			Implements(
-				_class,
-				new ::Interface( pInterfaceClass, actualTypeParameters ),
-				overrideResults
-			);
-
-			// エラーチェック
-			BOOST_FOREACH( const DynamicMethod::OverrideResult result, overrideResults )
-			{
-				OverrideErrorCheck( result );
+			// インターフェイスを実装する
+			{
+				Implements(
+					_class,
+					new ::Interface( pInterfaceClass, actualTypeParameters )
+				);
 			}
 		}
@@ -844,5 +850,5 @@
 
 				//継承させる
-				if( !pobj_c->InheritsClass( *pInheritsClass, actualTypeParameters, i ) ){
+				if( !pobj_c->InheritsInterface( *pInheritsClass, actualTypeParameters, i ) ){
 					goto Interface_InheritsError;
 				}
@@ -934,4 +940,5 @@
 						true,				// isVirtual
 						false,				// isOverride
+						true,				// Override修飾子チェック
 						interfaceName,
 						false,				// isAutoGeneration
@@ -1270,4 +1277,5 @@
 							isVirtual,
 							isOverride,
+							true,				// Override修飾子チェック
 							interfaceName,
 							false,
@@ -1345,4 +1353,29 @@
 }
 
+Type LexicalAnalyzer::TemplateExpand_ResolveType( const Type &baseType, const Types &actualTypes )
+{
+	if( baseType.IsNull() )
+	{
+		return baseType;
+	}
+
+	Type resultType( baseType );
+	if( resultType.IsTypeParameter() )
+	{
+		// 型パラメータだったとき
+		resultType = actualTypes[baseType.GetFormalTypeIndex()];
+	}
+	else if( resultType.IsObject() || resultType.IsInterface() )
+	{
+		// クラス・インターフェイスだったとき
+		const CClass *pExpandedClass = TemplateExpand( *const_cast<CClass *>(&baseType.GetClass()), actualTypes );
+		resultType.SetClassPtr( pExpandedClass );
+	}
+
+	resultType.SetPtrLevel( baseType.PtrLevel() );
+
+	return resultType;
+}
+
 void LexicalAnalyzer::TemplateExpand_ResolveMethod( const CMethod *pBaseMethod, const Types &actualTypes, CClass *pNewClass )
 {
@@ -1376,10 +1409,5 @@
 
 	// 戻り値のジェネリック型を解決
-	if( pUserProc->ReturnType().IsTypeParameter() )
-	{
-		Type type = actualTypes[pUserProc->ReturnType().GetFormalTypeIndex()];
-		type.SetPtrLevel( pUserProc->ReturnType().PtrLevel() );
-		pUserProc->SetReturnType( type );
-	}
+	pUserProc->SetReturnType( TemplateExpand_ResolveType( pUserProc->ReturnType(), actualTypes ) );
 
 	compiler.GetObjectModule().meta.GetUserProcs().Put( pUserProc );
@@ -1394,5 +1422,6 @@
 		pBaseMethod->IsAbstract(),
 		pBaseMethod->IsVirtual(),
-		false,
+		false,						// isOverride
+		false,						// Override修飾子チェック
 		"",
 		false,
@@ -1403,4 +1432,10 @@
 const CClass *LexicalAnalyzer::TemplateExpand( CClass &_class, const Types &actualTypes )
 {
+	// そもそもジェネリック型ではないとき
+	if( !_class.IsGeneric() )
+	{
+		return &_class;
+	}
+
 	// 展開済みのクラスがあればそれを返す
 	BOOST_FOREACH( const ExpandedTemplateClass *pExpandedTemplateClass, _class.expandedTemplateClasses )
@@ -1431,11 +1466,48 @@
 	);
 
+	// 展開済みクラスとして登録
+	_class.expandedTemplateClasses.push_back( new ExpandedTemplateClass( pNewClass, actualTypes ) );
+
 	// 基底クラス
-	pNewClass->SetSuperClass( &_class.GetSuperClass() );
+	if( _class.HasSuperClass() )
+	{
+		const CClass *pExpandedSuperClass = TemplateExpand( *const_cast<CClass *>(&_class.GetSuperClass()), actualTypes );
+		pNewClass->InheritsClass( *pExpandedSuperClass, pNewClass->GetSuperClassActualTypeParameters(), -1 );
+	}
 
 	// インターフェイスのジェネリック型を解決
 	BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
 	{
-		pNewClass->AddInterface( new ::Interface( &pInterface->GetClass(), actualTypes ) );
+		const CClass *pExpandedInterfaceClass = TemplateExpand( *const_cast<CClass *>(&pInterface->GetClass()), actualTypes );
+		Interface *pExpandedInterface = new ::Interface( pExpandedInterfaceClass, actualTypes );
+		pNewClass->AddInterface( pExpandedInterface );
+
+		// インターフェイス メソッドのジェネリック型を解決
+		BOOST_FOREACH( const CMethod *pMethod, pInterface->GetDynamicMethods() )
+		{
+			if( pMethod->GetUserProc().GetParentClassPtr() == &_class )
+			{
+				// ターゲットクラス内で実装されるメソッドの場合
+				TemplateExpand_ResolveMethod( pMethod, actualTypes, pNewClass );
+			}
+		}
+
+		/////////////////////////////////
+		// オーバーライドチェック
+		/////////////////////////////////
+		if( pExpandedInterface->GetDynamicMethods().size() != pInterface->GetDynamicMethods().size() )
+		{
+			Jenga::Throw( "インターフェイス メソッドのジェネリック型の解決に失敗している" );
+		}
+		else
+		{
+			for( int i=0; i<pInterface->GetDynamicMethods().size(); i++ )
+			{
+				if( pInterface->GetDynamicMethods()[i]->IsAbstract() != pExpandedInterface->GetDynamicMethods()[i]->IsAbstract() )
+				{
+					Jenga::Throw( "テンプレート展開時のオーバーライドに失敗している … " + pInterface->GetDynamicMethods()[i]->GetUserProc().GetFullName() );
+				}
+			}
+		}
 	}
 
@@ -1461,28 +1533,10 @@
 		if( pMethod->GetUserProc().GetParentClassPtr() == &_class )
 		{
-			// ターゲットクラス内で実装されるメソッドの場合
-
+			// ターゲットクラス内で実装されるメソッドの場合のみ（その他のメソッドはInheritsClassで継承されているはず）
 			TemplateExpand_ResolveMethod( pMethod, actualTypes, pNewClass );
 		}
-		else
-		{
-			DynamicMethod *pNewDynamicMethod = new DynamicMethod( *pMethod );
-			pNewClass->GetDynamicMethods().push_back( pNewDynamicMethod );
-		}
-	}
-
-	// インターフェイス メソッドのジェネリック型を解決
-	BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
-	{
-		BOOST_FOREACH( const CMethod *pMethod, pInterface->GetDynamicMethods() )
-		{
-			TemplateExpand_ResolveMethod( pMethod, actualTypes, pNewClass );
-		}
 	}
 
 	pNewClass->SetVtblNum( _class.GetVtblNum() );
-
-	// 展開済みクラスとして登録
-	_class.expandedTemplateClasses.push_back( new ExpandedTemplateClass( pNewClass, actualTypes ) );
 
 	pNewClass->Readed();
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Class.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Class.h	(revision 727)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Class.h	(revision 728)
@@ -319,4 +319,7 @@
 	bool InheritsClass( const CClass &inheritsClass, const Types &actualTypeParameters, int nowLine );
 
+	// インターフェイス継承
+	bool InheritsInterface( const CClass &inheritsInterfaceClass, const Types &actualTypeParameters, int nowLine );
+
 	//メンバ、メソッドの追加
 	void AddDynamicMember( Member *pMember );
Index: trunk/ab5.0/abdev/ab_common/include/Lexical/Interface.h
===================================================================
--- trunk/ab5.0/abdev/ab_common/include/Lexical/Interface.h	(revision 727)
+++ trunk/ab5.0/abdev/ab_common/include/Lexical/Interface.h	(revision 728)
@@ -69,4 +69,6 @@
 	}
 	Interface()
+		: pInterfaceClass( NULL )
+		, vtblOffset( NULL )
 	{
 	}
Index: trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp
===================================================================
--- trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp	(revision 727)
+++ trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp	(revision 728)
@@ -110,6 +110,6 @@
 
 	// 仮想関数になるメソッドに使用チェックをつける
-	const CClass &objThis = *this;
-	BOOST_FOREACH( const CMethod *pMethod, objThis.GetDynamicMethods() )
+	const CClass &_class = *this;
+	BOOST_FOREACH( const CMethod *pMethod, _class.GetDynamicMethods() )
 	{
 		if( pMethod->IsVirtual() )
@@ -118,6 +118,14 @@
 		}
 	}
-}
-
+
+	// インターフェイスメソッドに使用チェックをつける
+	BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
+	{
+		BOOST_FOREACH( const CMethod *pMethod, pInterface->GetDynamicMethods() )
+		{
+			pMethod->GetUserProc().Using();
+		}
+	}
+}
 bool CClass::IsClass() const
 {
@@ -268,4 +276,15 @@
 
 	return true;
+}
+
+bool CClass::InheritsInterface( const CClass &inheritsInterfaceClass, const Types &actualTypeParameters, int nowLine )
+{
+	if( !( this->IsInterface() || this->IsComInterface() ) )
+	{
+		Jenga::Throw( "非インターフェイスに対してCClass::InheritsInterfaceメソッドが呼ばれた" );
+	}
+
+	// インターフェイスを継承する
+	return this->InheritsClass( inheritsInterfaceClass, actualTypeParameters, nowLine );
 }
 
Index: trunk/ab5.0/abdev/compiler_x86/Compile_Object.cpp
===================================================================
--- trunk/ab5.0/abdev/compiler_x86/Compile_Object.cpp	(revision 727)
+++ trunk/ab5.0/abdev/compiler_x86/Compile_Object.cpp	(revision 728)
@@ -108,7 +108,37 @@
 	int typeSize = pClass->GetSize();
 
-	if(pClass->IsAbstract()){
+	if(pClass->IsAbstract())
+	{
+		std::string tempMessage;
+		BOOST_FOREACH( const CMethod *pMethod, pClass->GetDynamicMethods() ){
+			if(pMethod->IsVirtual()){
+				if(pMethod->IsAbstract()){
+					if( !tempMessage.empty() )
+					{
+						tempMessage += ", ";
+					}
+					tempMessage += pMethod->GetUserProc().GetName();
+				}
+			}
+		}
+
+		// インターフェイスのvtbl
+		BOOST_FOREACH( const ::Interface *pInterface, pClass->GetInterfaces() )
+		{
+			BOOST_FOREACH( const CMethod *pMethod, pInterface->GetDynamicMethods() ){
+				if(pMethod->IsVirtual()){
+					if(pMethod->IsAbstract()){
+						if( !tempMessage.empty() )
+						{
+							tempMessage += ", ";
+						}
+						tempMessage += pMethod->GetUserProc().GetName();
+					}
+				}
+			}
+		}
+
 		//抽象クラスだったとき
-		compiler.errorMessenger.Output(125,pClass->GetName(),cp);
+		compiler.errorMessenger.Output(-1,"\"%s\" は抽象クラスです。インスタンス化することはできません（抽象メソッド … " + tempMessage + "）。",cp);
 	}
 
Index: trunk/ab5.0/abdev/compiler_x86/Compile_ProcOp.cpp
===================================================================
--- trunk/ab5.0/abdev/compiler_x86/Compile_ProcOp.cpp	(revision 727)
+++ trunk/ab5.0/abdev/compiler_x86/Compile_ProcOp.cpp	(revision 728)
@@ -250,5 +250,5 @@
 		sprintf( temporary,
 			"Return New %s(ObjPtr( This ),Get_LONG_PTR( (Get_LONG_PTR( ObjPtr(This)+SizeOf(VoidPtr) ) + SizeOf(LONG_PTR)*%d) As VoidPtr ) As VoidPtr )",
-			userProc.ReturnType().GetClass().GetFullName().c_str(),
+			compiler.TypeToString( userProc.ReturnType() ).c_str(),
 			vtblMasterListIndex
 		);
