Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import com.facebook.litho.specmodels.model.SpecElementType;
import com.google.testing.compile.CompilationRule;
import javax.annotation.Nullable;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import org.jetbrains.annotations.NotNull;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -38,7 +38,7 @@ public class SpecElementTypeDeterminatorTest {
* for.
*/
public static class FakeKotlinSingleton {
@Nullable public static final FakeKotlinSingleton INSTANCE = null;
@NotNull public static final FakeKotlinSingleton INSTANCE = null;
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;

public class SpecElementTypeDeterminator {
static boolean isKotlinSingleton(TypeElement element) {
Expand Down Expand Up @@ -72,6 +75,8 @@ static boolean isPublicStaticFinalElement(Element e) {
}

static boolean isElementWithTypeName(Element e, String name) {
return e.asType().toString().equals(name);
TypeMirror type = e.asType();
return type.getKind() == TypeKind.DECLARED
&& ((TypeElement) ((DeclaredType) type).asElement()).getQualifiedName().contentEquals(name);
}
}
Loading