From 862d8f0f0ea77048d4c760e723fc758aa407f5ff Mon Sep 17 00:00:00 2001 From: "Sergey G. Grekhov" Date: Mon, 17 Jul 2023 13:19:43 +0400 Subject: [PATCH] Fixes #2136. Add type variable conflict test (#2137) --- .../Classes/same_name_type_variable_t01.dart | 8 +++---- .../Classes/same_name_type_variable_t02.dart | 8 +++---- .../Classes/same_name_type_variable_t03.dart | 8 +++---- .../Classes/same_name_type_variable_t04.dart | 8 +++---- .../Classes/same_name_type_variable_t05.dart | 8 +++---- .../Classes/same_name_type_variable_t06.dart | 8 +++---- .../Classes/same_name_type_variable_t07.dart | 10 ++++---- .../Classes/same_name_type_variable_t08.dart | 8 +++---- .../Classes/same_name_type_variable_t09.dart | 8 +++---- .../Classes/same_name_type_variable_t10.dart | 23 +++++++++++++++++++ 10 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 Language/Classes/same_name_type_variable_t10.dart diff --git a/Language/Classes/same_name_type_variable_t01.dart b/Language/Classes/same_name_type_variable_t01.dart index a8ec4b24b9..a9a24b858b 100644 --- a/Language/Classes/same_name_type_variable_t01.dart +++ b/Language/Classes/same_name_type_variable_t01.dart @@ -2,15 +2,15 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class. /// @author ilya /// @issue 14513 - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t02.dart b/Language/Classes/same_name_type_variable_t02.dart index e7e0a266ea..3725727515 100644 --- a/Language/Classes/same_name_type_variable_t02.dart +++ b/Language/Classes/same_name_type_variable_t02.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class instance variable. /// @author ilya - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t03.dart b/Language/Classes/same_name_type_variable_t03.dart index 10f5986924..508445f520 100644 --- a/Language/Classes/same_name_type_variable_t03.dart +++ b/Language/Classes/same_name_type_variable_t03.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class instance getter. /// @author ilya - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t04.dart b/Language/Classes/same_name_type_variable_t04.dart index c29e9b0c49..10c33cfe98 100644 --- a/Language/Classes/same_name_type_variable_t04.dart +++ b/Language/Classes/same_name_type_variable_t04.dart @@ -2,15 +2,15 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class instance setter. /// @author ilya /// @issue 14513 - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t05.dart b/Language/Classes/same_name_type_variable_t05.dart index 0a881ea23b..fa77e4dccc 100644 --- a/Language/Classes/same_name_type_variable_t05.dart +++ b/Language/Classes/same_name_type_variable_t05.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class static variable. /// @author ilya - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t06.dart b/Language/Classes/same_name_type_variable_t06.dart index 5a4ed5ac61..2cf77319e9 100644 --- a/Language/Classes/same_name_type_variable_t06.dart +++ b/Language/Classes/same_name_type_variable_t06.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class static getter. /// @author ilya - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t07.dart b/Language/Classes/same_name_type_variable_t07.dart index 3c211f56ec..074bf3f5b4 100644 --- a/Language/Classes/same_name_type_variable_t07.dart +++ b/Language/Classes/same_name_type_variable_t07.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class static setter. /// @author ilya -/// @issue 14513 - +/// @issue 14513 class A { // ^ diff --git a/Language/Classes/same_name_type_variable_t08.dart b/Language/Classes/same_name_type_variable_t08.dart index 0e4ef93660..b8df6c006a 100644 --- a/Language/Classes/same_name_type_variable_t08.dart +++ b/Language/Classes/same_name_type_variable_t08.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class instance method. /// @author ilya - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t09.dart b/Language/Classes/same_name_type_variable_t09.dart index 3dea1b7cbf..c17d45646a 100644 --- a/Language/Classes/same_name_type_variable_t09.dart +++ b/Language/Classes/same_name_type_variable_t09.dart @@ -2,14 +2,14 @@ // 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. -/// @assertion It is a compile time error if a generic class declares a type -/// variable with the same name as the class or any of its members or -/// constructors. +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// /// @description Checks that a type variable can not have the same name as /// the name of generic class static method. /// @author ilya - class A { // ^ // [analyzer] unspecified diff --git a/Language/Classes/same_name_type_variable_t10.dart b/Language/Classes/same_name_type_variable_t10.dart new file mode 100644 index 0000000000..f652613424 --- /dev/null +++ b/Language/Classes/same_name_type_variable_t10.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2023, 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. + +/// @assertion If a generic class named G declares a type variable named X, it +/// is a compile-time error if X is equal to G, or if G has a member whose +/// basename is X, or if G has a constructor named G.X. +/// +/// @description Checks that it is a compile-time error if a class `C` has a +/// constructor named `C.T`, where `T` is a type variable +/// @author sgrekhov22@gmail.com + +class C { +// ^ +// [analyzer] unspecified + C.T() {} +//^ +// [cfe] unspecified +} + +main() { + print(C); +}