Version 2.11.0-162.0.dev
Merge commit 'f04f00adaca1780d83751604b30e4d23a4c7e711' into 'dev'
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
index 3ffe641..542262d 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_export_of_internal_element_test.dart
@@ -2,12 +2,8 @@
// 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.
-import 'package:analyzer/dart/analysis/analysis_context.dart';
-import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/test_utilities/mock_packages.dart';
-import 'package:analyzer/src/workspace/bazel.dart';
-import 'package:analyzer/src/workspace/package_build.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/context_collection_resolution.dart';
@@ -25,9 +21,6 @@
class InvalidExportOfInternalElement_BazelPackageTest
extends BazelWorkspaceResolutionTest
with InvalidExportOfInternalElementTest {
- /// A cached analysis context for resolving sources via the same [Workspace].
- AnalysisContext analysisContext;
-
String get testPackageBazelBinPath => '$workspaceRootPath/bazel-bin/dart/my';
String get testPackageGenfilesPath =>
@@ -37,13 +30,6 @@
String get testPackageLibPath => myPackageLibPath;
@override
- Future<ResolvedUnitResult> resolveFile(String path) {
- analysisContext ??= contextFor(path);
- assert(analysisContext.workspace is BazelWorkspace);
- return analysisContext.currentSession.getResolvedUnit(path);
- }
-
- @override
void setUp() async {
super.setUp();
var metaPath = '$workspaceThirdPartyDartPath/meta';
@@ -59,14 +45,12 @@
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- newFile('$testPackageBazelBinPath/lib/bar.dart', content: r'''
+ await resolveFileCode('$testPackageBazelBinPath/lib/bar.dart', r'''
export 'src/foo.dart';
''');
- await resolveFile2('$testPackageBazelBinPath/lib/bar.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT, 0, 22),
]);
}
@@ -76,14 +60,12 @@
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- newFile('$testPackageBazelBinPath/lib/src/bar.dart', content: r'''
+ await resolveFileCode('$testPackageBazelBinPath/lib/src/bar.dart', r'''
export 'foo.dart';
''');
- await resolveFile2('$testPackageBazelBinPath/lib/src/bar.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_exporterIsInGenfilesLib() async {
@@ -91,14 +73,12 @@
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- newFile('$testPackageGenfilesPath/lib/bar.dart', content: r'''
+ await resolveFileCode('$testPackageGenfilesPath/lib/bar.dart', r'''
export 'src/foo.dart';
''');
- await resolveFile2('$testPackageGenfilesPath/lib/bar.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT, 0, 22),
]);
}
@@ -108,14 +88,12 @@
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- newFile('$testPackageGenfilesPath/lib/src/bar.dart', content: r'''
+ await resolveFileCode('$testPackageGenfilesPath/lib/src/bar.dart', r'''
export 'foo.dart';
''');
- await resolveFile2('$testPackageGenfilesPath/lib/src/bar.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_exporterIsInLib() async {
@@ -124,12 +102,11 @@
@internal class One {}
''');
- newFile('$testPackageLibPath/bar.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/bar.dart', r'''
export 'src/foo.dart';
''');
- await resolveFile2('$testPackageLibPath/bar.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT, 0, 22),
]);
}
@@ -140,12 +117,11 @@
@internal class One {}
''');
- newFile('$testPackageLibPath/src/bar.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/src/bar.dart', r'''
export 'foo.dart';
''');
- await resolveFile2('$testPackageLibPath/src/bar.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_exporterIsInTest() async {
@@ -154,12 +130,11 @@
@internal class One {}
''');
- newFile('$myPackageRootPath/test/foo_test.dart', content: r'''
+ await resolveFileCode('$myPackageRootPath/test/foo_test.dart', r'''
export 'package:dart.my/src/foo.dart';
''');
- await resolveFile2('$myPackageRootPath/test/foo_test.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_internalIsInBazelBin() async {
@@ -205,56 +180,43 @@
@reflectiveTest
class InvalidExportOfInternalElement_PackageBuildPackageTest
extends InvalidExportOfInternalElement_PubPackageTest {
- /// A cached analysis context for resolving sources via the same [Workspace].
- AnalysisContext analysisContext;
-
String get testPackageDartToolPath =>
'$testPackageRootPath/.dart_tool/build/generated/test';
- @override
- Future<ResolvedUnitResult> resolveFile(String path) {
- analysisContext ??= contextFor(path);
- assert(analysisContext.workspace is PackageBuildWorkspace);
- return analysisContext.currentSession.getResolvedUnit(path);
- }
-
- @override
- void setUp() async {
- analysisContext = null;
- super.setUp();
- newFolder(testPackageDartToolPath);
- }
-
+ @FailingTest(reason: r'''
+We try to analyze a file in .dart_tool, which is implicitly excluded from
+analysis. So, there is no context to analyze it.
+''')
void test_exporterInGeneratedLib() async {
newFile('$testPackageRootPath/lib/src/foo.dart', content: r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageRootPath/lib/src/foo.dart');
- newFile('$testPackageDartToolPath/lib/bar.dart', content: r'''
+ await resolveFileCode('$testPackageDartToolPath/lib/bar.dart', r'''
export 'package:test/src/foo.dart';
''');
- await resolveFile2('$testPackageDartToolPath/lib/bar.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT, 0, 35),
]);
}
+ @FailingTest(reason: r'''
+We try to analyze a file in .dart_tool, which is implicitly excluded from
+analysis. So, there is no context to analyze it.
+''')
void test_exporterInGeneratedLibSrc() async {
newFile('$testPackageRootPath/lib/src/foo.dart', content: r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageRootPath/lib/src/foo.dart');
- newFile('$testPackageDartToolPath/lib/src/bar.dart', content: r'''
+ await resolveFileCode('$testPackageDartToolPath/lib/src/bar.dart', r'''
export 'package:test/src/foo.dart';
''');
- await resolveFile2('$testPackageDartToolPath/lib/src/bar.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_exporterInLib() async {
@@ -262,14 +224,12 @@
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageRootPath/lib/src/foo.dart');
- newFile('$testPackageRootPath/lib/bar.dart', content: r'''
+ await resolveFileCode('$testPackageRootPath/lib/bar.dart', r'''
export 'package:test/src/foo.dart';
''');
- await resolveFile2('$testPackageRootPath/lib/bar.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT, 0, 35),
]);
}
@@ -279,14 +239,12 @@
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageRootPath/lib/src/foo.dart');
- newFile('$testPackageRootPath/lib/src/bar.dart', content: r'''
+ await resolveFileCode('$testPackageRootPath/lib/src/bar.dart', r'''
export 'package:test/src/foo.dart';
''');
- await resolveFile2('$testPackageRootPath/lib/src/bar.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_internalIsInGeneratedLibSrc() async {
@@ -336,12 +294,11 @@
@internal class One {}
''');
- newFile('$testPackageLibPath/bar.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/bar.dart', r'''
export 'src/foo.dart';
''');
- await resolveFile2('$testPackageLibPath/bar.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT, 0, 22),
]);
}
@@ -352,12 +309,11 @@
@internal class One {}
''');
- newFile('$testPackageLibPath/src/bar.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/src/bar.dart', r'''
export 'foo.dart';
''');
- await resolveFile2('$testPackageLibPath/src/bar.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_exporterIsInTest() async {
@@ -366,12 +322,11 @@
@internal class One {}
''');
- newFile('$testPackageRootPath/test/foo_test.dart', content: r'''
+ await resolveFileCode('$testPackageRootPath/test/foo_test.dart', r'''
export 'package:test/src/foo.dart';
''');
- await resolveFile2('$testPackageRootPath/test/foo_test.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_internalIsLibSrc() async {
diff --git a/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart b/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart
index 7de20a1..8a3ca44 100644
--- a/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/invalid_internal_annotation_test.dart
@@ -15,8 +15,7 @@
@reflectiveTest
class InvalidInternalAnnotationTest extends PubPackageResolutionTest {
- String get testPackageImplementationFilePath =>
- '$testPackageLibPath/src/foo.dart';
+ String get testPackageLibSrcFilePath => '$testPackageLibPath/src/foo.dart';
@override
void setUp() async {
@@ -29,137 +28,126 @@
}
void test_annotationInLib() async {
- newFile('$testPackageLibPath/foo.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/foo.dart', r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageLibPath/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
]);
}
void test_annotationInLib_onLibrary() async {
- newFile('$testPackageLibPath/foo.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/foo.dart', r'''
@internal
library foo;
import 'package:meta/meta.dart';
''');
- await resolveFile2('$testPackageLibPath/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 0, 9),
]);
}
void test_annotationInLibSrc() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_annotationInLibSrcSubdirectory() async {
- newFile('$testPackageLibPath/src/foo/foo.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/src/foo/foo.dart', r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageLibPath/src/foo/foo.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_annotationInLibSubdirectory() async {
- newFile('$testPackageLibPath/foo/foo.dart', content: r'''
+ await resolveFileCode('$testPackageLibPath/foo/foo.dart', r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageLibPath/foo/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
]);
}
void test_annotationInTest() async {
- newFile('$testPackageRootPath/test/foo_test.dart', content: r'''
+ await resolveFileCode('$testPackageRootPath/test/foo_test.dart', r'''
import 'package:meta/meta.dart';
@internal class One {}
''');
- await resolveFile2('$testPackageRootPath/test/foo_test.dart');
- assertErrorsInResolvedUnit(result, []);
+ assertNoErrorsInResult();
}
void test_privateClass() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal class _One {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
error(HintCode.UNUSED_ELEMENT, 49, 4),
]);
}
void test_privateClassConstructor_named() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class _C {
@internal _C.named();
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.UNUSED_ELEMENT, 39, 2),
error(HintCode.INVALID_INTERNAL_ANNOTATION, 46, 9),
]);
}
void test_privateClassConstructor_unnamed() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class _C {
@internal _C();
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.UNUSED_ELEMENT, 39, 2),
error(HintCode.INVALID_INTERNAL_ANNOTATION, 46, 9),
]);
}
void test_privateConstructor() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class C {
@internal C._f();
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 45, 9),
]);
}
void test_privateEnum() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal enum _E {one}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
error(HintCode.UNUSED_ELEMENT, 48, 2),
error(HintCode.UNUSED_FIELD, 52, 3),
@@ -167,193 +155,179 @@
}
void test_privateEnumValue() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
enum E {@internal _one}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 41, 9),
error(HintCode.UNUSED_FIELD, 51, 4),
]);
}
void test_privateExtension() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal extension _One on String {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
]);
}
void test_privateExtension_unnamed() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal extension on String {}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
]);
}
void test_privateField_instance() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class C {
@internal int _i = 0;
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.UNUSED_FIELD, 59, 2),
error(HintCode.INVALID_INTERNAL_ANNOTATION, 59, 6),
]);
}
void test_privateField_static() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class C {
@internal static int _i = 0;
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.UNUSED_FIELD, 66, 2),
error(HintCode.INVALID_INTERNAL_ANNOTATION, 66, 6),
]);
}
void test_privateGetter() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class C {
@internal int get _i => 0;
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 45, 9),
error(HintCode.UNUSED_ELEMENT, 63, 2),
]);
}
void test_privateMethod_instance() async {
- newFile(testPackageImplementationFilePath, content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class C {
@internal void _f() {}
}
''');
- await resolveFile2(testPackageImplementationFilePath);
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 45, 9),
error(HintCode.UNUSED_ELEMENT, 60, 2),
]);
}
void test_privateMethod_static() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class C {
@internal static void _f() {}
}
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 45, 9),
error(HintCode.UNUSED_ELEMENT, 67, 2),
]);
}
void test_privateMixin() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal mixin _One {}
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
error(HintCode.UNUSED_ELEMENT, 49, 4),
]);
}
void test_privateTopLevelFunction() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal void _f() {}
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
error(HintCode.UNUSED_ELEMENT, 48, 2),
]);
}
void test_privateTopLevelVariable() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal int _i = 1;
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 47, 6),
error(HintCode.UNUSED_ELEMENT, 47, 2),
]);
}
void test_privateTypedef() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
@internal typedef _T = void Function();
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.INVALID_INTERNAL_ANNOTATION, 33, 9),
error(HintCode.UNUSED_ELEMENT, 51, 2),
]);
}
void test_publicMethod_privateClass() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class _C {
@internal void f() {}
}
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.UNUSED_ELEMENT, 39, 2),
]);
}
void test_publicMethod_privateClass_static() async {
- newFile('$testPackageLibPath/src/foo.dart', content: r'''
+ await resolveFileCode(testPackageLibSrcFilePath, r'''
import 'package:meta/meta.dart';
class _C {
@internal static void f() {}
}
''');
- await resolveFile2('$testPackageLibPath/src/foo.dart');
- assertErrorsInResolvedUnit(result, [
+ assertErrorsInResult([
error(HintCode.UNUSED_ELEMENT, 39, 2),
error(HintCode.UNUSED_ELEMENT, 68, 1),
]);
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index 5eeb420..98f2f79 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -447,7 +447,7 @@
new OptionHandler(Flags.enableNativeNullAssertions, passThrough),
new OptionHandler(Flags.trustTypeAnnotations, setTrustTypeAnnotations),
new OptionHandler(Flags.trustPrimitives, passThrough),
- new OptionHandler(Flags.trustJSInteropTypeAnnotations, passThrough),
+ new OptionHandler(Flags.trustJSInteropTypeAnnotations, ignoreOption),
new OptionHandler(r'--help|/\?|/h', (_) => wantHelp = true),
new OptionHandler('--packages=.+', setPackageConfig),
new OptionHandler(Flags.noSourceMaps, passThrough),
diff --git a/pkg/compiler/lib/src/kernel/element_map_impl.dart b/pkg/compiler/lib/src/kernel/element_map_impl.dart
index a574666..ab22c77 100644
--- a/pkg/compiler/lib/src/kernel/element_map_impl.dart
+++ b/pkg/compiler/lib/src/kernel/element_map_impl.dart
@@ -1939,10 +1939,6 @@
KernelBehaviorBuilder(this.elementEnvironment, this.commonElements,
this.nativeBasicData, this.reporter, this.options);
-
- @override
- bool get trustJSInteropTypeAnnotations =>
- options.trustJSInteropTypeAnnotations;
}
class KernelNativeMemberResolver implements NativeMemberResolver {
diff --git a/pkg/compiler/lib/src/native/behavior.dart b/pkg/compiler/lib/src/native/behavior.dart
index a01fac5..0457090 100644
--- a/pkg/compiler/lib/src/native/behavior.dart
+++ b/pkg/compiler/lib/src/native/behavior.dart
@@ -736,7 +736,6 @@
CommonElements get commonElements;
DiagnosticReporter get reporter;
NativeBasicData get nativeBasicData;
- bool get trustJSInteropTypeAnnotations;
ElementEnvironment get elementEnvironment;
CompilerOptions get options;
DartTypes get dartTypes => commonElements.dartTypes;
@@ -817,21 +816,13 @@
_behavior.typesInstantiated.add(type);
}
- if (!trustJSInteropTypeAnnotations || dartTypes.isTopType(type)) {
- // By saying that only JS-interop types can be created, we prevent
- // pulling in every other native type (e.g. all of dart:html) when a
- // JS interop API returns dynamic or when we don't trust the type
- // annotations. This means that to some degree we still use the return
- // type to decide whether to include native types, even if we don't
- // trust the type annotation.
- ClassEntity cls = commonElements.jsJavaScriptObjectClass;
- _behavior.typesInstantiated.add(elementEnvironment.getThisType(cls));
- } else {
- // Otherwise, when the declared type is a Dart type, we do not
- // register an allocation because we assume it cannot be instantiated
- // from within the JS-interop code. It must have escaped from another
- // API.
- }
+ // By saying that only JS-interop types can be created, we prevent
+ // pulling in every other native type (e.g. all of dart:html) when a
+ // JS interop API returns dynamic. This means that to some degree we
+ // still use the return type to decide whether to include native types,
+ // even though we don't trust the type annotation.
+ ClassEntity cls = commonElements.jsJavaScriptObjectClass;
+ _behavior.typesInstantiated.add(elementEnvironment.getThisType(cls));
}
}
}
@@ -868,9 +859,7 @@
{bool isJsInterop}) {
_behavior = new NativeBehavior();
// TODO(sigmund,sra): consider doing something better for numeric types.
- _addReturnType(!isJsInterop || trustJSInteropTypeAnnotations
- ? type
- : commonElements.dynamicType);
+ _addReturnType(!isJsInterop ? type : commonElements.dynamicType);
_capture(type, isJsInterop);
_overrideWithAnnotations(
createsAnnotations, returnsAnnotations, lookupType);
@@ -898,15 +887,12 @@
// Note: For dart:html and other internal libraries we maintain, we can
// trust the return type and use it to limit what we enqueue. We have to
// be more conservative about JS interop types and assume they can return
- // anything (unless the user provides the experimental flag to trust the
- // type of js-interop APIs). We do restrict the allocation effects and say
- // that interop calls create only interop types (which may be unsound if
- // an interop call returns a DOM type and declares a dynamic return type,
- // but otherwise we would include a lot of code by default).
+ // anything. We do restrict the allocation effects and say that interop
+ // calls create only interop types (which may be unsound if an interop call
+ // returns a DOM type and declares a dynamic return type, but otherwise we
+ // would include a lot of code by default).
// TODO(sigmund,sra): consider doing something better for numeric types.
- _addReturnType(!isJsInterop || trustJSInteropTypeAnnotations
- ? returnType
- : commonElements.dynamicType);
+ _addReturnType(!isJsInterop ? returnType : commonElements.dynamicType);
_capture(type, isJsInterop);
for (DartType type in type.optionalParameterTypes) {
diff --git a/pkg/compiler/lib/src/options.dart b/pkg/compiler/lib/src/options.dart
index f9d0f30..f8c7901 100644
--- a/pkg/compiler/lib/src/options.dart
+++ b/pkg/compiler/lib/src/options.dart
@@ -281,9 +281,6 @@
/// The compiler is run from the build bot.
bool testMode = false;
- /// Whether to trust JS-interop annotations. (experimental)
- bool trustJSInteropTypeAnnotations = false;
-
/// Whether to trust primitive types during inference and optimizations.
bool trustPrimitives = false;
@@ -506,8 +503,6 @@
.._legacyJavaScript = _hasOption(options, Flags.legacyJavaScript)
.._noLegacyJavaScript = _hasOption(options, Flags.noLegacyJavaScript)
..testMode = _hasOption(options, Flags.testMode)
- ..trustJSInteropTypeAnnotations =
- _hasOption(options, Flags.trustJSInteropTypeAnnotations)
..trustPrimitives = _hasOption(options, Flags.trustPrimitives)
..useContentSecurityPolicy =
_hasOption(options, Flags.useContentSecurityPolicy)
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index e093833..b3b3e6f 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -4967,11 +4967,6 @@
new js.Template(null, js.objectLiteral(parameterNameMap));
var nativeBehavior = new NativeBehavior()..codeTemplate = codeTemplate;
- if (options.trustJSInteropTypeAnnotations) {
- InterfaceType thisType =
- _elementEnvironment.getThisType(constructor.enclosingClass);
- nativeBehavior.typesReturned.add(thisType);
- }
registry.registerNativeMethod(element);
// TODO(efortuna): Source information.
return new HForeignCode(
@@ -4991,10 +4986,9 @@
? _elementEnvironment.getThisType(element.enclosingClass)
: _elementEnvironment.getFunctionType(element).returnType;
// Native behavior effects here are similar to native/behavior.dart.
- // The return type is dynamic if we don't trust js-interop type
+ // The return type is dynamic because we don't trust js-interop type
// declarations.
- nativeBehavior.typesReturned.add(
- options.trustJSInteropTypeAnnotations ? type : dartTypes.dynamicType());
+ nativeBehavior.typesReturned.add(dartTypes.dynamicType());
// The allocation effects include the declared type if it is native (which
// includes js interop types).
@@ -5003,14 +4997,13 @@
nativeBehavior.typesInstantiated.add(type);
}
- // It also includes any other JS interop type if we don't trust the
- // annotation or if is declared too broad.
- if (!options.trustJSInteropTypeAnnotations ||
- type == _commonElements.objectType ||
- type is DynamicType) {
- nativeBehavior.typesInstantiated.add(_elementEnvironment
- .getThisType(_commonElements.jsJavaScriptObjectClass));
- }
+ // It also includes any other JS interop type. Technically, a JS interop API
+ // could return anything, so the sound thing to do would be to assume that
+ // anything that may come from JS as instantiated. In order to prevent the
+ // resulting code bloat (e.g. from `dart:html`), we unsoundly assume that
+ // only JS interop types are returned.
+ nativeBehavior.typesInstantiated.add(_elementEnvironment
+ .getThisType(_commonElements.jsJavaScriptObjectClass));
AbstractValue instructionType =
_typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld);
diff --git a/pkg/compiler/test/helpers/compiler_helper.dart b/pkg/compiler/test/helpers/compiler_helper.dart
index 562741f..eb7046a 100644
--- a/pkg/compiler/test/helpers/compiler_helper.dart
+++ b/pkg/compiler/test/helpers/compiler_helper.dart
@@ -37,7 +37,6 @@
bool enableTypeAssertions: false,
bool minify: false,
bool disableInlining: true,
- bool trustJSInteropTypeAnnotations: false,
bool disableTypeInference: true,
bool omitImplicitChecks: true,
bool enableVariance: false,
@@ -58,9 +57,6 @@
if (minify) {
options.add(Flags.minify);
}
- if (trustJSInteropTypeAnnotations) {
- options.add(Flags.trustJSInteropTypeAnnotations);
- }
if (disableInlining) {
options.add(Flags.disableInlining);
}
diff --git a/pkg/compiler/test/jsinterop/interop_anonymous_unreachable_test.dart b/pkg/compiler/test/jsinterop/interop_anonymous_unreachable_test.dart
index ded9c90..2e4e586 100644
--- a/pkg/compiler/test/jsinterop/interop_anonymous_unreachable_test.dart
+++ b/pkg/compiler/test/jsinterop/interop_anonymous_unreachable_test.dart
@@ -80,16 +80,6 @@
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_B"));
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_C"));
Expect.isTrue(generated1.contains("UniqueLongNameForTesting_E"));
-
- print(' - tree-shake when using flag -');
- String generated2 = await compile(program,
- trustJSInteropTypeAnnotations: true, returnAll: true);
- Expect.isTrue(generated2.contains("UniqueLongNameForTesting_A"));
- Expect.isTrue(generated2.contains("UniqueLongNameForTesting_D"));
-
- Expect.isFalse(generated2.contains("UniqueLongNameForTesting_B"));
- Expect.isFalse(generated2.contains("UniqueLongNameForTesting_C"));
- Expect.isFalse(generated2.contains("UniqueLongNameForTesting_E"));
}
testTreeShakingNativeTypes() async {
@@ -122,14 +112,6 @@
// but we exclude other native types like HTMLAudioElement
Expect.isFalse(generated1.contains("HTMLAudioElement"));
- print(' - allocation effect of dynamic excludes native types [flag] -');
- // Trusting types doesn't make a difference.
- String generated2 = await compile(program,
- trustJSInteropTypeAnnotations: true, returnAll: true);
- Expect.isTrue(generated2.contains("UniqueLongNameForTesting_A"));
- Expect.isTrue(generated2.contains("UniqueLongNameForTesting_B"));
- Expect.isFalse(generated2.contains("HTMLAudioElement"));
-
print(' - declared native types are included in allocation effect -');
String program2 = """
import 'dart:html';
diff --git a/pkg/dev_compiler/lib/src/kernel/compiler.dart b/pkg/dev_compiler/lib/src/kernel/compiler.dart
index d6ee556..f4d1611 100644
--- a/pkg/dev_compiler/lib/src/kernel/compiler.dart
+++ b/pkg/dev_compiler/lib/src/kernel/compiler.dart
@@ -4200,8 +4200,14 @@
@override
js_ast.Expression visitPropertyGet(PropertyGet node) {
- return _emitPropertyGet(
- node.receiver, node.interfaceTarget, node.name.text);
+ var propertyGet =
+ _emitPropertyGet(node.receiver, node.interfaceTarget, node.name.text);
+ if (_isCheckableNative(node.interfaceTarget)) {
+ // If target is a native getter with a non-nullable type, add a null check
+ // for soundness.
+ return runtimeCall('checkNativeNonNull(#)', [propertyGet]);
+ }
+ return propertyGet;
}
@override
@@ -4264,6 +4270,16 @@
}
}
+ /// Return whether [member] returns a native object whose type needs to be
+ /// checked.
+ bool _isCheckableNative(Member member) =>
+ member != null &&
+ member.isExternal &&
+ _extensionTypes.isNativeClass(member.enclosingClass) &&
+ member is Procedure &&
+ member.function != null &&
+ member.function.returnType.isPotentiallyNonNullable;
+
// TODO(jmesserly): can we encapsulate REPL name lookups and remove this?
// _emitMemberName would be a nice place to handle it, but we don't have
// access to the target expression there (needed for `dart.replNameLookup`).
@@ -4334,8 +4350,14 @@
@override
js_ast.Expression visitMethodInvocation(MethodInvocation node) {
- return _emitMethodCall(
+ var methodCall = _emitMethodCall(
node.receiver, node.interfaceTarget, node.arguments, node);
+ if (_isCheckableNative(node.interfaceTarget)) {
+ // If target is a native method with a non-nullable type, add a null check
+ // for soundness.
+ return runtimeCall('checkNativeNonNull(#)', [methodCall]);
+ }
+ return methodCall;
}
@override
@@ -5066,11 +5088,30 @@
var result = js.parseForeignJS(source).instantiate(jsArgs);
+ // Add a check to make sure any JS() values from a native type are typed
+ // properly.
+ if (_isWebLibrary(_currentLibrary.importUri)) {
+ var type = node.getStaticType(_staticTypeContext);
+ if (type.isPotentiallyNonNullable) {
+ result = runtimeCall('checkNativeNonNull(#)', [result]);
+ }
+ }
+
assert(result is js_ast.Expression ||
result is js_ast.Statement && node.parent is ExpressionStatement);
return result;
}
+ bool _isWebLibrary(Uri importUri) =>
+ importUri.scheme == 'dart' &&
+ (importUri.path == 'html' ||
+ importUri.path == 'svg' ||
+ importUri.path == 'indexed_db' ||
+ importUri.path == 'web_audio' ||
+ importUri.path == 'web_gl' ||
+ importUri.path == 'web_sql' ||
+ importUri.path == 'html_common');
+
bool _isNull(Expression expr) =>
expr is NullLiteral ||
expr.getStaticType(_staticTypeContext) == _coreTypes.nullType;
diff --git a/pkg/dev_compiler/tool/ddb b/pkg/dev_compiler/tool/ddb
index b2cd5ce..126090a 100755
--- a/pkg/dev_compiler/tool/ddb
+++ b/pkg/dev_compiler/tool/ddb
@@ -54,6 +54,11 @@
'parameters are not null.',
defaultsTo: false,
negatable: true)
+ ..addFlag('native-null-assertions',
+ help: 'Run with assertions on non-nullable values returned from native '
+ 'APIs.',
+ defaultsTo: true,
+ negatable: true)
..addFlag('observe',
help:
'Run the compiler in the Dart VM with --observe. Implies --debug.',
@@ -109,6 +114,7 @@
var run = mode == 'run' || mode == 'all';
var verbose = options['verbose'] as bool;
var nonNullAsserts = options['null-assertions'] as bool;
+ var nativeNonNullAsserts = options['null-assertions'] as bool;
var soundNullSafety = options['sound-null-safety'] as bool;
// Enable null safety either by passing the `non-nullable` experiment flag or
@@ -280,6 +286,7 @@
if ($nnbd) {
sdk.dart.weakNullSafetyWarnings(!$soundNullSafety);
sdk.dart.nonNullAsserts($nonNullAsserts);
+ sdk.dart.nativeNonNullAsserts($nativeNonNullAsserts);
}
sdk._debugger.registerDevtoolsFormatter();
app.$libname.main([]);
@@ -315,6 +322,7 @@
if ($nnbd) {
sdk.dart.weakNullSafetyWarnings(!$soundNullSafety);
sdk.dart.nonNullAsserts($nonNullAsserts);
+ sdk.dart.nativeNonNullAsserts($nativeNonNullAsserts);
}
sdk._isolate_helper.startRootIsolate(main, []);
} catch(e) {
@@ -351,6 +359,7 @@
if ($nnbd) {
dart.weakNullSafetyWarnings(!$soundNullSafety);
dart.nonNullAsserts($nonNullAsserts);
+ dart.nativeNonNullAsserts($nativeNonNullAsserts);
}
_isolate_helper.startRootIsolate(() => {}, []);
main([]);
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
index d931293..6fcd3d1 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart
@@ -870,3 +870,10 @@
}
return ${defineProperty(to, name, desc)};
})()''');
+
+checkNativeNonNull(dynamic variable) {
+ if (_nativeNonNullAsserts) {
+ return nullCheck(variable);
+ }
+ return variable;
+}
diff --git a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
index 8dd643c..acb1615 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/types.dart
@@ -44,6 +44,15 @@
_nonNullAsserts = enable;
}
+@notNull
+bool _nativeNonNullAsserts = false;
+
+/// Enables null assertions on native APIs to make sure value returned from the
+/// browser is sound. These apply to dart:html and similar web libraries.
+void nativeNonNullAsserts(bool enable) {
+ _nativeNonNullAsserts = enable;
+}
+
final metadata = JS('', 'Symbol("metadata")');
/// Types in dart are represented internally at runtime as follows.
diff --git a/tests/lib/html/js_typed_interop_anonymous2_exp_test.dart b/tests/lib/html/js_typed_interop_anonymous2_exp_test.dart
deleted file mode 100644
index 2c827b8..0000000
--- a/tests/lib/html/js_typed_interop_anonymous2_exp_test.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2015, 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.
-
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Same test as js_typed_interop_anonymous2, but using the
-// --experimental-trust-js-interop-type-annotations flag.
-@JS()
-library js_typed_interop_anonymous2_exp_test;
-
-import 'dart:html';
-import 'dart:js' as js;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class A {
- external factory A({B? b});
-
- external B? get b;
-}
-
-@JS()
-@anonymous
-class B {
- external factory B({C? c});
-
- external C? get c;
-}
-
-@JS()
-@anonymous
-class C {
- external factory C();
-}
-
-// D is unreachable, and that is OK
-@JS()
-@anonymous
-class D {
- external factory D();
-}
-
-main() {
- test('simple', () {
- var b = new B();
- var a = new A(b: b);
- expect(a.b, equals(b));
- expect(b.c, isNull);
- });
-}
diff --git a/tests/lib/html/js_typed_interop_anonymous_exp_test.dart b/tests/lib/html/js_typed_interop_anonymous_exp_test.dart
deleted file mode 100644
index e160bdd..0000000
--- a/tests/lib/html/js_typed_interop_anonymous_exp_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2015, 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.
-
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Same test as js_typed_interop_anonymous, but using the
-// --experimental-trust-js-interop-type-annotations flag.
-@JS()
-library js_typed_interop_anonymous_exp_test;
-
-import 'dart:html';
-import 'dart:js' as js;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class Literal {
- external factory Literal({int? x, String? y, num? z});
-
- external int? get x;
- external String? get y;
- external num? get z;
-}
-
-main() {
- test('simple', () {
- var l = new Literal(x: 3, y: "foo");
- expect(l.x, equals(3));
- expect(l.y, equals("foo"));
- expect(l.z, isNull);
- });
-}
diff --git a/tests/lib/html/js_typed_interop_anonymous_unreachable_exp_test.dart b/tests/lib/html/js_typed_interop_anonymous_unreachable_exp_test.dart
deleted file mode 100644
index 046dcff..0000000
--- a/tests/lib/html/js_typed_interop_anonymous_unreachable_exp_test.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2015, 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.
-
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Same test as js_typed_interop_anonymous_unreachable, but using the
-// --experimental-trust-js-interop-type-annotations flag.
-@JS()
-library js_typed_interop_anonymous_unreachable_exp_test;
-
-import 'dart:html';
-import 'dart:js' as js;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class Literal {
- external factory Literal({required int x, required String y, required num z});
-
- external int get x;
- external String get y;
- external num get z;
-}
-
-main() {
- test('nothing to do', () {
- // This test is empty, but it is a regression for Issue# 24974: dart2js
- // would crash trying to compile code that used @anonymous and that was
- // not reachable from main.
- });
-}
diff --git a/tests/lib/html/js_typed_interop_side_cast_exp_test.dart b/tests/lib/html/js_typed_interop_side_cast_exp_test.dart
deleted file mode 100644
index be112c8..0000000
--- a/tests/lib/html/js_typed_interop_side_cast_exp_test.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2015, 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.
-
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Similar test to js_typed_interop_side_cast, but because we are using the
-// --experimental-trust-js-interop-type-annotations flag, we test a slightly
-// different behavior.
-@JS()
-library js_typed_interop_side_cast_exp_test;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class A {
- external int get x;
- external factory A({required int x});
-}
-
-@JS()
-@anonymous
-class B {
- external int get x;
- external factory B({required int x});
-}
-
-@JS()
-@anonymous
-class C {
- external int get x;
- external factory C({required int x});
-}
-
-main() {
- test('side-casts work for reachable types', () {
- new C(x: 3); // make C reachable
- dynamic a = new A(x: 3);
- expect(a is C, isTrue);
- C c = a;
- expect(c.x, equals(3));
- });
-
- // Note: this test would fail without the experimental flag.
- test('side-casts do not work for unreachable types', () {
- dynamic a = new A(x: 3);
- expect(a is B, isFalse); //# 01: ok
- });
-}
diff --git a/tests/lib_2/html/js_typed_interop_anonymous2_exp_test.dart b/tests/lib_2/html/js_typed_interop_anonymous2_exp_test.dart
deleted file mode 100644
index ba4afc2..0000000
--- a/tests/lib_2/html/js_typed_interop_anonymous2_exp_test.dart
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2015, 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.
-//
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Same test as js_typed_interop_anonymous2, but using the
-// --experimental-trust-js-interop-type-annotations flag.
-@JS()
-library js_typed_interop_anonymous2_exp_test;
-
-import 'dart:html';
-import 'dart:js' as js;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class A {
- external factory A({B b});
-
- external B get b;
-}
-
-@JS()
-@anonymous
-class B {
- external factory B({C c});
-
- external C get c;
-}
-
-@JS()
-@anonymous
-class C {
- external factory C();
-}
-
-// D is unreachable, and that is OK
-@JS()
-@anonymous
-class D {
- external factory D();
-}
-
-main() {
- test('simple', () {
- var b = new B();
- var a = new A(b: b);
- expect(a.b, equals(b));
- expect(b.c, isNull);
- });
-}
diff --git a/tests/lib_2/html/js_typed_interop_anonymous_exp_test.dart b/tests/lib_2/html/js_typed_interop_anonymous_exp_test.dart
deleted file mode 100644
index 362a41c..0000000
--- a/tests/lib_2/html/js_typed_interop_anonymous_exp_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2015, 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.
-//
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Same test as js_typed_interop_anonymous, but using the
-// --experimental-trust-js-interop-type-annotations flag.
-@JS()
-library js_typed_interop_anonymous_exp_test;
-
-import 'dart:html';
-import 'dart:js' as js;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class Literal {
- external factory Literal({int x, String y, num z});
-
- external int get x;
- external String get y;
- external num get z;
-}
-
-main() {
- test('simple', () {
- var l = new Literal(x: 3, y: "foo");
- expect(l.x, equals(3));
- expect(l.y, equals("foo"));
- expect(l.z, isNull);
- });
-}
diff --git a/tests/lib_2/html/js_typed_interop_anonymous_unreachable_exp_test.dart b/tests/lib_2/html/js_typed_interop_anonymous_unreachable_exp_test.dart
deleted file mode 100644
index 95c6141..0000000
--- a/tests/lib_2/html/js_typed_interop_anonymous_unreachable_exp_test.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2015, 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.
-//
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Same test as js_typed_interop_anonymous_unreachable, but using the
-// --experimental-trust-js-interop-type-annotations flag.
-@JS()
-library js_typed_interop_anonymous_unreachable_exp_test;
-
-import 'dart:html';
-import 'dart:js' as js;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class Literal {
- external factory Literal({int x, String y, num z});
-
- external int get x;
- external String get y;
- external num get z;
-}
-
-main() {
- test('nothing to do', () {
- // This test is empty, but it is a regression for Issue# 24974: dart2js
- // would crash trying to compile code that used @anonymous and that was
- // not reachable from main.
- });
-}
diff --git a/tests/lib_2/html/js_typed_interop_side_cast_exp_test.dart b/tests/lib_2/html/js_typed_interop_side_cast_exp_test.dart
deleted file mode 100644
index a5061fb..0000000
--- a/tests/lib_2/html/js_typed_interop_side_cast_exp_test.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2015, 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.
-//
-// SharedOptions=--experimental-trust-js-interop-type-annotations
-
-// Similar test to js_typed_interop_side_cast, but because we are using the
-// --experimental-trust-js-interop-type-annotations flag, we test a slightly
-// different behavior.
-@JS()
-library js_typed_interop_side_cast_exp_test;
-
-import 'package:js/js.dart';
-import 'package:expect/minitest.dart';
-
-@JS()
-@anonymous
-class A {
- external int get x;
- external factory A({int x});
-}
-
-@JS()
-@anonymous
-class B {
- external int get x;
- external factory B({int x});
-}
-
-@JS()
-@anonymous
-class C {
- external int get x;
- external factory C({int x});
-}
-
-main() {
- test('side-casts work for reachable types', () {
- new C(x: 3); // make C reachable
- dynamic a = new A(x: 3);
- expect(a is C, isTrue);
- C c = a;
- expect(c.x, equals(3));
- });
-
- // Note: this test would fail without the experimental flag.
- test('side-casts do not work for unreachable types', () {
- dynamic a = new A(x: 3);
- expect(a is B, isFalse); //# 01: ok
- });
-}
diff --git a/tools/VERSION b/tools/VERSION
index e19e106..2ace34c 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 11
PATCH 0
-PRERELEASE 161
+PRERELEASE 162
PRERELEASE_PATCH 0
\ No newline at end of file