| // Copyright (c) 2024, 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. |
| |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| |
| import '../dart/resolution/context_collection_resolution.dart'; |
| import '../dart/resolution/node_text_expectations.dart'; |
| |
| main() { |
| defineReflectiveSuite(() { |
| defineReflectiveTests(AugmentationWithoutDeclarationTest); |
| defineReflectiveTests(UpdateNodeTextExpectations); |
| }); |
| } |
| |
| @reflectiveTest |
| class AugmentationWithoutDeclarationTest extends PubPackageResolutionTest { |
| test_class() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment class A {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_class_augments_class() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A {} |
| '''); |
| } |
| |
| test_class_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment A.named(); |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_constructor_augments_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int foo = 0; |
| } |
| |
| augment class A { |
| augment A.foo(); |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_constructor_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| void foo() {} |
| } |
| |
| augment class A { |
| augment A.foo(); |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceField_augments_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| A.foo(); |
| } |
| |
| augment class A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceField_augments_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int foo = 0; |
| } |
| |
| augment class A { |
| augment int foo = 1; |
| } |
| '''); |
| } |
| |
| test_class_instanceField_augments_staticField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int foo = 0; |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| augment class A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceField_augments_staticGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int get foo => 0; |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| augment class A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceField_augments_staticMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static void foo() {} |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| augment class A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceField_augments_staticSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static set foo(int _) {} |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| augment class A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceGetter_augments_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| A.foo(); |
| } |
| |
| augment class A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceGetter_augments_staticField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int foo = 0; |
| } |
| augment class A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceGetter_augments_staticGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int get foo => 0; |
| } |
| augment class A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceGetter_augments_staticMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static void foo() {} |
| } |
| augment class A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceGetter_augments_staticSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static set foo(int _) {} |
| } |
| augment class A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod_augments_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| A.foo(); |
| } |
| |
| augment class A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| void foo() {} |
| } |
| |
| augment class A { |
| augment void foo(); |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod_augments_staticField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int foo = 0; |
| } |
| augment class A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod_augments_staticGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int get foo => 0; |
| } |
| augment class A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod_augments_staticMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static void foo() {} |
| } |
| augment class A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceMethod_augments_staticSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static set foo(int _) {} |
| } |
| augment class A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceSetter_augments_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| A.foo(); |
| } |
| |
| augment class A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceSetter_augments_staticField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int foo = 0; |
| } |
| augment class A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceSetter_augments_staticGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static int get foo => 0; |
| } |
| augment class A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceSetter_augments_staticMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static void foo() {} |
| } |
| augment class A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_instanceSetter_augments_staticSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| static set foo(int _) {} |
| } |
| augment class A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_staticField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment static int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_staticField_augments_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int foo = 0; |
| } |
| augment class A { |
| augment static int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticField_augments_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int get foo => 0; |
| } |
| augment class A { |
| augment static int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticField_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| void foo() {} |
| } |
| augment class A { |
| augment static int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticField_augments_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| set foo(int _) {} |
| } |
| augment class A { |
| augment static int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment static int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_staticGetter_augments_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int foo = 0; |
| } |
| augment class A { |
| augment static int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticGetter_augments_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int get foo => 0; |
| } |
| augment class A { |
| augment static int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticGetter_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| void foo() {} |
| } |
| augment class A { |
| augment static int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticGetter_augments_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| set foo(int _) {} |
| } |
| augment class A { |
| augment static int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment static void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_staticMethod_augments_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int foo = 0; |
| } |
| augment class A { |
| augment static void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticMethod_augments_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int get foo => 0; |
| } |
| augment class A { |
| augment static void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticMethod_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| void foo() {} |
| } |
| augment class A { |
| augment static void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticMethod_augments_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| set foo(int _) {} |
| } |
| augment class A { |
| augment static void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A {} |
| |
| augment class A { |
| augment static set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_class_staticSetter_augments_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int foo = 0; |
| } |
| augment class A { |
| augment static set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticSetter_augments_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| int get foo => 0; |
| } |
| augment class A { |
| augment static set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticSetter_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| void foo() {} |
| } |
| augment class A { |
| augment static set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_class_staticSetter_augments_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| class A { |
| set foo(int _) {} |
| } |
| augment class A { |
| augment static set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^ |
| // [diag.conflictingStaticAndInstance] Class 'A' can't define static member 'foo' and have instance member 'A.foo' with the same name. |
| } |
| '''); |
| } |
| |
| test_enum() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment enum A {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_enum_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| enum A { |
| v; |
| const A(); |
| } |
| |
| augment enum A {; |
| augment const A.named(); |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| // ^^^^^ |
| // [diag.unusedElement] The declaration 'A.named' isn't referenced. |
| } |
| '''); |
| } |
| |
| test_enum_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| enum A { |
| v; |
| const A(); |
| } |
| |
| augment enum A {; |
| augment final int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_enum_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| enum A { |
| v; |
| const A(); |
| } |
| |
| augment enum A {; |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_enum_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| enum A { |
| v; |
| const A(); |
| } |
| |
| augment enum A {; |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_enum_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| enum A { |
| v; |
| const A(); |
| } |
| |
| augment enum A {; |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extension() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment extension A {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_extension_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension A on int {} |
| |
| augment extension A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extension_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension A on int {} |
| |
| augment extension A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extension_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension A on int {} |
| |
| augment extension A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extensionType() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment extension type A(int it) {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_extensionType_constructor() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension type A(int it) {} |
| |
| augment extension type A(int it) { |
| augment A.named() : this(0); |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extensionType_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension type A(int it) {} |
| |
| augment extension type A(int it) { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extensionType_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension type A(int it) {} |
| |
| augment extension type A(int it) { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_extensionType_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| extension type A(int it) {} |
| |
| augment extension type A(int it) { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_mixin() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment mixin A {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_mixin_instanceField() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| mixin A {} |
| |
| augment mixin A { |
| augment int foo = 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_mixin_instanceGetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| mixin A {} |
| |
| augment mixin A { |
| augment int get foo => 0; |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_mixin_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| mixin A {} |
| |
| augment mixin A { |
| augment void foo() {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_mixin_instanceMethod_augments_instanceMethod() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| mixin A { |
| void foo() {} |
| } |
| |
| augment mixin A { |
| augment void foo(); |
| } |
| '''); |
| } |
| |
| test_mixin_instanceSetter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| mixin A {} |
| |
| augment mixin A { |
| augment set foo(int _) {} |
| //^^^^^^^ |
| // [diag.augmentationWithoutDeclaration] The declaration being augmented doesn't exist. |
| } |
| '''); |
| } |
| |
| test_topLevel_function() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment void foo() {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_topLevel_function_augments_function() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| void foo() {} |
| |
| augment void foo(); |
| '''); |
| } |
| |
| test_topLevel_getter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment int get foo => 0; |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_topLevel_setter() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment set foo(int _) {} |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_topLevel_variable_multiple() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment int foo = 0, bar = 0; |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_topLevel_variable_multiple_oneMissing() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| int bar = 0; |
| |
| augment int foo = 1, bar = 2; |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_topLevel_variable_single() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| augment int foo = 0; |
| // [diag.augmentationWithoutDeclaration][column 1][length 7] The declaration being augmented doesn't exist. |
| '''); |
| } |
| |
| test_topLevel_variable_single_augments_variable() async { |
| await resolveTestCodeWithDiagnostics(r''' |
| int foo = 0; |
| |
| augment int foo = 1; |
| '''); |
| } |
| } |