// Copyright (c) 2018, 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 import 'dart:io' show File; import 'package:async_helper/async_helper.dart' show asyncTest; import 'package:front_end/src/api_prototype/compiler_options.dart' show CompilerOptions; import 'package:front_end/src/api_prototype/kernel_generator.dart' show kernelForModule; import 'package:front_end/src/api_prototype/memory_file_system.dart' show MemoryFileSystem; import 'package:front_end/src/base/processed_options.dart' show ProcessedOptions; import 'package:front_end/src/compute_platform_binaries_location.dart' show computePlatformBinariesLocation; import 'package:front_end/src/fasta/compiler_context.dart' show CompilerContext; import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent; import 'package:front_end/src/fasta/kernel/verifier.dart' show verifyComponent; import 'package:kernel/ast.dart' show Component; const Map files = const { "repro.dart": """ import 'lib.dart'; abstract class M implements Map> {} abstract class C extends UnmodifiableMapView> with M { C._() : super(null); } """, "lib.dart": """abstract class MapView { const MapView(Map map); } abstract class _UnmodifiableMapMixin {} abstract class UnmodifiableMapView extends MapView with _UnmodifiableMapMixin { UnmodifiableMapView(Map map) : super(map); }""", }; Future test() async { final String platformBaseName = "vm_platform_strong.dill"; final Uri base = Uri.parse("org-dartlang-test:///"); final Uri platformDill = base.resolve(platformBaseName); final List platformDillBytes = await new File.fromUri( computePlatformBinariesLocation(forceBuildDir: true) .resolve(platformBaseName)) .readAsBytes(); MemoryFileSystem fs = new MemoryFileSystem(base); fs.entityForUri(platformDill).writeAsBytesSync(platformDillBytes); fs .entityForUri(base.resolve("lib.dart")) .writeAsStringSync(files["lib.dart"]); CompilerOptions options = new CompilerOptions() ..fileSystem = fs ..sdkSummary = platformDill; Component component = (await kernelForModule([base.resolve("lib.dart")], options)) .component; fs = new MemoryFileSystem(base); fs.entityForUri(platformDill).writeAsBytesSync(platformDillBytes); fs .entityForUri(base.resolve("lib.dart.dill")) .writeAsBytesSync(serializeComponent(component)); fs .entityForUri(base.resolve("repro.dart")) .writeAsStringSync(files["repro.dart"]); options = new CompilerOptions() ..fileSystem = fs ..additionalDills = [base.resolve("lib.dart.dill")] ..sdkSummary = platformDill; List inputs = [base.resolve("repro.dart")]; component = (await kernelForModule(inputs, options)).component; List errors = await CompilerContext.runWithOptions( new ProcessedOptions(options: options, inputs: inputs), (_) => new Future>.value( verifyComponent(component, skipPlatform: true))); serializeComponent(component); if (errors.isNotEmpty) { throw "Verification failed"; } } main() { asyncTest(test); }