Skip to content

Commit

Permalink
Remove a very literal change-detector test, and move the comment to t…
Browse files Browse the repository at this point in the history
…he production code (which seems more discoverable).

PiperOrigin-RevId: 627693317
  • Loading branch information
graememorgan authored and Error Prone Team committed Apr 24, 2024
1 parent f289d9e commit fd9b826
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fd9b826

Please sign in to comment.