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

Attempting to use new `mixin` syntax crashes analyzer #34563

Closed
yjbanov opened this issue Sep 24, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@yjbanov
Copy link

commented Sep 24, 2018

Exception from analysis server (running from VSCode / Dart Code)

What I was doing

I was attempting to use the new mixin syntax. For example, open object.dart in Flutter and try changing the declaration of RenderObjectWithChildMixin from abstract class to mixin. The analyzer will crash in an instant.

Versions

  • Flutter SDK 0.4.3-pre.1162
  • Visual Studio Code 1.27.1
  • Dart Code 2.18.0

Analyzer Info

The analyzer was launched using the arguments:

/home/yjbanov/code/flutter/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot
--client-id=Dart-Code.dart-code
--client-version=2.18.0

Exception

Exception while using a UnrelatedTypeEqualityChecks to visit a BinaryExpressionImpl in AssertStatementImpl in BlockImpl in BlockFunctionBodyImpl in MethodDeclarationImpl in ClassDeclarationImpl in CompilationUnitImpl

NoSuchMethodError: The method 'substitute2' was called on null.
Receiver: null
Tried calling: substitute2(_List len:1, _List len:1)
#0      Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
#1      InterfaceTypeImpl.isDirectSupertypeOf (package:analyzer/src/dart/element/type.dart:1508:27)
#2      InterfaceTypeImpl.isMoreSpecificThan (package:analyzer/src/dart/element/type.dart:1591:16)
#3      DartTypeUtilities.unrelatedTypes (package:linter/src/util/dart_type_utilities.dart:218:18)
#4      _hasNonComparableOperands (package:linter/src/rules/unrelated_type_equality_checks.dart:152:25)
#5      _Visitor.visitBinaryExpression (package:linter/src/rules/unrelated_type_equality_checks.dart:190:9)
#6      BinaryExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:1116:49)
#7      LinterVisitor._runSubscriptions (package:analyzer/src/lint/linter_visitor.dart:671:14)
#8      LinterVisitor.visitBinaryExpression (package:analyzer/src/lint/linter_visitor.dart:53:5)
#9      BinaryExpressionImpl.accept (package:analyzer/src/dart/ast/ast.dart:1116:49)
#10     AssertStatementImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:695:17)
#11     RecursiveAstVisitor.visitAssertStatement (package:analyzer/dart/ast/visitor.dart:630:10)
#12     LinterVisitor.visitAssertStatement (package:analyzer/src/lint/linter_visitor.dart:36:11)
#13     AssertStatementImpl.accept (package:analyzer/src/dart/ast/ast.dart:691:49)
#14     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:8304:20)
#15     BlockImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1254:17)
#16     RecursiveAstVisitor.visitBlock (package:analyzer/dart/ast/visitor.dart:654:10)
#17     LinterVisitor.visitBlock (package:analyzer/src/lint/linter_visitor.dart:60:11)
#18     BlockImpl.accept (package:analyzer/src/dart/ast/ast.dart:1250:49)
#19     BlockFunctionBodyImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1199:13)
#20     RecursiveAstVisitor.visitBlockFunctionBody (package:analyzer/dart/ast/visitor.dart:660:10)
#21     LinterVisitor.visitBlockFunctionBody (package:analyzer/src/lint/linter_visitor.dart:66:11)
#22     BlockFunctionBodyImpl.accept (package:analyzer/src/dart/ast/ast.dart:1195:49)
#23     MethodDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:7695:12)
#24     RecursiveAstVisitor.visitMethodDeclaration (package:analyzer/dart/ast/visitor.dart:1014:10)
#25     LinterVisitor.visitMethodDeclaration (package:analyzer/src/lint/linter_visitor.dart:420:11)
#26     MethodDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:7686:49)
#27     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:8304:20)
#28     ClassDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:1795:13)
#29     RecursiveAstVisitor.visitClassDeclaration (package:analyzer/dart/ast/visitor.dart:690:10)
#30     LinterVisitor.visitClassDeclaration (package:analyzer/src/lint/linter_visitor.dart:96:11)
#31     ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1765:49)
#32     NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:8304:20)
#33     CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2437:21)
#34     RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:714:10)
#35     LinterVisitor.visitCompilationUnit (package:analyzer/src/lint/linter_visitor.dart:120:11)
#36     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2430:49)
#37     LibraryAnalyzer._computeLints (package:analyzer/src/dart/analysis/library_analyzer.dart:269:10)
#38     LibraryAnalyzer._analyze.<anonymous closure>.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:139:13)
#39     __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.forEach (dart:collection/runtime/libcompact_hash.dart:370:8)
#40     LibraryAnalyzer._analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:138:17)
#41     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:210:15)
#42     LibraryAnalyzer._analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:137:37)
#43     LibraryAnalyzer.analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:78:14)
<asynchronous suspension>
#44     _PerformanceTagImpl.makeCurrentWhileAsync (package:analyzer/src/generated/utilities_general.dart:222:21)
<asynchronous suspension>
#45     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:77:43)
<asynchronous suspension>
#46     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1244:71)
<asynchronous suspension>
#47     PerformanceLog.runAsync (package:front_end/src/base/performance_logger.dart:52:21)
<asynchronous suspension>
#48     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1220:20)
<asynchronous suspension>
#49     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1046:39)
<asynchronous suspension>
#50     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:1916:24)
<asynchronous suspension>
#51     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:1857:5)
#52     new AnalysisServer (package:analysis_server/src/analysis_server.dart:397:29)
#53     SocketServer.createAnalysisServer (package:analysis_server/src/socket_server.dart:81:26)
#54     StdioAnalysisServer.serveStdio (package:analysis_server/src/server/stdio_server.dart:37:18)
#55     Driver.start.<anonymous closure> (package:analysis_server/src/server/driver.dart:504:21)
#56     _rootRun (dart:async/zone.dart:1124:13)
#57     _CustomZone.run (dart:async/zone.dart:1021:19)
#58     _runZoned (dart:async/zone.dart:1516:10)
#59     runZoned (dart:async/zone.dart:1463:12)
#60     Driver._captureExceptions (package:analysis_server/src/server/driver.dart:550:12)
#61     Driver.start (package:analysis_server/src/server/driver.dart:502:7)
#62     main (file:///b/build/slave/Linux_Engine/build/src/third_party/dart/pkg/analysis_server/bin/server.dart:12:11)
#63     _AsyncAwaitCompleter.start (dart:async/runtime/libasync_patch.dart:49:6)
#64     main (file:///b/build/slave/Linux_Engine/build/src/third_party/dart/pkg/analysis_server/bin/server.dart:10:10)
#65     _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:287:32)
#66     _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

