소스 검색

* use new compare_rettype() to compare the return types of functions to decide whether they can be added as overloads so that operator overloads that have (different) generic types as return values are treated as different
+ added tests

Sven/Sarah Barth 2 일 전
부모
커밋
a3ae828b65
3개의 변경된 파일57개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      compiler/pparautl.pas
  2. 31 0
      tests/test/tgeneric126.pp
  3. 25 0
      tests/test/tgeneric127.pp

+ 1 - 1
compiler/pparautl.pas

@@ -817,7 +817,7 @@ implementation
       function equal_signature(fwpd,currpd:tprocdef;out sameparas,sameret:boolean):boolean;
         begin
           sameparas:=compare_paras(fwpd.paras,currpd.paras,cp_none,[cpo_ignorehidden,cpo_openequalisexact,cpo_ignoreuniv])=te_exact;
-          sameret:=compare_defs(fwpd.returndef,currpd.returndef,nothingn)=te_exact;
+          sameret:=compare_rettype(fwpd.returndef,currpd.returndef)=te_exact;
           result:=sameparas and sameret;
         end;
 

+ 31 - 0
tests/test/tgeneric126.pp

@@ -0,0 +1,31 @@
+{ %NORUN }
+
+program tgeneric126;
+
+{$mode delphi}
+
+type
+  TTest<S, T> = record
+    class operator Implicit(const aArg: TTest<S, T>): T;
+    class operator Implicit(const aArg: TTest<S, T>): TArray<T>;
+    class operator Implicit(const aArg: TTest<S, T>): S;
+  end;
+
+class operator TTest<S, T>.Implicit(const aArg: TTest<S, T>): T;
+begin
+
+end;
+
+class operator TTest<S, T>.Implicit(const aArg: TTest<S, T>): TArray<T>;
+begin
+
+end;
+
+class operator TTest<S, T>.Implicit(const aArg: TTest<S, T>): S;
+begin
+
+end;
+
+begin
+
+end.

+ 25 - 0
tests/test/tgeneric127.pp

@@ -0,0 +1,25 @@
+{ %FAIL }
+
+program tgeneric127;
+
+{$mode delphi}
+
+type
+  TTest<T> = record
+    class operator Implicit(const aArg: TTest<T>): T;
+    class operator Implicit(const aArg: TTest<T>): T;
+  end;
+
+class operator TTest<T>.Implicit(const aArg: TTest<T>): T;
+begin
+
+end;
+
+class operator TTest<T>.Implicit(const aArg: TTest<T>): T;
+begin
+
+end;
+
+begin
+
+end.