|
@@ -22748,11 +22748,14 @@ end;
|
|
|
|
|
|
procedure TPasResolver.GetIncompatibleTypeDesc(const GotType,
|
|
procedure TPasResolver.GetIncompatibleTypeDesc(const GotType,
|
|
ExpType: TPasResolverResult; out GotDesc, ExpDesc: String);
|
|
ExpType: TPasResolverResult; out GotDesc, ExpDesc: String);
|
|
|
|
+var
|
|
|
|
+ NeedProcSignature: Boolean;
|
|
begin
|
|
begin
|
|
{$IFDEF VerbosePasResolver}
|
|
{$IFDEF VerbosePasResolver}
|
|
writeln('TPasResolver.GetIncompatibleTypeDesc Got={',GetResolverResultDbg(GotType),'} Expected={',GetResolverResultDbg(ExpType),'}');
|
|
writeln('TPasResolver.GetIncompatibleTypeDesc Got={',GetResolverResultDbg(GotType),'} Expected={',GetResolverResultDbg(ExpType),'}');
|
|
{$ENDIF}
|
|
{$ENDIF}
|
|
- if GotType.BaseType<>ExpType.BaseType then
|
|
|
|
|
|
+ if (GotType.BaseType<>ExpType.BaseType)
|
|
|
|
+ and (GotType.BaseType<>btContext) and (ExpType.BaseType<>btContext) then
|
|
begin
|
|
begin
|
|
GotDesc:=GetBaseDescription(GotType);
|
|
GotDesc:=GetBaseDescription(GotType);
|
|
if ExpType.BaseType=btNil then
|
|
if ExpType.BaseType=btNil then
|
|
@@ -22766,8 +22769,9 @@ begin
|
|
end
|
|
end
|
|
else if (GotType.LoTypeEl<>nil) and (ExpType.LoTypeEl<>nil) then
|
|
else if (GotType.LoTypeEl<>nil) and (ExpType.LoTypeEl<>nil) then
|
|
begin
|
|
begin
|
|
- if (GotType.LoTypeEl.ClassType=ExpType.LoTypeEl.ClassType)
|
|
|
|
- and (GotType.LoTypeEl is TPasProcedureType) then
|
|
|
|
|
|
+ NeedProcSignature:=(GotType.LoTypeEl is TPasProcedureType)
|
|
|
|
+ and (ExpType.LoTypeEl is TPasProcedureType);
|
|
|
|
+ if NeedProcSignature then
|
|
begin
|
|
begin
|
|
// procedural types
|
|
// procedural types
|
|
GetIncompatibleProcParamsDesc(TPasProcedureType(GotType.LoTypeEl),
|
|
GetIncompatibleProcParamsDesc(TPasProcedureType(GotType.LoTypeEl),
|
|
@@ -22908,6 +22912,12 @@ begin
|
|
GotDesc:=GotDesc+')';
|
|
GotDesc:=GotDesc+')';
|
|
ExpDesc:=ExpDesc+')';
|
|
ExpDesc:=ExpDesc+')';
|
|
|
|
|
|
|
|
+ // function result
|
|
|
|
+ if GotType is TPasFunctionType then
|
|
|
|
+ GotDesc:=GotDesc+': '+GetTypeDescription(ResolveAliasType(TPasFunctionType(GotType).ResultEl.ResultType));
|
|
|
|
+ if ExpType is TPasFunctionType then
|
|
|
|
+ ExpDesc:=ExpDesc+': '+GetTypeDescription(ResolveAliasType(TPasFunctionType(ExpType).ResultEl.ResultType));
|
|
|
|
+
|
|
// modifiers
|
|
// modifiers
|
|
if (ptmOfObject in GotType.Modifiers) and not (ptmOfObject in ExpType.Modifiers) then
|
|
if (ptmOfObject in GotType.Modifiers) and not (ptmOfObject in ExpType.Modifiers) then
|
|
GotDesc:=GotDesc+' of Object'
|
|
GotDesc:=GotDesc+' of Object'
|
|
@@ -22921,10 +22931,21 @@ begin
|
|
GotDesc:=GotDesc+'; static'
|
|
GotDesc:=GotDesc+'; static'
|
|
else if not (ptmStatic in GotType.Modifiers) and (ptmStatic in ExpType.Modifiers) then
|
|
else if not (ptmStatic in GotType.Modifiers) and (ptmStatic in ExpType.Modifiers) then
|
|
ExpDesc:=ExpDesc+'; static';
|
|
ExpDesc:=ExpDesc+'; static';
|
|
|
|
+ if (ptmAsync in GotType.Modifiers) and not (ptmAsync in ExpType.Modifiers) then
|
|
|
|
+ GotDesc:=GotDesc+'; async'
|
|
|
|
+ else if not (ptmAsync in GotType.Modifiers) and (ptmAsync in ExpType.Modifiers) then
|
|
|
|
+ ExpDesc:=ExpDesc+'; async';
|
|
if (ptmVarargs in GotType.Modifiers) and not (ptmVarargs in ExpType.Modifiers) then
|
|
if (ptmVarargs in GotType.Modifiers) and not (ptmVarargs in ExpType.Modifiers) then
|
|
GotDesc:=GotDesc+'; varargs'
|
|
GotDesc:=GotDesc+'; varargs'
|
|
else if not (ptmVarargs in GotType.Modifiers) and (ptmVarargs in ExpType.Modifiers) then
|
|
else if not (ptmVarargs in GotType.Modifiers) and (ptmVarargs in ExpType.Modifiers) then
|
|
- ExpDesc:=ExpDesc+'; varargs';
|
|
|
|
|
|
+ ExpDesc:=ExpDesc+'; varargs'
|
|
|
|
+ else
|
|
|
|
+ begin
|
|
|
|
+ if GotType.VarArgsType<>nil then
|
|
|
|
+ GotDesc:=GotDesc+'; varargs of '+GetTypeDescription(ResolveAliasType(GotType.VarArgsType));
|
|
|
|
+ if ExpType.VarArgsType<>nil then
|
|
|
|
+ ExpDesc:=ExpDesc+'; varargs of '+GetTypeDescription(ResolveAliasType(ExpType.VarArgsType));
|
|
|
|
+ end;
|
|
|
|
|
|
// calling convention
|
|
// calling convention
|
|
if GotType.CallingConvention<>ExpType.CallingConvention then
|
|
if GotType.CallingConvention<>ExpType.CallingConvention then
|
|
@@ -22932,6 +22953,14 @@ begin
|
|
GotDesc:=GotDesc+';'+cCallingConventions[GotType.CallingConvention];
|
|
GotDesc:=GotDesc+';'+cCallingConventions[GotType.CallingConvention];
|
|
ExpDesc:=ExpDesc+';'+cCallingConventions[ExpType.CallingConvention];
|
|
ExpDesc:=ExpDesc+';'+cCallingConventions[ExpType.CallingConvention];
|
|
end;
|
|
end;
|
|
|
|
+
|
|
|
|
+ if GotDesc=ExpDesc then
|
|
|
|
+ begin
|
|
|
|
+ if GotType.Parent is TPasAnonymousProcedure then
|
|
|
|
+ GotDesc:='anonymous '+GotDesc;
|
|
|
|
+ if ExpType.Parent is TPasAnonymousProcedure then
|
|
|
|
+ ExpDesc:='anonymous '+ExpDesc;
|
|
|
|
+ end;
|
|
end;
|
|
end;
|
|
|
|
|
|
function TPasResolver.CheckCallProcCompatibility(ProcType: TPasProcedureType;
|
|
function TPasResolver.CheckCallProcCompatibility(ProcType: TPasProcedureType;
|
|
@@ -24588,7 +24617,7 @@ begin
|
|
end;
|
|
end;
|
|
if RaiseOnIncompatible then
|
|
if RaiseOnIncompatible then
|
|
RaiseIncompatibleTypeRes(20170216152444,nIncompatibleTypesGotExpected,
|
|
RaiseIncompatibleTypeRes(20170216152444,nIncompatibleTypesGotExpected,
|
|
- [],LHS,RHS,LErrorEl)
|
|
|
|
|
|
+ [],RHS,LHS,LErrorEl)
|
|
else
|
|
else
|
|
exit(cIncompatible);
|
|
exit(cIncompatible);
|
|
end
|
|
end
|