Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration tool throws exception with "nested extensions" #45902

Closed
DreadBoy opened this issue May 4, 2021 · 2 comments
Closed

Migration tool throws exception with "nested extensions" #45902

DreadBoy opened this issue May 4, 2021 · 2 comments
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). P2 A bug or feature request we're likely to work on

Comments

@DreadBoy
Copy link

DreadBoy commented May 4, 2021

I'm trying to migrate my project to null-safety with migration tool but it throws exception in one of my files. I assume it has problems with "nested extensions", I've included repro case below. When I run migration with dart migrate --skip-import-check I get this error:

# fvm dart migrate --skip-import-check
Migrating [app]

See https://dart.dev/go/null-safety-migration for a migration guide.

Note: more than one project found; migrating the top-level project.

Analyzing project...
Warning: package has unmigrated dependencies.

Continuing due to the presence of `--skip-import-check`.  To see a complete
list of the unmigrated dependencies, re-run without the `--skip-import-check`
flag.

No analysis issues found.

Generating migration suggestions...
Aborting migration due to an exception.  This most likely is due to a
bug in the migration tool.  Please consider filing a bug report at:

https://github.com/dart-lang/sdk/issues/new
Please include the SDK version (2.12.2) in your bug report.

To attempt to perform migration anyway, you may re-run with
--ignore-exceptions.

Exception details:

Bad state: Unrelated types: class Object and abstract class Iterable<E> at offset 335 in [app]\lib\utils\test.dart (myClass.valueOrNull?.mapIndexed((e, i) => e))

#0      DecoratedClassHierarchy.getDecoratedSupertype (package:nnbd_migration/src/decorated_class_hierarchy.dart:67:10)
#1      DecoratedClassHierarchy.asInstanceOf (package:nnbd_migration/src/decorated_class_hierarchy.dart:38:18)
#2      EdgeBuilder.getOrComputeElementType (package:nnbd_migration/src/edge_builder.dart:270:18)
#3      EdgeBuilder.visitMethodInvocation (package:nnbd_migration/src/edge_builder.dart:1284:20)
#4      MethodInvocationImpl.accept (package:analyzer/src/dart/ast/ast.dart:7186:49)
#5      EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#6      EdgeBuilder._handleAssignment (package:nnbd_migration/src/edge_builder.dart:2329:20)
#7      EdgeBuilder.visitVariableDeclarationList (package:nnbd_migration/src/edge_builder.dart:1924:11)
#8      VariableDeclarationListImpl.accept (package:analyzer/src/dart/ast/ast.dart:10655:15)
#9      EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#10     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#11     GeneralizingAstVisitor.visitStatement (package:analyzer/dart/ast/visitor.dart:517:39)
#12     GeneralizingAstVisitor.visitVariableDeclarationStatement (package:analyzer/dart/ast/visitor.dart:589:7)
#13     VariableDeclarationStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:10705:15)
#14     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#15     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#16     GeneralizingAstVisitor.visitStatement (package:analyzer/dart/ast/visitor.dart:517:39)
#17     GeneralizingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:165:31)
#18     BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1083:49)
#19     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#20     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#21     GeneralizingAstVisitor.visitFunctionBody (package:analyzer/dart/ast/visitor.dart:324:45)
#22     GeneralizingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:168:55)
#23     BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1038:49)
#24     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#25     EdgeBuilder.visitFunctionExpression.<anonymous closure> (package:nnbd_migration/src/edge_builder.dart:937:25)
#26     ScopedSet.doScoped (package:nnbd_migration/src/utilities/scoped_set.dart:44:13)
#27     EdgeBuilder.visitFunctionExpression (package:nnbd_migration/src/edge_builder.dart:935:28)
#28     FunctionExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:5004:49)
#29     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#30     EdgeBuilder.visitFunctionDeclaration (package:nnbd_migration/src/edge_builder.dart:886:9)
#31     FunctionDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:4866:49)
#32     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#33     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#34     GeneralizingAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:202:51)
#35     CompletenessTracker.visitCompilationUnit.<anonymous closure> (package:nnbd_migration/src/utilities/completeness_tracker.dart:52:24)
#36     PermissiveModeVisitor.reportExceptionsIfPermissive (package:nnbd_migration/src/utilities/permissive_mode.dart:26:24)
#37     CompletenessTracker.visitCompilationUnit (package:nnbd_migration/src/utilities/completeness_tracker.dart:43:5)
#38     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
#39     NullabilityMigrationImpl.processInput (package:nnbd_migration/src/nullability_migration_impl.dart:244:12)
#40     NonNullableFix.processUnit (package:nnbd_migration/src/front_end/non_nullable_fix.dart:164:15)
#41     _FixCodeProcessor.runLaterPhases.<anonymous closure> (package:nnbd_migration/migration_cli.dart:1154:19)
#42     _FixCodeProcessor.runLaterPhases.<anonymous closure> (package:nnbd_migration/migration_cli.dart:1152:28)
#43     _FixCodeProcessor.processResources (package:nnbd_migration/migration_cli.dart:1081:30)
<asynchronous suspension>
#44     _FixCodeProcessor.runLaterPhases (package:nnbd_migration/migration_cli.dart:1152:5)
<asynchronous suspension>
#45     MigrationCliRunner.run (package:nnbd_migration/migration_cli.dart:749:24)
<asynchronous suspension>
#46     MigrateCommand.run (package:nnbd_migration/migration_cli.dart:185:7)
<asynchronous suspension>
#47     CommandRunner.runCommand (package:args/command_runner.dart:196:13)
<asynchronous suspension>
#48     DartdevRunner.runCommand (package:dartdev/dartdev.dart:199:18)
<asynchronous suspension>
#49     runDartdev (package:dartdev/dartdev.dart:53:16)
<asynchronous suspension>
#50     main (file:///C:/b/s/w/ir/cache/builder/src/third_party/dart/pkg/dartdev/bin/dartdev.dart:11:3)
<asynchronous suspension>

File that trips the migration tool:

class MyClass<T> {}

extension IterableX<E> on Iterable<E> {
  Iterable<T> mapIndexed<T>(T Function(E e, int i) f) {
    var i = 0;
    return this.map((e) => f(e, i++));
  }
}

extension MyClassX<T> on MyClass<T> {
  T get valueOrNull => null;
}

void main() {
  final myClass = MyClass<List<String>>();
  final list = myClass.valueOrNull?.mapIndexed((e, i) => e);
}

My system:

# dart --version
Dart SDK version: 2.12.2 (stable) (Wed Mar 17 10:30:20 2021 +0100) on "windows_x64"

# fvm flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel unknown, 2.0.4, on Microsoft Windows [Version 10.0.19042.964], locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Ultimate Edition (version 2021.1)
[√] Connected device (3 available)

! Doctor found issues in 1 category.
@lrhn lrhn added the area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). label May 4, 2021
@stereotype441
Copy link
Member

Possibly reelated to #45206

@stereotype441 stereotype441 added the P2 A bug or feature request we're likely to work on label May 4, 2021
@stereotype441
Copy link
Member

As of 1c7fe71, the null safety migration tool has been removed from active development and retired. No further work on the tool is planned.

If you still need help, or you believe this issue has been closed in error, please feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

3 participants