Class StubparserRecordTest
The records these stub files annotate are compiled from source, in this same directory, so the
test needs -AmergeStubsWithSource: that is what makes an annotation file apply to a class
that is being compiled.
Without it the test passed, but only by accident, and it was order-dependent.
AnnotatedTypeFactory.fromElement consults the stub files only when
declarationFromElement finds no tree for the element, so whether a source-declared element gets
its stub annotations depends on whether javac still has its tree at the moment of the element's
first use -- and whichever type is computed first is frozen into elementCache for the
rest of the compilation. Adding a file to this directory whose name sorts before
PairRecord.java was enough to change the answer: new PairRecord(null) in
RecordUsage.java began reporting argument.type.incompatible, because the constructor's
type was cached from its source declaration, without the @Nullable its stub file gives
it.
-
Field Summary
Fields inherited from class org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest
checkerNames, checkerOptions, classpathExtra, testDir, testFiles -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckResult(TypecheckResult typecheckResult) Check that theTypecheckResultdid not fail.static String[]protected FileResolves the test root directory from the optionalTestRootDirectoryannotation or falls back to the default ofcurrentDir/tests.Methods inherited from class org.checkerframework.framework.test.CheckerFrameworkPerDirectoryTest
adjustTypecheckResult, customizeOptions, run
-
Constructor Details
-
StubparserRecordTest
Create a StubparserRecordTest.- Parameters:
testFiles- the files containing test code, which will be type-checked
-
-
Method Details
-
getTestDirs
-
resolveTestDirectory
Resolves the test root directory from the optionalTestRootDirectoryannotation or falls back to the default ofcurrentDir/tests.- Returns:
- the resolved directory
-
checkResult
Check that theTypecheckResultdid not fail.- Parameters:
typecheckResult- result to check
-