File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ public:
164164 return u;
165165 }
166166 /* * Forwards member access to contents. */
167- RefT opDot () { return _p; }
167+ auto opDot () inout { return _p; }
168168
169169 /**
170170 Postblit operator is undefined to prevent the cloning of $(D Unique) objects.
@@ -288,6 +288,26 @@ private:
288288 assert (! uf2.isEmpty);
289289}
290290
291+ // ensure Unique behaves correctly through const access paths
292+ @system unittest
293+ {
294+ struct Bar {int val;}
295+ struct Foo
296+ {
297+ Unique! Bar bar = new Bar ;
298+ }
299+
300+ Foo foo;
301+ foo.bar.val = 6 ;
302+ const Foo * ptr = &foo;
303+ static assert (is (typeof (ptr) == const (Foo * )));
304+ static assert (is (typeof (ptr.bar) == const (Unique! Bar )));
305+ static assert (is (typeof (ptr.bar.val) == const (int )));
306+ assert (ptr.bar.val == 6 );
307+ foo.bar.val = 7 ;
308+ assert (ptr.bar.val == 7 );
309+ }
310+
291311// Used in Tuple.toString
292312private template sharedToString (alias field)
293313 if (is (typeof (field) == shared ))
You can’t perform that action at this time.
0 commit comments