Răsfoiți Sursa

Fixed lookup for inner type declared in a generic base class

Brian Fiete 11 luni în urmă
părinte
comite
d9fd93ccbd

+ 19 - 1
IDEHelper/Compiler/BfResolvedTypeUtils.cpp

@@ -3417,7 +3417,21 @@ BfTypeDef* BfResolvedTypeSet::FindRootCommonOuterType(BfTypeDef* outerType, Look
 {
 	if (ctx->mModule->mCurTypeInstance == NULL)
 		return NULL;
-	BfTypeDef* commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType);
+
+	BfTypeDef* commonOuterType = NULL;
+
+	auto checkOuterTypeInst = ctx->mModule->mCurTypeInstance;
+	while (checkOuterTypeInst != NULL)
+	{
+		commonOuterType = ctx->mModule->FindCommonOuterType(checkOuterTypeInst->mTypeDef, outerType);
+		if (commonOuterType != NULL)
+		{			
+			outOuterTypeInstance = checkOuterTypeInst;
+			break;
+		}
+		checkOuterTypeInst = checkOuterTypeInst->mBaseType;
+	}
+
 	if ((commonOuterType == NULL) && (outerType != NULL))
 	{
 		auto staticSearch = ctx->mModule->GetStaticSearch();
@@ -3462,7 +3476,11 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
 				auto outerType = ctx->mModule->mSystem->GetOuterTypeNonPartial(typeDef);
 
 				if (typeRef == ctx->mRootTypeRef)
+				{
 					commonOuterType = FindRootCommonOuterType(outerType, ctx, checkTypeInstance);
+					if ((checkTypeInstance != NULL) && (checkTypeInstance->IsBoxed()))
+						checkTypeInstance = checkTypeInstance->GetUnderlyingType()->ToTypeInstance();
+				}
 				else
 					commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType);
 

+ 7 - 0
IDEHelper/Tests/src/TypeLookup.bf

@@ -1,5 +1,7 @@
 #pragma warning disable 168
 
+using System.Collections;
+
 namespace Tests
 {
 	class ClassE
@@ -120,4 +122,9 @@ namespace Tests
 			}
 		}
 	}
+
+	class DictExt : Dictionary<int, float>
+	{
+		Entry mEntry;
+	}
 }