Skip to content

Commit d5478a0

Browse files
authored
Merge pull request #10671 from github/revert-10640-atorralba/fix-cartesian-product
Java: Revert #10489 and #10640
2 parents e29be41 + 2deb3e5 commit d5478a0

File tree

5 files changed

+2
-47
lines changed

5 files changed

+2
-47
lines changed

java/ql/lib/change-notes/2022-09-20-CompilationUnit-getATypeInScope.md

Lines changed: 0 additions & 4 deletions
This file was deleted.

java/ql/lib/semmle/code/java/CompilationUnit.qll

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,5 @@ class CompilationUnit extends Element, File {
3131
*/
3232
Module getModule() { cumodule(this, result) }
3333

34-
/**
35-
* Gets a type which is available in the top-level scope of this compilation unit.
36-
* This can be a type:
37-
* - declared in this compilation unit as top-level type
38-
* - imported with an `import` declaration
39-
* - declared in the same package as this compilation unit
40-
* - declared in the package `java.lang`
41-
*
42-
* This predicate not consider "shadowing", it can have types as result whose simple name is
43-
* shadowed by another type in scope.
44-
*/
45-
ClassOrInterface getATypeInScope() {
46-
// See "Shadowing", https://docs.oracle.com/javase/specs/jls/se17/html/jls-6.html#jls-6.4.1
47-
// Currently shadowing is not considered
48-
result.(TopLevelType).getCompilationUnit() = this
49-
or
50-
exists(Import importDecl | importDecl.getCompilationUnit() = this |
51-
result =
52-
[
53-
importDecl.(ImportStaticTypeMember).getATypeImport(),
54-
importDecl.(ImportType).getImportedType(),
55-
importDecl.(ImportStaticOnDemand).getATypeImport(),
56-
importDecl.(ImportOnDemandFromType).getAnImport(),
57-
importDecl.(ImportOnDemandFromPackage).getAnImport(),
58-
]
59-
)
60-
or
61-
// From same package or java.lang, see https://docs.oracle.com/javase/specs/jls/se17/html/jls-7.html
62-
result.(TopLevelType).getPackage() = this.getPackage()
63-
or
64-
result.(TopLevelType).getPackage().hasName("java.lang")
65-
}
66-
6734
override string getAPrimaryQlClass() { result = "CompilationUnit" }
6835
}

java/ql/src/Advisory/Documentation/ImpossibleJavadocThrows.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
import java
1313

14-
ClassOrInterface getTaggedType(ThrowsTag tag) {
14+
RefType getTaggedType(ThrowsTag tag) {
1515
result.hasName(tag.getExceptionName()) and
16-
result = tag.getFile().(CompilationUnit).getATypeInScope()
16+
exists(ImportType i | i.getFile() = tag.getFile() | i.getImportedType() = result)
1717
}
1818

1919
// Uses ClassOrInterface as type for thrownType to also cover case where erroneously an interface
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
| ImpossibleJavadocThrows.java:9:5:9:12 | @throws | Javadoc for bad1 claims to throw InterruptedException but this is impossible. |
22
| ImpossibleJavadocThrows.java:16:5:16:15 | @exception | Javadoc for bad2 claims to throw Exception but this is impossible. |
3-
| ImpossibleJavadocThrows.java:23:5:23:12 | @throws | Javadoc for bad3 claims to throw Runnable but this is impossible. |

java/ql/test/query-tests/Javadoc/ImpossibleJavadocThrows.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ public void bad1() {
1818
public void bad2() {
1919
}
2020

21-
/**
22-
*
23-
* @throws Runnable
24-
*/
25-
public void bad3() {
26-
}
27-
2821
/**
2922
*
3023
* @throws InterruptedException

0 commit comments

Comments
 (0)