已开启
fix: fold is_subtype #612
fix: fold is_subtype #612
已开启
yanjs创建于 10 天前
1 个文件变更+13-2
Ccangjie-ci10 天前

PR&issue 合规检查结果 / PR & Issue Compliance Check Results

Item Target Result Notes
PR template Cangjie/llvm-project#612 FAIL 缺少编译/测试截图 / missing screenshots
Issue template Cangjie/cangjie_compiler#459 PASS 必填字段齐全 / required fields filled
PR-Issue consistency Cangjie/llvm-project#612 SKIP 模板无关联issue章节 / no issue section in template

检查结论 / Conclusion: FAIL

likedislike
@@ -213,7 +213,12 @@ static bool isSubType(GlobalVariable *Klass0, GlobalVariable *Klass1) {
213 return false;213 return false;
214 214 
215 for (unsigned i = ReturnTypeIdx + 1; i < TypeArgNum; ++i) {215 for (unsigned i = ReturnTypeIdx + 1; i < TypeArgNum; ++i) {
216- if (!isSubType(K1.getTypeArg(i), K0.getTypeArg(i))) {216+ GlobalVariable *Arg1 = K1.getTypeArg(i);
217+ GlobalVariable *Arg0 = K0.getTypeArg(i);
218+ if (!Arg1->hasInitializer() || !Arg0->hasInitializer()) {
219+ return false;
220+ }
221+ if (!isSubType(Arg1, Arg0)) {
217 return false;222 return false;
218 }223 }
219 }224 }
@@ -302,8 +307,14 @@ static bool tryInferSubType(DevirtualCallData &CallData) {
302 if (K0.isInterface() || K1.isInterface()) {307 if (K0.isInterface() || K1.isInterface()) {
303 // If it find the extensionDef of klass, the subType is true.308 // If it find the extensionDef of klass, the subType is true.
304 // Otherwise, the subtype is unknown.309 // Otherwise, the subtype is unknown.
305- if (getExtensionDef(Klass0, Klass1) == nullptr)310+ // Only fold when the interface type is concrete and has no where-cond.
311+ GlobalVariable *EDGV = getExtensionDef(Klass0, Klass1);
312+ if (EDGV == nullptr || !EDGV->hasInitializer())
306 continue;313 continue;
314+ ExtensionDefData ED(EDGV);
315+ if (ED.WhereCondFn != nullptr) {
316+ continue;
317+ }
307 } else if (K1.isFunction()) {318 } else if (K1.isFunction()) {
308 Result = isFunctionSubType(K0, K1);319 Result = isFunctionSubType(K0, K1);
309 } else {320 } else {