mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 23:41:50 +00:00
6f58da2ef8
Bug: Change-Id: I9050869dc3365d122cf3c8754b39859d20e20902 Reviewed-on: https://dart-review.googlesource.com/10161 Reviewed-by: Ben Konyi <bkonyi@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
// Regression test for https://code.google.com/p/dart/issues/detail?id=7697.
|
|
// dart2js used to optimize [noSuchMethod] based on the user-provided
|
|
// argument, and forget that the runtime might call it with its own
|
|
// [Invocation] implementation.
|
|
|
|
class Hey {
|
|
foo() => noSuchMethod(new FakeInvocationMirror());
|
|
noSuchMethod(x) => x;
|
|
}
|
|
|
|
class You extends Hey {
|
|
// We used to think this method is always called with a
|
|
// FakeInvocationMirror instance, but it's also called with the
|
|
// internal mirror implementation.
|
|
noSuchMethod(x) => x.isGetter;
|
|
}
|
|
|
|
class FakeInvocationMirror extends Invocation {
|
|
final bool isGetter = false;
|
|
@override
|
|
bool get isMethod => false;
|
|
|
|
@override
|
|
bool get isSetter => false;
|
|
|
|
@override
|
|
Symbol get memberName => null;
|
|
|
|
@override
|
|
Map<Symbol, dynamic> get namedArguments => {};
|
|
|
|
@override
|
|
List get positionalArguments => [];
|
|
}
|
|
|
|
main() {
|
|
var x = new Hey();
|
|
Expect.isTrue(x.foo() is FakeInvocationMirror);
|
|
var y = [new You() as dynamic];
|
|
Expect.isTrue(y[0].bar);
|
|
}
|