[dart:js_interop] Fix operator precedence in determining constructor type

Fixes https://github.com/dart-lang/sdk/issues/55107

The lack of parentheses around the ternary operator made the check
invalid when there are members that aren't constructors in the
extension type.

Change-Id: I87ce918c478113f682d3df28f148b7f59d4fd075
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355883
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
diff --git a/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart b/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart
index cad1e25..5b6d6a3 100644
--- a/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart
+++ b/pkg/_js_interop_checks/lib/src/transformations/js_util_optimizer.dart
@@ -958,10 +958,8 @@
       final kind = getExtensionTypeDescriptor(node)?.kind;
       final namedParams = node.function.namedParameters;
       return (kind == ExtensionTypeMemberKind.Constructor ||
-                  kind == ExtensionTypeMemberKind.Factory) &&
-              literal
-          ? namedParams.isNotEmpty
-          : namedParams.isEmpty;
+              kind == ExtensionTypeMemberKind.Factory) &&
+          (literal ? namedParams.isNotEmpty : namedParams.isEmpty);
     } else if (node.kind == ProcedureKind.Factory &&
         node.enclosingClass != null &&
         hasJSInteropAnnotation(node.enclosingClass!)) {
diff --git a/tests/lib/js/static_interop_test/isa/static_test.dart b/tests/lib/js/static_interop_test/isa/static_test.dart
index 1836a25..89ede85 100644
--- a/tests/lib/js/static_interop_test/isa/static_test.dart
+++ b/tests/lib/js/static_interop_test/isa/static_test.dart
@@ -8,6 +8,15 @@
 
 extension type NonLiteral._(JSObject o) implements JSObject {}
 
+extension type NonLiteralWithMembers._(JSObject o) implements JSObject {
+  external NonLiteralWithMembers();
+
+  external bool field;
+  external bool get getter;
+  external void setter(bool _);
+  external void method();
+}
+
 extension type ObjectLiteral._(JSObject o) implements JSObject {
   external ObjectLiteral({int a});
 }
@@ -43,6 +52,7 @@
   tearoffWithGenericTypeParam();
 
   any.isA<NonLiteral>();
+  any.isA<NonLiteralWithMembers>();
   any.isA<ObjectLiteral>();
   //  ^
   // [web] Type argument 'ObjectLiteral' has an object literal constructor. Because 'isA' uses the type's name or '@JS()' rename, this may result in an incorrect type check.