已开启
fix: fold is_subtype #612
yanjs创建于 10 天前
fix: fold is_subtype #612
已开启
共 1 个文件变更+13-2
| @@ -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 { |
PR&issue 合规检查结果 / PR & Issue Compliance Check Results
检查结论 / Conclusion: FAIL