Skip to content

Commit

Permalink
Automated g4 rollback of changelist 365712527.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Didn't fix Swift importing issue.

*** Original change description ***

Adds @SwiftUnavailable annotation to annotate methods with NS_SWIFT_UNAVAILABLE macro.

PiperOrigin-RevId: 365894292
  • Loading branch information
tomball authored and copybara-github committed Mar 30, 2021
1 parent 7ce8b8a commit 9d9ff05
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 60 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@
import com.google.devtools.j2objc.util.TranslationUtil;
import com.google.devtools.j2objc.util.TypeUtil;
import com.google.devtools.j2objc.util.UnicodeUtils;
import com.google.j2objc.annotations.SwiftUnavailable;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
Expand Down Expand Up @@ -612,12 +610,6 @@ private void printMethodDeclaration(MethodDeclaration m, boolean isCompanionClas
if (m.isUnavailable()) {
print(" NS_UNAVAILABLE");
}
AnnotationMirror annotation =
ElementUtil.getAnnotation(m.getExecutableElement(), SwiftUnavailable.class);
if (annotation != null) {
String message = (String) ElementUtil.getAnnotationValue(annotation, "value");
print(" NS_SWIFT_UNAVAILABLE(\"" + message + "\")");
}
println(";");
}

Expand All @@ -643,7 +635,6 @@ private boolean hasDeprecated(List<Annotation> annotations) {
return false;
}


@Override
protected void printNativeDeclaration(NativeDeclaration declaration) {
String code = declaration.getHeaderCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,15 +782,4 @@ public void testConstructorMapping() throws IOException {
fail("No mapping found for MyClass() constructor");
}
}

public void testSwiftUnavailableAnnotation() throws IOException {
String source = String.join("\n",
"import com.google.j2objc.annotations.SwiftUnavailable;",
"class Test {",
" @SwiftUnavailable(\"test message\")",
" public void test() {}",
"}");
String translation = translateSourceFile(source, "Test", "Test.h");
assertTranslation(translation, "- (void)test NS_SWIFT_UNAVAILABLE(\"test message\");");
}
}

0 comments on commit 9d9ff05

Please sign in to comment.