--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Aug 15 22:14:25 2016 -0700
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Tue Aug 16 16:43:00 2016 +0200
@@ -789,23 +789,25 @@
if (!TreeInfo.isDiamond(tree) ||
t.isErroneous()) {
return checkClassType(tree.clazz.pos(), t, true);
- } else if (tree.def != null && !allowDiamondWithAnonymousClassCreation) {
- log.error(tree.clazz.pos(),
- Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name)));
- return types.createErrorType(t);
- } else if (t.tsym.type.getTypeArguments().isEmpty()) {
- log.error(tree.clazz.pos(),
- "cant.apply.diamond.1",
- t, diags.fragment("diamond.non.generic", t));
- return types.createErrorType(t);
- } else if (tree.typeargs != null &&
- tree.typeargs.nonEmpty()) {
- log.error(tree.clazz.pos(),
- "cant.apply.diamond.1",
- t, diags.fragment("diamond.and.explicit.params", t));
- return types.createErrorType(t);
} else {
- return t;
+ if (tree.def != null && !allowDiamondWithAnonymousClassCreation) {
+ log.error(DiagnosticFlag.SOURCE_LEVEL, tree.clazz.pos(),
+ Errors.CantApplyDiamond1(t, Fragments.DiamondAndAnonClassNotSupportedInSource(source.name)));
+ }
+ if (t.tsym.type.getTypeArguments().isEmpty()) {
+ log.error(tree.clazz.pos(),
+ "cant.apply.diamond.1",
+ t, diags.fragment("diamond.non.generic", t));
+ return types.createErrorType(t);
+ } else if (tree.typeargs != null &&
+ tree.typeargs.nonEmpty()) {
+ log.error(tree.clazz.pos(),
+ "cant.apply.diamond.1",
+ t, diags.fragment("diamond.and.explicit.params", t));
+ return types.createErrorType(t);
+ } else {
+ return t;
+ }
}
}