mirror of
https://github.com/openjdk/jdk.git
synced 2026-08-04 07:05:31 +00:00
Merge branch 'JDK-8329951' into JDK-8348611
This commit is contained in:
commit
6852ed1bcb
@ -366,7 +366,7 @@ public class Analyzer {
|
||||
}
|
||||
|
||||
boolean isImplicitlyTyped(JCVariableDecl decl) {
|
||||
return decl.vartype.pos == Position.NOPOS;
|
||||
return decl.declaredUsingVar();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -5693,9 +5693,9 @@ public class Attr extends JCTree.Visitor {
|
||||
|
||||
private void setSyntheticVariableType(JCVariableDecl tree, Type type) {
|
||||
if (type.isErroneous()) {
|
||||
tree.vartype = make.at(Position.NOPOS).Erroneous();
|
||||
tree.vartype = make.at(tree.pos()).Erroneous();
|
||||
} else {
|
||||
tree.vartype = make.at(Position.NOPOS).Type(type);
|
||||
tree.vartype = make.at(tree.pos()).Type(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
26
test/langtools/tools/javac/tree/VarWarnPosition.java
Normal file
26
test/langtools/tools/javac/tree/VarWarnPosition.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8329951
|
||||
* @summary Check that "var" variable synthetic types have a source position
|
||||
* @compile/process/ref=VarWarnPosition.out -Xlint:deprecation -XDrawDiagnostics VarWarnPosition.java
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.*;
|
||||
|
||||
public class VarWarnPosition {
|
||||
|
||||
VarWarnPosition() {
|
||||
|
||||
// Test 1
|
||||
@SuppressWarnings("deprecation")
|
||||
List<Depr> deprecatedList = null;
|
||||
for (var deprValue : deprecatedList) { }
|
||||
|
||||
// Test 2
|
||||
Consumer<Depr> c = d -> { };
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
class Depr {}
|
||||
4
test/langtools/tools/javac/tree/VarWarnPosition.out
Normal file
4
test/langtools/tools/javac/tree/VarWarnPosition.out
Normal file
@ -0,0 +1,4 @@
|
||||
VarWarnPosition.java:18:14: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package
|
||||
VarWarnPosition.java:21:18: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package
|
||||
VarWarnPosition.java:21:28: compiler.warn.has.been.deprecated: Depr, compiler.misc.unnamed.package
|
||||
3 warnings
|
||||
Loading…
x
Reference in New Issue
Block a user