
345 Mass. 567 (1963)
188 N.E.2d 857
LONG ISLAND PAINTING CORP.
vs.
BEACON CONSTRUCTION COMPANY, INC. & others.
Supreme Judicial Court of Massachusetts, Suffolk.
January 8, 1963.
March 7, 1963.
Present: WILKINS, C.J., SPALDING, WHITTEMORE, SPIEGEL, & REARDON, JJ.
William D. Quigley, Assistant Attorney General, for Metropolitan District Commission.
Robert J. Sherer (Frederick W. Roche with him) for Beacon Construction Company, Inc.
Walter J. Hurley (Vincent J. Cosgrove with him) for the plaintiff.
Joseph M. Corwin, Sally A. Corwin, & Jerome A. McCusker, for Associated Subcontractors of Massachusetts, amicus curiae, submitted a brief.
WHITTEMORE, J.
The final decree of June 1, 1962, in the Superior Court on this bill for a declaratory decree under G.L.c. 231A ordered that the defendant Metropolitan District Commission (M.D.C.) pay to the plaintiff $19,977.66 out of the sum retained by M.D.C. under a general contract with Beacon Construction Company, Inc. (Beacon), dated April 24, 1959, for the reconstruction of Longfellow Bridge.
Beacon and Maryland Casualty Company (Maryland) were parties defendant but on November 30, 1961, the demurrers of Beacon and Maryland were sustained by interlocutory decrees which did not refer to any of the grounds of demurrer. Maryland's demurrer averred that no facts were set out entitling the plaintiff (Long Island) to relief against it and that there was no "actual controversy" between Long Island and Maryland. Beacon's demurrer averred that the bill showed no controversy between it and Long Island which could be determined with finality in the suit, insufficient facts to show a right to relief under G.L.c. 30, § 39F, and facts not alleged with substantial certainty and clarity; also that the relief sought could not be had under G.L.c. 231A.
The final decree dismissed the bill as to Beacon and Maryland. Beacon and M.D.C. appealed from the final decree.
The case was heard on a statement of agreed facts entered into by Long Island and M.D.C. It was agreed, *569 inter alia, as follows: Long Island, a subcontractor, had completed its work; M.D.C. had paid Beacon in full for that work; Beacon had only partially paid Long Island leaving $19,977.66 due; Long Island had made claim on M.D.C. for direct payment of this sum under G.L.c. 30, § 39F; Long Island had also perfected a lien under G.L.c. 149, § 29, against the performance bond on which Maryland was surety for alleged extras in the amount of $97,348; the retained percentage under the general contract was $25,342.10; no other claim under G.L.c. 30, § 39F, or G.L.c. 149, § 29, had been filed or received by M.D.C. against the general contract.
The substantive issue of law presented, and the only issue argued by M.D.C. on its appeal, is this: G.L.c. 30, § 39G, requires that M.D.C. deduct and retain from payment of a final (or semifinal) estimate "a sum sufficient to satisfy any and all outstanding claims or liens ... [duly filed against Beacon] under the provisions of section thirty-nine[1] or thirty-nine A of this chapter or section twenty-nine of chapter one hundred and forty-nine ..."; the lien of Long Island under c. 149, § 29, for $97,000 plus required that all of the retained percentage ($25,000 plus) be withheld from Beacon; therefore, there are no "sums payable to the general contractor on the general contract," and hence no sums from which it can make the payment which Long Island seeks and the final decree orders.
1. The final decree is based on a correct construction of the statutes. Under G.L.c. 30, § 30G,[2] Beacon had no right *570 to receive payment of any amount not in excess of "a sum sufficient to satisfy" all the specified claims or liens. Thus all persons who might have legal or equitable rights to the retained percentage ahead of Beacon were protected. Persons having such rights would be: (1) subcontractors under c. 30, § 39F, and (2) the surety, so far as it would have rights of subrogation because of payments to subcontractors under c. 149, § 29. See Water Works Supply Corp. v. Cahill, 344 Mass. 442, 447. But Long Island had a higher right than Beacon's. Subcontractors have direct rights against the retained funds under § 39F.[1a]Pioneer Steel Erectors, Inc. v. Commonwealth, 344 Mass. 195, 198-199. Section 39G does not bar the payment to a subcontractor under § 39F of amounts withheld from the general contractor under § 39G. This construction serves the purpose of the statutes with reasonable regard to the affected interests; the payment from the retained percentage discharges, pro tanto, the general contractor's obligation to the subcontractor and relieves the surety of a claim which would otherwise be perfectible against the bond under c. 149, § 29.
2. The final decree errs in making a statutory construction which purports to affect Beacon's rights although Beacon is not bound by it. See G.L.c. 231A, § 8. Beacon did not agree to the facts stated. The ruling is incorrect that because Beacon's demurrer was sustained Beacon could not "assert that it has an interest or would be affected by a declaration involving ... [Long Island and M.D.C.]." If this were an action or suit between private parties for the *571 recovery of the $19,000 plus, we assume M.D.C. would be bound to Long Island by the decree and would risk Beacon's possible right also to recover the sum paid to Long Island ostensibly for Beacon's account. But under c. 231A, § 8, "all persons shall be made parties who have or claim any interest which would be affected by the declaration." Furthermore this proceeding can be sustained only as a strict declaratory proceeding (see point 3), and M.D.C.'s consent to proceed in the absence of Beacon was beyond its authority so far as it might result in making the Commonwealth liable to Long Island and Beacon for the same retained sum.
Although M.D.C. has not argued the point, its appeal from the final decree opens the interlocutory decree to revision so far only as it appears to the full court that such final decree is "erroneously affected thereby." G.L.c. 214, § 27. The dismissal of the bill as to Beacon was grounded in the interlocutory decree. Hence we review that decree.
3. It was not a good ground for demurrer that the proceeding is against the Commonwealth and that G.L.c. 258 does not permit such a suit. The declaration sought by this bill is a construction of G.L.c. 30, §§ 39F and 39G and c. 149, § 29, so that M.D.C. may properly perform its obligations thereunder. In this respect the case is like Saint Luke's Hosp. v. Labor Relations Commn. 320 Mass. 467, where in a suit under G.L.c. 231A the court determined the jurisdiction of the Labor Relations Commission to entertain a certification proceeding under G.L.c. 150A. The Commonwealth is not a party. No decree against the Commonwealth for the sum which should be paid by M.D.C. is directly sought or can be entered on this bill. Compare Pioneer Steel Erectors, Inc. v. Commonwealth, 344 Mass. 195. Compare also Executive Air Serv. Inc. v. Division of Fisheries & Game, 342 Mass. 356, 358, which notes that in the Saint Luke's Hosp. case "the agency was the only party directly concerned."
So far as the demurrers raise issues not disposed of above, they are without merit.
4. The agreed facts and the tenor of the arguments suggest that there may be no substantial issue which Beacon *572 will seek to raise other than those now decided. That, of course, is beside the point. Beacon, as a necessary party, must have an opportunity to be heard. The interlocutory decree sustaining Beacon's demurrer and the final decree are reversed and the case is to stand for further proceedings in the Superior Court in accordance herewith.
So ordered.
NOTES
[1]  Although the reference to § 39 remains in § 39G, that section (39) was repealed by St. 1957, c. 682, § 2.
[2]  Section 39G reads in part: "Within sixty-five days after the work required by a contract with the commonwealth or any agency or political subdivision thereof ... has been completed to the satisfaction of the duly authorized representative or agent of the contracting authority, a final estimate of the quantity of work done thereunder and the value of such work shall be prepared.... The contracting authority shall deduct and retain from payment of said final estimate a sum sufficient to satisfy any and all outstanding claims or liens that have been duly filed against a contractor under the provisions of section thirty-nine or thirty-nine A of this chapter or section twenty-nine of chapter one hundred and forty-nine, and may also deduct and retain from such payment any other amounts to be deducted or retained in accordance with the terms of the contract."
[1a]  Section 39F reads in part: "If, within ten days after the aforementioned sixty-fifth day, the subcontractor has not received from the general contractor the entire balance due on the subcontract less the aforesaid amounts, the subcontractor shall give the awarding authority and the general contractor written notice of such failure to receive payment and of the amount so payable, but not paid, by the general contractor. Thereupon the awarding authority shall make, out of sums payable to the general contractor on the general contract, direct payment to the subcontractor of the entire balance due on the subcontract less the aforesaid amounts. Such direct payment by the awarding authority to any subcontractor and any payment to a general contractor for the account of a subcontractor as hereinbefore provided shall discharge the obligation of the awarding authority to the general contractor to the extent of such payment." The last two paragraphs of this section, added by St. 1960, c. 771, § 1, are inapplicable to the contract in suit. See ibid. § 9.
