sophia/test/contracts/polymorphism_variance_switching_chain_create.aes
Gaith Hallak c98ea25e8b
Fix: Get the type of Chain.create() from its application (#407)
* Get the type of Chain.create() from its application

* Add test contract

* Update CHANGELOG.md

* Update the tests

* Update tests again
2022-08-03 22:24:22 +02:00

30 lines
714 B
Plaintext

contract interface I =
entrypoint f : () => int
contract C1 : I =
entrypoint f() = 123
contract C2 : I =
entrypoint f() = 888
namespace Make =
stateful function new1() : I = Chain.create() : C1
stateful function new2() : I = Chain.create() : C2
stateful function new(c : I) : int = c.f()
main contract Main =
stateful entrypoint test1() =
let c = Make.new1()
Make.new(c)
stateful entrypoint test2() =
let c = Make.new2()
Make.new(c)
stateful entrypoint test3() =
let c1 = Chain.create() : C1 // succeeds
let c2 : I = Chain.create() : C1 // succeeds
let c3 : C1 = Chain.create() // succeeds
()