Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,15 @@ class AstWalker(val scope: Scope) {
case AstNode.NameParameter(_, name, annotation) =>
val dataType =
if (annotation != null)
getType(annotation)
// A bare class (or a container built from one, e.g. `list[Widget]`) resolves
// via getType to the raw ClassType/PrimitiveType itself - its real members
// live in getInstanceFields, which only an Instance wrapper exposes (see
// Instance.apply's docs). Every other call-site that produces a value of a
// user's own type (constructor calls, function-call return values, `for`
// targets) already goes through this same wrapping; a param annotation was
// the one place that didn't, silently losing all member completion for any
// annotated parameter.
Instance(getType(annotation))
else if (i >= delta) {
getType(params.defaults(i - delta)._1) match {
case BuiltinTypes.NONE_TYPE => BuiltinTypes.ANY_TYPE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ class TypeAstWalker {
(getType(subscript.base), subscript.slice) match {
case (BuiltinTypes.LIST_TYPE, Index(_, value)) =>
ListType(getType(value))
case (BuiltinTypes.SET_TYPE, Index(_, value)) =>
SetType(getType(value))
case (BuiltinTypes.DICT_TYPE, MultiSlice(_, Array(Index(_, key), Index(_, value)))) =>
new DictType(getType(key), getType(value))
// `tuple[X, ...]`: a homogeneous, variable-length tuple (as opposed to `tuple[X, Y]`,
// a fixed-arity tuple where each position has its own type).
case (BuiltinTypes.TUPLE_TYPE, MultiSlice(_, Array(Index(_, elt), Index(_, _: AstNode.Ellipsis)))) =>
new VarTupleType(getType(elt))
case (BuiltinTypes.TUPLE_TYPE, MultiSlice(_, elements)) if elements.forall {
case Index(_, _) => true
case _ => false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 107
# draw
class Widget:
def draw(self):
pass

def foo(items: set[Widget]):
for w in items:
w.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 114
# draw
class Widget:
def draw(self):
pass

def foo(items: tuple[Widget, ...]):
for w in items:
w.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 74
# draw
class Widget:
def draw(self):
pass

def foo(w: Widget):
w.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pyi:pyi.generic_list_paraminfer
# class Actor:
# def is_at_edge(self) -> None: ...
# def remove(self) -> None: ...
# def get_x(self) -> None: ...
# def get_actors() -> list[Actor]: ...
# 76
# get_x;is_at_edge;remove
from pyi.generic_list_paraminfer import *

def move(particle):
particle.

for p in get_actors():
move(p)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pyi:pyi.generic_set_paraminfer
# class Actor:
# def is_at_edge(self) -> None: ...
# def remove(self) -> None: ...
# def get_x(self) -> None: ...
# def get_actors() -> set[Actor]: ...
# 75
# get_x;is_at_edge;remove
from pyi.generic_set_paraminfer import *

def move(particle):
particle.

for p in get_actors():
move(p)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# pyi:pyi.generic_tuple_paraminfer
# class Actor:
# def is_at_edge(self) -> None: ...
# def remove(self) -> None: ...
# def get_x(self) -> None: ...
# def get_actors() -> tuple[Actor, ...]: ...
# 77
# get_x;is_at_edge;remove
from pyi.generic_tuple_paraminfer import *

def move(particle):
particle.

for p in get_actors():
move(p)
Loading