/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7062745
* @summary Regression: difference in overload resolution when two methods are maximally specific
*/
public class GenericOverrideTest {
enum SignatureKind {
}
}
enum ReturnTypeKind {
}
switch (this) {
case LIST:
return that == this;
case ARRAYLIST:
default: throw new AssertionError("Unexpected ret kind: " + this);
}
}
}
enum TypeArgumentKind {
this.typeargStr = typeargStr;
}
switch (this) {
default: return true;
}
}
switch (this) {
case NONE:
case UNBOUND:
case INTEGER:
case NUMBER:
case TYPEVAR:
default: throw new AssertionError("Unexpected typearg kind: " + this);
}
}
switch (this) {
case NONE:
//this case needs to workaround to javac's impl of 15.12.2.8 being too strict
//ideally should be just 'return true' (see 7067746)
case UNBOUND:
case INTEGER:
case NUMBER:
case TYPEVAR:
return true;
default: throw new AssertionError("Unexpected typearg kind: " + this);
}
}
}
//create default shared JavaCompiler - reused across multiple compilations
}
}
}
}
}
}
}
}
}
SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, ReturnTypeKind rt3, TypeArgumentKind ta3) {
this.source = new JavaSource();
this.diagChecker = new DiagnosticChecker();
}
"interface A { #S1 #R1#TA1 m(); }\n" +
"interface B { #S2 #R2#TA2 m(); }\n" +
"interface AB extends A, B {}\n" +
"class Test {\n" +
" void test(AB ab) { #R3#TA3 n = ab.m(); }\n" +
"}";
public JavaSource() {
}
return source;
}
}
try {
throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
}
check();
}
void check() {
checkCount++;
boolean errorExpected = false;
int mostSpecific = 0;
//first check that either |R1| <: |R2| or |R2| <: |R1|
errorExpected = true;
} else {
}
}
//check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw)
if (!errorExpected) {
errorExpected = true;
} else {
} else {
}
}
} else if (mostSpecific == 0) {
//when no signature is better than the other, an arbitrary choice
//must be made - javac always picks the second signature
mostSpecific = 2;
}
}
//finally, check that most specific return type is compatible with expected type
if (!errorExpected) {
errorExpected = true;
}
}
throw new Error("invalid diagnostics for source:\n" +
source.getCharContent(true) +
"\nExpected error: " + errorExpected);
}
}
boolean errorFound;
errorFound = true;
}
}
}
}