Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading with Widen-and-Box - Sierra & Bates

 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below, to find a signature match, the compiler first widens the 'boy' value all the way to double.
Its second choice is to box it into a Byte. If this fails, the Byte object is "widened" to type Object
("Is-A" test). The compiler then gives up; it doesn't widen and then box 'boy' into a Short object.
The S&B book simply says, "This is just too much for the compiler." My question is for clarification. I don't see a conceptual problem with trying to find an override match
by looking across the wrapper classes. Why was it decided that this should not be done? Was it to
avoid the processing required?

Jim ... ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic