Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1044)

Unified Diff: docs/language/informal/generic-method-syntax.md

Issue 2841483003: Added informal generic method syntax and generic function type specs. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: docs/language/informal/generic-method-syntax.md
diff --git a/docs/language/informal/generic-method-syntax.md b/docs/language/informal/generic-method-syntax.md
new file mode 100644
index 0000000000000000000000000000000000000000..12fb09977133ca043e366ac62736ff1892db039e
--- /dev/null
+++ b/docs/language/informal/generic-method-syntax.md
@@ -0,0 +1,581 @@
+
+
+
+
+
+
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+
+
+
+ <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frameworks-d7b19415c108234b91acac0d0c02091c860993c13687a757ee345cc1ecd3a9d1.css" media="all" rel="stylesheet" />
+ <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-678c6c9fa597e3eabad2135736d58fe40e2ef37d8e272589d7d39d7c1c0f9056.css" media="all" rel="stylesheet" />
+
+
+ <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/site-537c466d44a69d38c4bd60c2fd2955373ef96d051bd97b2ad30ed039acc97bff.css" media="all" rel="stylesheet" />
+
+
+ <meta name="viewport" content="width=device-width">
+
+ <title>INFORMAL SPECIFICATION: Generic Method Syntax · GitHub</title>
+ <link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="GitHub">
+ <link rel="fluid-icon" href="https://gist.github.com/fluidicon.png" title="GitHub">
+ <meta property="fb:app_id" content="1401488693436528">
+
+
+ <meta content="https://avatars3.githubusercontent.com/u/9606994?v=3&amp;s=400" property="og:image" /><meta content="Gist" property="og:site_name" /><meta content="object" property="og:type" /><meta content="INFORMAL SPECIFICATION: Generic Method Syntax" property="og:title" /><meta content="https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c" property="og:url" /><meta content="INFORMAL SPECIFICATION: Generic Method Syntax" property="og:description" />
+
+ <link rel="assets" href="https://assets-cdn.github.com/">
+
+ <meta name="pjax-timeout" content="1000">
+
+ <meta name="request-id" content="C852:2758B:2C020EC:46C8F04:58FDDC55" data-pjax-transient>
+
+
+ <meta name="selected-link" value="gist_code" data-pjax-transient>
+
+ <meta name="google-site-verification" content="KT5gs8h0wvaagLKAVWq8bbeNwnZZK1r1XQysX3xurLU">
+<meta name="google-site-verification" content="ZzhVyEFwb7w3e0-uOTltm8Jsck2F5StVihD0exw2fsA">
+ <meta name="google-analytics" content="UA-3769691-4">
+
+<meta content="collector.githubapp.com" name="octolytics-host" /><meta content="gist" name="octolytics-app-id" /><meta content="https://collector.githubapp.com/github-external/browser_event" name="octolytics-event-url" /><meta content="C852:2758B:2C020EC:46C8F04:58FDDC55" name="octolytics-dimension-request_id" />
+<meta content="/&lt;user-name&gt;/&lt;gist-id&gt;" data-pjax-transient="true" name="analytics-location" />
+
+
+
+
+ <meta class="js-ga-set" name="dimension1" content="Logged Out">
+
+
+
+ <meta content="true" name="octolytics-dimension-public" /><meta content="41132114" name="octolytics-dimension-gist_id" /><meta content="4353d7b4f669745bed3a5423e04a453c" name="octolytics-dimension-gist_name" /><meta content="false" name="octolytics-dimension-anonymous" /><meta content="9606994" name="octolytics-dimension-owner_id" /><meta content="eernstg" name="octolytics-dimension-owner_login" /><meta content="false" name="octolytics-dimension-forked" />
+
+ <meta class="js-ga-set" name="dimension5" content="public">
+ <meta class="js-ga-set" name="dimension6" content="owned">
+ <meta class="js-ga-set" name="dimension7" content="markdown">
+
+
+ <meta name="hostname" content="gist.github.com">
+ <meta name="user-login" content="">
+
+ <meta name="expected-hostname" content="gist.github.com">
+ <meta name="js-proxy-site-detection-payload" content="NmU3OWQ3MzkzZjM0NTExNTEwNTllMzQ0ZTFmMTlkYmUxNjJhYzgzNzg3YmRhMGFhY2RiYjVmZDY2ZTAzY2JhOHx7InJlbW90ZV9hZGRyZXNzIjoiMTA0LjEzMi4xODAuMTk4IiwicmVxdWVzdF9pZCI6IkM4NTI6Mjc1OEI6MkMwMjBFQzo0NkM4RjA0OjU4RkREQzU1IiwidGltZXN0YW1wIjoxNDkzMDMyMDIyLCJob3N0IjoiZ2l0aHViLmNvbSJ9">
+
+
+ <meta name="html-safe-nonce" content="6bd8afb890a51ca8210a32e1cf447ea96e2bdc74">
+
+ <meta http-equiv="x-pjax-version" content="2e017d75c6ea5cb7f0c7e24d0a0382b8">
+
+
+ <link href="/eernstg.atom" rel="alternate" title="atom" type="application/atom+xml">
+
+ <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/gist-67dd5139d22e4e9921ef362b5458f51e5973a20db04a54c9d74116748f852917.css" media="all" rel="stylesheet" />
+
+
+
+
+ <meta name="browser-stats-url" content="https://api.github.com/_private/browser/stats">
+
+ <meta name="browser-errors-url" content="https://api.github.com/_private/browser/errors">
+
+ <link rel="mask-icon" href="https://assets-cdn.github.com/pinned-octocat.svg" color="#000000">
+ <link rel="icon" type="image/x-icon" href="https://assets-cdn.github.com/favicon.ico">
+
+<meta name="theme-color" content="#1e2327">
+
+
+
+ </head>
+
+ <body class="logged-out env-production">
+
+
+
+ <div class="position-relative js-header-wrapper ">
+ <a href="#start-of-content" tabindex="1" class="accessibility-aid js-skip-to-content">Skip to content</a>
+ <div id="js-pjax-loader-bar" class="pjax-loader-bar"><div class="progress"></div></div>
+
+
+
+
+
+
+
+ <div class="header gist-header header-logged-out" role="banner">
+ <div class="container clearfix">
+
+ <a href="/" aria-label="Gist Homepage" class="header-logo-wordmark" data-hotkey="g d">
+ <svg aria-hidden="true" class="octicon octicon-logo-github" height="28" version="1.1" viewBox="0 0 45 16" width="78"><path fill-rule="evenodd" d="M18.53 12.03h-.02c.009 0 .015.01.024.011h.006l-.01-.01zm.004.011c-.093.001-.327.05-.574.05-.78 0-1.05-.36-1.05-.83V8.13h1.59c.09 0 .16-.08.16-.19v-1.7c0-.09-.08-.17-.16-.17h-1.59V3.96c0-.08-.05-.13-.14-.13h-2.16c-.09 0-.14.05-.14.13v2.17s-1.09.27-1.16.28c-.08.02-.13.09-.13.17v1.36c0 .11.08.19.17.19h1.11v3.28c0 2.44 1.7 2.69 2.86 2.69.53 0 1.17-.17 1.27-.22.06-.02.09-.09.09-.16v-1.5a.177.177 0 0 0-.146-.18zm23.696-2.2c0-1.81-.73-2.05-1.5-1.97-.6.04-1.08.34-1.08.34v3.52s.49.34 1.22.36c1.03.03 1.36-.34 1.36-2.25zm2.43-.16c0 3.43-1.11 4.41-3.05 4.41-1.64 0-2.52-.83-2.52-.83s-.04.46-.09.52c-.03.06-.08.08-.14.08h-1.48c-.1 0-.19-.08-.19-.17l.02-11.11c0-.09.08-.17.17-.17h2.13c.09 0 .17.08.17.17v3.77s.82-.53 2.02-.53l-.01-.02c1.2 0 2.97.45 2.97 3.88zm-8.72-3.61H33.84c-.11 0-.17.08-.17.19v5.44s-.55.39-1.3.39-.97-.34-.97-1.09V6.25c0-.09-.08-.17-.17-.17h-2.14c-.09 0-.17.08-.17.17v5.11c0 2.2 1.23 2.75 2.92 2.75 1.39 0 2.52-.77 2.52-.77s.05.39.08.45c.02.05.09.09.16.09h1.34c.11 0 .17-.08.17-.17l.02-7.47c0-.09-.08-.17-.19-.17zm-23.7-.01h-2.13c-.09 0-.17.09-.17.2v7.34c0 .2.13.27.3.27h1.92c.2 0 .25-.09.25-.27V6.23c0-.09-.08-.17-.17-.17zm-1.05-3.38c-.77 0-1.38.61-1.38 1.38 0 .77.61 1.38 1.38 1.38.75 0 1.36-.61 1.36-1.38 0-.77-.61-1.38-1.36-1.38zm16.49-.25h-2.11c-.09 0-.17.08-.17.17v4.09h-3.31V2.6c0-.09-.08-.17-.17-.17h-2.13c-.09 0-.17.08-.17.17v11.11c0 .09.09.17.17.17h2.13c.09 0 .17-.08.17-.17V8.96h3.31l-.02 4.75c0 .09.08.17.17.17h2.13c.09 0 .17-.08.17-.17V2.6c0-.09-.08-.17-.17-.17zM8.81 7.35v5.74c0 .04-.01.11-.06.13 0 0-1.25.89-3.31.89-2.49 0-5.44-.78-5.44-5.92S2.58 1.99 5.1 2c2.18 0 3.06.49 3.2.58.04.05.06.09.06.14L7.94 4.5c0 .09-.09.2-.2.17-.36-.11-.9-.33-2.17-.33-1.47 0-3.05.42-3.05 3.73s1.5 3.7 2.58 3.7c.92 0 1.25-.11 1.25-.11v-2.3H4.88c-.11 0-.19-.08-.19-.17V7.35c0-.09.08-.17.19-.17h3.74c.11 0 .19.08.19.17z"/></svg>
+ <svg aria-hidden="true" class="octicon octicon-logo-gist" height="28" version="1.1" viewBox="0 0 25 16" width="40"><path fill-rule="evenodd" d="M4.7 8.73h2.45v4.02c-.55.27-1.64.34-2.53.34-2.56 0-3.47-2.2-3.47-5.05 0-2.85.91-5.06 3.48-5.06 1.28 0 2.06.23 3.28.73V2.66C7.27 2.33 6.25 2 4.63 2 1.13 2 0 4.69 0 8.03c0 3.34 1.11 6.03 4.63 6.03 1.64 0 2.81-.27 3.59-.64V7.73H4.7v1zm6.39 3.72V6.06h-1.05v6.28c0 1.25.58 1.72 1.72 1.72v-.89c-.48 0-.67-.16-.67-.7v-.02zm.25-8.72c0-.44-.33-.78-.78-.78s-.77.34-.77.78.33.78.77.78.78-.34.78-.78zm4.34 5.69c-1.5-.13-1.78-.48-1.78-1.17 0-.77.33-1.34 1.88-1.34 1.05 0 1.66.16 2.27.36v-.94c-.69-.3-1.52-.39-2.25-.39-2.2 0-2.92 1.2-2.92 2.31 0 1.08.47 1.88 2.73 2.08 1.55.13 1.77.63 1.77 1.34 0 .73-.44 1.42-2.06 1.42-1.11 0-1.86-.19-2.33-.36v.94c.5.2 1.58.39 2.33.39 2.38 0 3.14-1.2 3.14-2.41 0-1.28-.53-2.03-2.75-2.23h-.03zm8.58-2.47v-.86h-2.42v-2.5l-1.08.31v2.11l-1.56.44v.48h1.56v5c0 1.53 1.19 2.13 2.5 2.13.19 0 .52-.02.69-.05v-.89c-.19.03-.41.03-.61.03-.97 0-1.5-.39-1.5-1.34V6.94h2.42v.02-.01z"/></svg>
+</a>
+ <div class="site-search js-site-search" role="search">
+ <div class="header-search" role="search">
+
+<!-- '"` --><!-- </textarea></xmp> --></option></form><form accept-charset="UTF-8" action="/search" class="position-relative" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>
+ <label class="header-search-wrapper form-control js-chromeless-input-container">
+ <input type="text"
+ class="form-control js-site-search-focus header-search-input"
+ data-hotkey="s"
+ name="q"
+ placeholder="Search…"
+ tabindex="1"
+ autocorrect="off"
+ autocomplete="off"
+ autocapitalize="off">
+ </label>
+
+</form></div>
+
+ </div>
+ <ul class="header-nav float-left" role="navigation">
+ <li class="header-nav-item">
+ <a href="/discover" class="header-nav-link" data-ga-click="Header, go to all gists, text:all gists">All gists</a>
+ </li>
+
+ <li class="header-nav-item">
+ <a href="https://github.com" class="header-nav-link" data-ga-click="Header, go to GitHub, text:GitHub">GitHub</a>
+ </li>
+ </ul>
+
+ <div class="header-actions" role="navigation">
+ <a href="/join?source=header-gist" class="btn btn-primary" data-ga-click="Header, sign up">Sign up for a GitHub account</a>
+ <a href="https://gist.github.com/auth/github?return_to=gist" class="btn" data-ga-click="Header, sign in">Sign in</a>
+ </div>
+ </div>
+</div>
+
+
+
+ </div>
+
+ <div id="start-of-content" class="accessibility-aid"></div>
+
+ <div id="js-flash-container">
+</div>
+
+
+
+ <div role="main">
+ <div itemscope itemtype="http://schema.org/Code">
+ <div id="gist-pjax-container" class="gist-content-wrapper" data-pjax-container>
+
+
+
+ <div class="gist-detail-intro gist-banner">
+ <div class="container">
+ <a href="/" class="btn btn-outline float-right">Create a gist now</a>
+ <p class="lead">
+ Instantly share code, notes, and snippets.
+ </p>
+ </div>
+ </div>
+
+
+<div class="gisthead pagehead repohead instapaper_ignore readability-menu experiment-repo-nav mb-4">
+ <div class="container">
+
+
+<div class="container repohead-details-container">
+
+ <ul class="pagehead-actions">
+
+
+ <li>
+ <a href="/login?return_to=https%3A%2F%2Fgist.github.com%2Feernstg%2F4353d7b4f669745bed3a5423e04a453c" aria-label="You must be signed in to star a gist" class="btn btn-sm btn-with-count tooltipped tooltipped-n" rel="nofollow">
+ <svg aria-hidden="true" class="octicon octicon-star" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z"/></svg>
+ Star
+</a>
+ <a href="/eernstg/4353d7b4f669745bed3a5423e04a453c/stargazers" aria-label="0 users starred this gist" class="social-count">
+ 0
+</a>
+ </li>
+
+ <li>
+ <a href="/login?return_to=https%3A%2F%2Fgist.github.com%2Feernstg%2F4353d7b4f669745bed3a5423e04a453c" aria-label="You must be signed in to fork a gist" class="btn btn-sm btn-with-count tooltipped tooltipped-n" rel="nofollow">
+ <svg aria-hidden="true" class="octicon octicon-repo-forked" height="16" version="1.1" viewBox="0 0 10 16" width="10"><path fill-rule="evenodd" d="M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z"/></svg>
+ Fork
+</a>
+ <a href="/eernstg/4353d7b4f669745bed3a5423e04a453c/forks" aria-label="0 users forked this gist" class="social-count">
+ 0
+</a>
+ </li>
+
+ </ul>
+
+ <h1 class="public css-truncate">
+ <img alt="@eernstg" class="avatar gist-avatar" height="26" src="https://avatars1.githubusercontent.com/u/9606994?v=3&amp;s=52" width="26" />
+ <span class="author"><a href="/eernstg" class="url fn" rel="author"><span itemprop="author">eernstg</span></a></span><!--
+ --><span class="path-divider">/</span><!--
+ --><strong itemprop="name" class="gist-header-title css-truncate-target"><a href="/eernstg/4353d7b4f669745bed3a5423e04a453c">GenericMethodSyntax.md</a></strong>
+
+ <div class="gist-timestamp">Last active <time-ago datetime="2017-01-26T16:00:50Z">Jan 26, 2017</time-ago></div>
+ </h1>
+</div>
+
+<div class="container gist-file-navigation">
+ <div class="float-right file-navigation-options" data-multiple>
+
+ <div class="file-navigation-option">
+ <input type="hidden" name="protocol_type" value="clone">
+
+ <div class="select-menu js-menu-container js-select-menu">
+ <div class="input-group js-select-button js-zeroclipboard-container">
+ <div class="input-group-button">
+ <button type="button" class="btn btn-sm select-menu-button js-menu-target" data-ga-click="Repository, clone Embed, location:repo overview">
+ Embed
+ </button>
+</div>
+<input type="text" class="form-control input-monospace input-sm js-zeroclipboard-target js-url-field" value="&lt;script src=&quot;https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c.js&quot;&gt;&lt;/script&gt;" aria-label="Clone this repository at &lt;script src=&quot;https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c.js&quot;&gt;&lt;/script&gt;" readonly>
+<div class="input-group-button">
+ <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/></svg></button>
+</div>
+
+ </div>
+
+ <div class="select-menu-modal-holder">
+ <div class="select-menu-modal js-menu-content">
+ <div class="select-menu-header">
+ <svg aria-label="Close" class="octicon octicon-x js-menu-close" height="16" role="img" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
+ <span class="select-menu-title">What would you like to do?</span>
+ </div>
+
+ <div class="select-menu-list js-navigation-container" role="menu">
+ <div class="select-menu-item js-navigation-item selected" role="menuitem" tabindex="0">
+ <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/></svg>
+ <div class="select-menu-item-text">
+ <input type="radio" name="protocol_selector" value="embed" checked>
+ <span class="select-menu-item-heading">
+
+ Embed
+ </span>
+ <span class="description">
+ Embed this gist in your website.
+ </span>
+ <span class="js-select-button-text hidden-select-button-text">
+ <div class="input-group-button">
+ <button type="button" class="btn btn-sm select-menu-button js-menu-target" data-ga-click="Repository, clone Embed, location:repo overview">
+ Embed
+ </button>
+</div>
+<input type="text" class="form-control input-monospace input-sm js-zeroclipboard-target js-url-field" value="&lt;script src=&quot;https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c.js&quot;&gt;&lt;/script&gt;" aria-label="Clone this repository at &lt;script src=&quot;https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c.js&quot;&gt;&lt;/script&gt;" readonly>
+<div class="input-group-button">
+ <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/></svg></button>
+</div>
+
+ </span>
+ </div>
+ </div>
+ <div class="select-menu-item js-navigation-item " role="menuitem" tabindex="0">
+ <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/></svg>
+ <div class="select-menu-item-text">
+ <input type="radio" name="protocol_selector" value="share" >
+ <span class="select-menu-item-heading">
+
+ Share
+ </span>
+ <span class="description">
+ Copy sharable URL for this gist.
+ </span>
+ <span class="js-select-button-text hidden-select-button-text">
+ <div class="input-group-button">
+ <button type="button" class="btn btn-sm select-menu-button js-menu-target" data-ga-click="Repository, clone Share, location:repo overview">
+ Share
+ </button>
+</div>
+<input type="text" class="form-control input-monospace input-sm js-zeroclipboard-target js-url-field" value="https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c" aria-label="Clone this repository at https://gist.github.com/eernstg/4353d7b4f669745bed3a5423e04a453c" readonly>
+<div class="input-group-button">
+ <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/></svg></button>
+</div>
+
+ </span>
+ </div>
+ </div>
+ <div class="select-menu-item js-navigation-item " role="menuitem" tabindex="0">
+ <svg aria-hidden="true" class="octicon octicon-check select-menu-item-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/></svg>
+ <div class="select-menu-item-text">
+ <input type="radio" name="protocol_selector" value="http" >
+ <span class="select-menu-item-heading">
+ Clone via
+ HTTPS
+ </span>
+ <span class="description">
+ Clone with Git or checkout with SVN using the repository's web address.
+ </span>
+ <span class="js-select-button-text hidden-select-button-text">
+ <div class="input-group-button">
+ <button type="button" class="btn btn-sm select-menu-button js-menu-target" data-ga-click="Repository, clone HTTPS, location:repo overview">
+ HTTPS
+ </button>
+</div>
+<input type="text" class="form-control input-monospace input-sm js-zeroclipboard-target js-url-field" value="https://gist.github.com/4353d7b4f669745bed3a5423e04a453c.git" aria-label="Clone this repository at https://gist.github.com/4353d7b4f669745bed3a5423e04a453c.git" readonly>
+<div class="input-group-button">
+ <button aria-label="Copy to clipboard" class="js-zeroclipboard btn btn-sm zeroclipboard-button tooltipped tooltipped-s" data-copied-hint="Copied!" type="button"><svg aria-hidden="true" class="octicon octicon-clippy" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M2 13h4v1H2v-1zm5-6H2v1h5V7zm2 3V8l-3 3 3 3v-2h5v-2H9zM4.5 9H2v1h2.5V9zM2 12h2.5v-1H2v1zm9 1h1v2c-.02.28-.11.52-.3.7-.19.18-.42.28-.7.3H1c-.55 0-1-.45-1-1V4c0-.55.45-1 1-1h3c0-1.11.89-2 2-2 1.11 0 2 .89 2 2h3c.55 0 1 .45 1 1v5h-1V6H1v9h10v-2zM2 5h8c0-.55-.45-1-1-1H8c-.55 0-1-.45-1-1s-.45-1-1-1-1 .45-1 1-.45 1-1 1H3c-.55 0-1 .45-1 1z"/></svg></button>
+</div>
+
+ </span>
+ </div>
+ </div>
+ </div>
+ <div class="select-menu-list" role="menu">
+ <a class="select-menu-item select-menu-action" href="https://help.github.com/articles/which-remote-url-should-i-use" target="_blank">
+ <svg aria-hidden="true" class="octicon octicon-question select-menu-item-icon" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M6 10h2v2H6v-2zm4-3.5C10 8.64 8 9 8 9H6c0-.55.45-1 1-1h.5c.28 0 .5-.22.5-.5v-1c0-.28-.22-.5-.5-.5h-1c-.28 0-.5.22-.5.5V7H4c0-1.5 1.5-3 3-3s3 1 3 2.5zM7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7z"/></svg>
+ <div class="select-menu-item-text">
+ Learn more about clone URLs
+ </div>
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+
+
+ <div class="file-navigation-option">
+</div>
+
+
+ <div class="file-navigation-option">
+ <a href="/eernstg/4353d7b4f669745bed3a5423e04a453c/archive/3b9e040372930e7c263fc075dd6997210586d659.zip"
+ class="btn btn-sm"
+ rel="nofollow"
+ data-ga-click="Gist, download zip, location:gist overview">
+ Download ZIP
+ </a>
+ </div>
+ </div>
+
+ <div class="float-left">
+ <nav class="reponav js-repo-nav js-sidenav-container-pjax"
+ role="navigation"
+ data-pjax="#gist-pjax-container">
+
+ <a href="/eernstg/4353d7b4f669745bed3a5423e04a453c" aria-label="Code" class="js-selected-navigation-item selected reponav-item" data-hotkey="g c" data-pjax="true" data-selected-links="gist_code /eernstg/4353d7b4f669745bed3a5423e04a453c">
+ <svg aria-hidden="true" class="octicon octicon-code" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M9.5 3L8 4.5 11.5 8 8 11.5 9.5 13 14 8 9.5 3zm-5 0L0 8l4.5 5L6 11.5 2.5 8 6 4.5 4.5 3z"/></svg>
+ Code
+</a>
+ <a href="/eernstg/4353d7b4f669745bed3a5423e04a453c/revisions" aria-label="Revisions" class="js-selected-navigation-item reponav-item" data-hotkey="g r" data-pjax="true" data-selected-links="gist_revisions /eernstg/4353d7b4f669745bed3a5423e04a453c/revisions">
+ <svg aria-hidden="true" class="octicon octicon-git-commit" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path fill-rule="evenodd" d="M10.86 7c-.45-1.72-2-3-3.86-3-1.86 0-3.41 1.28-3.86 3H0v2h3.14c.45 1.72 2 3 3.86 3 1.86 0 3.41-1.28 3.86-3H14V7h-3.14zM7 10.2c-1.22 0-2.2-.98-2.2-2.2 0-1.22.98-2.2 2.2-2.2 1.22 0 2.2.98 2.2 2.2 0 1.22-.98 2.2-2.2 2.2z"/></svg>
+ Revisions
+ <span class="Counter">22</span>
+</a>
+
+</nav>
+
+ </div>
+</div>
+
+
+ </div>
+</div>
+
+<div class="container new-discussion-timeline experiment-repo-nav">
+ <div class="repository-content gist-content">
+
+ <div>
+ <div class="repository-meta js-details-container Details">
+ <div class="repository-meta-content" itemprop="about">
+ INFORMAL SPECIFICATION: Generic Method Syntax
+ </div>
+</div>
+
+
+ <div class="js-gist-file-update-container js-task-list-container file-box">
+ <div id="file-genericmethodsyntax-md" class="file">
+ <div class="file-header">
+ <div class="file-actions">
+
+ <a href="/eernstg/4353d7b4f669745bed3a5423e04a453c/raw/3b9e040372930e7c263fc075dd6997210586d659/GenericMethodSyntax.md" class="btn btn-sm ">Raw</a>
+ </div>
+ <div class="file-info">
+ <span class="icon">
+ <svg aria-hidden="true" class="octicon octicon-gist" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.5 5L10 7.5 7.5 10l-.75-.75L8.5 7.5 6.75 5.75 7.5 5zm-3 0L2 7.5 4.5 10l.75-.75L3.5 7.5l1.75-1.75L4.5 5zM0 13V2c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v11c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1zm1 0h10V2H1v11z"/></svg>
+ </span>
+ <a class="tooltipped tooltipped-s css-truncate" aria-label="Permalink" href="#file-genericmethodsyntax-md">
+ <strong class="user-select-contain gist-blob-name css-truncate-target">
+ GenericMethodSyntax.md
+ </strong>
+ </a>
+ </div>
+ </div>
+
+ <div id="readme" class="readme blob instapaper_body">
+ <article class="markdown-body entry-content" itemprop="text"><h1><a id="user-content-feature-generic-method-syntax" class="anchor" href="#feature-generic-method-syntax" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Feature: Generic Method Syntax</h1>
+<h2><a id="user-content-feature-generic-method-syntax-1" class="anchor" href="#feature-generic-method-syntax-1" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Feature: Generic Method Syntax</h2>
+<p><strong>This document</strong> is an informal specification of the support for generic methods and functions which has been implemented in <code>dart2js</code> with option <code>--generic-method-syntax</code>, starting with commit <a href="https://github.com/dart-lang/sdk/commit/acc5f59a99d5d8747459c935e6360ac325606cc6">acc5f59</a>. In SDK 1.21 this feature is available by default (i.e., also without the option) in the virtual machine and the analyzer, as well as in <code>dart2js</code>.</p>
+<p>The <strong>motivation for</strong> having this <strong>feature</strong> is that it enables partial support for generic methods and functions, thus providing a bridge between not having generic methods and having full support for generic methods. In particular, code declaring and using generic methods may be type checked and compiled in strong mode, and the same code will now be acceptable in standard (non-strong) mode as well. The semantics is different in certain cases, but standard mode analysis will emit diagnostic messages (e.g., errors) for that.</p>
+<p>In this document, the word <strong>routine</strong> will be used when referring to something which can be a method, a top level function, a local function, or a function literal expression.</p>
+<p>With <strong>this feature</strong> it is possible to compile code where generic methods and functions are declared, implemented, and invoked. The runtime semantics does not include reification of type arguments. Evaluations of the runtime value of a routine type parameter is a runtime error or yields <code>dynamic</code>, depending on the context. No type checking takes place at usages of a method or function type parameter in the body, and no type checking regarding explicitly specified or omitted type arguments takes place at call sites.</p>
+<p>In short, generic methods and functions are supported syntactically, and the runtime semantics prevents dynamic usages of the type argument values, but it allows all usages where that dynamic value is not required. For instance, a generic routine type parameter, <code>T</code>, cannot be used in an expression like <code>x is T</code>, but it can be used as a type annotation. In a context where other tools may perform type checking, this allows for a similar level of expressive power as do language designs where type arguments are erased at compile time.</p>
+<p>The <strong>motivation for</strong> this <strong>document</strong> is that it serves as an informal specification for the implementation of support for the generic method syntax feature in all Dart tools.</p>
+<h2><a id="user-content-syntax" class="anchor" href="#syntax" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Syntax</h2>
+<p>The syntactic elements which are added or modified in order to support this feature are as follows, based on grammar rules given in the Dart Language Specification (Aug 19, 2015).</p>
+<pre><code>formalParameterPart:
+ typeParameters? formalParameterList
+functionSignature:
+ metadata returnType? identifier formalParameterPart
+typeParameter:
+ metadata identifier (('extends'|'super') type)?
+functionExpression:
+ formalParameterPart functionBody
+fieldFormalParameter:
+ metadata finalConstVarOrType? 'this' '.' identifier
+ formalParameterPart?
+argumentPart:
+ typeArguments? arguments
+selector:
+ assignableSelector | argumentPart
+assignableExpression:
+ primary (argumentPart* assignableSelector)+ |
+ 'super' unconditionalAssignableSelector |
+ identifier
+cascadeSection:
+ '..' (cascadeSelector argumentPart*)
+ (assignableSelector argumentPart*)*
+ (assignmentOperator expressionWithoutCascade)?
+</code></pre>
+<p>In a <a href="https://codereview.chromium.org/1177073002">draft specification</a> of generic methods from June 2015, the number of grammar changes is significantly higher, but that form can be obtained via renaming.</p>
+<p>This extension to the grammar gives rise to an <strong>ambiguity</strong> where the same tokens may be angle brackets of a type argument list as well as relational operators. For instance, <code>foo(a&lt;b,c&gt;(d))</code>[^1] may be parsed as a <code>postfixExpression</code> on the form <code>primary arguments</code> where the arguments are two relational expressions (<code>a&lt;b</code> and <code>c&gt;(d)</code>), and it may also be parsed such that there is a single argument which is an invocation of a generic function (<code>a&lt;b,c&gt;(d)</code>). The ambiguity is resolved in <strong>favor</strong> of the <strong>generic function invocation</strong> whenever the <code>primary</code> is followed by a balanced pair of angle brackets where the next token after the final <code>&gt;</code> is a left parenthesis (in short, we are "looking at <code>&lt; .. &gt;(</code>").</p>
+<p>This implies that an expression like <code>foo(a&lt;b,2&gt;(d))</code> will be rejected because it is parsed such that <code>foo</code> gets one argument which must be a generic function invocation, but <code>2</code> cannot parse correctly as a <code>type</code>. This is a breaking change, because the same expression used to parse correctly as an invocation of <code>foo</code> with two arguments.</p>
+<p>The <strong>reason</strong> why the generic function invocation is favored over the relational expressions is that it is considered to be a rare exception that this ambiguity arises: It requires a balanced set of angle brackets followed by a left parenthesis, which is already an unusual form. On top of that, the style guide recommendation to use named parameters for boolean arguments helps making this situation even less common.</p>
+<p>If it does occur then there is an easy <strong>workaround</strong>: an extra set of parentheses (as in <code>foo(a&lt;b,(2&gt;(d)))</code>) will resolve the ambiguity in the direction of relational expressions; or we might simply be able to remove the parentheses around the last expression (as in <code>foo(a&lt;b,2&gt;d)</code>), which will also eliminate the ambiguity.</p>
+<p>It should be noted that parsing techniques like recursive descent seem to conflict with this approach to disambiguation: Determining whether the remaining input starts with a balanced expression on the form <code>&lt;</code> .. <code>&gt;</code> seems to imply a need for an unbounded lookahead. However, if some type of "diet" parsing is used and various kinds of bracket tokens are matched up during the lexical analysis then it takes only a simple O(1) check in the parser to perform the required check.</p>
+<h2><a id="user-content-scope-of-the-mechanism" class="anchor" href="#scope-of-the-mechanism" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Scope of the Mechanism</h2>
+<p>With the syntax in place, it is obvious that certain potential extensions have <strong>not</strong> been <strong>included</strong>.</p>
+<p>For instance, constructors, setters, getters, and operators cannot be declared as generic. Actual type arguments cannot be passed at invocation sites for setters, getters, and operators, and for constructors there is a need to find a way to distinguish between type arguments for the new instance and type arguments for the constructor itself. It is possible that some of these restrictions will be lifted in a full-fledged version of this extension.</p>
+<p>Conversely, the inclusion of lower bounds for type parameters (using the keyword <code>super</code>) serves to demonstrate that lower bounds fit well into the syntax. There is no guarantee that a final version of generic methods will support lower bounds, and it is not required that an implementation must support them.</p>
+<p>In general, the support for generic methods offered by this feature is not intended to be complete, it is <strong>intended</strong> to allow <strong>for</strong> <strong>experiments</strong> such that a final version of the generic method support can be designed well, <strong>and</strong> it is intended to allow for the <strong>subset of usages</strong> where reification is not required.</p>
+<h2><a id="user-content-resolution-and-type-checking" class="anchor" href="#resolution-and-type-checking" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Resolution and Type Checking</h2>
+<p>In order to be useful, the support for generic methods and functions must be sufficiently complete and consistent to <strong>avoid spurious</strong> diagnostic <strong>messages</strong>. In particular, even though no regular type checks take place at usages of routine type parameters in the body where they are in scope, those type parameters should be resolved. If they had been ignored then any usage of a routine type parameter <code>X</code> would give rise to a <code>Cannot resolve type X</code> error message, or the usage might resolve to other declarations of <code>X</code> in enclosing scopes such as a class type parameter, both of which is unacceptable.</p>
+<p>In <code>dart2js</code> resolution, the desired behavior has been achieved by adding a new type parameter <strong>scope</strong> and putting the type parameters into that scope, giving each of them the bound <code>dynamic</code>. The type parameter scope is the current scope during resolution of the routine signature and the type parameter bounds, it encloses the formal parameter scope of the routine, and the formal parameter scope in turn encloses the body scope.</p>
+<p>This implies that every usage of a routine type parameter is treated during <strong>type checking</strong> as if it had been an alias for the type <code>dynamic</code>.</p>
+<p>Static checks for <strong>invocations</strong> of methods or functions where type arguments are passed are omitted entirely: The type arguments are parsed, but no checks are applied to certify that the given routine accepts type arguments, and no checks are applied for bound violations. Similarly, no checks are performed for invocations where no type arguments are passed, whether or not the given routine is statically known to accept type arguments.</p>
+<p>Certain usages of a routine type parameter <code>X</code> give rise to <strong>errors</strong>: It is a compile-time error if <code>X</code> is used as a type literal (e.g., <code>foo(X)</code>), or in an expression on the form <code>e is X</code> or <code>e is! X</code>.</p>
+<p>It could be argued that it should be a warning or an error if a routine type parameter <code>X</code> is used in an expression on the form <code>e as X</code>. The blind success of this test at runtime may introduce bugs into correct programs in situations where the type constraint is violated; in particular, this could cause "wrong" objects to propagate through local variables and parameters and even into data structures (say, when a <code>List&lt;T&gt;</code> is actually a <code>List&lt;dynamic&gt;</code>, because <code>T</code> is not present at runtime when the list is created). However, considering that these type constraint violations are expected to be rare, and considering that it is common to require that programs compile without warnings, we have chosen to omit this warning. A tool is still free to emit a hint, or in some other way indicate that there is an issue.</p>
+<h2><a id="user-content-dynamic-semantics" class="anchor" href="#dynamic-semantics" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Dynamic semantics</h2>
+<p>If a routine invocation specifies actual type arguments, e.g., <code>int</code> in the <strong>invocation</strong> <code>f&lt;int&gt;(42)</code>, those type arguments will not be evaluated at runtime, and they will not be passed to the routine in the invocation. Similarly, no type arguments are ever passed to a generic routine due to call-site inference. This corresponds to the fact that the type arguments have no runtime representation.</p>
+<p>When the body of a generic <strong>routine</strong> is <strong>executed</strong>, usages of the formal type parameters will either result in a run-time error, or they will yield the value yielded by an evaluation of <code>dynamic</code>, following the treatment of malformed types in Dart. There are the following cases:</p>
+<p>When <code>X</code> is a routine type parameter, the evaluation of <code>e is X</code>, <code>e is! X</code>, and <code>X</code> used as a type literal proceeds as if <code>X</code> had been a malformed type, producing a dynamic error if the type test itself is reached; the evaluation of <code>e as X</code> has the same outcome as the evaluation of <code>e</code>.</p>
+<p>Note that the forms containing <code>is</code> are compile-time errors, which means that implementations are free to reject the program, or to compile the program with a different runtime semantics for these expressions. The rationale for <code>dart2js</code> to allow the construct and compile it to a run time error is that (1) this allows more programs using generic methods to be compiled, and (2) an <code>is</code> expression that blindly returns <code>true</code> every time (or <code>false</code> every time) may silently introduce a bug into an otherwise correct program, so the expression must fail if it is ever evaluated.</p>
+<p>When <code>X</code> is a routine type parameter which is passed as a type argument to a generic class instantiation <code>G</code> which is itself used in <code>e is G</code>, <code>e is! G</code>, <code>e as G</code>, and <code>G</code> used as a type literal, evaluation again proceeds as if <code>X</code> were a malformed type, which in this case means that it is treated like <code>dynamic</code>.</p>
+<p>This may be surprising, so let us consider a couple of examples: When <code>X</code> is a routine type parameter, <code>42 is X</code> raises a dynamic error, <code>&lt;int&gt;[42] is List&lt;X&gt;</code> yields the value <code>true</code>, and <code>42 as X</code> yields <code>42</code>, no matter whether the syntax for the invocation of the routine included an actual type argument, and, if so, no matter which value the actual type argument would have had at the invocation.</p>
+<p>Object construction is similar: When <code>X</code> is a routine type parameter which is a passed as a type argument to a constructor invocation, the value passed to the constructor will be the value yielded by an evaluation of <code>dynamic</code>.</p>
+<p>In <strong>checked mode</strong>, when <code>X</code> is a routine type parameter which is used as a type annotation or in a generic type <code>G</code> used as a type annotation, no checked mode checks will ever fail for initialization or assignment to a local variable or parameter whose type annotation is <code>X</code>, and if the type annotation is a generic type <code>G</code> that contains <code>X</code>, checked mode checks will succeed or fail as if <code>X</code> had been the type <code>dynamic</code>.</p>
+<h2><a id="user-content-changes" class="anchor" href="#changes" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Changes</h2>
+<p>2017-Jan-04: Changed 'static error' to 'compile-time error', which is the phrase that the language specification uses.</p>
+<h2><a id="user-content-notes" class="anchor" href="#notes" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Notes</h2>
+<p>[^1]: These expressions violate the common style in Dart with respect to spacing and capitalization. That is because the ambiguity implies conflicting requirements, and we do not want to bias the appearance in one of the two directions.</p>
+</article>
+ </div>
+
+ </div>
+
+</div>
+
+
+ <a name="comments"></a>
+ <div class="discussion-timeline gist-discussion-timeline js-quote-selection-container ">
+ <div class="js-discussion js-socket-channel" data-channel="marked-as-read:gist:41132114">
+
+
+
+
+
+<!-- Rendered timeline since 2017-01-26 08:00:50 -->
+<div id="partial-timeline-marker"
+ class="js-timeline-marker js-updatable-content"
+ data-url="/eernstg/4353d7b4f669745bed3a5423e04a453c/show_partial?partial=gist%2Ftimeline_marker&amp;since=1485446450"
+ data-last-modified="Thu, 26 Jan 2017 16:00:50 GMT"
+ >
+</div>
+
+
+ <div class="discussion-timeline-actions">
+ <div class="flash flash-warn mt-3">
+ <a href="/join?source=comment-gist" class="btn btn-primary" rel="nofollow">Sign up for free</a>
+ <strong>to join this conversation on GitHub</strong>.
+ Already have an account?
+ <a href="/login?return_to=https%3A%2F%2Fgist.github.com%2Feernstg%2F4353d7b4f669745bed3a5423e04a453c" rel="nofollow">Sign in to comment</a>
+</div>
+
+ </div>
+ </div>
+ </div>
+</div>
+ </div>
+
+ <div class="modal-backdrop js-touch-events"></div>
+</div><!-- /.container -->
+
+ </div>
+ </div>
+
+ </div>
+
+ <div class="container site-footer-container">
+ <div class="site-footer" role="contentinfo">
+ <ul class="site-footer-links float-right">
+ <li><a href="https://github.com/contact" data-ga-click="Footer, go to contact, text:contact">Contact GitHub</a></li>
+ <li><a href="https://developer.github.com" data-ga-click="Footer, go to api, text:api">API</a></li>
+ <li><a href="https://training.github.com" data-ga-click="Footer, go to training, text:training">Training</a></li>
+ <li><a href="https://shop.github.com" data-ga-click="Footer, go to shop, text:shop">Shop</a></li>
+ <li><a href="https://github.com/blog" data-ga-click="Footer, go to blog, text:blog">Blog</a></li>
+ <li><a href="https://github.com/about" data-ga-click="Footer, go to about, text:about">About</a></li>
+
+ </ul>
+
+ <a href="https://github.com" aria-label="Homepage" class="site-footer-mark" title="GitHub">
+ <svg aria-hidden="true" class="octicon octicon-mark-github" height="24" version="1.1" viewBox="0 0 16 16" width="24"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
+</a>
+ <ul class="site-footer-links">
+ <li>&copy; 2017 <span title="0.13594s from github-fe124-cp1-prd.iad.github.net">GitHub</span>, Inc.</li>
+ <li><a href="https://github.com/site/terms" data-ga-click="Footer, go to terms, text:terms">Terms</a></li>
+ <li><a href="https://github.com/site/privacy" data-ga-click="Footer, go to privacy, text:privacy">Privacy</a></li>
+ <li><a href="https://github.com/security" data-ga-click="Footer, go to security, text:security">Security</a></li>
+ <li><a href="https://status.github.com/" data-ga-click="Footer, go to status, text:status">Status</a></li>
+ <li><a href="https://help.github.com" data-ga-click="Footer, go to help, text:help">Help</a></li>
+ </ul>
+ </div>
+</div>
+
+
+
+
+
+ <div id="ajax-error-message" class="ajax-error-message flash flash-error">
+ <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"/></svg>
+ <button type="button" class="flash-close js-flash-close js-ajax-error-dismiss" aria-label="Dismiss error">
+ <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
+ </button>
+ You can't perform that action at this time.
+ </div>
+
+
+ <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/compat-8a4318ffea09a0cdb8214b76cf2926b9f6a0ced318a317bed419db19214c690d.js"></script>
+ <script crossorigin="anonymous" src="https://assets-cdn.github.com/assets/frameworks-6d109e75ad8471ba415082726c00c35fb929ceab975082492835f11eca8c07d9.js"></script>
+ <script async="async" crossorigin="anonymous" src="https://assets-cdn.github.com/assets/github-55316b70ec9eb5a4dd5cd168f8f8da4d5fe20c53564512dd5aace9898aed70c5.js"></script>
+
+
+
+
+ <div class="js-stale-session-flash stale-session-flash flash flash-warn flash-banner d-none">
+ <svg aria-hidden="true" class="octicon octicon-alert" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M8.865 1.52c-.18-.31-.51-.5-.87-.5s-.69.19-.87.5L.275 13.5c-.18.31-.18.69 0 1 .19.31.52.5.87.5h13.7c.36 0 .69-.19.86-.5.17-.31.18-.69.01-1L8.865 1.52zM8.995 13h-2v-2h2v2zm0-3h-2V6h2v4z"/></svg>
+ <span class="signed-in-tab-flash">You signed in with another tab or window. <a href="">Reload</a> to refresh your session.</span>
+ <span class="signed-out-tab-flash">You signed out in another tab or window. <a href="">Reload</a> to refresh your session.</span>
+ </div>
+ <div class="facebox" id="facebox" style="display:none;">
+ <div class="facebox-popup">
+ <div class="facebox-content" role="dialog" aria-labelledby="facebox-header" aria-describedby="facebox-description">
+ </div>
+ <button type="button" class="facebox-close js-facebox-close" aria-label="Close modal">
+ <svg aria-hidden="true" class="octicon octicon-x" height="16" version="1.1" viewBox="0 0 12 16" width="12"><path fill-rule="evenodd" d="M7.48 8l3.75 3.75-1.48 1.48L6 9.48l-3.75 3.75-1.48-1.48L4.52 8 .77 4.25l1.48-1.48L6 6.52l3.75-3.75 1.48 1.48z"/></svg>
+ </button>
+ </div>
+</div>
+
+
+ </body>
+</html>
+

Powered by Google App Engine
This is Rietveld 408576698