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

Side by Side Diff: tests/html/custom/mirrors_2_test.dart

Issue 2862433002: Fix for issue 28196 - constant interceptors for mixin applications (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | tests/html/custom/mirrors_2_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library tests.html.mirrors_2_test;
6
7 @MirrorsUsed(targets: "tests.html.mirrors_2_test")
8 import 'dart:mirrors';
9 import 'dart:html';
10 import 'package:expect/expect.dart' show NoInline;
11 import 'package:unittest/unittest.dart';
12 import 'package:unittest/html_config.dart';
13 import '../utils.dart';
14
15 /// Regression test for http://dartbug/28196
16 ///
17 /// The constructor of a mixin application of a subclass of a Html element is
18 /// normally not used. With mirrors the constructor can become available. The
19 /// body of the factory has a 'receiver' with an exact type that is the mixin
20 /// application. The constructor body functions of the superclasses are called
21 /// using the interceptor calling convention. This creates an interceptor
22 /// constant of the mixin application type. In issue 28196 the constant has a
23 /// name containing '+' symbols, causing the program to crash during
24 /// initializing the constant pool.
25
26 main() {
27 useHtmlConfiguration();
28
29 var registered = false;
30 setUp(() => customElementsReady.then((_) {
31 if (!registered) {
32 registered = true;
33 document.registerElement(A.tag, A);
34 document.registerElement(B.tag, B);
35 }
36 }));
37
38 test('reflectClass', () {
39 expect('AA', new A().token());
40 expect('MM', new B().token());
41 reflectClass(B);
42 });
43 }
44
45 class A extends HtmlElement {
46 static final tag = 'x-a';
47 factory A() => new Element.tag(tag);
48
49 A.created() : super.created() {
50 // This function must not be inlined otherwise there is no reference to the
51 // interceptor constant. The `@NoInline()` annotation does not seem reliable
52 // on generative constructor bodies.
53 try {
54 uninlinedMethod();
55 uninlinedMethod();
56 uninlinedMethod();
57 } finally {
58 uninlinedMethod();
59 uninlinedMethod();
60 uninlinedMethod();
61 }
62 }
63 @NoInline()
64 uninlinedMethod() {}
65
66 token() => 'AA';
67 }
68
69 class B extends A with M {
70 static final tag = 'x-b';
71 factory B() => new Element.tag(tag);
72 B.created() : super.created();
73 }
74
75 class M {
76 token() => 'MM';
77 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/namer.dart ('k') | tests/html/custom/mirrors_2_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698