乐堂版本 2020.01
这不编译。
use v6;
class N1 {}
class T1 {}
class G1 {
has @.g is required where A1|Q1;
}
class Q1 {
has $.q is required where N1|T1|G1;
}
class A1 {
has Q1 @.a is required;
}
===SORRY!=== Error while compiling …
Illegally post-declared types:
A1 used at line 7
Q1 used at line 7
我认为仅在 G1 之前声明标识符会帮助我,但这也失败了:
===SORRY!=== Error while compiling …
Too late for unit-scoped class definition;
Please use the block form.
…:6
------> class A1;⏏ class Q1;
我如何使它工作?
最佳答案
您可以,但您需要将类定义为 stub 。
class A { }
只会定义一个空类。然而:
class A { ... } # note the yadayadayada
将定义一个 stub 。所以补充:
class A1 { ... }
class Q1 { ... }
到您的代码顶部,应该可以解决问题。
关于porting - "Illegally post-declared types"带循环类定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60041718/