Prechádzať zdrojové kódy

Merge pull request #2184 from Fusioon/fix-#1883

Fix inherited properties on interface
Brian Fiete 6 mesiacov pred
rodič
commit
19eb1f22a8
1 zmenil súbory, kde vykonal 24 pridanie a 2 odobranie
  1. 24 2
      IDEHelper/Compiler/BfExprEvaluator.cpp

+ 24 - 2
IDEHelper/Compiler/BfExprEvaluator.cpp

@@ -5891,6 +5891,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
 			flags = (BfLookupFieldFlags)(flags | BfLookupFieldFlag_IsFailurePass);
 
 		bool isBaseLookup = false;
+		int checkInterfaceIdx = 0;
 		while (curCheckType != NULL)
 		{
 			if (((flags & BfLookupFieldFlag_CheckingOuter) != 0) && ((mBfEvalExprFlags & BfEvalExprFlags_Comptime) != 0))
@@ -6248,8 +6249,16 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
 				}
 			}
 
-			isBaseLookup = true;
-			curCheckType = curCheckType->mBaseType;
+			if ((!isBaseLookup) && (startCheckType->IsInterface() && (checkInterfaceIdx < (int)startCheckType->mInterfaces.size())))
+			{
+				curCheckType = startCheckType->mInterfaces[checkInterfaceIdx].mInterfaceType;
+				checkInterfaceIdx++;
+			}
+			else
+			{
+				isBaseLookup = true;
+				curCheckType = curCheckType->mBaseType;
+			}
 		}
 	}
 	
@@ -19924,6 +19933,19 @@ BfModuleMethodInstance BfExprEvaluator::GetPropertyMethodInstance(BfMethodDef* m
 
 			if (bestIFaceEntry != NULL)
 			{
+				if ((checkTypeInst->IsInterface()))
+				{
+					auto propTypeInst = bestIFaceEntry->mInterfaceType->ToTypeInstance();
+					if (propTypeInst == NULL)
+					{
+						mModule->Fail("INTERNAL ERROR: Invalid property target", mPropSrc);
+						return BfModuleMethodInstance();
+					}
+					BF_ASSERT(propTypeInst->mTypeDef->mFullNameEx == methodDef->mDeclaringType->mFullNameEx);
+
+					return mModule->GetMethodInstance(propTypeInst, methodDef, BfTypeVector(), mPropGetMethodFlags);
+				}
+
 				auto ifaceMethodEntry = checkTypeInst->mInterfaceMethodTable[bestIFaceEntry->mStartInterfaceTableIdx + methodDef->mIdx];
 				BfMethodInstance* bestMethodInstance = ifaceMethodEntry.mMethodRef;
 				if (bestMethodInstance != NULL)