Skip to content

Commit 09550b3

Browse files
scheglovCommit Queue
authored andcommitted
Issue 57035. Fix for exception when asking class alias constructors.
Bug: #57035 Change-Id: I48aa20815b56c49f08e22509126f74891e694644 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393960 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent a36dbc7 commit 09550b3

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,6 @@ class ClassElementImpl extends ClassOrMixinElementImpl
490490
return;
491491
}
492492

493-
// Assign to break a possible infinite recursion during computing.
494-
_constructors = const <ConstructorElementImpl>[];
495-
496493
var superType = supertype;
497494
if (superType == null) {
498495
// Shouldn't ever happen, since the only classes with no supertype are
@@ -503,6 +500,9 @@ class ClassElementImpl extends ClassOrMixinElementImpl
503500
return;
504501
}
505502

503+
// Assign to break a possible infinite recursion during computing.
504+
_constructors = const <ConstructorElementImpl>[];
505+
506506
var superElement = superType.element as ClassElementImpl;
507507

508508
var constructorsToForward = superElement.constructors

pkg/analyzer/test/src/summary/elements/class_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26355,6 +26355,18 @@ library
2635526355
''');
2635626356
}
2635726357

26358+
test_classAlias_constructors_beforeOtherProperties() async {
26359+
// https://github.com/dart-lang/sdk/issues/57035
26360+
var library = await buildLibrary('''
26361+
abstract mixin class A {}
26362+
mixin M {}
26363+
class X = A with M;
26364+
''');
26365+
26366+
var X = library.getClass('X')!;
26367+
expect(X.constructors, hasLength(1));
26368+
}
26369+
2635826370
test_classAlias_constructors_default() async {
2635926371
var library = await buildLibrary('''
2636026372
class A {}

0 commit comments

Comments
 (0)