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

Exception in StrongTypeSystemImpl.functionTypeToConcreteType #27133

Closed
scheglov opened this issue Aug 22, 2016 · 10 comments
Closed

Exception in StrongTypeSystemImpl.functionTypeToConcreteType #27133

scheglov opened this issue Aug 22, 2016 · 10 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@scheglov
Copy link
Contributor

I was typing

  AnalysisContext get context => null;

  Index createIndex() {
    return null;
  }

in pkg/analysis_server/test/analysis_abstract.dart.

Somewhere after typing AnalysisContext it throws an exception.

Dart analysis server, SDK version 1.20.0-edge.4d4ebafad3f735b3d69360370b163f4e79d229ba, server version 1.15.0, error: Task failed: VerifyUnitTask for source /Users/scheglov/Source/Dart/sdk.git/sdk/pkg/analysis_server/test/plugin/set_analysis_domain_test.dart
Unexpected exception while performing VerifyUnitTask for source /Users/scheglov/Source/Dart/sdk.git/sdk/pkg/analysis_server/test/plugin/set_analysis_domain_test.dart
#0      AnalysisTask._safelyPerform (package:analyzer/task/model.dart:350:7)
#1      AnalysisTask.perform (package:analyzer/task/model.dart:238:7)
#2      AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
#3      AnalysisDriver.performAnalysisTask (package:analyzer/src/task/driver.dart:255:11)
#4      AnalysisContextImpl.performAnalysisTask.<anonymous closure> (package:analyzer/src/context/context.dart:1231:27)
#5      _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212:15)
#6      AnalysisContextImpl.performAnalysisTask (package:analyzer/src/context/context.dart:1229:50)
#7      PerformAnalysisOperation.perform (package:analysis_server/src/operation/operation_analysis.dart:371:37)
#8      AnalysisServer.performOperation (package:analysis_server/src/analysis_server.dart:892:17)
#9      Future.Future.<anonymous closure> (dart:async/future.dart:118)
#10     _rootRun (dart:async/zone.dart:1146)
#11     _CustomZone.run (dart:async/zone.dart:1026)
#12     _CustomZone.runGuarded (dart:async/zone.dart:924)
#13     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
#14     _rootRun (dart:async/zone.dart:1150)
#15     _CustomZone.run (dart:async/zone.dart:1026)
#16     _CustomZone.runGuarded (dart:async/zone.dart:924)
#17     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
#18     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:16)
#19     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:385)
#20     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
#21     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

Caused by The null object does not have a getter 'isDynamic'.

NoSuchMethodError: method not found: 'isDynamic'
Receiver: null
Arguments: []
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:44)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:47)
#2      StrongTypeSystemImpl.functionTypeToConcreteType.<anonymous closure> (package:analyzer/src/generated/type_system.dart:93:41)
#3      Object&ListMixin.any (dart:collection/list.dart:115)
#4      StrongTypeSystemImpl.functionTypeToConcreteType (package:analyzer/src/generated/type_system.dart:93:23)
#5      StrongTypeSystemImpl.typeToConcreteType (package:analyzer/src/generated/type_system.dart:460:14)
#6      ErrorVerifier._checkForNonAbstractClassInheritsAbstractMember (package:analyzer/src/generated/error_verifier.dart:4731:27)
#7      ErrorVerifier.visitClassDeclaration (package:analyzer/src/generated/error_verifier.dart:465:11)
#8      ClassDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:1847:15)
#9      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7688:20)
#10     CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2446:21)
#11     RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:1449:10)
#12     ErrorVerifier.visitCompilationUnit (package:analyzer/src/generated/error_verifier.dart:548:38)
#13     CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2439:15)
#14     VerifyUnitTask.internalPerform (package:analyzer/src/task/dart.dart:6454:10)
#15     AnalysisTask._safelyPerform (package:analyzer/task/model.dart:338:9)
#16     AnalysisTask.perform (package:analyzer/task/model.dart:238:7)
#17     AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:284:10)
#18     AnalysisDriver.performAnalysisTask (package:analyzer/src/task/driver.dart:255:11)
#19     AnalysisContextImpl.performAnalysisTask.<anonymous closure> (package:analyzer/src/context/context.dart:1231:27)
#20     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212:15)
#21     AnalysisContextImpl.performAnalysisTask (package:analyzer/src/context/context.dart:1229:50)
#22     PerformAnalysisOperation.perform (package:analysis_server/src/operation/operation_analysis.dart:371:37)
#23     AnalysisServer.performOperation (package:analysis_server/src/analysis_server.dart:892:17)
#24     Future.Future.<anonymous closure> (dart:async/future.dart:118)
#25     _rootRun (dart:async/zone.dart:1146)
#26     _CustomZone.run (dart:async/zone.dart:1026)
#27     _CustomZone.runGuarded (dart:async/zone.dart:924)
#28     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
#29     _rootRun (dart:async/zone.dart:1150)
#30     _CustomZone.run (dart:async/zone.dart:1026)
#31     _CustomZone.runGuarded (dart:async/zone.dart:924)
#32     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:951)
#33     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:16)
#34     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:385)
#35     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:414)
#36     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)


