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

CCE in LibraryUnit #345

Closed
bwilkerson opened this issue Nov 4, 2011 · 4 comments
Closed

CCE in LibraryUnit #345

bwilkerson opened this issue Nov 4, 2011 · 4 comments
Assignees

Comments

@bwilkerson
Copy link
Member

I don't have the steps to reproduce, but ran across the ClassCastException below. The code is assuming that a method name is always an identifier, but that is not true.


!SUBENTRY 1 com.google.dart.tools.core 4 0 2011-11-04 09:24:10.602
!MESSAGE Failed to parse file:/Users/brianwilkerson/dart/testing/b337.dart
!STACK 0
java.lang.ClassCastException: com.google.dart.compiler.ast.DartParameterizedNode cannot be cast to com.google.dart.compiler.ast.DartIdentifier
    at com.google.dart.compiler.ast.LibraryUnit$1.visitMethodDefinition(LibraryUnit.java:311)
    at com.google.dart.compiler.ast.LibraryUnit$1.visitMethodDefinition(LibraryUnit.java:1)
    at com.google.dart.compiler.ast.DartMethodDefinition.accept(DartMethodDefinition.java:90)
    at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
    at com.google.dart.compiler.ast.DartUnit.visitChildren(DartUnit.java:99)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitUnit(DartNodeTraverser.java:391)
    at com.google.dart.compiler.ast.LibraryUnit.populateTopLevelNodes(LibraryUnit.java:324)
    at com.google.dart.compiler.DartCompiler$Compiler.parseOutOfDateFiles(DartCompiler.java:286)
    at com.google.dart.compiler.DartCompiler$Compiler.updateAndResolve(DartCompiler.java:201)
    at com.google.dart.compiler.DartCompiler$Compiler.access$4(DartCompiler.java:190)
    at com.google.dart.compiler.DartCompiler.analyzeLibrary(DartCompiler.java:1165)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities.secureAnalyzeLibrary(DartCompilerUtilities.java:725)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities$ResolverRunnable.run(DartCompilerUtilities.java:421)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities$CompilerRunner.runSafe(DartCompilerUtilities.java:92)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities.resolveUnit(DartCompilerUtilities.java:708)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities.resolveUnit(DartCompilerUtilities.java:690)
    at com.google.dart.tools.core.internal.operation.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:126)
    at com.google.dart.tools.core.internal.operation.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:210)
    at com.google.dart.tools.core.internal.operation.DartModelOperation.run(DartModelOperation.java:374)
    at com.google.dart.tools.core.internal.operation.DartModelOperation.runOperation(DartModelOperation.java:441)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.reconcile(CompilationUnitImpl.java:1357)
    at com.google.dart.tools.ui.internal.text.dart.DartReconcilingStrategy$1.run(DartReconcilingStrategy.java:159)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at com.google.dart.tools.ui.internal.text.dart.DartReconcilingStrategy.reconcile(DartReconcilingStrategy.java:134)
    at com.google.dart.tools.ui.internal.text.dart.DartReconcilingStrategy.reconcile(DartReconcilingStrategy.java:102)
    at com.google.dart.tools.ui.internal.text.functions.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:93)
    at com.google.dart.tools.ui.internal.text.functions.DartCompositeReconcilingStrategy.reconcile(DartCompositeReconcilingStrategy.java:120)
    at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
    at com.google.dart.tools.ui.internal.text.functions.DartReconciler.process(DartReconciler.java:387)
    at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)

@scheglov
Copy link
Contributor

scheglov commented Nov 7, 2011

Set owner to @scheglov.
Added Started label.

@scheglov
Copy link
Contributor

scheglov commented Nov 9, 2011

It looks that main problem is that we allow parsing factory as library top level declaration.

factory foo<T>() {}

@bwilkerson
Copy link
Member Author

I would expect this to also be a problem if there is a constructor with a qualified name:

  class Point {
    Point.zero() {...}
  }

because the method's name (unless I'm misunderstanding) is "MyClass.factory", which can't be represented by a simple identifier.

@scheglov
Copy link
Contributor

scheglov commented Nov 9, 2011

I can not reproduce for constructor qualified name.
Original exception happens in LibraryUnit.populateTopLevelNodes() where it is really not expected to have method with qualified name.

OTOH MemberElementBuilder.buildConstructor() handles Class.name constructor name.

Fixed in trunk.
Now we will report such bad factory method just as normal top level DartMethodDefinition, without factory modifier. We will also mark it with error.


Added Fixed label.

nex3 pushed a commit that referenced this issue Aug 31, 2016
copybara-service bot pushed a commit that referenced this issue May 3, 2023
…, html, http, lints, markdown, matcher, mockito, path, protobuf, shelf, source_maps, source_span, sync_http, test, test_reflective_loader, tools, usage, vector_math, webdriver, webkit_inspection_protocol, yaml_edit

Revisions updated by `dart tools/rev_sdk_deps.dart`.

