
* Add polymorphism to syntax tree and parser * Add polymorphism to infer types * Fix pretty printing * Add new tests and fix old tests * Fix the comparison between unit and empty tuple * Report undefined interface errors before checking implemented interfaces * Add test for implementing multiple interfaces * Add test for implementing two interfaces with entrypoints of same names and different types * Add tests for interfaces implementing interfaces * Draft: Add variance switching * Revert "Draft: Add variance switching" This reverts commit 92dc6ac169cfbff447ed59de04994f564876b3fb. * Add variance switching * Fix broken tests * Fix broken abi tests * Add tests for variance switching * Fix tests after rebase * Variance switching for custom datatypes * Fix dialyzer warning * Add testing for custom types variance switching * Make opposite_variance a separate function * Make is_subtype/4 a separate function * Fix warning * Mark tvars as invariant * Add type_vars_uvar ets table to ets_tables() * Don't destroy and recreate type errors table when not needed * Fixes from the reviews * Use is_list to check if a var is a list * Compare named args in fun_t * Test only for covariance and contravariance * Remove arrows_in_type and use infer_type_vars_variance instead * Add tests for option and type aliases * Fix previous commit * Rename check_implemented_interfaces_recursive to check_implemented_interfaces1 * Make interfaces declare functions from extended interfaces * Restore test.aes * Add test for variance switching in records * Enable variance switching for record types * Handle builtin types type variables separately * Add tests for oracles and oracle queries * Replace compare_types with non-throwing version of unify * Add the context to unification error * Test variance switching for bivariant records * Give clear names to the records in records variance switching test * Handle comments about polymorphism_variance_switching.aes * Rename datatypes in custom types variance switching test for readability * Change the variance of the oracle_query type vars * Add test for accessing maps with the wrong type * Default to invariant when the variance of the type vars is unknown * Rename test files to have common prefix * Rename functions in variance switching tests for readability * Fix variance inference * Eliminate redundant tests * Test all cases for bivariant
76 lines
2.8 KiB
Plaintext
76 lines
2.8 KiB
Plaintext
contract interface Creature =
|
|
entrypoint is_alive : () => bool
|
|
|
|
contract interface Animal : Creature =
|
|
entrypoint is_alive : () => bool
|
|
entrypoint sound : () => string
|
|
|
|
contract Cat : Animal =
|
|
entrypoint sound() = "meow"
|
|
entrypoint is_alive() = true
|
|
|
|
main contract Main =
|
|
entrypoint init() = ()
|
|
|
|
stateful function g0(_ : Creature) : Cat = Chain.create()
|
|
stateful function f0(x : Cat) : Creature = g0(x)
|
|
stateful function h0() =
|
|
let a : Animal = (Chain.create() : Cat)
|
|
let c : Creature = (Chain.create() : Cat)
|
|
let c1 : Creature = a
|
|
()
|
|
|
|
stateful function g1(x : Animal) : Cat = Chain.create()
|
|
stateful function f1(x : Cat) : Animal = g1(x)
|
|
|
|
stateful function g11(x : list(Animal)) : list(Cat) = [Chain.create()]
|
|
stateful function f11(x : list(Cat)) : list(Animal) = g11(x)
|
|
|
|
stateful function g12(x : Animal * Animal) : Cat * Cat = (Chain.create(), Chain.create())
|
|
stateful function f12(x : Cat * Cat) : Animal * Animal = g12(x)
|
|
|
|
stateful function g13() : map(Cat, Cat) = { [Chain.create()] = Chain.create() }
|
|
stateful function f13() : map(Animal, Animal) = g13()
|
|
|
|
stateful function g2(x : Cat) : Cat = Chain.create()
|
|
stateful function f2(x : Animal) : Animal = g2(x) // fail
|
|
|
|
stateful function g3(x : Cat) : Animal = f1(x)
|
|
stateful function f3(x : Cat) : Cat = g3(x) // fail
|
|
|
|
stateful function g4(x : (Cat => Animal)) : Cat = Chain.create()
|
|
stateful function f4(x : (Animal => Cat)) : Animal = g4(x)
|
|
|
|
stateful function g44(x : list(list(Cat) => list(Animal))) : Cat = Chain.create()
|
|
stateful function f44(x : list(list(Animal) => list(Cat))) : Animal = g44(x)
|
|
|
|
stateful function g5(x : (Animal => Animal)) : Cat = Chain.create()
|
|
stateful function f5(x : (Cat => Cat)) : Animal = g5(x) // fail
|
|
|
|
stateful function g6() : option(Cat) = Some(Chain.create())
|
|
stateful function f6() : option(Animal) = g6()
|
|
stateful function h6() : option(Cat) = f6() // fail
|
|
|
|
type cat_type = Cat
|
|
type animal_type = Animal
|
|
type cat_cat_map = map(cat_type, cat_type)
|
|
type animal_animal_map = map(animal_type, animal_type)
|
|
|
|
stateful function g71(x : animal_type) : cat_type = Chain.create()
|
|
stateful function f71(x : cat_type) : animal_type = g1(x)
|
|
|
|
stateful function g72() : cat_cat_map = { [Chain.create()] = Chain.create() }
|
|
stateful function f72() : animal_animal_map = g13()
|
|
|
|
stateful function g73() =
|
|
let some_cat : Cat = Chain.create()
|
|
let some_animal : Animal = some_cat
|
|
|
|
let some_cat_cat_map : map(Cat, Cat) = g13()
|
|
let some_animal_animal_map : map(Animal, Animal) = some_cat_cat_map
|
|
|
|
let x : Animal = some_animal_animal_map[some_cat] // success
|
|
let y : Cat = some_cat_cat_map[some_animal] // fail
|
|
|
|
()
|