flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Hot reload fails with annotations on typed required arguments

Open tjarvstrand opened this issue 3 years ago • 1 comments

Hot reload fails with the message "Reload not performed. Analysis issues found (view issues)" when using an annotation on a required typed argument.

Steps to Reproduce

Here's a minimal failing example: https://github.com/tjarvstrand/reloadbug

Just start it, and change something to trigger hot reload. It fails, even though there are no issues and doing a hot restart works fine.

The issue is with this piece of code:

const MyHomePage({super.key, @PathParam('title') required String title}) : title = title;

Meanwhile, all of the below examples work and reload properly

const MyHomePage({super.key, @PathParam('title') required this.title});
const MyHomePage({super.key, @PathParam('title') required title}) : title = title;
const MyHomePage({super.key, @PathParam('title') String title = ''}) : title = title;

Version info

IntelliJ plugins:

  • dart 212.5744
  • flutter 70.0.2
[✓] Flutter (Channel stable, 3.0.5, on Ubuntu 21.04 5.11.0-49-generic, locale en_US.UTF-8)
    • Flutter version 3.0.5 at /home/tjarvstrand/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (9 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    • Android SDK at /home/tjarvstrand/Android/Sdk
    • Platform android-31, build-tools 33.0.0-rc1
    • ANDROID_HOME = /home/tjarvstrand/Android/Sdk
    • Java binary at: /usr/local/lib/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /usr/local/lib/android-studio
    • Flutter plugin version 69.0.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.2)
    • IntelliJ at /usr/local/lib/idea
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code
    • VS Code at /snap/code/current
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • SM G965F (mobile) • 22a8d9b4660b7ece • android-arm64  • Android 10 (API 29)
    • Linux (desktop)   • linux            • linux-x64      • Ubuntu 21.04 5.11.0-49-generic
    • Chrome (web)      • chrome           • web-javascript • Google Chrome 105.0.5195.125

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

tjarvstrand avatar Sep 17 '22 10:09 tjarvstrand

Thanks for the detailed report! I was easily able to run the IDE in a debugger and find the culprit. This is actually due to a bug in the Dart parser that's in the Dart plugin. I created an issue for it: https://youtrack.jetbrains.com/issue/IDEA-302067/Dart-Invalid-error-reported-from-PSI-parser

This issue can be closed but I'll leave it open for a bit in case others hit the same problem.

stevemessick avatar Sep 19 '22 22:09 stevemessick

The Dart plugin with the fix has been published, please update.

alexander-doroshko avatar Sep 28 '22 17:09 alexander-doroshko

Thanks, @alexander-doroshko !

stevemessick avatar Sep 28 '22 17:09 stevemessick