Skip to content

Commit

Permalink
Version 3.0.0-164.0.dev
Browse files Browse the repository at this point in the history
Merge 1d4e6f3 into dev
  • Loading branch information
Dart CI committed Jan 25, 2023
2 parents d9151e5 + 1d4e6f3 commit f706208
Show file tree
Hide file tree
Showing 1,178 changed files with 30,289 additions and 20,870 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3684,8 +3684,8 @@ class _FlowAnalysisImpl<Node extends Object, Statement extends Node,
// If there's a scrutinee, and its value is known to be the same as that of
// the synthetic cache variable, promote it too.
if (scrutineeReference != null &&
_current.infoFor(scrutineeReference.promotionKey).ssaNode ==
_scrutineeSsaNode) {
_current.infoFor(matchedValueReference.promotionKey).ssaNode ==
_current.infoFor(scrutineeReference.promotionKey).ssaNode) {
ifTrue = ifTrue
.tryPromoteForTypeCheck(this, scrutineeReference, staticType)
.ifTrue;
Expand Down
19 changes: 19 additions & 0 deletions pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7136,6 +7136,25 @@ main() {
});
});
});

test("Subpattern doesn't promote scrutinee", () {
var x = Var('x');
var y = Var('y');
h.run([
declare(x, initializer: expr('Object')),
ifCase(
x.expr,
objectPattern(
requiredType: 'num',
fields: [y.pattern(type: 'int').recordField('sign')]),
[
// TODO(paulberry): objectPattern should have promoted to
// `num`
checkNotPromoted(x),
// TODO(paulberry): should promote `x.sign` to `int`.
]),
]);
});
});

test('Pattern inside guard', () {
Expand Down
2 changes: 2 additions & 0 deletions pkg/_fe_analyzer_shared/test/mini_ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ class Harness {
static Map<String, Type> _coreMemberTypes = {
'int.>': Type('bool Function(num)'),
'int.>=': Type('bool Function(num)'),
'num.sign': Type('num'),
};

final MiniAstOperations _operations = MiniAstOperations();
Expand Down Expand Up @@ -1077,6 +1078,7 @@ class MiniAstOperations
'List <: Iterable<int>': Type('List<int>'),
'Never <: int': Type('Never'),
'num <: int': Type('num'),
'num <: Object': Type('num'),
};

static final Map<String, Type> _coreNormalizeResults = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,52 @@ mixin CastPatternTestCases on AbstractCompletionDriverTest {
);
}

Future<void> test_partialType_declaration() async {
Future<void> test_noType_afterDeclaration() async {
await computeSuggestions('''
void f(Object x) {
switch (x) {
case var i as ^
}
}
class A01 {}
class A02 {}
class B01 {}
''');
assertResponse('''
suggestions
A01
kind: class
A02
kind: class
B01
kind: class
''');
}

Future<void> test_noType_afterReference() async {
await computeSuggestions('''
void f(Object x) {
const i = 0;
switch (x) {
case i as ^
}
}
class A01 {}
class A02 {}
class B01 {}
''');
assertResponse('''
suggestions
A01
kind: class
A02
kind: class
B01
kind: class
''');
}

Future<void> test_partialType_afterDeclaration() async {
await computeSuggestions('''
void f(Object x) {
switch (x) {
Expand Down Expand Up @@ -79,7 +124,7 @@ suggestions
}
}

Future<void> test_partialType_reference() async {
Future<void> test_partialType_afterReference() async {
await computeSuggestions('''
void f(Object x) {
const i = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,51 +334,6 @@ suggestions
kind: keyword
when
kind: keyword
''');
}

Future<void> test_noColon_afterAs_afterDeclaration() async {
await computeSuggestions('''
void f(Object x) {
switch (x) {
case var i as ^
}
}
class A01 {}
class A02 {}
class B01 {}
''');
assertResponse('''
suggestions
A01
kind: class
A02
kind: class
B01
kind: class
''');
}

Future<void> test_noColon_afterAs_afterReference() async {
await computeSuggestions('''
void f(Object x) {
const i = 0;
switch (x) {
case i as ^
}
}
class A01 {}
class A02 {}
class B01 {}
''');
assertResponse('''
suggestions
A01
kind: class
A02
kind: class
B01
kind: class
''');
}
}
5 changes: 0 additions & 5 deletions pkg/compiler/lib/src/ir/impact.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,6 @@ class ConstantImpactVisitor extends ir.VisitOnceConstantVisitor {
visitConstant(node.tearOffConstant);
}

@override
void visitTypedefTearOffConstant(ir.TypedefTearOffConstant node) {
defaultConstant(node);
}

@override
void visitInstanceConstant(ir.InstanceConstant node) {
registry.registerConstInstantiation(
Expand Down
Loading

0 comments on commit f706208

Please sign in to comment.