Diagnostics requested after the error occurred are:

[
    {
        "name": "/home/yjbanov/code/flutter/flutter/packages/flutter",
        "explicitFileCount": 895,
        "implicitFileCount": 1476,
        "workItemQueueLength": 819,
        "cacheEntryExceptions": []
    }
]

@stereotype441 @JekCharlsonYu @leafpetersen

@yjbanov

This comment has been minimized.

Copy link
Author

commented Sep 24, 2018

To narrow it down a bit, the analyzer is able to recover once the declaration is fully finished.

This line causes the crash:

mixin RenderObjectWithChildMixin<ChildType extends RenderObject> extends RenderObject {
//                                                               ^
//                                                        not yet converted to `on`

However, after changing extends to on, the analyzer is happy:

mixin RenderObjectWithChildMixin<ChildType extends RenderObject> on RenderObject {

@stereotype441 stereotype441 added this to the Dart2.1 milestone Sep 24, 2018

@scheglov scheglov self-assigned this Sep 24, 2018

@bwilkerson

This comment has been minimized.

Copy link
Member

commented Sep 24, 2018

Looks like there are a couple of issues:

  1. We should handle the case when there is no supertype.
  2. We might want to recover better when there's an extends clause. For example, it might make sense to treat it like part of the on clause.

@danrubel in case you're interested in the recovery piece.

@scheglov

This comment has been minimized.

Copy link
Contributor

commented Sep 24, 2018

dart-bot pushed a commit that referenced this issue Sep 24, 2018

Mixin declarations don't have supertype, fix isMoreSpecificThan().
R=brianwilkerson@google.com, paulberry@google.com

Bug: #34563
Change-Id: I0edcc887694e895856cb262865b8ec61976bafad
Reviewed-on: https://dart-review.googlesource.com/76281
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>

@scheglov scheglov closed this Sep 24, 2018

@bwilkerson

This comment has been minimized.

Copy link
Member

commented Sep 24, 2018

Re-opening for the recovery work.

@scheglov

This comment has been minimized.

Copy link
Contributor

commented Sep 24, 2018

@scheglov

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2018

The fix for the crash landed.
I'm going to remove Crash and P1 tags, because recovery is not a P1 work IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.