From fd9b826d595cabe56a66c060ce52504cd24630af Mon Sep 17 00:00:00 2001 From: ghm Date: Wed, 24 Apr 2024 05:15:01 -0700 Subject: [PATCH] Remove a very literal change-detector test, and move the comment to the production code (which seems more discoverable). PiperOrigin-RevId: 627693317 --- .../annotations/CompileTimeConstant.java | 3 +++ .../CompileTimeConstantExpressionMatcherTest.java | 14 -------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/annotations/src/main/java/com/google/errorprone/annotations/CompileTimeConstant.java b/annotations/src/main/java/com/google/errorprone/annotations/CompileTimeConstant.java index c1348a89e50..a420676186c 100644 --- a/annotations/src/main/java/com/google/errorprone/annotations/CompileTimeConstant.java +++ b/annotations/src/main/java/com/google/errorprone/annotations/CompileTimeConstant.java @@ -130,5 +130,8 @@ */ @Documented @Retention(CLASS) +// TODO(xtof): We'd like to eventually support other cases, but I first need to determine with +// confidence that the checker can ensure all initializations and assignments to such variables are +// compile-time-constant. @Target({ElementType.PARAMETER, ElementType.FIELD}) public @interface CompileTimeConstant {} diff --git a/core/src/test/java/com/google/errorprone/matchers/CompileTimeConstantExpressionMatcherTest.java b/core/src/test/java/com/google/errorprone/matchers/CompileTimeConstantExpressionMatcherTest.java index 550414d108d..5d8dd39ec0b 100644 --- a/core/src/test/java/com/google/errorprone/matchers/CompileTimeConstantExpressionMatcherTest.java +++ b/core/src/test/java/com/google/errorprone/matchers/CompileTimeConstantExpressionMatcherTest.java @@ -16,19 +16,15 @@ package com.google.errorprone.matchers; -import static com.google.common.truth.Truth.assertThat; import static com.google.errorprone.BugPattern.SeverityLevel.WARNING; import static com.google.errorprone.util.ASTHelpers.getSymbol; import com.google.errorprone.BugPattern; import com.google.errorprone.CompilationTestHelper; import com.google.errorprone.VisitorState; -import com.google.errorprone.annotations.CompileTimeConstant; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher; import com.sun.source.tree.VariableTree; -import java.lang.annotation.ElementType; -import java.lang.annotation.Target; import javax.lang.model.element.ElementKind; import org.junit.Test; import org.junit.runner.RunWith; @@ -170,16 +166,6 @@ public void finalCompileTimeConstantConstructorParameters() { .doTest(); } - // TODO(xtof): We'd like to eventually support other cases, but I first need - // to determine with confidence that the checker can ensure all initializations - // and assignments to such variables are compile-time-constant. - // For now, the annotation's target is restricted to ElementType.PARAMETER. - @Test - public void compileTimeConstantAnnotationOnlyAllowedOnParameterOrField() { - assertThat(CompileTimeConstant.class.getAnnotation(Target.class).value()) - .isEqualTo(new ElementType[] {ElementType.PARAMETER, ElementType.FIELD}); - } - @Test public void conditionalExpression() { testHelper