[ddc] do not enforce assertInterop on native methods from native tests

Change-Id: I3819da5708bc8a7f21d14d5531d9178c05839f45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178140
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart b/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart
index 4f3b390..363ff0b 100644
--- a/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart
+++ b/pkg/dev_compiler/lib/src/compiler/shared_compiler.dart
@@ -482,7 +482,7 @@
   /// Emits imports and extension methods into [items].
   @protected
   void emitImportsAndExtensionSymbols(List<js_ast.ModuleItem> items,
-      {bool forceExtensionSymbols: false}) {
+      {bool forceExtensionSymbols = false}) {
     var modules = <String, List<Library>>{};
 
     for (var import in _imports.keys) {
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index 83399b9..9a1b17c 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -2460,7 +2460,7 @@
   js_ast.PropertyAccess _emitTopLevelNameNoInterop(NamedNode n,
       {String suffix = ''}) {
     // Some native tests use top-level native methods.
-    var isTopLevelNative = n is Member && _isNative(n);
+    var isTopLevelNative = n is Member && isNative(n);
     return js_ast.PropertyAccess(
         isTopLevelNative
             ? runtimeCall('global.self')
@@ -6229,31 +6229,3 @@
 
   _SwitchLabelState(this.label, this.variable);
 }
-
-/// Whether [member] is declared native, as in:
-///
-///    void foo() native;
-///
-/// This syntax is only allowed in sdk libraries like `dart:html` and native
-/// tests.
-bool _isNative(Member member) {
-  // The CFE represents `native` members with the `external` bit and with an
-  // internal @ExternalName annotation.
-  if (member.isExternal &&
-      allowedNativeTest(member.enclosingLibrary.importUri)) {
-    for (var annotation in member.annotations) {
-      if (annotation is ConstantExpression) {
-        var constant = annotation.constant;
-        if (constant is InstanceConstant &&
-            constant.classNode.name == 'ExternalName' &&
-            _isDartInternal(constant.classNode.enclosingLibrary.importUri)) {
-          return true;
-        }
-      }
-    }
-  }
-  return false;
-}
-
-bool _isDartInternal(Uri uri) =>
-    uri.scheme == 'dart' && uri.path == '_internal';
diff --git a/pkg/dev_compiler/lib/src/kernel/js_interop.dart b/pkg/dev_compiler/lib/src/kernel/js_interop.dart
index ae20b09..13b1f25 100644
--- a/pkg/dev_compiler/lib/src/kernel/js_interop.dart
+++ b/pkg/dev_compiler/lib/src/kernel/js_interop.dart
@@ -45,7 +45,9 @@
 bool isJsMember(Member member) {
   // TODO(vsm): If we ever use external outside the SDK for non-JS interop,
   // we're need to fix this.
-  return !_isLibrary(member.enclosingLibrary, ['dart:*']) && member.isExternal;
+  return !_isLibrary(member.enclosingLibrary, ['dart:*']) &&
+      member.isExternal &&
+      !isNative(member);
 }
 
 bool _annotationIsFromJSLibrary(String expectedName, Expression value) {
diff --git a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
index fbc740a..64eb246 100644
--- a/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
+++ b/pkg/dev_compiler/lib/src/kernel/kernel_helpers.dart
@@ -353,3 +353,28 @@
       t is TypedefType ||
       t is VoidType;
 }
+
+/// Whether [member] is declared native, as in:
+///
+///    void foo() native;
+///
+/// This syntax is only allowed in sdk libraries and native tests.
+bool isNative(Member member) =>
+    // The CFE represents `native` members with the `external` bit and with an
+    // internal @ExternalName annotation as a marker.
+    member.isExternal && member.annotations.any(_isNativeMarkerAnnotation);
+
+bool _isNativeMarkerAnnotation(Expression annotation) {
+  if (annotation is ConstantExpression) {
+    var constant = annotation.constant;
+    if (constant is InstanceConstant &&
+        constant.classNode.name == 'ExternalName' &&
+        _isDartInternal(constant.classNode.enclosingLibrary.importUri)) {
+      return true;
+    }
+  }
+  return false;
+}
+
+bool _isDartInternal(Uri uri) =>
+    uri.scheme == 'dart' && uri.path == '_internal';