227244745a
The access key, which determines when matching expressions generate identical ASTs, created in PromotableCachableExpression, wrongfully used the cache key, which determines what expressions should be stored in the same cache. This meant that accessing two instance members with the same name but through different promotions (and thus with different interface targets) could wrongfully use the same expression in all cases. The promoted access key is now built using the *access* key of the expression prior to promotion. Closes #55310 Change-Id: I7944e5eecb5018553e058b4e9a66dc355d345974 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361800 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
37 lines
880 B
Dart
37 lines
880 B
Dart
// 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.
|
|
|
|
class Other {
|
|
String text = 42.toString();
|
|
}
|
|
|
|
class Inner {
|
|
Other? other = int.parse('3') == 3 ? Other() : null;
|
|
}
|
|
|
|
sealed class Wrapper {}
|
|
|
|
class WrapperA extends Wrapper {
|
|
Inner inner = Inner();
|
|
}
|
|
|
|
class WrapperB extends Wrapper {
|
|
Inner inner = Inner();
|
|
}
|
|
|
|
var obj = int.parse('1') == 1 ? WrapperB() : WrapperA();
|
|
|
|
void main() {
|
|
foo(obj);
|
|
}
|
|
|
|
void foo(Wrapper wrapper) {
|
|
print(switch (wrapper) {
|
|
WrapperA(inner: Inner(other: final Other other)) => other.text,
|
|
WrapperA(inner: Inner(other: null)) => "no other",
|
|
WrapperB(inner: Inner(other: final Other other)) => other.text,
|
|
WrapperB(inner: Inner(other: null)) => "no other",
|
|
});
|
|
}
|