|
1 /* |
|
2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 /** |
|
25 * JDK-8029667: Prototype linking is incorrect |
|
26 * |
|
27 * @test |
|
28 * @run |
|
29 */ |
|
30 |
|
31 function f(x) { |
|
32 return (function inner() { |
|
33 var y; (function dummy() { return y })() // force own scope for the inner function |
|
34 with({}) { // 'with' block turns off fast scopes |
|
35 return x |
|
36 } |
|
37 })(); |
|
38 } |
|
39 print(f(1)); |
|
40 print(f(2)); |
|
41 |
|
42 function g(x) { |
|
43 (function inner() { |
|
44 var y; (function dummy() { return y })() // force own scope for the inner function |
|
45 with({}) { // 'with' block turns off fast scopes |
|
46 // Test setter as well as getter |
|
47 x = x + 2; |
|
48 } |
|
49 })(); |
|
50 print(x); |
|
51 } |
|
52 |
|
53 g(1); |
|
54 g(2); |
|
55 |
|
56 var withScopes = [{ func: function() { print("called 1");} }, { func: function() { print("called 2");} }]; |
|
57 |
|
58 for(var i in withScopes) { |
|
59 with (withScopes[i]) { |
|
60 var main = function() { |
|
61 var frame; // <---- this local variable caused scope to be not set properly prior to fix |
|
62 |
|
63 function callFunc() { |
|
64 frame = func(); |
|
65 } |
|
66 |
|
67 callFunc(); |
|
68 } |
|
69 } |
|
70 main(); |
|
71 } |
|
72 |
|
73 for(var i in withScopes) { |
|
74 with (withScopes[i]) { |
|
75 var main = function() { |
|
76 var frame; // <---- this local variable caused scope to be not set properly prior to fix |
|
77 |
|
78 function callFunc() { |
|
79 frame = func = i; |
|
80 } |
|
81 |
|
82 callFunc(); |
|
83 } |
|
84 } |
|
85 main(); |
|
86 } |
|
87 |
|
88 print(withScopes[0].func); |
|
89 print(withScopes[1].func); |
|
90 |
|
91 |