已合并
Fix interface crash #9686
dddzzzhhh创建于 1月12日
Fix interface crash #9686
已合并
共 3 个文件变更+63-3
| @@ -1,5 +1,5 @@ | |||
| 1 | /** | 1 | /** |
| 2 | - * Copyright (c) 2021-2025 Huawei Device Co., Ltd. | 2 | + * Copyright (c) 2021-2026 Huawei Device Co., Ltd. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. | 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at | 5 | * You may obtain a copy of the License at |
| @@ -35,6 +35,7 @@ | |||
| 35 | 35 | ||
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | + | ||
| 38 | 39 | ||
| 39 | namespace ark::es2panda::compiler { | 40 | namespace ark::es2panda::compiler { |
| 40 | 41 | ||
| @@ -384,7 +385,8 @@ ir::AstNode *HandleOpAssignment(public_lib::Context *ctx, ir::AssignmentExpressi | |||
| 384 | InitScopesPhaseETS::RunExternalNode(loweringResult, ctx->parserProgram->VarBinder()); | 385 | InitScopesPhaseETS::RunExternalNode(loweringResult, ctx->parserProgram->VarBinder()); |
| 385 | checker->VarBinder()->AsETSBinder()->ResolveReferencesForScopeWithContext(loweringResult, scope); | 386 | checker->VarBinder()->AsETSBinder()->ResolveReferencesForScopeWithContext(loweringResult, scope); |
| 386 | 387 | ||
| 387 | - checker::SavedCheckerContext scc {checker, checker::CheckerStatus::IGNORE_VISIBILITY, ContainingClass(assignment)}; | 388 | + checker::SavedCheckerContext scc {checker, checker::CheckerStatus::IGNORE_VISIBILITY, |
| 389 | + util::Helpers::GetContainingObjectType(assignment)}; | ||
| 388 | checker::ScopeContext sc {checker, scope}; | 390 | checker::ScopeContext sc {checker, scope}; |
| 389 | 391 | ||
| 390 | loweringResult->Check(checker); | 392 | loweringResult->Check(checker); |
| @@ -494,7 +496,8 @@ static ir::AstNode *HandleUpdate(public_lib::Context *ctx, ir::UpdateExpression | |||
| 494 | auto *checker = ctx->GetChecker()->AsETSChecker(); | 496 | auto *checker = ctx->GetChecker()->AsETSChecker(); |
| 495 | 497 | ||
| 496 | auto expressionCtx = varbinder::LexicalScope<varbinder::Scope>::Enter(checker->VarBinder(), scope); | 498 | auto expressionCtx = varbinder::LexicalScope<varbinder::Scope>::Enter(checker->VarBinder(), scope); |
| 497 | - checker::SavedCheckerContext scc {checker, checker::CheckerStatus::IGNORE_VISIBILITY, ContainingClass(upd)}; | 499 | + checker::SavedCheckerContext scc {checker, checker::CheckerStatus::IGNORE_VISIBILITY, |
| 500 | + util::Helpers::GetContainingObjectType(upd)}; | ||
| 498 | checker::ScopeContext sc {checker, scope}; | 501 | checker::ScopeContext sc {checker, scope}; |
| 499 | 502 | ||
| 500 | loweringResult->SetParent(upd->Parent()); | 503 | loweringResult->SetParent(upd->Parent()); |
| @@ -0,0 +1,28 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | +interface I { | ||
| 18 | + x: number; | ||
| 19 | + inc() { | ||
| 20 | + this.x += 1 | ||
| 21 | + } | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +function main() { | ||
| 25 | + const obj: I = { x: 1 }; | ||
| 26 | + obj.inc() | ||
| 27 | + arktest.assertEQ(obj.x, 2); | ||
| 28 | +} | ||
| @@ -0,0 +1,29 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | +interface I { | ||
| 17 | + x: number; | ||
| 18 | + inc() { | ||
| 19 | + this.x++; | ||
| 20 | + this.x++; | ||
| 21 | + this.x--; | ||
| 22 | + } | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +function main() { | ||
| 26 | + const obj: I = { x: 1 } | ||
| 27 | + obj.inc() | ||
| 28 | + arktest.assertEQ(obj.x, 2); | ||
| 29 | +} | ||
Same change needs to be applied to
HandleUpdate.