fork download
  1. // テストコード
  2. module a;
  3. import b;
  4. class C{
  5. void f(){}
  6. }
  7. void main(){
  8. auto s = S!C(new C);
  9. s.f(); // ここがError: undefined identifier 'f', did you mean 'import b'?
  10. }
  11.  
  12.  
  13. // これだとa.d(xx): Error: undefined identifier 'f', did you mean 'import b'?
  14. module b;
  15. struct S(T){
  16. private T t_; // NG alias thisが無効になる
  17. alias t_ this;
  18. static S!T opCall(T t){
  19. S!T s;
  20. s.t_ = t;
  21. return s;
  22. }
  23. }
  24.  
  25. // これだとコンパイル通る
  26. module b;
  27. struct S(T){
  28. T t_; // OK alias thisが有効になる
  29. alias t_ this;
  30. static S!T opCall(T t){
  31. S!T s;
  32. s.t_ = t;
  33. return s;
  34. }
  35. }
  36.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty