
514 P.2d 568 (1973)
Leonora FUJIOKA, a minor, by Kazumi Fujioka, her guardian ad litem, et al., Plaintiffs,
v.
Harold C. H. KAM and Edith T. M. Kam, Co-executors of the Estate of York Fon Kam doing business as Kalihi Queen's Super Market, et al., Defendants and Third-Party Plaintiffs-Appellants,
v.
HON HOONG CHEE and Sadaichi Kitajima, Third-Party Defendants-Appellees, and
John Doe Wong et al., Third-Party Defendants.
No. 5328.
Supreme Court of Hawaii.
September 24, 1973.
*569 Christopher P. McKenzie, Honolulu (Gould & McKenzie, Honolulu, of counsel), for defendants and third-party plaintiffs-appellants.
John Gillmor and Gerald Y. Sekiya, Honolulu (Bortz, Case, Stack, Kay, Cronin & Clause, Honolulu, of counsel), for third-party defendant-appellee, Hon Hoong Chee.
John A. Roney, Honolulu (Jenks, Kidwell, Goodsill & Anderson, Honolulu, of counsel), for third-party defendant-appellee, Sadaichi Kitajima.
Before RICHARDSON, C.J., and MARUMOTO, ABE, LEVINSON and KOBAYASHI, JJ.
ABE, Justice.
On February 13, 1970, Leonora Fujioka, a minor, suffered injuries when a portion of the roof of Kalihi Queen's Super Market fell upon her. Action for damages was instituted on her behalf against the owners of the building. The defendants-owners filed a third-party complaint against Hon Hoong Chee, engineer, and Sadaichi Kitajima, general contractor, as third-party defendants. The engineer had performed services in the planning and designing of the building and the general contractor had constructed the improvement. The owners alleged negligence and/or breach of warranty on the part of the engineer and general contractor.
Both the engineer and general contractor moved for summary judgment on the ground that their services were rendered on the building which had been completed before 1956, more than ten years before the collapse of the portion of the roof, and that under the provision of HRS § 657-8[1] they were not liable for contribution or indemnity. The motion was granted and judgment was entered accordingly.
It is to be noted that Section 657-8 was first enacted by our legislature as Act 194, SLH 1967 by adding a new section, Sec. 241-7.1, to Chapter 241, RLH 1955. The first portion of the statute established a statute of limitation of two years after the accruing of the cause of action against registered and licensed persons for services rendered in the designing and construction of improvements on land. The next portion, which is in issue here, provides that no action to recover damages for injuries arising from condition of any improvement on land shall be brought against such registered and licensed persons in any event ten years after the performance or furnishing of such services.
The owners, on appeal before this court, for the first time attacked the constitutionality *570 of the statute. Thus, it is contended by the engineer and the contractor that this court should not consider the issue because they were denied the opportunity to present evidence in the trial court and for the further reason that the trial judge was denied the opportunity to rule on the issue. It is the general rule that an appellate court should only reverse a judgment of a trial court on the legal theory presented by the appellant in the trial court. Kawamoto v. Yasutake, 49 Haw. 42, 410 P.2d 976 (1966); Bank of Hawaii v. Char, 43 Haw. 223 (1959), aff'd, 9 Cir., 287 F.2d 51 (1961), cert. den. 366 U.S. 972, 81 S.Ct. 1938, 6 L.Ed.2d 1261 (1961); Hormel v. Helvering, 312 U.S. 552, 556, 557, 61 S.Ct. 719, 85 L.Ed. 1037 (1941). However, we have also said that the rule is not inflexible and that an appellate court may deviate and hear new legal arguments when justice requires. We also stated that in the exercise of this discretion an appellate court should determine whether the consideration of the issue requires additional facts, whether the resolution of the question will affect the integrity of the findings of fact of the trial court; and whether the question is of great public import. Greene v. Texeira, 54 Haw. 231, 234-235, 505 P.2d 1169, 1172 (1973); In re Taxes, Hawaiian Land Co., 53 Haw. 45, 53, 487 P.2d 1070, 1076 (1971), appeal dismissed, 405 U.S. 907, 92 S.Ct. 938, 30 L.Ed.2d 778 (1972). See also, Kennedy v. Silas Mason Co., 334 U.S. 249, 68 S.Ct. 1031, 92 L.Ed. 1347 (1948); Duarte v. Bank of Hawaii, 287 F.2d 51 (1961), cert. den. 366 U.S. 972, 81 S.Ct. 1938, 6 L.Ed.2d 1261 (1961), affirming the territorial Supreme Court's decision in Bank of Hawaii v. Char, 43 Haw. 223 (1959).
Here, the trial court rendered its judgment on a motion for summary judgment. Thus, there is no material fact in issue and the resolution of the constitutional issue does not require additional facts. Further, we believe that the constitutionality of the statute is of great public import, and therefore we will consider the issue, though it was raised for the first time before this court.
Under the common law, one who suffers injuries has a claim for relief, or a cause of action in tort, against another who owed the injured party a duty but failed to do what a reasonably prudent person would have done, or did what a reasonably prudent person would not have done under the circumstances, providing that such omission or commission is the proximate cause of the injuries suffered. Pratt v. Daly, 55 Ariz. 535, 104 P.2d 147 (1940).
We agree with courts of other jurisdictions that our state legislature may, by legislative act, change or entirely abrogate common law rules through its exercise of the legislative power under the Hawaii State Constitution, but in the exercise of such power, the legislature may not violate a constitutional provision. Warehouse Co. v. Tobacco Growers, 276 U.S. 71, 48 S.Ct. 291, 72 L.Ed. 473 (1928); Pizitz Co. v. Yeldell, 274 U.S. 112, 47 S.Ct. 509, 71 L.Ed. 952 (1927); Vogts v. Guerrett, 142 Colo. 527, 351 P.2d 851 (1960).
The question is whether the grant of immunity to the engineer and the contractor violates any provision of the Hawaii State Constitution or the United States Constitution.

EQUAL PROTECTION
We have said that "what is prohibited by the equal protection guaranty is class legislation, discriminating against some and favoring others. The guaranty was not intended to take from the states the right and power to classify the subjects of legislation, provided such classification of persons and things is reasonable for the purpose of legislation." State v. Johnston, 51 Haw. 195, 203, 456 P.2d 805, 810 (1969), appeal dismissed, 397 U.S. 336, 90 S.Ct. 1152, 25 L.Ed.2d 352 (1970).
We also said that "in exercising this right to classify in order to achieve social goals the legislature may not act arbitrarily; *571 that is, the classification of a particular group as a subject for regulation must be reasonable in relation to the purpose of the legislation." Hasegawa v. Maui Pineapple Co., 52 Haw. 327, 439, 475 P.2d 679, 681 (1970).
The United States Supreme Court said that the equal protection guaranty
"does not prohibit legislation which is limited either in the objects to which it is directed, or by the territory within which it is to operate. It merely requires that all persons subject[ed] to such legislation shall be treated alike, under like circumstances and conditions, both in the privileges conferred and in the liabilities imposed." Thus the guaranty was intended to secure equality of protection not only for all but against all similarly situated. Indeed, protection is not protection unless it does so. Immunity granted to a class, however limited, having the effect to deprive another class, however limited of a personal or property right, is just as clearly a denial of equal protection of the laws to the latter class as if the immunity were in favor of, or the deprivation of right permitted working against, a larger class. Truax v. Corrigan, 257 U.S. 312, 333, 42 S.Ct. 124, 130, 66 L.Ed. 254 (1921).
It would appear that the object or purpose of the legislation was to grant immunity to registered and licensed persons performing services in the construction industry. One may question whether this grant of immunity is justified as a reasonable exercise of the police power of the state. However, assuming that the legislature under its police power was justified in enacting the statute, can the discrimination or classification be upheld under the equal protection guaranty?
Under the record of this case it must be assumed arguendo that both the engineer and the contractor were negligent and their negligence was the proximate cause of the injuries suffered by the plaintiff; and that but for the statute in question the owners would be entitled to relief from the two parties under the third-party complaint. Thus, the statute on one hand grants immunity to the engineer and the contractor, who should and would be, but for the statute, primarily responsible for the injuries. On the other hand, the owners are burdened with the liability for the damages proximately caused by the negligence of the engineer and the contractor for the reason that, under the common law rule in this jurisdiction, the owners are under a duty to use reasonable care for the safety of all persons reasonably expected to be upon the premises. Gibo v. City & County, 51 Haw. 299, 301, 459 P.2d 198, 199 (1969); Pickard v. City & County, 51 Haw. 134, 452 P.2d 445 (1969). In spite of this unfair result, the engineer and the contractor contend that the statute does not violate the equal protection guaranty of the State Constitution.
Stated another way, the cause of the injuries is the same, the plaintiff is the same and the injuries are the same  but under the statute the plaintiff may not recover from the engineer and the contractor even though the negligence of the engineer and the contractor may have been the sole proximate cause of the injuries suffered by the plaintiff. However, the plaintiff may recover damages from the owners, and the owners will have no right to have the engineer and the contractor reimburse or contribute to them the amount of damages they are required to pay the plaintiff. We are unable to see any rational basis for treating the engineer and the contractor differently from the owners under the same circumstances.
It is clear that the classification does not rest upon some reasonable consideration of differences (between the classes under the same circumstances), which have a fair and substantial relation to the object of the legislation. Nor is the classification founded upon a reasonable distinction or difference necessitated by state policy. A statute making such an unsupportable classification fails to meet the requirements of the equal protection guaranty. Morey v. Doud, 354 U.S. 457, 465-469, 77 S.Ct. 1344, *572 1 L.Ed.2d 1485 (1957); Smith v. Cahoon, 283 U.S. 553, 566-567, 51 S.Ct. 582, 75 L.Ed. 1264 (1931); Royster Guano Co. v. Virginia, 253 U.S. 412, 416, 40 S.Ct. 560, 64 L.Ed. 989 (1920); Kansas City v. Webb, 484 S.W.2d 817 (Mo. 1972), cert. den., 409 U.S. 851, 93 S.Ct. 62, 34 L.Ed.2d 93 (1972); Wattigny v. State, 257 La. 945, 244 So.2d 842 (1971); Gray v. Whitmore, 17 Cal. App.3d 1, 28, 94 Cal. Rptr. 904, 920 (1971). See also the decision of this court: Territory v. Pottie, 19 Haw. 99, 104 (1908) and Hasegawa v. Maui Pineapple Co., 52 Haw. 327, 329-333, 475 P.2d 679, 681-683 (1970).
The Illinois Supreme Court held a similar Illinois statute unconstitutional and said:
More important is the fact that of all those whose negligence in connection with the construction of an improvement to real estate might result in damage to property or injury to person more than four years [the period provided in the Illinois statute] after construction is completed, the statute singles out the architect and the contractor, and grants them immunity. It is not at all inconceivable that the owner or person in control of such an improvement might be held liable for damage or injury that results from a defective condition for which the architect or contractor is in fact responsible. Not only is the owner or person in control given no immunity; the statute takes away his action for indemnity against the architect or contractor.
The arbitrary quality of the statute clearly appears when we consider that architects and contractors are not the only persons whose negligence in the construction of a building or other improvement may cause damage to property or injury to persons. If, for example, four years after a building is completed a cornice should fall because the adhesive used was defective, the manufacturer of the adhesive is granted no immunity. And so it is with all others who furnish materials used in constructing the improvement. But if the cornice fell because of defective design or construction for which an architect or contractor was responsible, immunity is granted. It can not be said that the one event is more likely than the other to occur within four years after construction is completed.
Skinner v. Anderson, 38 Ill.2d 455, 460, 231 N.E.2d 588, 591 (1967).
As we have said, the general requirement of the principle of "the equal protection clause is that all persons shall be treated alike under like circumstances and conditions, both in privileges conferred and in the liabilities imposed." State v. Johnston, 51 Haw. 195, 202, 456 P.2d 805, 809 (1969).
Here, it is clear that the statute calls for arbitrary and capricious discrimination and must therefore be declared an invidious discrimination violative of the equal protection guaranty.
Reversed.
NOTES
[1]  HRS § 657-8 reads:

Limitation of action for damages based on professional services or licensed construction to improve real property. No action to recover damages for any injury to property, real or personal, or for bodily injury or wrongful death, arising out of any condition of an improvement to real property, nor any action for contribution or indemnity for damages sustained on account of such injury, shall be brought against any registered and/or duly licensed person performing or furnishing professional or licensed services in the design, planning, supervision, or observation of construction or construction of the improvement to real property more than two years after the cause of action has accrued, but in any event not more than ten years after the performance or furnishing of the services except that this provision shall not apply to surveyors for their own errors in boundary surveys.
