[cfe] Use required type for lookup in map/list pattern
The members used to match a map/list pattern should be pulled from the required type and not the matched type in order to avoid wrongfully using extension type members. Closes #63315 Change-Id: Idccc19fad1a3fc5cd1ecac2cfdb0ef0ee431d50f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502700 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
committed by
dart-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
9af6bae2e1
commit
756dd1c665
@@ -364,7 +364,6 @@ class NullCheckPattern extends Pattern {
|
||||
class ListPattern extends Pattern {
|
||||
static const int FlagNeedsCheck = 1 << 0;
|
||||
static const int FlagHasRestPattern = 1 << 1;
|
||||
static const int FlagIsNeverPattern = 1 << 2;
|
||||
|
||||
int flags = 0;
|
||||
|
||||
@@ -403,17 +402,6 @@ class ListPattern extends Pattern {
|
||||
/// This is set during inference.
|
||||
DartType? lookupType;
|
||||
|
||||
/// If `true`, this list pattern is performed on an expression of type
|
||||
/// `Never`.
|
||||
///
|
||||
/// This is set during inference.
|
||||
bool get isNeverPattern => flags & FlagIsNeverPattern != 0;
|
||||
void set isNeverPattern(bool value) {
|
||||
flags = value
|
||||
? (flags | FlagIsNeverPattern)
|
||||
: (flags & ~FlagIsNeverPattern);
|
||||
}
|
||||
|
||||
/// If `true`, this list pattern contains a rest pattern.
|
||||
///
|
||||
/// This is set during inference.
|
||||
@@ -966,7 +954,6 @@ class AssignedVariablePattern extends Pattern {
|
||||
|
||||
class MapPattern extends Pattern {
|
||||
static const int FlagNeedsCheck = 1 << 0;
|
||||
static const int FlagIsNeverPattern = 1 << 1;
|
||||
|
||||
int flags = 0;
|
||||
|
||||
@@ -1008,16 +995,6 @@ class MapPattern extends Pattern {
|
||||
/// This is set during inference.
|
||||
DartType? lookupType;
|
||||
|
||||
/// If `true`, this map pattern is performed on an expression of type `Never`.
|
||||
///
|
||||
/// This is set during inference.
|
||||
bool get isNeverPattern => flags & FlagIsNeverPattern != 0;
|
||||
void set isNeverPattern(bool value) {
|
||||
flags = value
|
||||
? (flags | FlagIsNeverPattern)
|
||||
: (flags & ~FlagIsNeverPattern);
|
||||
}
|
||||
|
||||
/// Reference to the target of the `containsKey` method of the map.
|
||||
///
|
||||
/// This is set during inference.
|
||||
|
||||
Reference in New Issue
Block a user