Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tests/compiler/dart2js_native/subclassing_4_test.dart

Issue 22854016: Native subclasses of a mixin include classes extending native classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/interceptor_simplifier.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:_js_helper' show Creates, setNativeSubclassDispatchRecord; 6 import 'dart:_js_helper' show Creates, setNativeSubclassDispatchRecord;
7 import 'dart:_interceptors' show Interceptor, findInterceptorForType; 7 import 'dart:_interceptors' show Interceptor, findInterceptorForType;
8 8
9 // Test calling convention of methods introduced on subclasses of native 9 // Test calling convention on subclasses of native classes.
10 // class of mixin.
11
12 doFoo(r, x) => '$x,${r.oof()},${r.miz()}';
13 10
14 class M { 11 class M {
15 miz() => 'M'; 12 miz() => 'M';
16 } 13 }
17 14
18 class N native "N" { 15 class N native "N" {}
19 foo(x) => (doFoo)(this, x);
20 }
21 16
22 class A extends N {} 17 class A extends N {}
23 18
24 class B extends A with M { 19 class B extends A with M {
25 // [oof] is introduced only on this subclass of a native class. It should 20 // The call to [miz] has a know type [B]. The call is in an intercepted
26 // have interceptor calling convention. 21 // method and to an intercepted method, so the ambient interceptor can be
27 oof() => 'B'; 22 // used. For correct optimization of the interceptor, the compiler needs to
28 // [miz] is introduced only on the mixin-application A+M. 23 // (1) correctly determine that B is an intercepted type (because it extends a
24 // native class) and (2) realize that the intersection of [B] and subclasses
25 // of mixin applications of [M] is non-empty.
26 callMiz() => this.miz();
29 } 27 }
30 28
31 B makeB() native; 29 B makeB() native;
32 30
33 @Creates('=Object') 31 @Creates('=Object')
34 getBPrototype() native; 32 getBPrototype() native;
35 33
36 void setup() native r""" 34 void setup() native r"""
37 function B() {} 35 function B() {}
38 makeB = function(){return new B;}; 36 makeB = function(){return new B;};
39
40 getBPrototype = function(){return B.prototype;}; 37 getBPrototype = function(){return B.prototype;};
41 """; 38 """;
42 39
43 main() { 40 main() {
44 setup(); 41 setup();
45 42
46 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B)); 43 setNativeSubclassDispatchRecord(getBPrototype(), findInterceptorForType(B));
47 44
48 B b = makeB(); 45 B b = makeB();
49 Expect.equals('1,B,M', b.foo(1)); 46 Expect.equals('M', b.callMiz());
50 } 47 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/interceptor_simplifier.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698