java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:132)
    at com.jetbrains.lang.dart.analyzer.DartAnalysisServerService$1.serverError(DartAnalysisServerService.java:216)
    at com.google.dart.server.internal.BroadcastAnalysisServerListener.serverError(BroadcastAnalysisServerListener.java:180)
    at com.google.dart.server.internal.remote.processor.NotificationServerErrorProcessor.process(NotificationServerErrorProcessor.java:37)
    at com.google.dart.server.internal.remote.RemoteAnalysisServerImpl.processNotification(RemoteAnalysisServerImpl.java:502)
    at com.google.dart.server.internal.remote.RemoteAnalysisServerImpl.processResponse(RemoteAnalysisServerImpl.java:517)
    at com.google.dart.server.internal.remote.RemoteAnalysisServerImpl.access$600(RemoteAnalysisServerImpl.java:49)
    at com.google.dart.server.internal.remote.RemoteAnalysisServerImpl$ServerResponseReaderThread.run(RemoteAnalysisServerImpl.java:868)
@scheglov scheglov added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-strong-mode type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Aug 22, 2016
@bwilkerson bwilkerson added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Aug 22, 2016
@bwilkerson
Copy link
Member

@leafpetersen @jmesserly

@leafpetersen
Copy link
Member

Looks like the .type field on a ParameterElement is allowed to be null, and that code (and some other code in that file) assumes that it isn't. A bit surprising that the field is just null instead of being resolved to dynamic, but it is documented that way. I'll take a look.

@leafpetersen leafpetersen self-assigned this Aug 22, 2016
@jmesserly
Copy link

oh dear. elements with null types should not really happen. That's super bad because we rely on ParameterElement having a type in a ton of places.

@leafpetersen
Copy link
Member

@bwilkerson Any thoughts? Given that the documentation explicitly calls out that it might be null I'm hesitant to rely on it being non-null, but it does feel a bit off to me.

@jmesserly
Copy link

so I looked up those docs, that's for VariableElement (and I'm not sure if the doc is still true, but ignoring that). ParameterElement seems to always have a type filled in if you look in resolver.dart. Here's visitSimpleFormalParameter, but the others are similar:

  Object visitSimpleFormalParameter(SimpleFormalParameter node) {
    super.visitSimpleFormalParameter(node);
    DartType declaredType;
    TypeName typeName = node.type;
    if (typeName == null) {
      declaredType = _dynamicType;
    } else {
      declaredType = _typeNameResolver._getType(typeName);
    }
    Element element = node.identifier.staticElement;
    if (element is ParameterElementImpl) {
      element.type = declaredType;
    } else {
      // TODO(brianwilkerson) Report the internal error.
    }
    return null;
  }

(_typeNameResolver._getType returns typeName.type ?? undefinedType so it always returns a non-null value)

@jmesserly
Copy link

and the doc claims:

  /**
   * Return the declared type of this variable, or `null` if the variable did
   * not have a declared type (such as if it was declared using the keyword
   * 'var').
   */

but that's not what the code seems to do anymore, even for variables.

@bwilkerson
Copy link
Member

I think it would be better if type were never null anywhere, but I'd have to try to figure out why we allowed it anywhere before I could say it was safe / reasonable.

@scheglov scheglov assigned scheglov and unassigned leafpetersen Aug 23, 2016
@scheglov
Copy link
Contributor Author

I found why this happens.
It has nothing to do with strong mode.
Will fix it soon.

@scheglov
Copy link
Contributor Author

@scheglov
Copy link
Contributor Author

23bc00b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P1 A high priority bug; for example, a single project is unusable or has many test failures type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants