Macro. Issue 55931. Failing test for adding 'extends' and then new type.

Bug: https://github.com/dart-lang/sdk/issues/55931
Change-Id: Iaf7f147b1d710d55f70ecaa2d26a8c2f88fd4afe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371781
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2024-06-14 21:11:59 +00:00 committed by Commit Queue
parent 2e9bd8a967
commit 9d642f43fe
2 changed files with 59 additions and 2 deletions

View file

@ -182,10 +182,11 @@ Future<List<Object>> resolveIdentifiers(
const DeclareType.named(this.name, this.code);
@override
buildTypesForClass(clazz, builder) {
buildTypesForClass(clazz, builder) async {
var parts = await resolveIdentifiers(builder, code);
builder.declareType(
name,
DeclarationCode.fromString(code),
DeclarationCode.fromParts(parts),
);
}
}

View file

@ -6153,6 +6153,62 @@ abstract class MacroElementsTest extends MacroElementsBaseTest {
@override
bool get retainDataForTesting => true;
@FailingTest(
issue: 'https://github.com/dart-lang/sdk/issues/55931',
reason: r'''
Here we apply `SetExtendsType` first, so `augment class B` is first.
Then we apply `DeclareType`, so `class C @113` is next.
But the actual merged code has the different order.
Note, that the code below has the _expected_ merged code.
''',
)
test_addClass_extendsTypeOther() async {
var library = await buildLibrary(r'''
import 'append.dart';
class A {}
@DeclareType('C', 'class C {}')
@SetExtendsType('{{package:test/test.dart@A}}', [])
class B {}
''');
configuration
..withConstructors = false
..withMetadata = false;
checkElementText(library, r'''
library
imports
package:test/append.dart
definingUnit
classes
class A @29
class B @125
augmentation: self::@augmentation::package:test/test.macro.dart::@classAugmentation::B
supertype: A
augmented
augmentationImports
package:test/test.macro.dart
macroGeneratedCode
---
augment library 'package:test/test.dart';
import 'package:test/test.dart' as prefix0;
augment class B extends prefix0.A {
}
class C {}
---
imports
package:test/test.dart as prefix0 @78
definingUnit
classes
augment class B @94
augmentationTarget: self::@class::B
class C @113
''');
}
test_disable_declarationsPhase() async {
var library = await buildLibrary(r'''
// @dart = 3.2