dart-sdk/tests/dartdevc_2/js_interop_non_external_lib.dart
Srujan Gaddam 293ae7dabe [ddc] Add interop classes for static members
Fixes https://github.com/dart-lang/sdk/issues/46967

Creates classes for non-external factories and static members, and
modifies invocations to point to these members instead. Tear-offs of
interop constructors (external or otherwise) are now supported since
they're just non-external static methods.

Change-Id: Id754fb4bc872051a8df4169aefd4bdc078452fb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270501
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-12-08 04:57:50 +00:00

44 lines
1 KiB
Dart

// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
// Define a JS class in a different library to test that name resolution works
// for non-external factories and static methods. Also uses class type
// parameters to make sure we generate a generic class.
@JS()
library js_interop_non_external_lib;
import 'package:js/js.dart';
@JS('JSClass')
class OtherJSClass<T> {
external OtherJSClass.cons(T t);
factory OtherJSClass(T t) {
field = 'unnamed';
return OtherJSClass.cons(t);
}
factory OtherJSClass.named(T t) {
field = 'named';
return OtherJSClass.cons(t);
}
factory OtherJSClass.redirecting(T t) = OtherJSClass;
static String field = '';
static String get getSet {
return field;
}
static set getSet(String val) {
field = val;
}
static String method() => field;
static T genericMethod<T>(T t) => t;
}