Skip to content

Commit

Permalink
Issue 37401. Support for const Set default values in mocks.
Browse files Browse the repository at this point in the history
Bug: #37401
Change-Id: Ia65a0e6204f64a308dd27810759a8b7416244248
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108841
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Vijay Menon <[email protected]>
  • Loading branch information
scheglov authored and [email protected] committed Jul 12, 2019
1 parent 55b67e9 commit 464a5a6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/dev_compiler/lib/src/analyzer/code_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4511,6 +4511,10 @@ class CodeGenerator extends Object
return _emitConstList(type.typeArguments[0],
value.toListValue().map(_emitDartObject).toList());
}
if (type.element == types.setType.element) {
return _emitConstSet(type.typeArguments[0],
value.toSetValue().map(_emitDartObject).toList());
}
if (type.element == types.mapType.element) {
var entries = <js_ast.Expression>[];
value.toMapValue().forEach((key, value) {
Expand Down Expand Up @@ -5811,6 +5815,12 @@ class CodeGenerator extends Object
return _emitType(type.instantiate(typeArgs));
}

js_ast.Expression _emitConstSet(
DartType elementType, List<js_ast.Expression> elements) {
return cacheConst(
runtimeCall('constSet([#], #)', [elements, _emitType(elementType)]));
}

js_ast.Expression _emitSetImplType(InterfaceType type, {bool identity}) {
var typeArgs = type.typeArguments;
if (typeArgs.isEmpty) return _emitType(type);
Expand Down

0 comments on commit 464a5a6

Please sign in to comment.