Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/previewfeature/FieldsWithJdkInternalJavacPreviewFeature.java
Nikita Eshkeev c40da789be [PreviewFeature] IDEA-259284 Support the new PreviewFeature annotation's package
This patch encapsulates the logic that checks if a used feature is annotated with PreviewFeature in its own visitor. The visitor now checks both PreviewFeature annotations with old and new packages.

GitOrigin-RevId: f3ddc2a840b8c3a8bb4e1a731e2c208002a29fd4
2021-01-13 20:54:42 +00:00

31 lines
1.3 KiB
Java

import jdk.internal.javac.PreviewFeature;
import jdk.internal.javac.PreviewFeature.Feature;
class Main {
@PreviewFeature(feature=Feature.PATTERN_MATCHING_IN_INSTANCEOF)
static String instanceOf;
@PreviewFeature(feature=Feature.RECORDS)
static long records;
@PreviewFeature(feature=Feature.TEXT_BLOCKS)
String textBlocks;
int i;
<error descr="Patterns in 'instanceof' are not supported at language level '9'">org.myorg.jdk.internal.javac.preview.FromPreview</error> preview;
static {
String s = <error descr="Text block literals are not supported at language level '9'">new Main().textBlocks</error>;
String o = <error descr="Patterns in 'instanceof' are not supported at language level '9'">Main.instanceOf</error>;
long l = <error descr="Records are not supported at language level '9'">records</error>;
int k = new Main().i;
<error descr="Patterns in 'instanceof' are not supported at language level '9'">org.myorg.jdk.internal.javac.preview.FromPreview</error> local = null;
}
void f(<error descr="Text block literals are not supported at language level '9'">NotDirectlyAnnotatedField</error> a) {
<error descr="Text block literals are not supported at language level '9'">a.id</error> = 0;
}
}
@PreviewFeature(feature=Feature.TEXT_BLOCKS)
class NotDirectlyAnnotatedField {
int id;
}