I'm going to develop an example scenario here:
There is a computer that is connected to an interface on the switch that has been assigned VLAN2 and another computer on an interface that has been assigned VLAN3. A router on a stick is connected to a no switchport port on the switch with the default route set to the IP of that interface. 2 SVIs have been set up for each of the VLANs, each with individual IPs and subnet masks and MAC addresses. The default gateways of the computers are set to the IP addresses of their corresponding SVIs (which cisco documentation tells us to do : https://www.cisco.com/c/en/us/support/docs/lan-switching/inter-vlan-routing/41860-howto-L3-intervlanrouting.html).
Computer 1 wishes to send a packet to the internet, IDK, to the ISP DNS server for instance. Let's say computer 1 doesn't know the MAC address of its default gateway so sends an ARP with the broadcast address.
Typically, if it were a L2 switch then it would just flood the ARP request to all ports on the VLAN which includes the trunk to the gateway; however, my question concerns L3-aware switches where the default gateway is indeed on the switch itself (in the form of the SVI). How does the switch recognise this and NOT flood to all the ports on the switch in the VLAN. Does the switch just specially detect broadcast packets, check to see if it's an ARP, check to see if the destination belongs to one of its SVIs and return the MAC, if not, flood to all ports on the VLAN?