感谢对仓颉社区的支持与关注,欢迎反馈缺陷。
使用 cjc 分别在 O0 / O1 / O2 优化等级下编译如下类型体操代码:
interface I1<T> {} interface I2<T> {} interface I3 {} interface I4 {} interface I5 {} open class CBase<T> {} class CA<T> <: CBase<T> & I1<T> {} extend<T> CA<T> <: I5 where T <: I4 {} extend CA<Bool> <: I4 {} extend CA<Float64> <: I2<Bool> {} extend<T> CBase<T> <: I3 where T <: I3 {} extend Float64 <: I3 {} extend Bool <: I4 {} func test<T>() { if (CA<T>() is I5) { println("CA<T> is I5") } } main() { let x: CA<Float64> = CA<Float64>() if (x is I5) { println("x is I5") } 0 }
在不同优化等级下结果不一致:
不同优化等级结果应当一致。
使用 cjc 分别在 O0 / O1 / O2 优化等级下编译如下代码:
运行环境
OS: macOS 26.1 25B78 arm64 Host: Mac15,6 Kernel: 25.1.0 Uptime: 26 days, 15 hours, 19 mins Packages: 235 (brew) Shell: zsh 5.9 Resolution: 1512x982, 1920x1080 Terminal: vscode CPU: Apple M3 Pro GPU: Apple M3 Pro Memory: 3469MiB / 18432MiB
Cangjie Compiler: 1.0.4 (cjnative)
❯ cjc -v Cangjie Compiler: 1.0.4 (cjnative) Target: aarch64-apple-darwin
[ ] dev [x] main [ ] release/1.0 [ ] release/OpenHarmony-release-6.0
感谢反馈,相关同事分析中。
你好,此问题在daily已修复。
感谢对仓颉社区的支持与关注,欢迎反馈缺陷。
发生了什么问题?
使用 cjc 分别在 O0 / O1 / O2 优化等级下编译如下类型体操代码:
interface I1<T> {} interface I2<T> {} interface I3 {} interface I4 {} interface I5 {} open class CBase<T> {} class CA<T> <: CBase<T> & I1<T> {} extend<T> CA<T> <: I5 where T <: I4 {} extend CA<Bool> <: I4 {} extend CA<Float64> <: I2<Bool> {} extend<T> CBase<T> <: I3 where T <: I3 {} extend Float64 <: I3 {} extend Bool <: I4 {} func test<T>() { if (CA<T>() is I5) { println("CA<T> is I5") } } main() { let x: CA<Float64> = CA<Float64>() if (x is I5) { println("x is I5") } 0 }在不同优化等级下结果不一致:
期望行为是什么?
不同优化等级结果应当一致。
如何复现该缺陷
使用 cjc 分别在 O0 / O1 / O2 优化等级下编译如下代码:
interface I1<T> {} interface I2<T> {} interface I3 {} interface I4 {} interface I5 {} open class CBase<T> {} class CA<T> <: CBase<T> & I1<T> {} extend<T> CA<T> <: I5 where T <: I4 {} extend CA<Bool> <: I4 {} extend CA<Float64> <: I2<Bool> {} extend<T> CBase<T> <: I3 where T <: I3 {} extend Float64 <: I3 {} extend Bool <: I4 {} func test<T>() { if (CA<T>() is I5) { println("CA<T> is I5") } } main() { let x: CA<Float64> = CA<Float64>() if (x is I5) { println("x is I5") } 0 }其他补充信息
运行环境
cjc版本信息
Cangjie Compiler: 1.0.4 (cjnative)
分支版本信息
[ ] dev
[x] main
[ ] release/1.0
[ ] release/OpenHarmony-release-6.0