Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: tests/compiler/dart2js/semantic_visitor_test.dart

Issue 1140903002: Handle constant constructors with parse errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/semantic_visitor_test.dart
diff --git a/tests/compiler/dart2js/semantic_visitor_test.dart b/tests/compiler/dart2js/semantic_visitor_test.dart
index 3d9372449961a0fd6b18f57b28f60aa6e7ceaf7d..7fe4ec344c66ae4f17343dee0e9c3e269e0b24cb 100644
--- a/tests/compiler/dart2js/semantic_visitor_test.dart
+++ b/tests/compiler/dart2js/semantic_visitor_test.dart
@@ -2458,6 +2458,57 @@ const Map<String, List<Test>> SEND_TESTS = const {
arguments: '(true,42)',
type: 'Class',
selector: 'CallStructure(arity=2)')),
+ const Test(
+ '''
+ class Class {}
+ m() => const Class();
+ ''',
+ const Visit(VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
+ arguments: '()',
+ type: 'Class',
+ selector: 'CallStructure(arity=0)')),
+ const Test(
+ '''
+ class Class {
+ const Class() // Delibrate syntax error.
+ }
+ m() => const Class();
+ ''',
+ const Visit(VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
+ arguments: '()',
+ type: 'dynamic',
+ selector: 'CallStructure(arity=0)')),
+ const Test(
+ '''
+ class Target {}
+ class Class {
+ const factory Class() = Target;
+ }
+ m() => const Class();
+ ''',
+ const Visit(VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
+ arguments: '()',
+ type: 'Class',
+ selector: 'CallStructure(arity=0)')),
+ /* Enable this when constness is handled consistently.
+ const Test(
+ '''
+ class Target {
+ const Target();
+ }
+ class Redirection {
+ factory Redirection() = Target;
+ }
+ class Class {
+ const factory Class() = Redirection;
+ }
+ m() => const Class();
+ ''',
+ const Visit(VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
+ arguments: '()',
+ type: 'Class',
+ selector: 'CallStructure(arity=0)')),
+ */
],
};
@@ -3324,6 +3375,7 @@ Future test(List<String> arguments,
index++;
});
});
+
mainSource.writeln("main() {}");
sourceFiles['main.dart'] = mainSource.toString();
@@ -5589,6 +5641,22 @@ class SemanticSendTestVisitor extends SemanticTestVisitor {
selector: callStructure));
apply(arguments, arg);
}
+
+ @override
+ errorNonConstantConstructorInvoke(
+ NewExpression node,
+ Element element,
+ DartType type,
+ NodeList arguments,
+ CallStructure callStructure,
+ arg) {
+ visits.add(new Visit(
+ VisitKind.ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
+ type: type,
+ arguments: arguments,
+ selector: callStructure));
+ apply(arguments, arg);
+ }
}
class SemanticDeclarationTestVisitor extends SemanticTestVisitor {
@@ -6417,6 +6485,7 @@ enum VisitKind {
VISIT_UNRESOLVED_CONSTRUCTOR_INVOKE,
VISIT_ABSTRACT_CLASS_CONSTRUCTOR_INVOKE,
VISIT_UNRESOLVED_REDIRECTING_FACTORY_CONSTRUCTOR_INVOKE,
+ ERROR_NON_CONSTANT_CONSTRUCTOR_INVOKE,
VISIT_INSTANCE_GETTER_DECL,
VISIT_INSTANCE_SETTER_DECL,
« no previous file with comments | « pkg/compiler/lib/src/resolution/send_resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698