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

VM reports no static method when no such method is on an instance #13655

Closed
gbracha opened this issue Sep 27, 2013 · 2 comments
Closed

VM reports no static method when no such method is on an instance #13655

gbracha opened this issue Sep 27, 2013 · 2 comments
Labels
area-vm closed-obsolete Closed as the reported issue is no longer relevant

Comments

@gbracha
Copy link
Contributor

gbracha commented Sep 27, 2013

Given the following code

class C<T> {
  foo() => T();
}

main() {
  print(new C<int>().foo());
}

We get the following error message, that claims that no static method T was found, when in reality it is a missing instance method.

Unhandled exception:
No constructor 'C.foo' declared in class 'C'.

NoSuchMethodError : method not found: 'C.foo'
Receiver: Type: class 'C'
Arguments: [...]

­0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:99:5)

­1 main (file:///Users/gbracha/dart/dart/dart-sdk/C.dart:7:23)

gbracha-macpro:dart-sdk gbracha$ emacs C.dart
gbracha-macpro:dart-sdk gbracha$ ./bin/dart C.dart
Unhandled exception:
No static method 'T' declared in class 'C'.

NoSuchMethodError : method not found: 'T'
Receiver: Type: class 'C'
Arguments: [...]

­0 NoSuchMethodError._throwNew (dart:core-patch/errors_patch.dart:99:5)

­1 C.foo (file:///Users/gbracha/dart/dart/dart-sdk/C.dart:3:12)

­2 main (file:///Users/gbracha/dart/dart/dart-sdk/C.dart:7:25)

@srawlins
Copy link
Member

This has been fixed. The VM now reports a missing instance method:

Unhandled exception:
Class 'C<int>' has no instance method 'T'.

NoSuchMethodError: method not found: 'T'
Receiver: Instance of 'C<int>'
Arguments: []
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      C.foo (file:///Users/srawlins/code/dart-repo2/sdk/13655.dart:2:12)
#3      main (file:///Users/srawlins/code/dart-repo2/sdk/13655.dart:6:22)
#4      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:261)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

@lrhn
Copy link
Member

lrhn commented Jan 19, 2016

And for the record, that's the spec-mandated behavior, even if it looks odd that because a T type variable is in scope, it turns T() into this.T() where the T no longer refers to the type variable.

@lrhn lrhn added the closed-obsolete Closed as the reported issue is no longer relevant label Jan 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm closed-obsolete Closed as the reported issue is no longer relevant
Projects
None yet
Development

No branches or pull requests

4 participants