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

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>221767</bug_id>
          
          <creation_ts>2021-02-11 11:53:02 -0800</creation_ts>
          <short_desc>Investigate creation and use of checked_objc_cast&lt;&gt;</short_desc>
          <delta_ts>2021-02-18 11:53:14 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=221428</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>darin</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1728207</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2021-02-11 11:53:02 -0800</bug_when>
    <thetext>Investigate creation and use of checked_objc_cast&lt;&gt;.

Via Darin Adler (paraphrasing): The dynamic_objc_cast&lt;&gt; method exists, but there may be some cases in WebKit where we actually want a checked_objc_cast&lt;&gt; method, similar to checked_cf_cast&lt;&gt;.

In a nutshell:
- Use checked_objc_cast&lt;&gt; if we always expect the same type of object (or nil), and it&apos;s obviously incorrect if a different (non-nil) object is referenced.
- Use dynamic_objc_cast&lt;&gt; if we&apos;re checking for a particular type, but it&apos;s not fatal if we get a different type.  The result of dynamic_objc_cast&lt;&gt; should always be nil-checked.

See also the discussion in Bug 221428 Comment #0 for the differences between checked_cf_cast&lt;&gt; and dynamic_cf_cast&lt;&gt;:
&lt;https://bugs.webkit.org/show_bug.cgi?id=221428#c0&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1728218</commentid>
    <comment_count>1</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2021-02-11 12:05:42 -0800</bug_when>
    <thetext>Because Objective-C has built in predictable behavior for nil, it’s probably a little less common to *need* the stricter checking than in CF code and checked_cf_cast, but I think I spotted a few cases where the runtime check and abort of the &quot;checked&quot; version would be better than what we have right now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1730960</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-02-18 11:53:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/74488150&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>