Files
sdk/tests/language/constructor/reference_test.dart
T
Konstantin Shcheglov 571f564eda Rewrite TypeName to ConstructorName in one place, consolidate error reporting.
Change-Id: I5ea1369d65c5eb47e920f68806d28f34931d372e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148983
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-05-26 21:32:22 +00:00

118 lines
3.8 KiB
Dart

// Copyright (c) 2018, 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 Foo<X> {
const Foo();
const Foo.bar();
const Foo.baz();
}
main() {
new Foo();
new Foo.bar();
new Foo.bar.baz();
// ^^^^^^^
// [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
new Foo<int>();
new Foo<int>.bar();
new Foo<int>.bar.baz();
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected '(' after this.
// ^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
// [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
new Foo.bar<int>();
// ^
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
new Foo.bar<int>.baz();
// ^
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^^^^^^^
// [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
new Foo.bar.baz<int>();
// ^^^^^^^
// [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
// ^^^
// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
const Foo();
const Foo.bar();
const Foo.bar.baz();
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_TYPE
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
const Foo<int>();
const Foo<int>.bar();
const Foo<int>.bar.baz();
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected '(' after this.
// ^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
// [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
const Foo.bar<int>();
// ^
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
const Foo.bar<int>.baz();
// ^
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_TYPE
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
const Foo.bar.baz<int>();
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.CONST_WITH_NON_TYPE
// ^^^
// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
Foo();
Foo.bar();
Foo.bar.baz();
// ^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
// [cfe] Getter not found: 'bar'.
Foo<int>();
Foo<int>.bar();
Foo<int>.bar.baz();
// ^^^
// [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
// [cfe] Expected '(' after this.
// ^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
// [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
Foo.bar<int>();
// ^
// [cfe] A constructor invocation can't have type arguments on the constructor name.
// ^^^^^
// [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
Foo.bar<int>.baz();
// ^
// [cfe] A constructor invocation can't have type arguments on the constructor name.
//^^^^^^^
// [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
// ^
// [cfe] Method not found: 'Foo.bar.baz'.
Foo.bar.baz<int>();
// ^^^
// [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
// [cfe] Getter not found: 'bar'.
}