Skip to content

dart migrate exception: A decorated type for the bound of T should have been stored by the NodeBuilder #45470

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

Closed
kluverua opened this issue Mar 25, 2021 · 8 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

@kluverua
Copy link

kluverua commented Mar 25, 2021

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

Got this error while migrating my project using the dart migrate utility:
My class: approvals_bloc.dart

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: A decorated type for the bound of T should have been stored by the NodeBuilder via recordTypeParameterBound 
at offset 2223 in C:\app\lib\blocs\approval\approvals_bloc.dart (..onItemsImported = _onItemsImported)

#0      Variables.decoratedTypeParameterBound (package:nnbd_migration/src/variables.dart:138:9)
#1      EdgeBuilder._getTypeParameterTypeBound (package:nnbd_migration/src/edge_builder.dart:2258:10)
#2      _AssignmentChecker._checkAssignment_recursion (package:nnbd_migration/src/edge_builder.dart:3470:21)
#3      _AssignmentChecker._checkAssignment (package:nnbd_migration/src/edge_builder.dart:3373:5)
#4      _AssignmentChecker._checkAssignment_recursion (package:nnbd_migration/src/edge_builder.dart:3488:9)
#5      _AssignmentChecker._checkAssignment (package:nnbd_migration/src/edge_builder.dart:3373:5)
#6      _AssignmentChecker._checkAssignment_recursion (package:nnbd_migration/src/edge_builder.dart:3513:9)
#7      _AssignmentChecker._checkAssignment (package:nnbd_migration/src/edge_builder.dart:3373:5)
#8      EdgeBuilder._handleAssignment (package:nnbd_migration/src/edge_builder.dart:2398:11)
#9      EdgeBuilder.visitAssignmentExpression (package:nnbd_migration/src/edge_builder.dart:409:26)
#10     AssignmentExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:715:49)
#11     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#12     EdgeBuilder._dispatchList (package:nnbd_migration/src/edge_builder.dart:2229:7)
#13     EdgeBuilder.visitCascadeExpression (package:nnbd_migration/src/edge_builder.dart:552:7)
#14     CascadeExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:1253:49)
#15     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#16     EdgeBuilder.visitExpressionStatement (package:nnbd_migration/src/edge_builder.dart:801:25)
#17     ExpressionStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:3676:49)
#18     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#19     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#20     GeneralizingAstVisitor.visitStatement (package:analyzer/dart/ast/visitor.dart:517:39)
#21     GeneralizingAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:165:31)
#22     BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1083:49)
#23     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#24     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#25     GeneralizingAstVisitor.visitFunctionBody (package:analyzer/dart/ast/visitor.dart:324:45)
#26     GeneralizingAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:168:55)
#27     BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1038:49)
#28     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#29     EdgeBuilder._handleExecutableDeclaration (package:nnbd_migration/src/edge_builder.dart:2488:7)
#30     EdgeBuilder.visitConstructorDeclaration (package:nnbd_migration/src/edge_builder.dart:712:5)
#31     ConstructorDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:2566:15)
#32     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#33     EdgeBuilder._dispatchList (package:nnbd_migration/src/edge_builder.dart:2229:7)
#34     EdgeBuilder.visitClassOrMixinOrExtensionDeclaration (package:nnbd_migration/src/edge_builder.dart:607:7)
#35     EdgeBuilder.visitClassDeclaration (package:nnbd_migration/src/edge_builder.dart:574:5)
#36     ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1536:49)
#37     EdgeBuilder._dispatch (package:nnbd_migration/src/edge_builder.dart:2207:24)
#38     EdgeBuilder.visitNode (package:nnbd_migration/src/edge_builder.dart:1340:9)
#39     GeneralizingAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:202:51)
#40     CompletenessTracker.visitCompilationUnit.<anonymous closure> (package:nnbd_migration/src/utilities/completeness_tracker.dart:52:24)
#41     PermissiveModeVisitor.reportExceptionsIfPermissive (package:nnbd_migration/src/utilities/permissive_mode.dart:26:24)
#42     CompletenessTracker.visitCompilationUnit (package:nnbd_migration/src/utilities/completeness_tracker.dart:43:5)
#43     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2134:49)
#44     NullabilityMigrationImpl.processInput (package:nnbd_migration/src/nullability_migration_impl.dart:244:12)
#45     NonNullableFix.processUnit (package:nnbd_migration/src/front_end/non_nullable_fix.dart:164:15)
#46     _FixCodeProcessor.runLaterPhases.<anonymous closure> (package:nnbd_migration/migration_cli.dart:1154:19)
#47     _FixCodeProcessor.runLaterPhases.<anonymous closure> (package:nnbd_migration/migration_cli.dart:1152:28)
#48     _FixCodeProcessor.processResources (package:nnbd_migration/migration_cli.dart:1081:30)
<asynchronous suspension>
#49     _FixCodeProcessor.runLaterPhases (package:nnbd_migration/migration_cli.dart:1152:5)
<asynchronous suspension>
#50     MigrationCliRunner.run (package:nnbd_migration/migration_cli.dart:749:24)
<asynchronous suspension>
#51     MigrateCommand.run (package:nnbd_migration/migration_cli.dart:185:7)
<asynchronous suspension>
#52     CommandRunner.runCommand (package:args/command_runner.dart:196:13)
<asynchronous suspension>
#53     DartdevRunner.runCommand (package:dartdev/dartdev.dart:199:18)
<asynchronous suspension>
#54     runDartdev (package:dartdev/dartdev.dart:53:16)
<asynchronous suspension>
#55     main (file:///C:/b/s/w/ir/cache/builder/src/third_party/dart/pkg/dartdev/bin/dartdev.dart:11:3)
<asynchronous suspension>

