langtools/test/tools/javac/generics/T6751514.java
author hseigel
Wed, 02 Mar 2016 23:48:41 +0000
changeset 36397 c487ced7231c
parent 7681 1f0819a3341f
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1468
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     1
/*
7681
1f0819a3341f 6962318: Update copyright year
ohair
parents: 5520
diff changeset
     2
 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
1468
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     4
 *
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     8
 *
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    14
 *
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    18
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5213
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5213
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 5213
diff changeset
    21
 * questions.
1468
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    22
 */
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    23
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    24
/*
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    25
 * @test
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    26
 * @bug     6751514
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    27
 * @summary Unary post-increment with type variables crash javac during lowering
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    28
 * @author Maurizio Cimadamore
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    29
 */
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    30
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    31
public class T6751514 {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    32
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    33
    static class Foo<X> {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    34
        X x;
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    35
        Foo (X x) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    36
            this.x = x;
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    37
        }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    38
    }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    39
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    40
    static void test1(Foo<Integer> foo) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    41
        int start = foo.x;
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    42
        equals(foo.x += 1, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    43
        equals(foo.x++, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    44
        equals(++foo.x, start + 3);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    45
        equals(foo.x--, start + 3);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    46
        equals(foo.x -= 1, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    47
        equals(--foo.x, start);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    48
    }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    49
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    50
    static void test2(Foo<Integer> foo) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    51
        int start = foo.x;
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    52
        equals((foo.x) += 1, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    53
        equals((foo.x)++, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    54
        equals(++(foo.x), start + 3);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    55
        equals((foo.x)--, start + 3);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    56
        equals((foo.x) -= 1, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    57
        equals(--(foo.x), start);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    58
    }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    59
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    60
    static void test3(Foo<Integer> foo) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    61
        int start = foo.x;
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    62
        equals(((foo.x)) += 1, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    63
        equals(((foo.x))++, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    64
        equals(++((foo.x)), start + 3);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    65
        equals(((foo.x))--, start + 3);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    66
        equals(((foo.x)) -= 1, start + 1);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    67
        equals(--((foo.x)), start);
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    68
    }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    69
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    70
    public static void main(String[] args) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    71
        test1(new Foo<Integer>(1));
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    72
        test2(new Foo<Integer>(1));
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    73
        test3(new Foo<Integer>(1));
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    74
    }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    75
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    76
    static void equals(int found, int req) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    77
        if (found != req) {
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    78
            throw new AssertionError("Error (expected: "+ req +
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    79
                                     " - found: " + found + ")");
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    80
        }
19d266637353 6751514: Unary post-increment with type variables crash javac during lowering
mcimadamore
parents:
diff changeset
    81
    }
5213
6efe8a6d26eb 6933914: fix missing newlines
jjg
parents: 1468
diff changeset
    82
}