|
@@ -1295,7 +1295,7 @@ type
|
|
|
|
|
|
TPasResolverOption = (
|
|
TPasResolverOption = (
|
|
proFixCaseOfOverrides, // fix Name of overriding proc/property to the overriden proc/property
|
|
proFixCaseOfOverrides, // fix Name of overriding proc/property to the overriden proc/property
|
|
- proClassPropertyNonStatic, // class property accessors are non static
|
|
|
|
|
|
+ proClassPropertyNonStatic, // class property accessors can be non static
|
|
proPropertyAsVarParam, // allows to pass a property as a var/out argument
|
|
proPropertyAsVarParam, // allows to pass a property as a var/out argument
|
|
proClassOfIs, // class-of supports is and as operator
|
|
proClassOfIs, // class-of supports is and as operator
|
|
proExtClassInstanceNoTypeMembers, // class members of external class cannot be accessed by instance
|
|
proExtClassInstanceNoTypeMembers, // class members of external class cannot be accessed by instance
|
|
@@ -5942,14 +5942,13 @@ begin
|
|
RaiseMsg(20181218195552,nInvalidXModifierY,sInvalidXModifierY,['record '+GetElementTypeName(Proc),'abstract'],Proc);
|
|
RaiseMsg(20181218195552,nInvalidXModifierY,sInvalidXModifierY,['record '+GetElementTypeName(Proc),'abstract'],Proc);
|
|
if Proc.IsForward then
|
|
if Proc.IsForward then
|
|
RaiseMsg(20181218195514,nInvalidXModifierY,sInvalidXModifierY,['record '+GetElementTypeName(Proc),'forward'],Proc);
|
|
RaiseMsg(20181218195514,nInvalidXModifierY,sInvalidXModifierY,['record '+GetElementTypeName(Proc),'forward'],Proc);
|
|
- if Proc.IsStatic then
|
|
|
|
- if (Proc.ClassType<>TPasClassProcedure) and (Proc.ClassType<>TPasClassFunction) then
|
|
|
|
- RaiseMsg(20190206150922,nInvalidXModifierY,sInvalidXModifierY,[GetElementTypeName(Proc),'static'],Proc);
|
|
|
|
if IsClassMethod(Proc) then
|
|
if IsClassMethod(Proc) then
|
|
begin
|
|
begin
|
|
if not Proc.IsStatic then
|
|
if not Proc.IsStatic then
|
|
RaiseMsg(20190106121503,nClassMethodsMustBeStaticInX,sClassMethodsMustBeStaticInX,['records'],Proc);
|
|
RaiseMsg(20190106121503,nClassMethodsMustBeStaticInX,sClassMethodsMustBeStaticInX,['records'],Proc);
|
|
- end;
|
|
|
|
|
|
+ end
|
|
|
|
+ else if Proc.IsStatic then
|
|
|
|
+ RaiseMsg(20190206150922,nInvalidXModifierY,sInvalidXModifierY,[GetElementTypeName(Proc),'static'],Proc);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
begin
|
|
begin
|
|
@@ -6476,12 +6475,15 @@ var
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
- function ExpectedClassAccessorStatic: boolean;
|
|
|
|
|
|
+ function CheckClassAccessorStatic(ProcIsStatic: boolean): boolean;
|
|
begin
|
|
begin
|
|
- if (ClassScope<>nil) and (proClassPropertyNonStatic in Options) then
|
|
|
|
- Result:=false
|
|
|
|
|
|
+ if ClassScope=nil then
|
|
|
|
+ // record: class getter/setter must be static
|
|
|
|
+ Result:=ProcIsStatic=true
|
|
|
|
+ else if proClassPropertyNonStatic in Options then
|
|
|
|
+ Result:=true // both allowed
|
|
else
|
|
else
|
|
- Result:=true;
|
|
|
|
|
|
+ Result:=ProcIsStatic=true;
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure CheckIndexArg(ArgNo: integer; const IndexResolved: TPasResolverResult;
|
|
procedure CheckIndexArg(ArgNo: integer; const IndexResolved: TPasResolverResult;
|
|
@@ -6893,7 +6895,7 @@ begin
|
|
begin
|
|
begin
|
|
if Proc.ClassType<>TPasClassFunction then
|
|
if Proc.ClassType<>TPasClassFunction then
|
|
RaiseXExpectedButYFound(20170216151834,'class function',GetElementTypeName(Proc),PropEl.ReadAccessor);
|
|
RaiseXExpectedButYFound(20170216151834,'class function',GetElementTypeName(Proc),PropEl.ReadAccessor);
|
|
- if Proc.IsStatic<>ExpectedClassAccessorStatic then
|
|
|
|
|
|
+ if not CheckClassAccessorStatic(Proc.IsStatic) then
|
|
if Proc.IsStatic then
|
|
if Proc.IsStatic then
|
|
RaiseMsg(20170216151837,nClassPropertyAccessorMustNotBeStatic,sClassPropertyAccessorMustNotBeStatic,[],PropEl.ReadAccessor)
|
|
RaiseMsg(20170216151837,nClassPropertyAccessorMustNotBeStatic,sClassPropertyAccessorMustNotBeStatic,[],PropEl.ReadAccessor)
|
|
else
|
|
else
|
|
@@ -6948,7 +6950,7 @@ begin
|
|
begin
|
|
begin
|
|
if Proc.ClassType<>TPasClassProcedure then
|
|
if Proc.ClassType<>TPasClassProcedure then
|
|
RaiseXExpectedButYFound(20170216151903,'class procedure',GetElementTypeName(Proc),PropEl.WriteAccessor);
|
|
RaiseXExpectedButYFound(20170216151903,'class procedure',GetElementTypeName(Proc),PropEl.WriteAccessor);
|
|
- if Proc.IsStatic<>ExpectedClassAccessorStatic then
|
|
|
|
|
|
+ if not CheckClassAccessorStatic(Proc.IsStatic) then
|
|
if Proc.IsStatic then
|
|
if Proc.IsStatic then
|
|
RaiseMsg(20170216151905,nClassPropertyAccessorMustNotBeStatic,sClassPropertyAccessorMustNotBeStatic,[],PropEl.WriteAccessor)
|
|
RaiseMsg(20170216151905,nClassPropertyAccessorMustNotBeStatic,sClassPropertyAccessorMustNotBeStatic,[],PropEl.WriteAccessor)
|
|
else
|
|
else
|