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

Transformer throws on admitSubtypeCapability #49

Closed
lassedamgaard opened this issue Dec 4, 2015 · 5 comments
Closed

Transformer throws on admitSubtypeCapability #49

lassedamgaard opened this issue Dec 4, 2015 · 5 comments
Assignees
Labels

Comments

@lassedamgaard
Copy link

Not sure if this capability is supposed to work in js, if not a better error message/guard should be provided.

This is the capability spec:

class Foo extends Reflectable {
  const Foo() : super(admitSubtypeCapability);
Build error:
Transform Reflectable on foobar|ReflectableTransformed threw error: *** Unexpected situation encountered!
Please report a bug on github.com/dart-lang/reflectable: Unexpected capability _AdmitSubtypeCapability.
package:reflectable/src/incompleteness.dart 28                unreachableError
package:reflectable/src/transformer_implementation.dart 3136  TransformerImplementation._capabilityOfExpression
package:reflectable/src/transformer_implementation.dart 3179  TransformerImplementation._capabilitiesOf.capabilityOfExpression
dart:_internal/iterable.dart 413                              MappedListIterable.elementAt
dart:_internal/iterable.dart 219                              ListIterable.toList
package:reflectable/src/transformer_implementation.dart 3187  TransformerImplementation._capabilitiesOf
package:reflectable/src/transformer_implementation.dart 2840  TransformerImplementation._computeWorld.getReflectorDomain.<fn>
dart:collection-patch/compact_hash.dart 254                   _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent
package:reflectable/src/transformer_implementation.dart 2838  TransformerImplementation._computeWorld.getReflectorDomain
package:reflectable/src/transformer_implementation.dart 2866  TransformerImplementation._computeWorld.addClassDomain
package:reflectable/src/transformer_implementation.dart 2962  TransformerImplementation._computeWorld
package:reflectable/src/transformer_implementation.dart 3327  TransformerImplementation.apply.<async>
dart:async/zone.dart 1149                                     _RootZone.runUnary
dart:async/future_impl.dart 502                               _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 585                               _Future._propagateToListeners
dart:async/future_impl.dart 568                               _Future._propagateToListeners.handleWhenCompleteCallback.<fn>
dart:async/zone.dart 1149                                     _RootZone.runUnary
dart:async/future_impl.dart 502                               _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 585                               _Future._propagateToListeners
dart:async/future_impl.dart 376                               _Future._completeWithValue
dart:async/future_impl.dart 430                               _Future._asyncComplete.<fn>
dart:async/schedule_microtask.dart 43                         _microtaskLoop
dart:async/schedule_microtask.dart 52                         _microtaskLoopEntry
dart:isolate-patch/isolate_patch.dart 96                      _runPendingImmediateCallback
dart:isolate-patch/isolate_patch.dart 151                     _RawReceivePortImpl._handleMessage

package:reflectable/src/incompleteness.dart 28                unreachableError
package:reflectable/src/transformer_implementation.dart 3136  TransformerImplementation._capabilityOfExpression
package:reflectable/src/transformer_implementation.dart 3179  TransformerImplementation._capabilitiesOf.capabilityOfExpression
dart:_internal                                                ListIterable.toList
package:reflectable/src/transformer_implementation.dart 3187  TransformerImplementation._capabilitiesOf
package:reflectable/src/transformer_implementation.dart 2840  TransformerImplementation._computeWorld.getReflectorDomain.<fn>
dart:collection                                               _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent
package:reflectable/src/transformer_implementation.dart 2838  TransformerImplementation._computeWorld.getReflectorDomain
package:reflectable/src/transformer_implementation.dart 2866  TransformerImplementation._computeWorld.addClassDomain
package:reflectable/src/transformer_implementation.dart 2962  TransformerImplementation._computeWorld
package:reflectable/src/transformer_implementation.dart 3327  TransformerImplementation.apply.<async>

@eernstg
Copy link
Collaborator

eernstg commented Dec 4, 2015

Thanks for spotting this! It is a bug when you get the 'Unexpected situation' exception (a fix will be included in the next commit), but it will not help you much: admitSubtypeCapability has not yet been implemented, and you would just get an UnimplementedError exception instead.

There is a rather detailed discussion about this capability in the design document https://github.com/dart-lang/reflectable/blob/master/reflectable/doc/TheDesignOfReflectableCapabilities.md which illustrates why the whole concept is questionable (and hence it might be dropped). However, if it would be very helpful for you then please make the case for it, and then we can keep your arguments in mind because they are on the issue list.

PS: That would then be a new issue, because this one gets closed when the bug fix is available.

@eernstg eernstg added the bug label Dec 4, 2015
@eernstg eernstg self-assigned this Dec 4, 2015
@sigurdm
Copy link
Collaborator

sigurdm commented Dec 4, 2015

I think @lassedamgaard mentions superclassQuantifyCapability, not admitSubtypeCapability.
@lassedamgaard: Are you sure this is the only capability spec in your program? - the error message suggest you are using admitSubtypeCapability, and that is still unimplemented.

@lassedamgaard
Copy link
Author

Sorry guys, wrong copy-pasta, the capability spec was supposed to say admitSubtypeCapability. I've corrected it.
Anyway, I don't have a need for this capability at the moment, just spotted this trying some things out and thought it should have a better error message. In general if there are going to be capabilities that aren't supported by the transformer I think they should be checked early and generate a descriptive error message instead of throwing.

@eernstg
Copy link
Collaborator

eernstg commented Dec 4, 2015

The error message for admitSubtypeCapability was plain wrong (a certain test for whether we encountered such a capability was wrong, so we missed that case and continued to the final catch-all case that we should never reach -- hence the "Unexpected situation"). It is fixed in the next upcoming commit.

With respect to the diagnostic message: There is already issue #39 requesting a similar thing, namely that errors should be reported but then caught, such that the transformer can continue transforming the remaining entry points rather than stopping entirely.

@eernstg
Copy link
Collaborator

eernstg commented Dec 8, 2015

@eernstg eernstg closed this as completed Dec 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants