@@ -538,6 +538,8 @@ $(H3 $(LNAME2 delegating-constructors, Delegating Constructors))
538
538
}
539
539
------
540
540
541
+ $(H3 $(LNAME2 ctor-restrictions, Restrictions))
542
+
541
543
$(P The following restrictions apply:)
542
544
543
545
$(OL
@@ -555,14 +557,16 @@ $(H3 $(LNAME2 delegating-constructors, Delegating Constructors))
555
557
calls.)
556
558
)
557
559
558
- $(LI If a constructor's code contains a delegating constructor call, all
560
+ $(LI If a constructor's code contains a delegating/base constructor call, all
559
561
possible execution paths through the constructor must make exactly one
560
- delegating constructor call :
562
+ of those calls :
561
563
562
564
------
563
- this() { a || super(); } // illegal
565
+ this() { a || super(); } // illegal, 0 or 1 call
566
+
567
+ this() { (a) ? this(1) : super(); } // OK
564
568
565
- this() { (a) ? this(1) : super() ; } // ok
569
+ this() { super(); this(1); } // illegal, 2 calls
566
570
567
571
this()
568
572
{
@@ -575,11 +579,14 @@ $(H3 $(LNAME2 delegating-constructors, Delegating Constructors))
575
579
)
576
580
577
581
$(LI It is illegal to refer to $(D this) implicitly or explicitly
578
- prior to making a delegating constructor call.)
582
+ prior to making a delegating/base constructor call.)
579
583
580
- $(LI Delegating constructor calls cannot appear after labels.)
584
+ $(LI Delegating/base constructor calls cannot appear after labels.)
581
585
)
582
586
587
+ $(P See also: $(RELATIVE_LINK2 field-init, field initialization).)
588
+
589
+
583
590
$(H3 $(LNAME2 implicit-base-construction, Implicit Base Class Construction))
584
591
585
592
$(P If there is no constructor for a class, but there is a constructor
0 commit comments