Files
sdk/tests/language/bad_constructor_test.dart
T
Dan Rubel a8bf40399f Update fasta parser to report error on static constructor
This refactors how modifiers are passed to listener so that the
OutlineBuilder can report a static constructor error.

* Remove handleModifier/s calls from parseMethod
* Pass name and modifiers in beginMethod event
* Update listeners to process method modifiers in beginMethod event
    * AstBuilder
    * NodeListener
    * OutlineBuilder
* Address comment in https://dart-review.googlesource.com/c/sdk/+/42800

Change-Id: Iabd4a18613c1814eb5a157df4acf60dd9060d5eb
Reviewed-on: https://dart-review.googlesource.com/43120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2018-02-23 13:18:46 +00:00

35 lines
867 B
Dart

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class A {
// Constructor may not be static.
static A(); // //# 00: compile-time error
// Factory may not be static.
static factory A() { return null; } // //# 01: syntax error
// Named constructor may not conflict with names of methods and fields.
var m;
A.m() { m = 0; } // //# 04: compile-time error
set q(var value) {
m = 0;
} // No name conflict with q=.
A.q(); // //# 05: ok
A(); // //# 05: ok
A.foo() : m = 0; // //# 06: compile-time error
int foo(int a, int b) => a + b * m;
}
class B {
// Constructor may not be static.
static B(){} // //# 07: compile-time error
}
main() {
new A();
new B();
}