Fixed type name for bounded generic types

This commit is contained in:
Andrey Vlasovskikh
2013-07-30 18:48:54 +04:00
parent 3fe46855fa
commit 3128b7f70a
3 changed files with 7 additions and 7 deletions
@@ -39,7 +39,7 @@ public class PyGenericType implements PyType {
@NotNull
@Override
public String getName() {
return myBound != null ? myName + " (" + myBound.getName() + ")" : myName;
return myBound != null ? myName + " <= " + myBound.getName() : myName;
}
@Override
@@ -53,11 +53,11 @@ public class PyUnionType implements PyType {
}
public String getName() {
return "one of (" + StringUtil.join(myMembers, new NullableFunction<PyType, String>() {
public String fun(PyType pyType) {
return pyType == null ? "unknown" : pyType.getName();
return StringUtil.join(myMembers, new NullableFunction<PyType, String>() {
public String fun(PyType type) {
return type != null ? type.getName() : null;
}
}, ", ") + ")";
}, " | ");
}
/**
@@ -1,12 +1,12 @@
def test():
def f(x):
"""
:type x: T <= int or str
:type x: T <= int | str
:rtype: T
"""
pass
x = f(10)
y = f('foo')
z = f(<warning descr="Expected type 'T (one of (int, str))', got 'list' instead">[]</warning>)
z = f(<warning descr="Expected type 'T <= int | str', got 'list' instead">[]</warning>)
return x + <warning descr="Expected type 'one of (int, long, float, complex)', got 'str' instead">y</warning>