Skip to content

Commit 3a4c889

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Add a test case demonstrating #32290.
Change-Id: Ic8513a5ee1fb9de0d3e71a06f85d5bfb60024d1f Reviewed-on: https://dart-review.googlesource.com/43481 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent 53d0203 commit 3a4c889

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ class ResynthesizeAstStrongTest extends _ResynthesizeAstTest {
6262
AnalysisOptionsImpl createOptions() =>
6363
super.createOptions()..strongMode = true;
6464

65+
@failingTest // See dartbug.com/32290
66+
test_const_constructor_inferred_args() =>
67+
test_const_constructor_inferred_args();
68+
6569
@override
6670
@failingTest
6771
test_instantiateToBounds_functionTypeAlias_simple() async {

pkg/analyzer/test/src/summary/resynthesize_common.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,41 @@ final dynamic f;
24742474
}
24752475
}
24762476

2477+
test_const_constructor_inferred_args() async {
2478+
if (!isStrongMode) return;
2479+
var library = await checkLibrary('''
2480+
class C<T> {
2481+
final T t;
2482+
const C(this.t);
2483+
const C.named(this.t);
2484+
}
2485+
const Object x = const C(0);
2486+
const Object y = const C.named(0);
2487+
''');
2488+
checkElementText(library, '''
2489+
class C<T> {
2490+
final T t;
2491+
const C(T this.t);
2492+
const C.named(T this.t);
2493+
}
2494+
const Object x = const
2495+
C/*location: test.dart;C*/(0);
2496+
const Object y = const
2497+
C/*location: test.dart;C*/.
2498+
named/*location: test.dart;C;named*/(0);
2499+
''');
2500+
TopLevelVariableElementImpl x =
2501+
library.definingCompilationUnit.topLevelVariables[0];
2502+
InstanceCreationExpression xExpr = x.constantInitializer;
2503+
var xType = xExpr.constructorName.staticElement.returnType;
2504+
expect(xType.toString(), 'C<int>');
2505+
TopLevelVariableElementImpl y =
2506+
library.definingCompilationUnit.topLevelVariables[0];
2507+
InstanceCreationExpression yExpr = y.constantInitializer;
2508+
var yType = yExpr.constructorName.staticElement.returnType;
2509+
expect(yType.toString(), 'C<int>');
2510+
}
2511+
24772512
test_const_finalField_hasConstConstructor() async {
24782513
var library = await checkLibrary(r'''
24792514
class C {

pkg/analyzer/test/src/summary/resynthesize_kernel_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ class C {
147147
await super.test_class_type_parameters_bound();
148148
}
149149

150+
@failingTest // See dartbug.com/32290
151+
test_const_constructor_inferred_args() =>
152+
test_const_constructor_inferred_args();
153+
150154
@failingTest
151155
@FastaProblem('https://github.com/dart-lang/sdk/issues/30258')
152156
test_constructor_redirected_factory_named_generic() async {

0 commit comments

Comments
 (0)