Skip to content

Commit

Permalink
Issue 54362. Allow importing lower case named types.
Browse files Browse the repository at this point in the history
Bug: #54362
Change-Id: I59359262bee28eb55d2e0220750f1d7628293d96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356661
Reviewed-by: Keerti Parthasarathy <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Mar 11, 2024
1 parent b9b341f commit edd875c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,17 @@ class ImportLibrary extends MultiCorrectionProducer {
@override
String? nameOfType(AstNode node) {
final parent = node.parent;
if (node is NamedType) {
final importPrefix = node.importPrefix;
if (parent is ConstructorName && importPrefix != null) {
return importPrefix.name.lexeme;
}
return node.name2.lexeme;
} else if (node is PrefixedIdentifier) {
if (parent is NamedType) {
return node.prefix.name;
}
switch (node) {
case NamedType():
final importPrefix = node.importPrefix;
if (parent is ConstructorName && importPrefix != null) {
return importPrefix.name.lexeme;
}
return node.name2.lexeme;
case SimpleIdentifier():
return node.name;
}
return super.nameOfType(node);
return null;
}

void _importExtensionInLibrary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,24 @@ void f(Test t) {}
''', target: b.path);
}

Future<void> test_withClass_simpleIdentifier_lowerCase() async {
newFile('$testPackageLibPath/lib.dart', '''
class eX {}
''');
await resolveTestCode('''
void f() {
eX;
}
''');
await assertHasFix('''
import 'package:test/lib.dart';
void f() {
eX;
}
''');
}

Future<void> test_withExtension_pub_this() async {
updateTestPubspecFile(r'''
name: test
Expand Down

0 comments on commit edd875c

Please sign in to comment.