Clojure

Reflection incorrectly avoids "More than one matching method" exceptions

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Duplicate
  • Affects Version/s: None
  • Fix Version/s: Backlog
  • Component/s: None
  • Labels:
    None

Description

From the google group:

The following correctly throws an IllegalArgumentException "More than one matching method" due to the nil resulting in ambiguity between two overloaded version of append.

(let [sb (StringBuilder.)]
  (.append sb nil))</code></pre>And yet the following, which uses reflection, works:
<pre><code>(def s nil)
(let [sb (StringBuilder.)]
  (.append sb s))
This is due to a divergence in method resolution between direct and reflected calls. Both examples should result in an exception due to ambiguity.

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/466
Hide
Assembla Importer added a comment -

ataggart said: Simpler example of the problem.

Show
Assembla Importer added a comment - ataggart said: Simpler example of the problem.
Hide
Assembla Importer added a comment -

ataggart said: Fixed via patch at ticket #445.

Show
Assembla Importer added a comment - ataggart said: Fixed via patch at ticket #445.
Hide
Stuart Halloway added a comment -

See #445

Show
Stuart Halloway added a comment - See #445

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: