Heat the oven to 350°F. Grease an 8x8-inch (2-qt.) glass or ceramic baking dish. Cut the squash in half lengthwise and scrape out the seeds and fibers. Slice the squash and potatoes about 1/8 inch thick (use a mandoline if you have one). Line the bottom of the baking dish with a layer of squash (overlapping slightly), season lightly with salt and pepper, sprinkle with a little of the Parmigiano, and drizzle with a little of the cream. Cover with a layer of potato slices, season with salt, pepper, Parmigiano, and cream. Repeat with the remaining squash and potatoes until the dish is full, ending with a top layer of squash, seasoned and topped with any remaining cheese and cream. (You may have extra squash.) Press down lightly to distribute the cream and compact the layers. The last layer of squash should be just sitting in the cream, but not covered by it. Cover the dish with foil and bake until the vegetables feel tender when poked with a thin, sharp knife (check the middle layer), about 1 hour and 10 minutes.
For a gratin, alternate layers of squash and potato, drizzling cream and sprinkling Parmigiano in between.
Press gently on the completed layers to distribute the cream evenly.
Combine the walnuts and buttered breadcrumbs. Remove the gratin from the oven, sprinkle with the breadcrumb-nut mixture, and bake until the top is lightly browned, 5 to 10 minutes. Let sit in a warm place for 20 minutes before serving so that liquids will set and tighten the gratin. Cut into 9 squares and serve.
Finish cooking the gratin uncovered to brown the breadcrumb-walnut topping.