<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>8092</bug_id>
          
          <creation_ts>2009-10-27 22:13:38 +0000</creation_ts>
          <short_desc>HTMLCollection subclass interfaces are incompatible with static languages</short_desc>
          <delta_ts>2010-10-04 14:47:29 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>pre-LC1 HTML5 spec (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>NE</keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Maciej Stachowiak">mjs</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>philipj</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>29136</commentid>
    <comment_count>0</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2009-10-27 22:13:38 +0000</bug_when>
    <thetext>HTMLCollection has a namedItem method that returns &quot;Element&quot;, and the interfaces that inherit from HTMLCollection (such as HTMLAllCollection) override it with a namedItem method that returns &quot;object&quot;.

This is a problem because you can&apos;t generate interfaces for any statically typed language (e.g. Java or Objective-C) from the WebIDL as written. The base class would return a specific type (&quot;Element) but subclasses would return a more general type (Java &quot;Object&quot; or Objective-C &quot;id&quot;), which is not allowed in those languages. Return types in derived classes have to be covariant, not contravariant. This would be fixed by having namedItem() in the base interface declared to return &quot;object&quot; type, even though in practice a vanilla HTMLCollection will only return Elements.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>29137</commentid>
    <comment_count>1</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2009-10-27 22:15:11 +0000</bug_when>
    <thetext>As a side note, though contravariant return types are not really a problem in JS, declaring a more specific return type in the WebIDL doesn&apos;t particularly help JavaScript either. The exposed JavaScript behavior is not affected.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>30001</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2009-12-08 15:45:42 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter&apos;s comments.

But note that anyone who is using polymorphism with HTMLCollection is going to shoot themselves in the foot really badly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>30002</commentid>
    <comment_count>3</comment_count>
    <who name="">contributor</who>
    <bug_when>2009-12-08 15:46:09 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r4418.
Check-in comment: Change the IDL for HTMLCollection to support statically typed languages.
http://html5.org/tools/web-apps-tracker?from=4417&amp;to=4418
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>30004</commentid>
    <comment_count>4</comment_count>
    <who name="Maciej Stachowiak">mjs</who>
    <bug_when>2009-12-08 16:06:59 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; 
&gt; But note that anyone who is using polymorphism with HTMLCollection is going to
&gt; shoot themselves in the foot really badly.
&gt; 

I think you are probably right. All that&apos;s essential to be able to run the IDL compiler on the spec IDL to generate ObjC or Java bindings without failing.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>