Skip to content

Commit

Permalink
[cfe] Report cyclic dependency on declaration, not on type variable
Browse files Browse the repository at this point in the history
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/339941/comment/356b962f_a73d18c8/

Change-Id: I193cee03bdfa766621d57dd4a47cc9f0da6c9c92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340440
Reviewed-by: Erik Ernst <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Chloe Stefantsova <[email protected]>
  • Loading branch information
chloestefantsova authored and Commit Queue committed Dec 7, 2023
1 parent d3f2736 commit d0aa049
Show file tree
Hide file tree
Showing 26 changed files with 50 additions and 80 deletions.
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/fasta/kernel/type_algorithms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ List<NonSimplicityIssue> convertRawTypeCyclesIntoIssues(
if (cycle.length == 1) {
// Loop.
issues.add(new NonSimplicityIssue(
cycle.single.typeVariable!,
declaration,
templateBoundIssueViaLoopNonSimplicity
.withArguments(cycle.single.type.declaration!.name),
null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:28: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:9: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'F2' here.
// typedef F2 = void Function<X extends F2>();
// ^
// ^^
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:5:9: Error: The typedef 'F1' has a reference to itself.
// typedef F1<X> = List<G1<X>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:28: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:9: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'F2' here.
// typedef F2 = void Function<X extends F2>();
// ^
// ^^
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:5:9: Error: The typedef 'F1' has a reference to itself.
// typedef F1<X> = List<G1<X>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:28: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:9: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'F2' here.
// typedef F2 = void Function<X extends F2>();
// ^
// ^^
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:5:9: Error: The typedef 'F1' has a reference to itself.
// typedef F1<X> = List<G1<X>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:28: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:9: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'F2' here.
// typedef F2 = void Function<X extends F2>();
// ^
// ^^
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:5:9: Error: The typedef 'F1' has a reference to itself.
// typedef F1<X> = List<G1<X>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:28: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:9: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'F2' here.
// typedef F2 = void Function<X extends F2>();
// ^
// ^^
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:5:9: Error: The typedef 'F1' has a reference to itself.
// typedef F1<X> = List<G1<X>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:28: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/general/cyclic_typedef.dart:8:9: Error: Generic type 'F2' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'F2' here.
// typedef F2 = void Function<X extends F2>();
// ^
// ^^
//
// pkg/front_end/testcases/general/cyclic_typedef.dart:5:9: Error: The typedef 'F1' has a reference to itself.
// typedef F1<X> = List<G1<X>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:26: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C, TypeY extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:26: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C, TypeY extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:26: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C, TypeY extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:26: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C, TypeY extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:26: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C, TypeY extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:8:26: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends A, TypeY extends A> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_for_each.dart:10:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends C, TypeY extends C> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends Map<A, A>> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:11:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends Map<C, C>> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends Map<A, A>> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:11:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends Map<C, C>> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends Map<A, A>> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:11:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends Map<C, C>> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends Map<A, A>> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:11:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends Map<C, C>> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends Map<A, A>> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:11:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends Map<C, C>> = int;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ library;
//
// Problems in library:
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:9: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:9:7: Error: Generic type 'A' can't be used without type arguments in the bounds of its own type variables.
// Try providing type arguments to 'A' here.
// class A<TypeX extends Map<A, A>> {}
// ^^^^^
// ^
//
// pkg/front_end/testcases/instantiate_to_bound/non_simple_co_inductive_no_dup.dart:11:9: Error: The typedef 'C' has a reference to itself.
// typedef C<TypeX extends Map<C, C>> = int;
Expand Down
2 changes: 1 addition & 1 deletion tests/language/regress/regress34635_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class A<X extends C> {}
// [analyzer] COMPILE_TIME_ERROR.NOT_INSTANTIATED_BOUND

class C<X extends C> {}
// ^
// ^
// [cfe] Generic type 'C' can't be used without type arguments in the bounds of its own type variables.
// ^
// [analyzer] COMPILE_TIME_ERROR.NOT_INSTANTIATED_BOUND
Expand Down

0 comments on commit d0aa049

Please sign in to comment.