overturetool / overture

The Overture Tool
http://overturetool.org
GNU General Public License v3.0
49 stars 25 forks source link

Class unions cannot be used to start threads #765

Closed nickbattle closed 3 years ago

nickbattle commented 3 years ago

The following spec produces an error:

class A
operations
    op: () ==> ()
    op() == skip;

thread
    op();

end A

class B
operations
    op: () ==> ()
    op() == skip;

thread
    op();

end B

class C
operations
    op: A | B ==> ()
    op(obj) == start(obj);    -- Error 3237: Class does not define a thread

end C

Clearly the object does define a thread as each of the components of the union do. The problem is partly because thread definitions are currently "protected" by default, and partly because the simulated type created by the union only considers visible types. Because the start call is outside both A and B, the protected threads are not visible.

I think this ought to be legal (and it is used in one of the variants of the POP3 example!)

nickbattle commented 3 years ago

Now fixed in ncb/development.