mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Resynthesize function types in constants.
R=brianwilkerson@google.com Bug: https://github.com/dart-lang/sdk/issues/31554#issuecomment-354624024 Change-Id: Id5dc525f5d803c455e5336f460523d57ec832ace Reviewed-on: https://dart-review.googlesource.com/32147 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
ad66944dfd
commit
a0abc35f60
|
@ -748,21 +748,14 @@ class _ExprBuilder {
|
|||
}
|
||||
|
||||
TypeAnnotation _buildType(DartType type) {
|
||||
if (type is InterfaceType) {
|
||||
var name = AstTestFactory.identifier3(type.element.name)
|
||||
..staticElement = type.element
|
||||
..staticType = type;
|
||||
List<TypeAnnotation> arguments = _buildTypeArguments(type.typeArguments);
|
||||
return AstTestFactory.typeName3(name, arguments)..type = type;
|
||||
List<TypeAnnotation> argumentNodes;
|
||||
if (type is ParameterizedType) {
|
||||
argumentNodes = _buildTypeArguments(type.typeArguments);
|
||||
}
|
||||
if (type is DynamicTypeImpl || type is TypeParameterType) {
|
||||
var identifier = AstTestFactory.identifier3(type.name)
|
||||
..staticElement = type.element
|
||||
..staticType = type;
|
||||
return AstTestFactory.typeName3(identifier)..type = type;
|
||||
}
|
||||
// TODO(scheglov) Implement for other types.
|
||||
throw new UnimplementedError('type: (${type.runtimeType}) $type');
|
||||
TypeName node = AstTestFactory.typeName4(type.name, argumentNodes);
|
||||
node.type = type;
|
||||
(node.name as SimpleIdentifier).staticElement = type.element;
|
||||
return node;
|
||||
}
|
||||
|
||||
TypeArgumentList _buildTypeArgumentList(List<kernel.DartType> kernels) {
|
||||
|
|
|
@ -2263,6 +2263,15 @@ class C {
|
|||
}
|
||||
}
|
||||
|
||||
test_class_setter_invalid_named_parameter() async {
|
||||
var library = await checkLibrary('class C { void set x({a}) {} }');
|
||||
checkElementText(library, r'''
|
||||
class C {
|
||||
void set x({dynamic a}) {}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_setter_invalid_no_parameter() async {
|
||||
var library = await checkLibrary('class C { void set x() {} }');
|
||||
checkElementText(library, r'''
|
||||
|
@ -2272,15 +2281,6 @@ class C {
|
|||
''');
|
||||
}
|
||||
|
||||
test_class_setter_invalid_too_many_parameters() async {
|
||||
var library = await checkLibrary('class C { void set x(a, b) {} }');
|
||||
checkElementText(library, r'''
|
||||
class C {
|
||||
void set x(dynamic a, dynamic b) {}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_class_setter_invalid_optional_parameter() async {
|
||||
var library = await checkLibrary('class C { void set x([a]) {} }');
|
||||
checkElementText(library, r'''
|
||||
|
@ -2290,11 +2290,11 @@ class C {
|
|||
''');
|
||||
}
|
||||
|
||||
test_class_setter_invalid_named_parameter() async {
|
||||
var library = await checkLibrary('class C { void set x({a}) {} }');
|
||||
test_class_setter_invalid_too_many_parameters() async {
|
||||
var library = await checkLibrary('class C { void set x(a, b) {} }');
|
||||
checkElementText(library, r'''
|
||||
class C {
|
||||
void set x({dynamic a}) {}
|
||||
void set x(dynamic a, dynamic b) {}
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
@ -4277,6 +4277,27 @@ const dynamic v = const <
|
|||
}
|
||||
}
|
||||
|
||||
test_const_topLevel_typedList_typedefArgument() async {
|
||||
shouldCompareLibraryElements = false;
|
||||
var library = await checkLibrary(r'''
|
||||
typedef int F(String id);
|
||||
const v = const <F>[];
|
||||
''');
|
||||
if (isStrongMode) {
|
||||
checkElementText(library, r'''
|
||||
typedef F = int Function(String id);
|
||||
const List<(String) → int> v = const <
|
||||
null/*location: test.dart;F;-*/>[];
|
||||
''');
|
||||
} else {
|
||||
checkElementText(library, r'''
|
||||
typedef F = int Function(String id);
|
||||
const dynamic v = const <
|
||||
null/*location: test.dart;F;-*/>[];
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
||||
test_const_topLevel_typedMap() async {
|
||||
var library = await checkLibrary(r'''
|
||||
const vDynamic1 = const <dynamic, int>{};
|
||||
|
|
Loading…
Reference in a new issue