nac3standalone: added typevar test
This commit is contained in:
parent
b97c016629
commit
234823c51a
40
nac3standalone/demo/src/typevar.py
Normal file
40
nac3standalone/demo/src/typevar.py
Normal file
@ -0,0 +1,40 @@
|
||||
from typing import TypeVar, Generic
|
||||
|
||||
@extern
|
||||
def output_int32(x: int32):
|
||||
...
|
||||
|
||||
class A:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def foo(self):
|
||||
output_int32(1)
|
||||
|
||||
class B:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def foo(self):
|
||||
output_int32(2)
|
||||
|
||||
|
||||
T = TypeVar("T", A, B)
|
||||
|
||||
|
||||
class C(Generic[T]):
|
||||
x: T
|
||||
|
||||
def __init__(self, x: T):
|
||||
self.x = x
|
||||
|
||||
def foo(self):
|
||||
self.x.foo()
|
||||
|
||||
|
||||
def run() -> int32:
|
||||
insta = A()
|
||||
inst = C(insta)
|
||||
inst.foo()
|
||||
return 0
|
||||
|
@ -62,6 +62,9 @@ fn main() {
|
||||
let parser_result = parser::parse_program(&program, file_name.into()).unwrap();
|
||||
|
||||
for stmt in parser_result.into_iter() {
|
||||
if matches!(stmt.node, StmtKind::Import { .. } | StmtKind::ImportFrom { .. }) {
|
||||
continue;
|
||||
}
|
||||
if let StmtKind::Assign { targets, value, .. } = &stmt.node {
|
||||
fn handle_typevar_definition(
|
||||
var: &Expr,
|
||||
|
Loading…
Reference in New Issue
Block a user