<h2 dir="auto"><g-emoji class="g-emoji" alias="bug" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f41b.png">🐛</g-emoji> Bug</h2>
<p dir="auto">The JIT can't pass following code when I tried to passing another instance with same class type.</p>
<h2 dir="auto">To Reproduce</h2>
<h3 dir="auto">not working in python3.6</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import torch

@torch.jit.script
class A:
    def __init__(self):
        self.v = 100
    
    def copy(self, b: 'A'):
        self.v = b.v"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">torch</span>

<span class="pl-en">@<span class="pl-s1">torch</span>.<span class="pl-s1">jit</span>.<span class="pl-s1">script</span></span>
<span class="pl-k">class</span> <span class="pl-v">A</span>:
    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>):
        <span class="pl-s1">self</span>.<span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-c1">100</span>
    
    <span class="pl-k">def</span> <span class="pl-en">copy</span>(<span class="pl-s1">self</span>, <span class="pl-s1">b</span>: <span class="pl-s">'A'</span>):
        <span class="pl-s1">self</span>.<span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-s1">b</span>.<span class="pl-s1">v</span></pre></div>
<h3 dir="auto">working in python3.6</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class A:
    def __init__(self):
        self.v = 100
    
    def copy(self, b: 'A'):
        self.v = b.v"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">A</span>:
    <span class="pl-k">def</span> <span class="pl-en">__init__</span>(<span class="pl-s1">self</span>):
        <span class="pl-s1">self</span>.<span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-c1">100</span>
    
    <span class="pl-k">def</span> <span class="pl-en">copy</span>(<span class="pl-s1">self</span>, <span class="pl-s1">b</span>: <span class="pl-s">'A'</span>):
        <span class="pl-s1">self</span>.<span class="pl-s1">v</span> <span class="pl-c1">=</span> <span class="pl-s1">b</span>.<span class="pl-s1">v</span></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">RuntimeError:<br>
Expression of type string_literal cannot be used in a type expression:<br>
at demo_class.py:8:23<br>
def copy(self, b: 'A'):<br>
~ &lt;--- HERE<br>
self.v = b.v</p>
<h2 dir="auto">Environment</h2>
<p dir="auto">Collecting environment information...<br>
PyTorch version: 1.2.0<br>
Is debug build: No<br>
CUDA used to build PyTorch: 10.0.130</p>
<p dir="auto">OS: Ubuntu 18.04.3 LTS<br>
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0<br>
CMake version: version 3.10.2</p>
<p dir="auto">Python version: 3.6<br>
Is CUDA available: Yes<br>
CUDA runtime version: 10.1.243<br>
GPU models and configuration: GPU 0: GeForce GTX 1080<br>
Nvidia driver version: 430.26<br>
cuDNN version: Could not collect</p>
<p dir="auto">Versions of relevant libraries:<br>
[pip3] numpy==1.15.0<br>
[pip3] torch==1.2.0<br>
[pip3] torch-nightly==1.2.0.dev20190530<br>
[pip3] torchvision==0.2.2.post3<br>
[conda] Could not collect</p>
<h2 dir="auto">Additional context</h2>
<p dir="auto"><a href="https://www.python.org/dev/peps/pep-0484/#forward-references" rel="nofollow">Reference</a><br>
<a href="https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel" rel="nofollow">Stack Overflow</a></p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/suo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/suo">@suo</a></p>
<h2 dir="auto">🐛 Bug</h2>
<p dir="auto">Cannot type a class with an annotation that contains itself using python 3 style comments</p>
<h2 dir="auto">To Reproduce</h2>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="@torch.jit.script
Class UDT(object):
	def __init__(x):
		self.x = x

	def __add__(other: 'UDT'): -&gt; 'UDT'
		return UDT(self.x + other.x)"><pre class="notranslate"><code class="notranslate">@torch.jit.script
Class UDT(object):
	def __init__(x):
		self.x = x

	def __add__(other: 'UDT'): -&gt; 'UDT'
		return UDT(self.x + other.x)
</code></pre></div>
<h2 dir="auto">Expected behavior</h2>
<p dir="auto">Should work based on the description of forward references in PEP 484<br>
<a href="https://www.python.org/dev/peps/pep-0484/#forward-references" rel="nofollow">https://www.python.org/dev/peps/pep-0484/#forward-references</a></p>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/suo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/suo">@suo</a></p>