mcimadamore@133: /* ohair@798: * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. mcimadamore@133: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. mcimadamore@133: * mcimadamore@133: * This code is free software; you can redistribute it and/or modify it mcimadamore@133: * under the terms of the GNU General Public License version 2 only, as mcimadamore@133: * published by the Free Software Foundation. mcimadamore@133: * mcimadamore@133: * This code is distributed in the hope that it will be useful, but WITHOUT mcimadamore@133: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or mcimadamore@133: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mcimadamore@133: * version 2 for more details (a copy is included in the LICENSE file that mcimadamore@133: * accompanied this code). mcimadamore@133: * mcimadamore@133: * You should have received a copy of the GNU General Public License version mcimadamore@133: * 2 along with this work; if not, write to the Free Software Foundation, mcimadamore@133: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. mcimadamore@133: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. mcimadamore@133: */ mcimadamore@133: mcimadamore@133: /* mcimadamore@133: * @test mcimadamore@133: * @bug 6751514 mcimadamore@133: * @summary Unary post-increment with type variables crash javac during lowering mcimadamore@133: * @author Maurizio Cimadamore mcimadamore@133: */ mcimadamore@133: mcimadamore@133: public class T6751514 { mcimadamore@133: mcimadamore@133: static class Foo { mcimadamore@133: X x; mcimadamore@133: Foo (X x) { mcimadamore@133: this.x = x; mcimadamore@133: } mcimadamore@133: } mcimadamore@133: mcimadamore@133: static void test1(Foo foo) { mcimadamore@133: int start = foo.x; mcimadamore@133: equals(foo.x += 1, start + 1); mcimadamore@133: equals(foo.x++, start + 1); mcimadamore@133: equals(++foo.x, start + 3); mcimadamore@133: equals(foo.x--, start + 3); mcimadamore@133: equals(foo.x -= 1, start + 1); mcimadamore@133: equals(--foo.x, start); mcimadamore@133: } mcimadamore@133: mcimadamore@133: static void test2(Foo foo) { mcimadamore@133: int start = foo.x; mcimadamore@133: equals((foo.x) += 1, start + 1); mcimadamore@133: equals((foo.x)++, start + 1); mcimadamore@133: equals(++(foo.x), start + 3); mcimadamore@133: equals((foo.x)--, start + 3); mcimadamore@133: equals((foo.x) -= 1, start + 1); mcimadamore@133: equals(--(foo.x), start); mcimadamore@133: } mcimadamore@133: mcimadamore@133: static void test3(Foo foo) { mcimadamore@133: int start = foo.x; mcimadamore@133: equals(((foo.x)) += 1, start + 1); mcimadamore@133: equals(((foo.x))++, start + 1); mcimadamore@133: equals(++((foo.x)), start + 3); mcimadamore@133: equals(((foo.x))--, start + 3); mcimadamore@133: equals(((foo.x)) -= 1, start + 1); mcimadamore@133: equals(--((foo.x)), start); mcimadamore@133: } mcimadamore@133: mcimadamore@133: public static void main(String[] args) { mcimadamore@133: test1(new Foo(1)); mcimadamore@133: test2(new Foo(1)); mcimadamore@133: test3(new Foo(1)); mcimadamore@133: } mcimadamore@133: mcimadamore@133: static void equals(int found, int req) { mcimadamore@133: if (found != req) { mcimadamore@133: throw new AssertionError("Error (expected: "+ req + mcimadamore@133: " - found: " + found + ")"); mcimadamore@133: } mcimadamore@133: } jjg@525: }