From 856afa72489dd9c3bf2585dc806c5fd1b4b0d8db Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Tue, 2 Jun 2026 11:57:55 -0700 Subject: [PATCH] CQ. Fix superclassName value for constConstructorWithNonConstSuper. Change-Id: Ib90558dfabf72b2a3743dc06b6bc4886eb65fbba Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508442 Reviewed-by: Johnni Winther --- .../lib/src/generated/error_verifier.dart | 4 +++- .../super_constructor_invocation_test.dart | 2 +- ...st_constructor_with_non_const_super_test.dart | 16 ++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart index e369564abd8..f06d9e6afde 100644 --- a/pkg/analyzer/lib/src/generated/error_verifier.dart +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart @@ -3764,7 +3764,9 @@ class ErrorVerifier extends RecursiveAstVisitor var errorRange = superInvocation?.sourceRange ?? implicitErrorRange; diagnosticReporter.report( diag.constConstructorWithNonConstSuper - .withArguments(superclassName: element.enclosingElement.displayName) + .withArguments( + superclassName: invokedSuper.enclosingElement.displayName, + ) .atSourceRange(errorRange), ); return true; diff --git a/pkg/analyzer/test/src/dart/resolution/super_constructor_invocation_test.dart b/pkg/analyzer/test/src/dart/resolution/super_constructor_invocation_test.dart index 8d4351885f8..f66233e2033 100644 --- a/pkg/analyzer/test/src/dart/resolution/super_constructor_invocation_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/super_constructor_invocation_test.dart @@ -127,7 +127,7 @@ class A { class B extends A { const B() : super(5); // ^^^^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); diff --git a/pkg/analyzer/test/src/diagnostics/const_constructor_with_non_const_super_test.dart b/pkg/analyzer/test/src/diagnostics/const_constructor_with_non_const_super_test.dart index e5d76738b29..b30cf2d39d3 100644 --- a/pkg/analyzer/test/src/diagnostics/const_constructor_with_non_const_super_test.dart +++ b/pkg/analyzer/test/src/diagnostics/const_constructor_with_non_const_super_test.dart @@ -20,7 +20,7 @@ class A {} class B extends A { const new(): super(); // ^^^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); } @@ -31,7 +31,7 @@ class A {} class B extends A { const B(): super(); // ^^^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); } @@ -42,7 +42,7 @@ class A {} class const B() extends A { this : super(); // ^^^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); } @@ -53,7 +53,7 @@ class A {} class B extends A { const new(); // ^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); } @@ -64,7 +64,7 @@ class A {} class B extends A { const B(); // ^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); } @@ -74,7 +74,7 @@ class B extends A { class A {} class const B() extends A { // ^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. this; } '''); @@ -85,7 +85,7 @@ class const B() extends A { class A {} class const B() extends A; // ^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. '''); } @@ -114,7 +114,7 @@ class B extends A { const B.foo() : this.bar(); const B.bar() : super._(); // ^^^^^^^^^ -// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'B'. +// [diag.constConstructorWithNonConstSuper] A constant constructor can't call a non-constant super constructor of 'A'. } '''); }