args (https://github.com/dart-lang/args/compare/5ac2ba1..1864048):
  1864048  2023-05-03  Devon Carew  added package topics to the pubspec file (#242)
  db229fb  2023-05-02  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#241)

bazel_worker (https://github.com/dart-lang/bazel_worker/compare/d5f8837..1b86d3c):
  1b86d3c  2023-05-02  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#72)

characters (https://github.com/dart-lang/characters/compare/b306414..2af6783):
  2af6783  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#81)

cli_util (https://github.com/dart-lang/cli_util/compare/6c318c2..7234f17):
  7234f17  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#82)

collection (https://github.com/dart-lang/collection/compare/9db854d..26e3e67):
  26e3e67  2023-05-03  Lasse R.H. Nielsen  Accept SDK version above 3.0. (#281)

file (https://github.com/google/file.dart/compare/72a67c3..b905180):
  b905180  2023-05-01  dependabot[bot]  Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#212)
  8158a35  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.3.0 to 3.5.2 (#218)

html (https://github.com/dart-lang/html/compare/0438b26..5d87dc8):
  5d87dc8  2023-05-03  Devon Carew  added package topics to the pubspec file (#215)

http (https://github.com/dart-lang/http/compare/877f134..f581ff7):
  f581ff7  2023-05-01  Nate Bosch  Prepare to publish (#914)
  fa53651  2023-05-01  Brian Quinlan  Document that RetryClient may consume a lot of memory (#915)

lints (https://github.com/dart-lang/lints/compare/ba7d75e..17276ec):
  17276ec  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#116)

markdown (https://github.com/dart-lang/markdown/compare/82b050d..6db8fc1):
  6db8fc1  2023-05-02  Jonas Finnemann Jensen  Prepare 7.1.0 (#538)

matcher (https://github.com/dart-lang/matcher/compare/7228c26..5890f2b):
  5890f2b  2023-05-01  Nate Bosch  Expand bound for `test_api` dependency (#219)

mockito (https://github.com/dart-lang/mockito/compare/beb45ba..56173fa):
  56173fa  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#626)

path (https://github.com/dart-lang/path/compare/23e3319..1552cfd):
  1552cfd  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#142)
  82ddc60  2023-05-01  Jonathan  fixed mistake in split method doc comment (#141)

protobuf (https://github.com/dart-lang/protobuf/compare/b90a4c4..9d7cf0d):
  9d7cf0d  2023-05-01  Kevin Moore  Update Github Actions (#827)

shelf (https://github.com/dart-lang/shelf/compare/9a792b4..79e3cee):
  79e3cee  2023-05-03  Devon Carew  add package topics for package:shelf_router_generator (#346)
  25861e5  2023-05-03  Devon Carew  add topics to the pubspec files (#345)

source_maps (https://github.com/dart-lang/source_maps/compare/0a4b030..f0a8506):
  f0a8506  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#77)

source_span (https://github.com/dart-lang/source_span/compare/905a167..69fa991):
  69fa991  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#97)

sync_http (https://github.com/dart-lang/sync_http/compare/660ad87..c3d6ad4):
  c3d6ad4  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#36)

test (https://github.com/dart-lang/test/compare/b252463..9484592):
  9484592a  2023-05-02  Nate Bosch  Prepare to publish checks (#2005)

test_reflective_loader (https://github.com/dart-lang/test_reflective_loader/compare/a85a930..d1b763f):
  d1b763f  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#48)

tools (https://github.com/dart-lang/tools/compare/516995e..b55f0d4):
  b55f0d4  2023-05-02  Elias Yishak  `pddFlag` removal + tests for pdd restricted instance of `Analytics` (#86)

usage (https://github.com/dart-lang/usage/compare/f97752f..929a4e3):
  929a4e3  2023-05-02  dependabot[bot]  Bump actions/checkout from 3.5.0 to 3.5.2 (#193)

vector_math (https://github.com/google/vector_math.dart/compare/7dec984..e3de8da):
  e3de8da  2023-05-01  dependabot[bot]  Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#291)

webdriver (https://github.com/google/webdriver.dart/compare/562aa06..d0f78d0):
  d0f78d0  2023-05-01  dependabot[bot]  Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#273)
  1ef3348  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.3.0 to 3.5.2 (#275)

webkit_inspection_protocol (https://github.com/google/webkit_inspection_protocol.dart/compare/8401098..39a3c29):
  39a3c29  2023-05-01  dependabot[bot]  Bump dart-lang/setup-dart from 1.4.0 to 1.5.0 (#102)
  5555c53  2023-05-01  dependabot[bot]  Bump nanasess/setup-chromedriver from 1.1.0 to 2.0.0 (#101)
  9adce2a  2023-05-01  dependabot[bot]  Bump actions/checkout from 3.3.0 to 3.5.2 (#103)

yaml_edit (https://github.com/dart-lang/yaml_edit/compare/5f392a1..e05282b):
  e05282b  2023-05-02  Jonas Finnemann Jensen  Prepare 2.1.1 release (#52)

Change-Id: Iee7fd84d32ae37b76147d62c2268df19cf8db95b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300863
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants