langtools/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java
author mcimadamore
Tue, 04 Jun 2013 11:34:31 +0100
changeset 18008 6d75e3886bac
parent 15384 5a8d00abf076
child 30730 d3ce7619db2c
permissions -rw-r--r--
8015505: Spurious inference error when return type of generic method requires unchecked conversion to target Summary: Use check context compatibility during 15.12.2.8 check (only when JDK 8 inference is enabled) Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     1
/*
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     4
 *
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     8
 *
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    14
 *
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    18
 *
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    21
 * questions.
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    22
 */
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    23
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    24
/*
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    25
 * @test
15384
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    26
 * @bug 7062745 8006694
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    27
 * @summary  Regression: difference in overload resolution when two methods
15384
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    28
 *  are maximally specific
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    29
 *  temporarily workaround combo tests are causing time out in several platforms
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    30
 * @library ../../../lib
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    31
 * @build JavacTestingAbstractThreadedTest
15384
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    32
 * @run main/othervm GenericOverrideTest
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    33
 */
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    34
15384
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    35
// use /othervm to avoid jtreg timeout issues (CODETOOLS-7900047)
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    36
// see JDK-8006746
5a8d00abf076 8006694: temporarily workaround combo tests are causing time out in several platforms
vromero
parents: 15040
diff changeset
    37
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    38
import java.net.URI;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    39
import java.util.Arrays;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    40
import javax.tools.Diagnostic;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    41
import javax.tools.JavaFileObject;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    42
import javax.tools.SimpleJavaFileObject;
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    43
import com.sun.source.util.JavacTask;
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    44
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    45
public class GenericOverrideTest
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    46
    extends JavacTestingAbstractThreadedTest
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
    47
    implements Runnable {
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    48
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    49
    enum SourceLevel {
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    50
        SOURCE_7("-source", "7"),
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    51
        SOURCE_DEFAULT();
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    52
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    53
        String[] opts;
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    54
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    55
        SourceLevel(String... opts) {
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    56
            this.opts = opts;
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    57
        }
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    58
    }
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
    59
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    60
    enum SignatureKind {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    61
        NON_GENERIC(""),
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    62
        GENERIC("<X>");
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    63
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    64
        String paramStr;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    65
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    66
        private SignatureKind(String paramStr) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    67
            this.paramStr = paramStr;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    68
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    69
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    70
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    71
    enum ReturnTypeKind {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    72
        LIST("List"),
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    73
        ARRAYLIST("ArrayList");
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    74
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    75
        String retStr;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    76
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    77
        private ReturnTypeKind(String retStr) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    78
            this.retStr = retStr;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    79
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    80
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    81
        boolean moreSpecificThan(ReturnTypeKind that) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    82
            switch (this) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    83
                case LIST:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    84
                    return that == this;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    85
                case ARRAYLIST:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    86
                    return that == LIST || that == ARRAYLIST;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    87
                default: throw new AssertionError("Unexpected ret kind: " + this);
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    88
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    89
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    90
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    91
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    92
    enum TypeArgumentKind {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    93
        NONE(""),
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    94
        UNBOUND("<?>"),
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    95
        INTEGER("<Number>"),
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    96
        NUMBER("<Integer>"),
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    97
        TYPEVAR("<X>");
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    98
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
    99
        String typeargStr;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   100
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   101
        private TypeArgumentKind(String typeargStr) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   102
            this.typeargStr = typeargStr;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   103
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   104
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   105
        boolean compatibleWith(SignatureKind sig) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   106
            switch (this) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   107
                case TYPEVAR: return sig != SignatureKind.NON_GENERIC;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   108
                default: return true;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   109
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   110
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   111
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   112
        boolean moreSpecificThan(TypeArgumentKind that, boolean strict) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   113
            switch (this) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   114
                case NONE:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   115
                    return that == this || !strict;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   116
                case UNBOUND:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   117
                    return that == this || that == NONE;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   118
                case INTEGER:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   119
                case NUMBER:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   120
                case TYPEVAR:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   121
                    return that == this || that == NONE || that == UNBOUND;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   122
                default: throw new AssertionError("Unexpected typearg kind: " + this);
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   123
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   124
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   125
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   126
        boolean assignableTo(TypeArgumentKind that, SignatureKind sig, SourceLevel level) {
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   127
            switch (this) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   128
                case NONE:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   129
                    //this case needs to workaround to javac's impl of 15.12.2.8 being too strict
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   130
                    //ideally should be just 'return true' (see 7067746/8015505)
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   131
                    return level == SourceLevel.SOURCE_DEFAULT ||
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   132
                            sig == SignatureKind.NON_GENERIC || that == NONE;
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   133
                case UNBOUND:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   134
                    return that == this || that == NONE;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   135
                case INTEGER:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   136
                case NUMBER:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   137
                    return that == this || that == NONE || that == UNBOUND;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   138
                case TYPEVAR:
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   139
                    return true;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   140
                default: throw new AssertionError("Unexpected typearg kind: " + this);
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   141
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   142
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   143
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   144
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   145
    public static void main(String... args) throws Exception {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   146
        for (SignatureKind sig1 : SignatureKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   147
            for (ReturnTypeKind rt1 : ReturnTypeKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   148
                for (TypeArgumentKind ta1 : TypeArgumentKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   149
                    if (!ta1.compatibleWith(sig1)) continue;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   150
                    for (SignatureKind sig2 : SignatureKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   151
                        for (ReturnTypeKind rt2 : ReturnTypeKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   152
                            for (TypeArgumentKind ta2 : TypeArgumentKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   153
                                if (!ta2.compatibleWith(sig2)) continue;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   154
                                for (ReturnTypeKind rt3 : ReturnTypeKind.values()) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   155
                                    for (TypeArgumentKind ta3 : TypeArgumentKind.values()) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   156
                                        if (!ta3.compatibleWith(SignatureKind.NON_GENERIC))
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   157
                                            continue;
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   158
                                        for (SourceLevel level : SourceLevel.values()) {
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   159
                                            pool.execute(
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   160
                                                    new GenericOverrideTest(sig1,
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   161
                                                    rt1, ta1, sig2, rt2,
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   162
                                                    ta2, rt3, ta3, level));
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   163
                                        }
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   164
                                    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   165
                                }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   166
                            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   167
                        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   168
                    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   169
                }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   170
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   171
        }
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   172
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   173
        checkAfterExec();
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   174
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   175
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   176
    SignatureKind sig1, sig2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   177
    ReturnTypeKind rt1, rt2, rt3;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   178
    TypeArgumentKind ta1, ta2, ta3;
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   179
    SourceLevel level;
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   180
    JavaSource source;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   181
    DiagnosticChecker diagChecker;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   182
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   183
    GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1,
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   184
            SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2,
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   185
            ReturnTypeKind rt3, TypeArgumentKind ta3, SourceLevel level) {
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   186
        this.sig1 = sig1;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   187
        this.sig2 = sig2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   188
        this.rt1 = rt1;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   189
        this.rt2 = rt2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   190
        this.rt3 = rt3;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   191
        this.ta1 = ta1;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   192
        this.ta2 = ta2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   193
        this.ta3 = ta3;
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   194
        this.level = level;
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   195
        this.source = new JavaSource();
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   196
        this.diagChecker = new DiagnosticChecker();
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   197
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   198
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   199
    class JavaSource extends SimpleJavaFileObject {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   200
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   201
        String template = "import java.util.*;\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   202
                          "interface A { #S1 #R1#TA1 m(); }\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   203
                          "interface B { #S2 #R2#TA2 m(); }\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   204
                          "interface AB extends A, B {}\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   205
                          "class Test {\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   206
                          "  void test(AB ab) { #R3#TA3 n = ab.m(); }\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   207
                          "}";
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   208
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   209
        String source;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   210
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   211
        public JavaSource() {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   212
            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   213
            source = template.replace("#S1", sig1.paramStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   214
                    replace("#S2", sig2.paramStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   215
                    replace("#R1", rt1.retStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   216
                    replace("#R2", rt2.retStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   217
                    replace("#R3", rt3.retStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   218
                    replace("#TA1", ta1.typeargStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   219
                    replace("#TA2", ta2.typeargStr).
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   220
                    replace("#TA3", ta3.typeargStr);
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   221
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   222
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   223
        @Override
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   224
        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   225
            return source;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   226
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   227
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   228
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   229
    @Override
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   230
    public void run() {
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   231
        JavacTask ct = (JavacTask)comp.getTask(null, fm.get(), diagChecker,
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   232
                level.opts != null ? Arrays.asList(level.opts) : null,
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   233
                null, Arrays.asList(source));
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   234
        try {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   235
            ct.analyze();
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   236
        } catch (Throwable ex) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   237
            throw new AssertionError("Error thrown when compiling the following code:\n" +
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   238
                    source.getCharContent(true));
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   239
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   240
        check();
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   241
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   242
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   243
    void check() {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   244
        checkCount.incrementAndGet();
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   245
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   246
        boolean errorExpected = false;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   247
        int mostSpecific = 0;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   248
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   249
        //first check that either |R1| <: |R2| or |R2| <: |R1|
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   250
        if (rt1 != rt2) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   251
            if (!rt1.moreSpecificThan(rt2) &&
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   252
                    !rt2.moreSpecificThan(rt1)) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   253
                errorExpected = true;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   254
            } else {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   255
                mostSpecific = rt1.moreSpecificThan(rt2) ? 1 : 2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   256
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   257
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   258
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   259
        //check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw)
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   260
        if (!errorExpected) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   261
            if (ta1 != ta2) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   262
                boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) ||
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   263
                        ta2.moreSpecificThan(ta1, true);
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   264
                if (!ta1.moreSpecificThan(ta2, useStrictCheck) &&
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   265
                        !ta2.moreSpecificThan(ta1, useStrictCheck)) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   266
                    errorExpected = true;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   267
                } else {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   268
                    int mostSpecific2 = ta1.moreSpecificThan(ta2, useStrictCheck) ? 1 : 2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   269
                    if (mostSpecific != 0 && mostSpecific2 != mostSpecific) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   270
                        errorExpected = mostSpecific == 1 ?
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   271
                                ta1 != TypeArgumentKind.NONE :
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   272
                                ta2 != TypeArgumentKind.NONE;
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   273
                    } else {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   274
                        mostSpecific = mostSpecific2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   275
                    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   276
                }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   277
            } else if (mostSpecific == 0) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   278
                //when no signature is better than the other, an arbitrary choice
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   279
                //must be made - javac always picks the second signature
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   280
                mostSpecific = 2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   281
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   282
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   283
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   284
        //finally, check that most specific return type is compatible with expected type
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   285
        if (!errorExpected) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   286
            ReturnTypeKind msrt = mostSpecific == 1 ? rt1 : rt2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   287
            TypeArgumentKind msta = mostSpecific == 1 ? ta1 : ta2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   288
            SignatureKind mssig = mostSpecific == 1 ? sig1 : sig2;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   289
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   290
            if (!msrt.moreSpecificThan(rt3) ||
18008
6d75e3886bac 8015505: Spurious inference error when return type of generic method requires unchecked conversion to target
mcimadamore
parents: 15384
diff changeset
   291
                    !msta.assignableTo(ta3, mssig, level)) {
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   292
                errorExpected = true;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   293
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   294
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   295
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   296
        if (errorExpected != diagChecker.errorFound) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   297
            throw new Error("invalid diagnostics for source:\n" +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   298
                source.getCharContent(true) +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   299
                "\nFound error: " + diagChecker.errorFound +
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   300
                "\nExpected error: " + errorExpected);
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   301
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   302
    }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   303
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   304
    static class DiagnosticChecker
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   305
        implements javax.tools.DiagnosticListener<JavaFileObject> {
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   306
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   307
        boolean errorFound;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   308
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   309
        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   310
            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   311
                errorFound = true;
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   312
            }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   313
        }
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   314
    }
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 11381
diff changeset
   315
10197
28afe0fb34c8 7062745: Regression: difference in overload resolution when two methods are maximally specific
mcimadamore
parents:
diff changeset
   316
}