I think the error is in this method:

  // ignore: always_specify_types
  void _onItemsImported<ApprovalModel>(List items) {
    syncIndicatorBloc?.add(SyncFinished(SyncType.import));
    add(UpdateApprovalsFromCache(items));
  }

A long time ago there was another error in this method:
The argument type 'List<ApprovalModel>' can't be assigned to the parameter type 'List<ApprovalModel>'.
I solve it with workaround:

void _onItemsImported<ApprovalModel>(List<ApprovalModel> items) {

//replace with ====>

// ignore: always_specify_types
void _onItemsImported<ApprovalModel>(List items) {

Here is UpdateApprovalsFromCache class:

/// Event for obtaining approvals.
class UpdateApprovalsFromCache extends ApprovalEvent {
  /// Approvals.
  List<ApprovalModel> approvals;

  /// Creates instance.
  UpdateApprovalsFromCache(this.approvals);
}
@devoncarew devoncarew added the area-migration (deprecated) Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool). label Mar 25, 2021
@stereotype441
Copy link
Member

@kluverua thanks for the bug report! Were you able to make progress by rerunning migration with --ignore-exceptions?

@kluverua
Copy link
Author

Doh, forgot to mention that. Yes, it is over.
It converts my method to this:

// ignore: always_specify_types
  void _onItemsImported<ApprovalModel>(List items) {
    syncIndicatorBloc?.add(SyncFinished(SyncType.import));
    add(UpdateApprovalsFromCache(items as List<ApprovalModel>));
  }

And i get error:
The argument type 'List<ApprovalModel>' can't be assigned to the parameter type 'List<ApprovalModel>'.
And now I can't find a workaround for this in any way :(

Btw, here is UpdateApprovalsFromCache class in its entirety:
approval_event.dart

@kluverua
Copy link
Author

Now I think the error is not related to dart migration.
Should i write this error in this issue #32042 ?
Or create new issue?

@kluverua
Copy link
Author

kluverua commented Mar 27, 2021

Here is fix:

..onItemsImported = _onItemsImported
...
void _onItemsImported<T>(List<T> items) {
  syncIndicatorBloc?.add(SyncFinished(SyncType.import));
  add(UpdateApprovalsFromCache(items as List<ApprovalModel>));
}

@stereotype441
Copy link
Member

Hi @kluverua, thanks for all the information. I'm glad you were able to make progress with your migratoin! Unfortunately I haven't managed to reproduce the failure from the information you provided.

Do you think you understand what happened well enough that you could write a short isolated program that demonstrates it? (In other words, a short program that doesn't depend on any of your code but still fails to migrate in the same way. The program wouldn't have to do anything useful other than provoke the bug). If you could manage to do that, I would be happy to try to debug further.

@stereotype441 stereotype441 added the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Mar 30, 2021
@kluverua
Copy link
Author

kluverua commented Mar 30, 2021

Ok, if you really want it :)

typedef RepositoryItemsImported = void Function<T>(List<T> items);

abstract class Class1<T> {
  RepositoryItemsImported onItemsImported;
}

class Class2 extends Class1<String> {
  Class2() {
    onItemsImported = _onItemsImported;
  }

  void add(List<String> e) {
  }

  void _onItemsImported<String>(List items) {
    add(items);
  }
}

p.s. you can even delete type RepositoryItemsImported and get same error

@no-response no-response bot removed the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Mar 30, 2021
@stereotype441
Copy link
Member

@kluverua awesome, thank you! That reproduces the bug for me :)

@stereotype441 stereotype441 added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Mar 30, 2021
@stereotype441 stereotype441 added P2 A bug or feature request we're likely to work on and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Aug 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