Finely chop the garlic. Strip the corn from the cobs and dice the squash into 1/4-inch cubes. Chop the tomatoes roughly. Put a large pot of generously salted water on to boil.
Put 2 tablespoons of the olive oil in a large sauté pan with high sides over low heat. Add the garlic and cook, stirring frequently, until softened and fragrant (but not brown), 3 to 5 minutes. Raise the heat to medium and add the corn and squash and several pinches of salt. Cook for a minute or two. Add the tomatoes and another couple pinches of salt; when the mixture bubbles, lower the heat so that it's simmering briskly. (You want the tomatoes to cook down and release their juices into the sauce while the pasta cooks, but you don't want it to get dry.)
Add the pasta to the boiling water and cook according to the package directions, until just al dente. Keep an eye on your sauce and lower or turn off the heat if it's looking at all dry.
Reserve a cup of the pasta cooking water and drain the pasta well. Stir the remaining 2 tablespoons of olive oil into the pasta, then add it to the sauce and stir through. Add a little of the pasta water to loosen things up, taste for seasoning and add more salt if necessary and some freshly cracked black pepper. Tear the basil roughly and stir it into the pasta. Serve right away, adding a few dollops of ricotta to each portion.