[CFE] Fix leak via extension types

Found via the weekly bot.

Change-Id: Id5b7890db4d4c0e1dfca4160c99ceb0c7dbfaafe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363040
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen
2024-04-17 08:48:11 +00:00
committed by Commit Queue
parent ce840baa4c
commit 166e46575f
4 changed files with 62 additions and 0 deletions
@@ -39,6 +39,7 @@ class ClassMembersBuilder implements ClassHierarchyMembers {
_delayedChecks.clear();
_delayedTypeComputations.clear();
_delayedMemberComputations.clear();
extensionTypeDeclarationNodes.clear();
}
void registerDelayedTypeComputation(DelayedTypeComputation computation) {
@@ -0,0 +1,25 @@
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
# Reproduce a leak.
type: newworld
worlds:
- entry: main.dart
noFullComponent: true
sources:
main.dart: |
extension type const _Foo._(int _foo) {
_Foo operator +(_Foo other) => throw "hello";
}
expectedLibraryCount: 1
- entry: main.dart
worldType: updated
expectInitializeFromDill: false
noFullComponent: true
invalidate:
- main.dart
expectedLibraryCount: 1
advancedInvalidation: bodiesOnly
@@ -0,0 +1,18 @@
main = <No Member>;
library from "org-dartlang-test:///main.dart" as main {
extension type _Foo(dart.core::int _foo) {
abstract extension-type-member representation-field get _foo() → dart.core::int;
operator + = main::_Foo|+;
constructor _ = main::_Foo|constructor#_;
constructor tearoff _ = main::_Foo|constructor#_#_#tearOff;
}
static extension-type-member method _Foo|constructor#_(dart.core::int _foo) → main::_Foo% /* erasure=dart.core::int, declared=! */ {
lowered final main::_Foo% /* erasure=dart.core::int, declared=! */ #this = _foo;
return #this;
}
static extension-type-member method _Foo|constructor#_#_#tearOff(dart.core::int _foo) → main::_Foo% /* erasure=dart.core::int, declared=! */
return main::_Foo|constructor#_(_foo);
static extension-type-member method _Foo|+(lowered final main::_Foo% /* erasure=dart.core::int, declared=! */ #this, main::_Foo% /* erasure=dart.core::int, declared=! */ other) → main::_Foo% /* erasure=dart.core::int, declared=! */
return throw "hello";
}
@@ -0,0 +1,18 @@
main = <No Member>;
library from "org-dartlang-test:///main.dart" as main {
extension type _Foo(dart.core::int _foo) {
abstract extension-type-member representation-field get _foo() → dart.core::int;
operator + = main::_Foo|+;
constructor _ = main::_Foo|constructor#_;
constructor tearoff _ = main::_Foo|constructor#_#_#tearOff;
}
static extension-type-member method _Foo|constructor#_(dart.core::int _foo) → main::_Foo% /* erasure=dart.core::int, declared=! */ {
lowered final main::_Foo% /* erasure=dart.core::int, declared=! */ #this = _foo;
return #this;
}
static extension-type-member method _Foo|constructor#_#_#tearOff(dart.core::int _foo) → main::_Foo% /* erasure=dart.core::int, declared=! */
return main::_Foo|constructor#_(_foo);
static extension-type-member method _Foo|+(lowered final main::_Foo% /* erasure=dart.core::int, declared=! */ #this, main::_Foo% /* erasure=dart.core::int, declared=! */ other) → main::_Foo% /* erasure=dart.core::int, declared=! */
return throw "hello";
}