@@ -255,14 +255,18 @@ private List<LuaIdentifierNameSyntax> GetBaseCopyFields(BaseTypeSyntax baseType)
255255 if ( baseType != null ) {
256256 var baseTypeSymbol = semanticModel_ . GetTypeInfo ( baseType . Type ) . Type ;
257257 if ( baseTypeSymbol . TypeKind == TypeKind . Class && baseTypeSymbol . SpecialType != SpecialType . System_Object ) {
258- if ( ! baseTypeSymbol . GetMembers ( "Finalize" ) . IsEmpty ) {
258+ if ( baseTypeSymbol . IsMemberExists ( "Finalize" , true ) ) {
259259 return new List < LuaIdentifierNameSyntax > ( ) { LuaIdentifierNameSyntax . __GC } ;
260260 }
261261 }
262262 }
263263 return null ;
264264 }
265265
266+ private bool IsBaseTypeNotSystemObject ( LuaExpressionSyntax baseTypeExpression ) {
267+ return ! ( baseTypeExpression is LuaIdentifierNameSyntax name && name . ValueText == LuaIdentifierNameSyntax . Object . ValueText ) ;
268+ }
269+
266270 private void BuildTypeDeclaration ( INamedTypeSymbol typeSymbol , TypeDeclarationSyntax node , LuaTypeDeclarationSyntax typeDeclaration ) {
267271 typeDeclarations_ . Push ( new TypeDeclarationInfo ( typeSymbol , typeDeclaration ) ) ;
268272
@@ -278,15 +282,19 @@ private void BuildTypeDeclaration(INamedTypeSymbol typeSymbol, TypeDeclarationSy
278282 var baseTypes = new List < LuaExpressionSyntax > ( ) ;
279283 foreach ( var baseType in node . BaseList . Types ) {
280284 var baseTypeName = BuildInheritTypeName ( baseType ) ;
281- baseTypes . Add ( baseTypeName ) ;
282- CheckBaseTypeGenericKind ( ref hasExtendSelf , typeSymbol , baseType ) ;
285+ if ( IsBaseTypeNotSystemObject ( baseTypeName ) ) {
286+ baseTypes . Add ( baseTypeName ) ;
287+ CheckBaseTypeGenericKind ( ref hasExtendSelf , typeSymbol , baseType ) ;
288+ }
283289 }
284290
285- var genericArgument = CheckSpeaicalGenericArgument ( typeSymbol ) ;
286- var baseCopyFields = GetBaseCopyFields ( node . BaseList . Types . FirstOrDefault ( ) ) ;
287- typeDeclaration . AddBaseTypes ( baseTypes , genericArgument , baseCopyFields ) ;
288- if ( hasExtendSelf && ! typeSymbol . HasStaticCtor ( ) ) {
289- typeDeclaration . SetStaticCtorEmpty ( ) ;
291+ if ( baseTypes . Count > 0 ) {
292+ var genericArgument = CheckSpeaicalGenericArgument ( typeSymbol ) ;
293+ var baseCopyFields = GetBaseCopyFields ( node . BaseList . Types . FirstOrDefault ( ) ) ;
294+ typeDeclaration . AddBaseTypes ( baseTypes , genericArgument , baseCopyFields ) ;
295+ if ( hasExtendSelf && ! typeSymbol . HasStaticCtor ( ) ) {
296+ typeDeclaration . SetStaticCtorEmpty ( ) ;
297+ }
290298 }
291299 }
292300
@@ -391,14 +399,19 @@ internal void AcceptPartialType(PartialTypeDeclaration major, List<PartialTypeDe
391399 foreach ( var baseType in baseTypes ) {
392400 semanticModel_ = generator_ . GetSemanticModel ( baseType . SyntaxTree ) ;
393401 var baseTypeName = BuildInheritTypeName ( baseType ) ;
394- baseTypeExpressions . Add ( baseTypeName ) ;
395- CheckBaseTypeGenericKind ( ref hasExtendSelf , major . Symbol , baseType ) ;
396- }
397- var genericArgument = CheckSpeaicalGenericArgument ( major . Symbol ) ;
398- var baseCopyFields = GetBaseCopyFields ( baseTypes . FirstOrDefault ( ) ) ;
399- major . TypeDeclaration . AddBaseTypes ( baseTypeExpressions , genericArgument , baseCopyFields ) ;
400- if ( hasExtendSelf && ! major . Symbol . HasStaticCtor ( ) ) {
401- major . TypeDeclaration . SetStaticCtorEmpty ( ) ;
402+ if ( IsBaseTypeNotSystemObject ( baseTypeName ) ) {
403+ baseTypeExpressions . Add ( baseTypeName ) ;
404+ CheckBaseTypeGenericKind ( ref hasExtendSelf , major . Symbol , baseType ) ;
405+ }
406+ }
407+
408+ if ( baseTypeExpressions . Count > 0 ) {
409+ var genericArgument = CheckSpeaicalGenericArgument ( major . Symbol ) ;
410+ var baseCopyFields = GetBaseCopyFields ( baseTypes . FirstOrDefault ( ) ) ;
411+ major . TypeDeclaration . AddBaseTypes ( baseTypeExpressions , genericArgument , baseCopyFields ) ;
412+ if ( hasExtendSelf && ! major . Symbol . HasStaticCtor ( ) ) {
413+ major . TypeDeclaration . SetStaticCtorEmpty ( ) ;
414+ }
402415 }
403416 }
404417
0 commit comments