Files
sdk/tests/language_2/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

55 lines
1.0 KiB
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.
// A constructor can't be static.
class A {
static //# 00: compile-time error
A();
}
// A factory constructor can't be static.
class B {
static //# 01: syntax error
factory B() { return null; }
}
// A named constructor can't have the same name as a field.
class C {
var field;
C
.field //# 04: compile-time error
();
C.good();
}
// A named constructor can't have the same name as a method.
class D {
method() {}
D
.method //# 06: compile-time error
();
D.good();
}
// A named constructor can have the same name as a setter.
class E {
set setter(value) {} //# 05: ok
E.setter();
}
// A constructor can't be static.
class F {
static //# 07: compile-time error
F(){}
}
main() {
new A();
new B();
new C.good();
new D.good();
new E.setter();
new F();
}