mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 07:31:33 +00:00
3f46fe216d
BUG= R=floitsch@google.com Review URL: https://codereview.chromium.org//383413003 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38375 260f80e4-7a28-3924-810f-c04153c831b5
36 lines
876 B
Dart
36 lines
876 B
Dart
// Copyright (c) 2014, 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 "dart:_js_helper";
|
|
import "package:expect/expect.dart";
|
|
|
|
@Native("A")
|
|
class A {
|
|
var foo;
|
|
}
|
|
|
|
class B {
|
|
var foo;
|
|
}
|
|
|
|
nativeId(x) native;
|
|
|
|
void setup() native """
|
|
nativeId = function(x) { return x; }
|
|
""";
|
|
|
|
main() {
|
|
setup();
|
|
var b = new B();
|
|
b.foo = (x) => x + 1;
|
|
b = nativeId(b); // Inferrer doesn't know if A has been instantiated.
|
|
// At this point b could be A or B. The call to "foo" thus needs to go through
|
|
// an interceptor. Tests that the interceptor doesn't screw with retrieving
|
|
// the field and invoking the closure.
|
|
// Use a type-check to guarantee that b is a "B".
|
|
if (b is B) {
|
|
Expect.equals(499, b.foo(498));
|
|
}
|
|
}
|