dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.58k forks source link

Dart Analysis Server server crashed on generics refactor #57058

Open Solido opened 1 week ago

Solido commented 1 week ago

Flutter master.

I’m working on a project that structure around a core class:

sealed class Operation<T, C, R> Everything was working well but I found a solution to simplify to <T, R>

The moment I started the refactor I got this log analyze crashed living whole source no more traversable.

Restarting the server crash it after 5 tentatives.
[19:45:28] [Analyzer] [Error] [Bad state: Empty path: []
#0      InterfaceLeastUpperBoundHelper._computeTypeAtMaxUniqueDepth (package:analyzer/src/dart/element/least_upper_bound.dart:314:5)
#1      InterfaceLeastUpperBoundHelper._computeLeastUpperBound (package:analyzer/src/dart/element/least_upper_bound.dart:176:12)
#2      InterfaceLeastUpperBoundHelper.compute (package:analyzer/src/dart/element/least_upper_bound.dart:103:18)
#3      LeastUpperBoundHelper.getLeastUpperBound (package:analyzer/src/dart/element/least_upper_bo…

Current status is I've been able to complete the refactor by hand, grep and memory so I'm not sure what was triggering this crash as the code base is as deep as wide.

The main culprit seems around a Mixin without generics (dynamic) on Operation<T, C, R> A warning was thrown before crash that sub classes cannot implement both the typed and generic methods.

I'm sorry I can not pinpoint more precisely the root cause to reproduce it.

Some more not much actionnables hints but maybe helpful:

I was able to start the conversion starting by the leaf-classes and then trying to go up in the hierarchy. Changing the root class generic, removing C, was my last operation to have it work.

Starting the refactor by the root class nearly instantly kill the analyzer.

Dear analyzer team, you have all my gratitude for this tool. I've never felt so alone with my own code than when it is not active anymore... ;)

dart-github-bot commented 1 week ago

Summary: The Dart analysis server crashes when refactoring a sealed class with generics, specifically when removing a generic type parameter. The crash occurs after the user attempts to refactor a mixin without generics that extends the generic class.

bwilkerson commented 1 week ago

@scheglov

scheglov commented 1 week ago

Noted, but I was not able to reproduce it.