dart-archive / polymer-dart

Polymer support for Dart
https://pub.dartlang.org/packages/polymer
BSD 3-Clause "New" or "Revised" License
181 stars 33 forks source link

_checkInstanceParameterListShape - incorrect number of arguments #681

Closed Hecatoncheir closed 8 years ago

Hecatoncheir commented 8 years ago

Hi. While i open pages, i get a some message error in console:

Class 'NonGenericClassMirrorImpl' has no instance method '_checkInstanceParameterListShape' with matching arguments.

NoSuchMethodError: incorrect number of arguments passed to method named '_checkInstanceParameterListShape'
Receiver: Instance of 'NonGenericClassMirrorImpl'
Tried calling: _checkInstanceParameterListShape("componentsChanged", 2)
Found: _checkInstanceParameterListShape(methodName, numberOfPositionalArguments, namedArgumentNames)
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      _InstanceMirrorImpl.invoke (package:reflectable/src/reflectable_transformer_based.dart:248:16)
#3      addDeclarationToPrototype.<anonymous closure> (package:polymer/src/common/declarations.dart:134:35)
#4      BlinkElement.setAttribute_Callback_2 (dart:_blink:7565)
#5      BlinkElement.setAttribute_Callback_2_ (dart:_blink:7566)
#6      Element.setAttribute (dart:html:13699)
#7      _ElementAttributeMap.[]= (dart:html:36927)
#8      showCompanyPage.<showCompanyPage_async_body> (package:engine/client/resource/company.dart:9:22)
#9      Future.Future.microtask.<anonymous closure> (dart:async/future.dart:144)
#10     _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:41)
#11     _asyncRunCallback (dart:async/schedule_microtask.dart:48)
#12     _ScheduleImmediateHelper._handleMutation (dart:html:42407)

polymer: '1.0.0-rc.15'

@PolymerRegister('page-view')
class PageView extends PolymerElement {
  PageView.created() : super.created();

  @Property(reflectToAttribute: true, observer: 'componentsChanged')
  String components;

  @reflectable
  componentsChanged(event, [details]) async {
    print(components);
  }
}

I just try send json encoded string to polymer element attribute, and print it in event handler function: gist May be i do it wrong?

jakemac53 commented 8 years ago

This looks like a reflectable bug, looking into it further...

cc @eernstg

jakemac53 commented 8 years ago

In general, you should avoid using the attributes to set element fields and just set the properties directly. That being said this should work. I tried a simpler version of the gist you posted and that is working for me though, not sure exactly what the difference is.

Hecatoncheir commented 8 years ago

I try do something:

showCompanyPage(RouteEvent event) async {
  Map componentsForPage = new Map();

  // Configure components for page
  componentsForPage['entity-form'] = 'true';

  pageView.components = JSON.encode(componentsForPage);

  print('Company page');
}
@PolymerRegister('page-view')
class PageView extends PolymerElement {
  PageView.created() : super.created();

  @Property(observer: 'componentsChanged')
  String components;

  @reflectable
  componentsChanged(event, [details]) async {
    print(components);
  }
}

It's sent from router, and it didn't work too. I can't send it another way.

jakemac53 commented 8 years ago

I think maybe you just need to update your version of reflectable, https://github.com/dart-lang/reflectable/search?utf8=%E2%9C%93&q=_checkInstanceParameterListShape shows it being invoked with 3 arguments not 2 like your stack trace shows.

Hecatoncheir commented 8 years ago

I did it. And it did not help: screen shot 2016-02-02 at 22 17 54

Hecatoncheir commented 8 years ago

When i delete .pub from project directory and run pub serve again i get new trouble for my live:

Uncaught 'package:reflectable/src/reflectable_transformer_based.dart': error: line 256 pos 64: unexpected token '.'
        methodName, positionalArguments.length, namedArguments?.keys)) {
jakemac53 commented 8 years ago

What version of the sdk are you running, it seems like maybe you just don't have the null-aware operator support?

Hecatoncheir commented 8 years ago

1.14.0

dart --version
Dart VM version: 1.14.0 (Thu Jan 28 09:20:03 2016) on "macos_x64"
pub --version
Pub 1.14.0

What version have null-aware operator?

jakemac53 commented 8 years ago

That version should be fine, are you sure that is the same version as the dartium which you are running? (Sometimes people have multiple sdks installed, and if you launch dartium from say an editor you might be running an older version)

Hecatoncheir commented 8 years ago

Sure, my mistake. Thanks for help. Now work perfectly. Sorry for that.

jakemac53 commented 8 years ago

Its unfortunately pretty easy to get in this situation :(

Hecatoncheir commented 8 years ago

Yes, it's true :(

eernstg commented 8 years ago

I love problems that go away before I even discover them. ;-)

Hecatoncheir commented 8 years ago

Yeah, it's good :) I need to be more attentively the next time.