forked from py2many/py2many
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py2many: Fix type inference for methods
Allows classes.py to pass on many targets Related to: py2many#400
- Loading branch information
Showing
11 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Foo: | ||
def bar(self): | ||
return self.baz() | ||
|
||
def baz(self) -> int: | ||
return 10 | ||
|
||
|
||
if __name__ == "__main__": | ||
f = Foo() | ||
b = f.bar() | ||
print(b) | ||
assert b == 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <cassert> // NOLINT(build/include_order) | ||
#include <iostream> // NOLINT(build/include_order) | ||
|
||
#include "pycpp/runtime/builtins.h" // NOLINT(build/include_order) | ||
#include "pycpp/runtime/sys.h" // NOLINT(build/include_order) | ||
class Foo { | ||
public: | ||
inline int bar() { return this->baz(); } | ||
|
||
inline int baz() { return 10; } | ||
}; | ||
|
||
int main(int argc, char** argv) { | ||
pycpp::sys::argv = std::vector<std::string>(argv, argv + argc); | ||
Foo f = Foo(); | ||
auto b = f.bar(); | ||
std::cout << b; | ||
std::cout << std::endl; | ||
assert(b == 10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// @dart=2.9 | ||
import 'package:sprintf/sprintf.dart'; | ||
|
||
class Foo { | ||
int bar() { | ||
return baz(); | ||
} | ||
|
||
int baz() { | ||
return 10; | ||
} | ||
} | ||
|
||
main(List<String> argv) { | ||
final Foo f = Foo(); | ||
final b = f.bar(); | ||
print(sprintf("%s", [b])); | ||
assert(b == 10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
type Foo struct { | ||
} | ||
|
||
func bar(self Foo) int { | ||
return baz(self) | ||
} | ||
|
||
func baz(self Foo) int { | ||
return 10 | ||
} | ||
|
||
func main() { | ||
var f Foo = Foo{} | ||
b := bar(f) | ||
fmt.Printf("%v\n", b) | ||
if !(b == 10) { | ||
panic("assert") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
struct Foo | ||
|
||
end | ||
|
||
function bar(self::Foo)::Int64 | ||
return baz(self) | ||
end | ||
|
||
function baz(self::Foo)::Int64 | ||
return 10 | ||
end | ||
|
||
function main() | ||
f = Foo() | ||
b = bar(f) | ||
println(join([b], " ")) | ||
@assert(b == 10) | ||
end | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class Foo { | ||
|
||
fun bar(): Int { | ||
return baz() | ||
} | ||
|
||
fun baz(): Int { | ||
return 10 | ||
} | ||
} | ||
|
||
fun main(argv: Array<String>) { | ||
val f = Foo() | ||
val b = f.bar() | ||
println("$b") | ||
assert(b == 10) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Callable, Dict, List, Set, Optional | ||
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64 | ||
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64 | ||
import sys | ||
|
||
|
||
class Foo: | ||
def bar(self) -> int: | ||
return self.baz() | ||
|
||
def baz(self) -> int: | ||
return 10 | ||
|
||
|
||
if __name__ == "__main__": | ||
f: Foo = Foo() | ||
b = f.bar() | ||
print(b) | ||
assert b == 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//! ```cargo | ||
//! [package] | ||
//! edition = "2018" | ||
//! [dependencies] | ||
//! anyhow = "*" | ||
//! ``` | ||
#![allow(clippy::collapsible_else_if)] | ||
#![allow(clippy::double_parens)] // https://github.com/adsharma/py2many/issues/17 | ||
#![allow(clippy::map_identity)] | ||
#![allow(clippy::needless_return)] | ||
#![allow(clippy::print_literal)] | ||
#![allow(clippy::ptr_arg)] | ||
#![allow(clippy::redundant_static_lifetimes)] // https://github.com/adsharma/py2many/issues/266 | ||
#![allow(clippy::unnecessary_cast)] | ||
#![allow(clippy::upper_case_acronyms)] | ||
#![allow(clippy::useless_vec)] | ||
#![allow(non_camel_case_types)] | ||
#![allow(non_snake_case)] | ||
#![allow(non_upper_case_globals)] | ||
#![allow(unused_imports)] | ||
#![allow(unused_mut)] | ||
#![allow(unused_parens)] | ||
|
||
extern crate anyhow; | ||
use anyhow::Result; | ||
|
||
pub struct Foo {} | ||
|
||
impl Foo { | ||
pub fn bar(&self) -> i32 { | ||
return self.baz(); | ||
} | ||
|
||
pub fn baz(&self) -> i32 { | ||
return 10; | ||
} | ||
} | ||
pub fn main() -> Result<()> { | ||
let f: Foo = Foo {}; | ||
let b = f.bar(); | ||
println!("{}", b); | ||
assert!((b as i32) == 10); | ||
Ok(()) | ||
} |