Version 1.23.0-dev.9.0 Merge commit '9a9074bf6b26d6a4202571172270c64ade4b6dc9' into dev
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_locator.dart b/pkg/analysis_server/lib/src/plugin/plugin_locator.dart index 968ee53..85e3527 100644 --- a/pkg/analysis_server/lib/src/plugin/plugin_locator.dart +++ b/pkg/analysis_server/lib/src/plugin/plugin_locator.dart
@@ -37,6 +37,8 @@ */ final ResourceProvider resourceProvider; + final Map<String, String> pluginMap = <String, String>{}; + /** * Initialize a newly created plugin locator to use the given * [resourceProvider] to access the file system. @@ -56,6 +58,13 @@ * returning it. */ String findPlugin(String packageRoot) { + return pluginMap.putIfAbsent(packageRoot, () => _findPlugin(packageRoot)); + } + + /** + * The implementation of [findPlugin]. + */ + String _findPlugin(String packageRoot) { Folder packageFolder = resourceProvider.getFolder(packageRoot); File pubspecFile = packageFolder.getChildAssumingFile(pubspecFileName); if (pubspecFile.exists) {
diff --git a/pkg/analysis_server/lib/src/services/correction/assist.dart b/pkg/analysis_server/lib/src/services/correction/assist.dart index 3b8ea1c..7158950 100644 --- a/pkg/analysis_server/lib/src/services/correction/assist.dart +++ b/pkg/analysis_server/lib/src/services/correction/assist.dart
@@ -83,6 +83,8 @@ 'CONVERT_DOCUMENTATION_INTO_LINE', 30, "Convert into line documentation comment"); + static const CONVERT_FLUTTER_CHILD = + const AssistKind('CONVERT_FLUTTER_CHILD', 30, "Convert to children:"); static const CONVERT_INTO_BLOCK_BODY = const AssistKind( 'CONVERT_INTO_BLOCK_BODY', 30, "Convert into block body"); static const CONVERT_INTO_EXPRESSION_BODY = const AssistKind( @@ -119,10 +121,10 @@ "Join 'if' statement with outer 'if' statement"); static const JOIN_VARIABLE_DECLARATION = const AssistKind( 'JOIN_VARIABLE_DECLARATION', 30, "Join variable declaration"); - static const MOVE_FLUTTER_WIDGET_DOWN = const AssistKind( - "MOVE_FLUTTER_WIDGET_DOWN", 30, "Move widget down"); - static const MOVE_FLUTTER_WIDGET_UP = const AssistKind( - "MOVE_FLUTTER_WIDGET_UP", 30, "Move widget up"); + static const MOVE_FLUTTER_WIDGET_DOWN = + const AssistKind("MOVE_FLUTTER_WIDGET_DOWN", 30, "Move widget down"); + static const MOVE_FLUTTER_WIDGET_UP = + const AssistKind("MOVE_FLUTTER_WIDGET_UP", 30, "Move widget up"); static const REPARENT_FLUTTER_LIST = const AssistKind( "REPARENT_FLUTTER_LIST", 30, "Wrap widget list with new widget"); static const REPARENT_FLUTTER_WIDGET = const AssistKind(
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart index c343b17..18d32b1 100644 --- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart +++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -121,6 +121,7 @@ _addProposal_convertDocumentationIntoLine(); _addProposal_convertToBlockFunctionBody(); _addProposal_convertToExpressionFunctionBody(); + _addProposal_convertFlutterChild(); _addProposal_convertToForIndexLoop(); _addProposal_convertToIsNot_onIs(); _addProposal_convertToIsNot_onNot(); @@ -505,6 +506,73 @@ _addAssist(DartAssistKind.CONVERT_DOCUMENTATION_INTO_LINE, []); } + void _addProposal_convertFlutterChild() { + NamedExpression namedExp; + // Allow assist to activate from either the new-expr or the child: arg. + if (node is SimpleIdentifier && + node.parent is Label && + node.parent.parent is NamedExpression) { + namedExp = node.parent.parent as NamedExpression; + if ((node as SimpleIdentifier).name != 'child' || + namedExp.expression == null) { + return; + } + if (namedExp.parent?.parent is! InstanceCreationExpression) { + return; + } + InstanceCreationExpression newExpr = namedExp.parent.parent; + if (newExpr == null || !_isFlutterInstanceCreationExpression(newExpr)) { + return; + } + } else { + InstanceCreationExpression newExpr = _identifyNewExpression(); + if (newExpr == null || !_isFlutterInstanceCreationExpression(newExpr)) { + _coverageMarker(); + return; + } + namedExp = _findChildArgument(newExpr); + if (namedExp == null || namedExp.expression == null) { + _coverageMarker(); + return; + } + } + InstanceCreationExpression childArg = _getChildWidget(namedExp, false); + if (childArg == null) { + _coverageMarker(); + return; + } + int childLoc = namedExp.offset + 'child'.length; + _addInsertEdit(childLoc, 'ren'); + int listLoc = childArg.offset; + String childArgSrc = utils.getNodeText(childArg); + if (!childArgSrc.contains(eol)) { + _addInsertEdit(listLoc, '<Widget>['); + _addInsertEdit(listLoc + childArg.length, ']'); + } else { + int newlineLoc = childArgSrc.lastIndexOf(eol); + if (newlineLoc == childArgSrc.length) { + newlineLoc -= 1; + } + String indentOld = utils.getLinePrefix(childArg.offset + 1 + newlineLoc); + String indentNew = '$indentOld${utils.getIndent(1)}'; + // The separator includes 'child:' but that has no newlines. + String separator = + utils.getText(namedExp.offset, childArg.offset - namedExp.offset); + String prefix = separator.contains(eol) ? "" : "$eol$indentNew"; + if (prefix.isEmpty) { + _addInsertEdit(namedExp.offset + 'child:'.length, ' <Widget>['); + _addRemoveEdit(rangeStartLength(childArg.offset - 2, 2)); + } else { + _addInsertEdit(listLoc, '<Widget>['); + } + String newChildArgSrc = childArgSrc.replaceAll( + new RegExp("^$indentOld", multiLine: true), "$indentNew"); + newChildArgSrc = "$prefix$newChildArgSrc,$eol$indentOld]"; + _addReplaceEdit(rangeNode(childArg), newChildArgSrc); + } + _addAssist(DartAssistKind.CONVERT_FLUTTER_CHILD, []); + } + void _addProposal_convertIntoFinalField() { // Find the enclosing getter. MethodDeclaration getter; @@ -2311,11 +2379,12 @@ return _getChildWidget(child); } - InstanceCreationExpression _getChildWidget(NamedExpression child) { + InstanceCreationExpression _getChildWidget(NamedExpression child, + [bool strict = false]) { if (child?.expression is InstanceCreationExpression) { InstanceCreationExpression childNewExpr = child.expression; if (_isFlutterInstanceCreationExpression(childNewExpr)) { - if (_findChildArgument(childNewExpr) != null) { + if (!strict || (_findChildArgument(childNewExpr) != null)) { return childNewExpr; } }
diff --git a/pkg/analysis_server/test/services/correction/assist_test.dart b/pkg/analysis_server/test/services/correction/assist_test.dart index b52c25d..29b3920 100644 --- a/pkg/analysis_server/test/services/correction/assist_test.dart +++ b/pkg/analysis_server/test/services/correction/assist_test.dart
@@ -1036,6 +1036,129 @@ '''); } + test_convertFlutterChild_OK_multiLine() async { + _configureFlutterPkg({ + 'src/widgets/framework.dart': _flutter_framework_code, + }); + await resolveTestUnit(''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + /*caret*/child: new Container( + width: 200.0, + height: 300.0, + ), + key: null, + ), +// end + ); +} +'''); + _setCaretLocation(); + await assertHasAssist( + DartAssistKind.CONVERT_FLUTTER_CHILD, + ''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + /*caret*/children: <Widget>[ + new Container( + width: 200.0, + height: 300.0, + ), + ], + key: null, + ), +// end + ); +} +'''); + } + + test_convertFlutterChild_OK_newlineChild() async { + // This case could occur with deeply nested constructors, common in Flutter. + _configureFlutterPkg({ + 'src/widgets/framework.dart': _flutter_framework_code, + }); + await resolveTestUnit(''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + /*caret*/child: + new Container( + width: 200.0, + height: 300.0, + ), + key: null, + ), +// end + ); +} +'''); + _setCaretLocation(); + await assertHasAssist( + DartAssistKind.CONVERT_FLUTTER_CHILD, + ''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + /*caret*/children: <Widget>[ + new Container( + width: 200.0, + height: 300.0, + ), + ], + key: null, + ), +// end + ); +} +'''); + } + + test_convertFlutterChild_OK_singleLine() async { + _configureFlutterPkg({ + 'src/widgets/framework.dart': _flutter_framework_code, + }); + await resolveTestUnit(''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + /*caret*/child: new GestureDetector(), + key: null, + ), +// end + ); +} +'''); + _setCaretLocation(); + await assertHasAssist( + DartAssistKind.CONVERT_FLUTTER_CHILD, + ''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + /*caret*/children: <Widget>[new GestureDetector()], + key: null, + ), +// end + ); +} +'''); + } + test_convertToBlockBody_BAD_noEnclosingFunction() async { await resolveTestUnit(''' var v = 123; @@ -3502,6 +3625,104 @@ '''); } + test_moveFlutterWidgetDown_OK() async { + _configureFlutterPkg({ + 'src/widgets/framework.dart': _flutter_framework_code, + }); + await resolveTestUnit(''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new /*caret*/GestureDetector( + onTap: () => startResize(), + child: new Center( + child: new Container( + width: 200.0, + height: 300.0, + ), + key: null, + ), + ), +// end + ); +} +startResize() {} +'''); + _setCaretLocation(); + await assertHasAssist( + DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN, + ''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + child: new /*caret*/GestureDetector( + onTap: () => startResize(), + child: new Container( + width: 200.0, + height: 300.0, + ), + ), + key: null, + ), +// end + ); +} +startResize() {} +'''); + } + + test_moveFlutterWidgetUp_OK() async { + _configureFlutterPkg({ + 'src/widgets/framework.dart': _flutter_framework_code, + }); + await resolveTestUnit(''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new Center( + child: new /*caret*/GestureDetector( + onTap: () => startResize(), + child: new Container( + width: 200.0, + height: 300.0, + ), + ), + key: null, + ), +// end + ); +} +startResize() {} +'''); + _setCaretLocation(); + await assertHasAssist( + DartAssistKind.MOVE_FLUTTER_WIDGET_UP, + ''' +import 'package:flutter/src/widgets/framework.dart'; +build() { + return new Scaffold( +// start + body: new /*caret*/GestureDetector( + onTap: () => startResize(), + child: new Center( + child: new Container( + width: 200.0, + height: 300.0, + ), + key: null, + ), + ), +// end + ); +} +startResize() {} +'''); + } + test_removeTypeAnnotation_classField_OK() async { await resolveTestUnit(''' class A { @@ -3666,104 +3887,6 @@ await assertNoAssist(DartAssistKind.REPARENT_FLUTTER_LIST); } - test_moveFlutterWidgetDown_OK() async { - _configureFlutterPkg({ - 'src/widgets/framework.dart': _flutter_framework_code, - }); - await resolveTestUnit(''' -import 'package:flutter/src/widgets/framework.dart'; -build() { - return new Scaffold( -// start - body: new /*caret*/GestureDetector( - onTap: () => startResize(), - child: new Center( - child: new Container( - width: 200.0, - height: 300.0, - ), - key: null, - ), - ), -// end - ); -} -startResize() {} -'''); - _setCaretLocation(); - await assertHasAssist( - DartAssistKind.MOVE_FLUTTER_WIDGET_DOWN, - ''' -import 'package:flutter/src/widgets/framework.dart'; -build() { - return new Scaffold( -// start - body: new Center( - child: new /*caret*/GestureDetector( - onTap: () => startResize(), - child: new Container( - width: 200.0, - height: 300.0, - ), - ), - key: null, - ), -// end - ); -} -startResize() {} -'''); - } - - test_moveFlutterWidgetUp_OK() async { - _configureFlutterPkg({ - 'src/widgets/framework.dart': _flutter_framework_code, - }); - await resolveTestUnit(''' -import 'package:flutter/src/widgets/framework.dart'; -build() { - return new Scaffold( -// start - body: new Center( - child: new /*caret*/GestureDetector( - onTap: () => startResize(), - child: new Container( - width: 200.0, - height: 300.0, - ), - ), - key: null, - ), -// end - ); -} -startResize() {} -'''); - _setCaretLocation(); - await assertHasAssist( - DartAssistKind.MOVE_FLUTTER_WIDGET_UP, - ''' -import 'package:flutter/src/widgets/framework.dart'; -build() { - return new Scaffold( -// start - body: new /*caret*/GestureDetector( - onTap: () => startResize(), - child: new Center( - child: new Container( - width: 200.0, - height: 300.0, - ), - key: null, - ), - ), -// end - ); -} -startResize() {} -'''); - } - test_reparentFlutterList_OK_multiLine() async { _configureFlutterPkg({ 'src/widgets/framework.dart': _flutter_framework_code,
diff --git a/pkg/compiler/lib/src/closure.dart b/pkg/compiler/lib/src/closure.dart index 9d7dc74..95962b6 100644 --- a/pkg/compiler/lib/src/closure.dart +++ b/pkg/compiler/lib/src/closure.dart
@@ -1081,7 +1081,7 @@ closedWorldRefiner.registerClosureClass(globalizedElement); MethodElement callElement = new SynthesizedCallMethodElementX( Identifiers.call, element, globalizedElement, node, elements); - backend.mirrorsData.maybeMarkClosureAsNeededForReflection( + backend.mirrorsDataBuilder.maybeMarkClosureAsNeededForReflection( globalizedElement, callElement, element); MemberElement enclosing = element.memberContext; enclosing.nestedClosures.add(callElement);
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart index 372938b..7a6b935 100644 --- a/pkg/compiler/lib/src/js_backend/backend.dart +++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -380,10 +380,10 @@ bool htmlLibraryIsLoaded = false; /// Resolution analysis for tracking reflective access to type variables. - TypeVariableResolutionAnalysis typeVariableResolutionAnalysis; + TypeVariableResolutionAnalysis _typeVariableResolutionAnalysis; /// Codegen handler for reflective access to type variables. - TypeVariableCodegenAnalysis typeVariableCodegenAnalysis; + TypeVariableCodegenAnalysis _typeVariableCodegenAnalysis; /// Resolution support for generating table of interceptors and /// constructors for custom elements. @@ -440,7 +440,7 @@ OneShotInterceptorData _oneShotInterceptorData; BackendUsage _backendUsage; BackendUsageBuilder _backendUsageBuilder; - MirrorsData mirrorsData; + MirrorsDataImpl _mirrorsData; CheckedModeHelpers _checkedModeHelpers; native.NativeResolutionEnqueuer _nativeResolutionEnqueuer; @@ -504,7 +504,7 @@ impacts = new BackendImpacts(compiler.options, commonElements, helpers); backendClasses = new JavaScriptBackendClasses( compiler.elementEnvironment, helpers, nativeBaseData); - mirrorsData = new MirrorsData( + _mirrorsData = new MirrorsDataImpl( compiler, compiler.options, commonElements, helpers, constants); _backendUsageBuilder = new BackendUsageBuilderImpl( compiler.elementEnvironment, commonElements, helpers); @@ -515,10 +515,8 @@ _nativeCodegenEnqueuer = new native.NativeCodegenEnqueuer( compiler, emitter, _nativeResolutionEnqueuer); - typeVariableResolutionAnalysis = new TypeVariableResolutionAnalysis( + _typeVariableResolutionAnalysis = new TypeVariableResolutionAnalysis( compiler.elementEnvironment, impacts, backendUsageBuilder); - typeVariableCodegenAnalysis = - new TypeVariableCodegenAnalysis(this, helpers, mirrorsData); customElementsResolutionAnalysis = new CustomElementsResolutionAnalysis( compiler.resolution, constantSystem, @@ -550,7 +548,7 @@ nativeBaseData, nativeResolutionEnqueuer, backendUsageBuilder, - mirrorsData, + mirrorsDataBuilder, customElementsResolutionAnalysis, rtiNeedBuilder); patchResolverTask = new PatchResolverTask(compiler); @@ -574,6 +572,24 @@ Target get target => _target; + /// Resolution analysis for tracking reflective access to type variables. + TypeVariableResolutionAnalysis get typeVariableResolutionAnalysis { + assert(invariant(NO_LOCATION_SPANNABLE, _typeVariableCodegenAnalysis == null, + message: "TypeVariableHandler has already been created.")); + return _typeVariableResolutionAnalysis; + } + + /// Codegen handler for reflective access to type variables. + TypeVariableCodegenAnalysis get typeVariableCodegenAnalysis { + assert(invariant(NO_LOCATION_SPANNABLE, _typeVariableCodegenAnalysis != null, + message: "TypeVariableHandler has not been created yet.")); + return _typeVariableCodegenAnalysis; + } + + MirrorsData get mirrorsData => _mirrorsData; + + MirrorsDataBuilder get mirrorsDataBuilder => _mirrorsData; + /// Codegen support for tree-shaking entries of `LookupMap`. LookupMapAnalysis get lookupMapAnalysis { assert(invariant(NO_LOCATION_SPANNABLE, _lookupMapAnalysis != null, @@ -782,7 +798,7 @@ for (Entity entity in compiler.enqueuer.resolution.processedEntities) { processAnnotations(entity, closedWorldRefiner); } - mirrorsData.computeMembersNeededForReflection( + mirrorsDataBuilder.computeMembersNeededForReflection( compiler.enqueuer.resolution.worldBuilder, closedWorld); _backendUsage = _backendUsageBuilder.close(); _rtiNeed = rtiNeedBuilder.computeRuntimeTypesNeed( @@ -875,7 +891,7 @@ _interceptorDataBuilder, _backendUsageBuilder, _rtiNeedBuilder, - mirrorsData, + mirrorsDataBuilder, noSuchMethodRegistry, customElementsResolutionAnalysis, lookupMapResolutionAnalysis, @@ -890,6 +906,7 @@ /// Creates an [Enqueuer] for code generation specific to this backend. CodegenEnqueuer createCodegenEnqueuer( CompilerTask task, Compiler compiler, ClosedWorld closedWorld) { + _typeVariableCodegenAnalysis = new TypeVariableCodegenAnalysis(this, helpers, mirrorsData); _lookupMapAnalysis = new LookupMapAnalysis( reporter, constantSystem, @@ -914,7 +931,6 @@ backendClasses, backendUsage, rtiNeed, - mirrorsData, customElementsCodegenAnalysis, typeVariableCodegenAnalysis, lookupMapAnalysis, @@ -1192,7 +1208,6 @@ rtiNeed, nativeCodegenEnqueuer, namer, - mirrorsData, oneShotInterceptorData, lookupMapAnalysis, rtiChecksBuilder);
diff --git a/pkg/compiler/lib/src/js_backend/codegen_listener.dart b/pkg/compiler/lib/src/js_backend/codegen_listener.dart index 81e8cd3..d867b23 100644 --- a/pkg/compiler/lib/src/js_backend/codegen_listener.dart +++ b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
@@ -39,7 +39,6 @@ final BackendUsage _backendUsage; final RuntimeTypesNeed _rtiNeed; - final MirrorsData _mirrorsData; final CustomElementsCodegenAnalysis _customElementsAnalysis; final TypeVariableCodegenAnalysis _typeVariableCodegenAnalysis; @@ -58,7 +57,6 @@ this._backendClasses, this._backendUsage, this._rtiNeed, - this._mirrorsData, this._customElementsAnalysis, this._typeVariableCodegenAnalysis, this._lookupMapAnalysis, @@ -251,7 +249,6 @@ @override WorldImpact registerUsedElement(MemberElement member) { WorldImpactBuilderImpl worldImpact = new WorldImpactBuilderImpl(); - _mirrorsData.registerUsedMember(member); _customElementsAnalysis.registerStaticUse(member); if (member.isFunction && member.isInstanceMember) {
diff --git a/pkg/compiler/lib/src/js_backend/impact_transformer.dart b/pkg/compiler/lib/src/js_backend/impact_transformer.dart index e4ad53e..f244be1 100644 --- a/pkg/compiler/lib/src/js_backend/impact_transformer.dart +++ b/pkg/compiler/lib/src/js_backend/impact_transformer.dart
@@ -44,7 +44,7 @@ final NativeBasicData _nativeBaseData; final NativeResolutionEnqueuer _nativeResolutionEnqueuer; final BackendUsageBuilder _backendUsageBuider; - final MirrorsData _mirrorsData; + final MirrorsDataBuilder _mirrorsDataBuilder; final CustomElementsResolutionAnalysis _customElementsResolutionAnalysis; final RuntimeTypesNeedBuilder _rtiNeedBuilder; @@ -57,7 +57,7 @@ this._nativeBaseData, this._nativeResolutionEnqueuer, this._backendUsageBuider, - this._mirrorsData, + this._mirrorsDataBuilder, this._customElementsResolutionAnalysis, this._rtiNeedBuilder); @@ -226,7 +226,7 @@ if (worldImpact.constSymbolNames.isNotEmpty) { registerImpact(_impacts.constSymbol); for (String constSymbolName in worldImpact.constSymbolNames) { - _mirrorsData.registerConstSymbol(constSymbolName); + _mirrorsDataBuilder.registerConstSymbol(constSymbolName); } } @@ -344,7 +344,6 @@ final RuntimeTypesNeed _rtiNeed; final NativeCodegenEnqueuer _nativeCodegenEnqueuer; final Namer _namer; - final MirrorsData _mirrorsData; final OneShotInterceptorData _oneShotInterceptorData; final LookupMapAnalysis _lookupMapAnalysis; final RuntimeTypesChecksBuilder _rtiChecksBuilder; @@ -360,7 +359,6 @@ this._rtiNeed, this._nativeCodegenEnqueuer, this._namer, - this._mirrorsData, this._oneShotInterceptorData, this._lookupMapAnalysis, this._rtiChecksBuilder); @@ -444,10 +442,6 @@ } } - for (String name in impact.constSymbols) { - _mirrorsData.registerConstSymbol(name); - } - for (Set<ClassElement> classes in impact.specializedGetInterceptors) { _oneShotInterceptorData.registerSpecializedGetInterceptor( classes, _namer);
diff --git a/pkg/compiler/lib/src/js_backend/mirrors_data.dart b/pkg/compiler/lib/src/js_backend/mirrors_data.dart index ffe5997..97d348c 100644 --- a/pkg/compiler/lib/src/js_backend/mirrors_data.dart +++ b/pkg/compiler/lib/src/js_backend/mirrors_data.dart
@@ -16,7 +16,104 @@ import 'backend_helpers.dart'; import 'constant_handler_javascript.dart'; -class MirrorsData { +abstract class MirrorsData { + /// True if a call to preserveMetadataMarker has been seen. This means that + /// metadata must be retained for dart:mirrors to work correctly. + // resolution-empty-queue + bool get mustRetainMetadata; + + /// True if any metadata has been retained. This is slightly different from + /// [mustRetainMetadata] and tells us if any metadata was retained. For + /// example, if [mustRetainMetadata] is true but there is no metadata in the + /// program, this variable will stil be false. + // emitter + bool get hasRetainedMetadata; + + /// True if a call to preserveLibraryNames has been seen. + // emitter + bool get mustRetainLibraryNames; + + /// True if a call to preserveNames has been seen. + // resolution-empty-queue + bool get mustPreserveNames; + + /// True if a call to disableTreeShaking has been seen. + bool get isTreeShakingDisabled; + + /// True if a call to preserveUris has been seen and the preserve-uris flag + /// is set. + bool get mustPreserveUris; + + /// Set of symbols that the user has requested for reflection. + Iterable<String> get symbolsUsed; + + /// Set of elements that the user has requested for reflection. + Iterable<Element> get targetsUsed; + + /// Should [element] (a getter) that would normally not be generated due to + /// treeshaking be retained for reflection? + bool shouldRetainGetter(Element element); + + /// Should [element] (a setter) hat would normally not be generated due to + /// treeshaking be retained for reflection? + bool shouldRetainSetter(Element element); + + /// Should [name] be retained for reflection? + bool shouldRetainName(String name); + + /// Returns true if this element is covered by a mirrorsUsed annotation. + /// + /// Note that it might still be ok to tree shake the element away if no + /// reflection is used in the program (and thus [isTreeShakingDisabled] is + /// still false). Therefore _do not_ use this predicate to decide inclusion + /// in the tree, use [requiredByMirrorSystem] instead. + bool referencedFromMirrorSystem(Element element, [recursive = true]); + + /// Returns `true` if [element] can be accessed through reflection, that is, + /// is in the set of elements covered by a `MirrorsUsed` annotation. + /// + /// This property is used to tag emitted elements with a marker which is + /// checked by the runtime system to throw an exception if an element is + /// accessed (invoked, get, set) that is not accessible for the reflective + /// system. + bool isAccessibleByReflection(Element element); + + bool retainMetadataOf(Element element); + + bool invokedReflectively(Element element); + + /// Returns `true` if this member element needs reflection information at + /// runtime. + bool isMemberAccessibleByReflection(MemberElement element); + + /// Returns true if this element has to be enqueued due to + /// mirror usage. Might be a subset of [referencedFromMirrorSystem] if + /// normal tree shaking is still active ([isTreeShakingDisabled] is false). + bool requiredByMirrorSystem(Element element); +} + +abstract class MirrorsDataBuilder { + void registerUsedMember(MemberElement member); + + /// Called by [MirrorUsageAnalyzerTask] after it has merged all @MirrorsUsed + /// annotations. The arguments corresponds to the unions of the corresponding + /// fields of the annotations. + void registerMirrorUsage( + Set<String> symbols, Set<Element> targets, Set<Element> metaTargets); + + /// Called when `const Symbol(name)` is seen. + void registerConstSymbol(String name); + + void maybeMarkClosureAsNeededForReflection( + ClosureClassElement globalizedElement, + FunctionElement callFunction, + FunctionElement function); + + void computeMembersNeededForReflection( + ResolutionWorldBuilder worldBuilder, ClosedWorld closedWorld); +} + +class MirrorsDataImpl implements MirrorsData, MirrorsDataBuilder { /// True if a call to preserveMetadataMarker has been seen. This means that /// metadata must be retained for dart:mirrors to work correctly. bool mustRetainMetadata = false; @@ -43,10 +140,10 @@ /// is set. bool mustPreserveUris = false; - /// List of symbols that the user has requested for reflection. + /// Set of symbols that the user has requested for reflection. final Set<String> symbolsUsed = new Set<String>(); - /// List of elements that the user has requested for reflection. + /// Set of elements that the user has requested for reflection. final Set<Element> targetsUsed = new Set<Element>(); /// List of annotations provided by user that indicate that the annotated @@ -64,7 +161,7 @@ final JavaScriptConstantCompiler _constants; - MirrorsData(this._compiler, this._options, this._commonElements, + MirrorsDataImpl(this._compiler, this._options, this._commonElements, this._helpers, this._constants); void registerUsedMember(MemberElement member) { @@ -164,15 +261,13 @@ if (metaTargets != null) metaTargetsUsed.addAll(metaTargets); } - /** - * Returns `true` if [element] can be accessed through reflection, that is, - * is in the set of elements covered by a `MirrorsUsed` annotation. - * - * This property is used to tag emitted elements with a marker which is - * checked by the runtime system to throw an exception if an element is - * accessed (invoked, get, set) that is not accessible for the reflective - * system. - */ + /// Returns `true` if [element] can be accessed through reflection, that is, + /// is in the set of elements covered by a `MirrorsUsed` annotation. + /// + /// This property is used to tag emitted elements with a marker which is + /// checked by the runtime system to throw an exception if an element is + /// accessed (invoked, get, set) that is not accessible for the reflective + /// system. bool isAccessibleByReflection(Element element) { if (element.isClass) { element = _getDartClass(element); @@ -410,7 +505,7 @@ _membersNeededForReflection.add(globalizedElement); } - /// Called when [:const Symbol(name):] is seen. + /// Called when `const Symbol(name)` is seen. void registerConstSymbol(String name) { symbolsUsed.add(name); if (name.endsWith('=')) {
diff --git a/pkg/compiler/lib/src/js_backend/resolution_listener.dart b/pkg/compiler/lib/src/js_backend/resolution_listener.dart index 31d6cee..52f1881 100644 --- a/pkg/compiler/lib/src/js_backend/resolution_listener.dart +++ b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
@@ -48,7 +48,7 @@ final InterceptorDataBuilder _interceptorData; final BackendUsageBuilder _backendUsage; final RuntimeTypesNeedBuilder _rtiNeedBuilder; - final MirrorsData _mirrorsData; + final MirrorsDataBuilder _mirrorsDataBuilder; final NoSuchMethodRegistry _noSuchMethodRegistry; final CustomElementsResolutionAnalysis _customElementsAnalysis; @@ -73,7 +73,7 @@ this._interceptorData, this._backendUsage, this._rtiNeedBuilder, - this._mirrorsData, + this._mirrorsDataBuilder, this._noSuchMethodRegistry, this._customElementsAnalysis, this._lookupMapResolutionAnalysis, @@ -286,7 +286,7 @@ @override WorldImpact registerUsedElement(MemberElement member) { WorldImpactBuilderImpl worldImpact = new WorldImpactBuilderImpl(); - _mirrorsData.registerUsedMember(member); + _mirrorsDataBuilder.registerUsedMember(member); _customElementsAnalysis.registerStaticUse(member); if (member.isFunction && member.isInstanceMember) {
diff --git a/pkg/compiler/lib/src/mirrors_used.dart b/pkg/compiler/lib/src/mirrors_used.dart index 8414a54..7ddd29a 100644 --- a/pkg/compiler/lib/src/mirrors_used.dart +++ b/pkg/compiler/lib/src/mirrors_used.dart
@@ -99,7 +99,7 @@ List<String> symbols = analyzer.mergedMirrorUsage.symbols; List<Element> targets = analyzer.mergedMirrorUsage.targets; List<Element> metaTargets = analyzer.mergedMirrorUsage.metaTargets; - compiler.backend.mirrorsData.registerMirrorUsage( + compiler.backend.mirrorsDataBuilder.registerMirrorUsage( symbols == null ? null : new Set<String>.from(symbols), targets == null ? null : new Set<Element>.from(targets), metaTargets == null ? null : new Set<Element>.from(metaTargets));
diff --git a/pkg/compiler/lib/src/parser/element_listener.dart b/pkg/compiler/lib/src/parser/element_listener.dart index 5c1a5e7..55e7e25 100644 --- a/pkg/compiler/lib/src/parser/element_listener.dart +++ b/pkg/compiler/lib/src/parser/element_listener.dart
@@ -731,6 +731,16 @@ case ErrorKind.Unspecified: errorCode = MessageKind.GENERIC; break; + + case ErrorKind.BuiltInIdentifierAsType: + errorCode = MessageKind.GENERIC; + arguments = {"text": "Can't use '${token.lexeme}' as a type."}; + break; + + case ErrorKind.BuiltInIdentifierInDeclaration: + errorCode = MessageKind.GENERIC; + arguments = {"text": "Can't use '${token.lexeme}' as a name here."}; + break; } SourceSpan span = reporter.spanFromToken(token); reportError(span, errorCode, arguments);
diff --git a/pkg/front_end/lib/src/fasta/colors.dart b/pkg/front_end/lib/src/fasta/colors.dart index 6f3214d..753da3d 100644 --- a/pkg/front_end/lib/src/fasta/colors.dart +++ b/pkg/front_end/lib/src/fasta/colors.dart
@@ -98,9 +98,16 @@ /// Note: do not call this method directly, as it is expensive to /// compute. Instead, use [CompilerContext.enableColors]. bool computeEnableColors(CompilerContext context) { - if (Platform.isWindows) { + bool ansiSupported; + try { + ansiSupported = Platform.ansiSupported; + } on NoSuchMethodError catch (e) { + // Ignored: We're running on an older version of the Dart VM which doesn't + // implement `ansiSupported`. + } + if (ansiSupported == false) { if (context.options.verbose) { - print("Not enabling colors, running on Windows."); + print("Not enabling colors, 'Platform.ansiSupported' is false."); } return false; } @@ -119,6 +126,16 @@ return false; } + if (ansiSupported == true && Platform.isWindows) { + if (context.options.verbose) { + print("Enabling colors as OS is Windows."); + } + return true; + } + + // We have to check if the terminal actually supports colors. Currently, + // `Platform.ansiSupported` is hard-coded to true on non-Windows platforms. + // The `-S` option of `tput` allows us to query multiple capabilities at // once. ProcessResult result = Process.runSync(
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index 87d342a..d9156ba 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -818,18 +818,26 @@ Token last = parts.last; Quote quote = analyzeQuote(first.lexeme); List<Expression> expressions = <Expression>[]; - expressions + // Contains more than just \' or \". + if (first.lexeme.length > 1) { + expressions .add(new StringLiteral(unescapeFirstStringPart(first.lexeme, quote))); + } for (int i = 1; i < parts.length - 1; i++) { var part = parts[i]; if (part is Token) { - expressions.add(new StringLiteral(unescape(part.lexeme, quote))); + if (part.lexeme.length != 0) { + expressions.add(new StringLiteral(unescape(part.lexeme, quote))); + } } else { expressions.add(toValue(part)); } } - expressions + // Contains more than just \' or \". + if (last.lexeme.length > 1) { + expressions .add(new StringLiteral(unescapeLastStringPart(last.lexeme, quote))); + } push(new StringConcatenation(expressions) ..fileOffset = endToken.charOffset); }
diff --git a/pkg/front_end/lib/src/fasta/parser/error_kind.dart b/pkg/front_end/lib/src/fasta/parser/error_kind.dart index 1dc8ef4..1c98c55 100644 --- a/pkg/front_end/lib/src/fasta/parser/error_kind.dart +++ b/pkg/front_end/lib/src/fasta/parser/error_kind.dart
@@ -7,6 +7,8 @@ /// Kinds of error codes. enum ErrorKind { AsciiControlCharacter, + BuiltInIdentifierAsType, + BuiltInIdentifierInDeclaration, EmptyNamedParameterList, EmptyOptionalParameterList, Encoding,
diff --git a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart index 6b72d0f..17d04f4 100644 --- a/pkg/front_end/lib/src/fasta/parser/identifier_context.dart +++ b/pkg/front_end/lib/src/fasta/parser/identifier_context.dart
@@ -11,8 +11,10 @@ class IdentifierContext { /// Identifier is being declared as the name of an import prefix (i.e. `Foo` /// in `import "..." as Foo;`) - static const importPrefixDeclaration = - const IdentifierContext._('importPrefixDeclaration', inDeclaration: true); + static const importPrefixDeclaration = const IdentifierContext._( + 'importPrefixDeclaration', + inDeclaration: true, + isBuiltInIdentifierAllowed: false); /// Identifier is the start of a dotted name in a conditional import or /// export. @@ -44,8 +46,10 @@ isContinuation: true); /// Identifier is the name being declared by a typedef declaration. - static const typedefDeclaration = - const IdentifierContext._('typedefDeclaration', inDeclaration: true); + static const typedefDeclaration = const IdentifierContext._( + 'typedefDeclaration', + inDeclaration: true, + isBuiltInIdentifierAllowed: false); /// Identifier is a field initializer in a formal parameter list (i.e. it /// appears directly after `this.`). @@ -83,8 +87,8 @@ isContinuation: true); /// Identifier is the type name being declared by an enum declaration. - static const enumDeclaration = - const IdentifierContext._('enumDeclaration', inDeclaration: true); + static const enumDeclaration = const IdentifierContext._('enumDeclaration', + inDeclaration: true, isBuiltInIdentifierAllowed: false); /// Identifier is an enumerated value name being declared by an enum /// declaration. @@ -93,27 +97,32 @@ /// Identifier is the name being declared by a named mixin declaration (e.g. /// `Foo` in `class Foo = X with Y;`). - static const namedMixinDeclaration = - const IdentifierContext._('namedMixinDeclaration', inDeclaration: true); + static const namedMixinDeclaration = const IdentifierContext._( + 'namedMixinDeclaration', + inDeclaration: true, + isBuiltInIdentifierAllowed: false); /// Identifier is the name being declared by a class declaration. - static const classDeclaration = - const IdentifierContext._('classDeclaration', inDeclaration: true); + static const classDeclaration = const IdentifierContext._('classDeclaration', + inDeclaration: true, isBuiltInIdentifierAllowed: false); /// Identifier is the name of a type variable being declared (e.g. `Foo` in /// `class C<Foo extends num> {}`). - static const typeVariableDeclaration = - const IdentifierContext._('typeVariableDeclaration', inDeclaration: true); + static const typeVariableDeclaration = const IdentifierContext._( + 'typeVariableDeclaration', + inDeclaration: true, + isBuiltInIdentifierAllowed: false); /// Identifier is the start of a reference to a type declared elsewhere. - static const typeReference = - const IdentifierContext._('typeReference', isScopeReference: true); + static const typeReference = const IdentifierContext._('typeReference', + isScopeReference: true, isBuiltInIdentifierAllowed: false); /// Identifier is part of a reference to a type declared elsewhere, but it's /// not the first identifier of the reference. static const typeReferenceContinuation = const IdentifierContext._( 'typeReferenceContinuation', - isContinuation: true); + isContinuation: true, + isBuiltInIdentifierAllowed: false); /// Identifier is a name being declared by a top level variable declaration. static const topLevelVariableDeclaration = const IdentifierContext._( @@ -262,12 +271,16 @@ /// Indicates whether the identifier should be looked up in the current scope. final bool isScopeReference; + /// Indicates whether built-in identifiers are allowed in this context. + final bool isBuiltInIdentifierAllowed; + const IdentifierContext._(this._name, {this.inDeclaration: false, this.inLibraryOrPartOfDeclaration: false, this.inSymbol: false, this.isContinuation: false, - this.isScopeReference: false}); + this.isScopeReference: false, + this.isBuiltInIdentifierAllowed: true}); String toString() => _name; }
diff --git a/pkg/front_end/lib/src/fasta/parser/parser.dart b/pkg/front_end/lib/src/fasta/parser/parser.dart index 7d7dd55..5a0d95a 100644 --- a/pkg/front_end/lib/src/fasta/parser/parser.dart +++ b/pkg/front_end/lib/src/fasta/parser/parser.dart
@@ -887,6 +887,13 @@ if (!token.isIdentifier()) { token = reportUnrecoverableError(token, ErrorKind.ExpectedIdentifier)?.next; + } else if (token.isBuiltInIdentifier && + !context.isBuiltInIdentifierAllowed) { + if (context.inDeclaration) { + reportRecoverableError(token, ErrorKind.BuiltInIdentifierInDeclaration); + } else if (!optional("dynamic", token)) { + reportRecoverableError(token, ErrorKind.BuiltInIdentifierAsType); + } } listener.handleIdentifier(token, context); return token.next;
diff --git a/pkg/front_end/lib/src/fasta/scanner/string_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/string_scanner.dart index d397cc9..a7ac73b 100644 --- a/pkg/front_end/lib/src/fasta/scanner/string_scanner.dart +++ b/pkg/front_end/lib/src/fasta/scanner/string_scanner.dart
@@ -8,7 +8,7 @@ import 'precedence.dart' show PrecedenceInfo; -import 'token.dart' show StringToken, Token; +import 'token.dart' show StringToken; /** * Scanner that reads from a String and creates tokens that points to
diff --git a/pkg/front_end/lib/src/fasta/scanner/token.dart b/pkg/front_end/lib/src/fasta/scanner/token.dart index bb7efd8..5d72286 100644 --- a/pkg/front_end/lib/src/fasta/scanner/token.dart +++ b/pkg/front_end/lib/src/fasta/scanner/token.dart
@@ -124,8 +124,9 @@ bool get isEof => false; - @override bool get isOperator => info.isOperator; + + bool get isBuiltInIdentifier => false; } /** @@ -177,6 +178,12 @@ bool isIdentifier() => keyword.isPseudo || keyword.isBuiltIn; + bool get isBuiltInIdentifier { + // TODO(ahe): Remove special case for "deferred" once dartbug.com/29069 is + // fixed. + return keyword.isBuiltIn || identical("deferred", lexeme); + } + String toString() => "KeywordToken($lexeme)"; }
diff --git a/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart b/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart index cca00d0..291ddf3 100644 --- a/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart +++ b/pkg/front_end/lib/src/fasta/scanner/utf8_bytes_scanner.dart
@@ -10,7 +10,7 @@ import 'precedence.dart' show PrecedenceInfo; -import 'token.dart' show StringToken, Token; +import 'token.dart' show StringToken; import 'array_based_scanner.dart' show ArrayBasedScanner;
diff --git a/pkg/kernel/bin/reified_dart.dart b/pkg/kernel/bin/reified_dart.dart index b87807d..dfdeb30 100755 --- a/pkg/kernel/bin/reified_dart.dart +++ b/pkg/kernel/bin/reified_dart.dart
@@ -141,6 +141,7 @@ } ProcessResult result = await Process.run(dartkPath, [ + "--strong", "--sdk=$sdkPath", "--target=vmreify", "--link",
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart index c04a54d..220878e 100644 --- a/pkg/kernel/lib/ast.dart +++ b/pkg/kernel/lib/ast.dart
@@ -2756,6 +2756,7 @@ abstract class Statement extends TreeNode { accept(StatementVisitor v); + accept1(StatementVisitor1 v, arg); } /// A statement with a compile-time error. @@ -2763,6 +2764,7 @@ /// Should throw an exception at runtime. class InvalidStatement extends Statement { accept(StatementVisitor v) => v.visitInvalidStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitInvalidStatement(this, arg); visitChildren(Visitor v) {} transformChildren(Transformer v) {} @@ -2776,6 +2778,7 @@ } accept(StatementVisitor v) => v.visitExpressionStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitExpressionStatement(this, arg); visitChildren(Visitor v) { expression?.accept(v); @@ -2797,6 +2800,7 @@ } accept(StatementVisitor v) => v.visitBlock(this); + accept1(StatementVisitor1 v, arg) => v.visitBlock(this, arg); visitChildren(Visitor v) { visitList(statements, v); @@ -2814,6 +2818,7 @@ class EmptyStatement extends Statement { accept(StatementVisitor v) => v.visitEmptyStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitEmptyStatement(this, arg); visitChildren(Visitor v) {} transformChildren(Transformer v) {} @@ -2829,6 +2834,7 @@ } accept(StatementVisitor v) => v.visitAssertStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitAssertStatement(this, arg); visitChildren(Visitor v) { condition?.accept(v); @@ -2860,6 +2866,7 @@ } accept(StatementVisitor v) => v.visitLabeledStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitLabeledStatement(this, arg); visitChildren(Visitor v) { body?.accept(v); @@ -2899,6 +2906,7 @@ BreakStatement(this.target); accept(StatementVisitor v) => v.visitBreakStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitBreakStatement(this, arg); visitChildren(Visitor v) {} transformChildren(Transformer v) {} @@ -2914,6 +2922,7 @@ } accept(StatementVisitor v) => v.visitWhileStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitWhileStatement(this, arg); visitChildren(Visitor v) { condition?.accept(v); @@ -2942,6 +2951,7 @@ } accept(StatementVisitor v) => v.visitDoStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitDoStatement(this, arg); visitChildren(Visitor v) { body?.accept(v); @@ -2974,6 +2984,7 @@ } accept(StatementVisitor v) => v.visitForStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitForStatement(this, arg); visitChildren(Visitor v) { visitList(variables, v); @@ -3010,6 +3021,7 @@ } accept(StatementVisitor v) => v.visitForInStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitForInStatement(this, arg); visitChildren(Visitor v) { variable?.accept(v); @@ -3047,6 +3059,7 @@ } accept(StatementVisitor v) => v.visitSwitchStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitSwitchStatement(this, arg); visitChildren(Visitor v) { expression?.accept(v); @@ -3109,6 +3122,8 @@ ContinueSwitchStatement(this.target); accept(StatementVisitor v) => v.visitContinueSwitchStatement(this); + accept1(StatementVisitor1 v, arg) => + v.visitContinueSwitchStatement(this, arg); visitChildren(Visitor v) {} transformChildren(Transformer v) {} @@ -3126,6 +3141,7 @@ } accept(StatementVisitor v) => v.visitIfStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitIfStatement(this, arg); visitChildren(Visitor v) { condition?.accept(v); @@ -3157,6 +3173,7 @@ } accept(StatementVisitor v) => v.visitReturnStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitReturnStatement(this, arg); visitChildren(Visitor v) { expression?.accept(v); @@ -3180,6 +3197,7 @@ } accept(StatementVisitor v) => v.visitTryCatch(this); + accept1(StatementVisitor1 v, arg) => v.visitTryCatch(this, arg); visitChildren(Visitor v) { body?.accept(v); @@ -3245,6 +3263,7 @@ } accept(StatementVisitor v) => v.visitTryFinally(this); + accept1(StatementVisitor1 v, arg) => v.visitTryFinally(this, arg); visitChildren(Visitor v) { body?.accept(v); @@ -3292,6 +3311,7 @@ } accept(StatementVisitor v) => v.visitYieldStatement(this); + accept1(StatementVisitor1 v, arg) => v.visitYieldStatement(this, arg); visitChildren(Visitor v) { expression?.accept(v); @@ -3376,6 +3396,7 @@ } accept(StatementVisitor v) => v.visitVariableDeclaration(this); + accept1(StatementVisitor1 v, arg) => v.visitVariableDeclaration(this, arg); visitChildren(Visitor v) { type?.accept(v); @@ -3409,6 +3430,7 @@ } accept(StatementVisitor v) => v.visitFunctionDeclaration(this); + accept1(StatementVisitor1 v, arg) => v.visitFunctionDeclaration(this, arg); visitChildren(Visitor v) { variable?.accept(v);
diff --git a/pkg/kernel/lib/target/vm.dart b/pkg/kernel/lib/target/vm.dart index ed22544..72c7165 100644 --- a/pkg/kernel/lib/target/vm.dart +++ b/pkg/kernel/lib/target/vm.dart
@@ -83,7 +83,7 @@ setup_builtin_library.transformProgram(program); if (strongMode) { - new Erasure().transform(program); + performErasure(program); } new SanitizeForVM().transform(program); @@ -99,4 +99,8 @@ .transform(program); _hierarchy = null; // Hierarchy must be recomputed. } + + void performErasure(Program program) { + new Erasure().transform(program); + } }
diff --git a/pkg/kernel/lib/target/vmreify.dart b/pkg/kernel/lib/target/vmreify.dart index db2c63e..1d0fe0a9 100644 --- a/pkg/kernel/lib/target/vmreify.dart +++ b/pkg/kernel/lib/target/vmreify.dart
@@ -40,4 +40,10 @@ // TODO(dmitryas): remove this when the libraries are in dart:_internal @override void performTreeShaking(Program program) {} + + // Here we disable Erasure pass of VmTarget class. The information deleted by + // the Erasure pass is required for Generic Type Reification. Also, reify + // transformation also performs its own Erasure pass. + @override + void performErasure(Program program) {} }
diff --git a/pkg/kernel/lib/transformations/closure/converter.dart b/pkg/kernel/lib/transformations/closure/converter.dart index 9ebd806..a2a45e5 100644 --- a/pkg/kernel/lib/transformations/closure/converter.dart +++ b/pkg/kernel/lib/transformations/closure/converter.dart
@@ -676,8 +676,8 @@ String closureClassName = createNameForClosureClass(procedure.function); Class closureClass = null; for (TreeNode node in newLibraryMembers) { - if (node is Class && (node as Class).name == closureClassName) { - closureClass = node as Class; + if (node is Class && node.name == closureClassName) { + closureClass = node; } } if (closureClass == null) { @@ -739,7 +739,7 @@ positionalParameters: positionalParameters, namedParameters: namedParameters, requiredParameterCount: function.requiredParameterCount, - returnType: substitute(function.returnType, substitution), + returnType: substitute(function.returnType, cloner.typeSubstitution), inferredReturnValue: inferredReturnValue); }
diff --git a/pkg/kernel/lib/transformations/reify/transformation/builder.dart b/pkg/kernel/lib/transformations/reify/transformation/builder.dart index db46b96..13af0ed 100644 --- a/pkg/kernel/lib/transformations/reify/transformation/builder.dart +++ b/pkg/kernel/lib/transformations/reify/transformation/builder.dart
@@ -238,12 +238,8 @@ } if (type is InterfaceType || type is Supertype) { - InterfaceType interfaceType = null; - if (type is InterfaceType) { - interfaceType = type; - } else { - interfaceType = (type as Supertype).asInterfaceType; - } + InterfaceType interfaceType = + (type is InterfaceType) ? type : (type as Supertype).asInterfaceType; Class cls = interfaceType.classNode; Expression declaration = createReference(cls); List<DartType> typeArguments = interfaceType.typeArguments;
diff --git a/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart b/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart index aafff7d..1a103f6 100644 --- a/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart +++ b/pkg/kernel/lib/transformations/reify/transformation/remove_generics.dart
@@ -27,12 +27,24 @@ } TreeNode removeTypeArgumentsOfStaticCall(StaticInvocation node) { - Class cls = node.target.parent; - if (removeTypeParameters(cls)) { - node.arguments.types.clear(); - Procedure target = node.target; - target.function.typeParameters.clear(); + if (node.target.parent is Class) { + Class cls = node.target.parent; + if (!removeTypeParameters(cls)) { + return node; + } + } else { + // If parent is a Library, then a global procedure is invoked, and it may + // be a generic function, so we need to remove type arguments anyway. + assert(node.target.parent is Library); } + node.arguments.types.clear(); + Procedure target = node.target; + target.function.typeParameters.clear(); + return node; + } + + TreeNode removeTypeArgumentOfMethodInvocation(MethodInvocation node) { + node.arguments.types.clear(); return node; } @@ -96,7 +108,8 @@ @override StaticInvocation visitStaticInvocation(StaticInvocation node) { node.transformChildren(this); - if (node.target.kind == ProcedureKind.Factory) { + if (node.target.kind == ProcedureKind.Factory || + node.target.kind == ProcedureKind.Method) { node = removeTypeArgumentsOfStaticCall(node); } return node; @@ -116,4 +129,10 @@ } return node; } + + @override + Expression visitMethodInvocation(MethodInvocation node) { + node.transformChildren(this); + return removeTypeArgumentOfMethodInvocation(node); + } }
diff --git a/pkg/kernel/lib/transformations/reify/transformation/transformer.dart b/pkg/kernel/lib/transformations/reify/transformation/transformer.dart index 8672485..a057443 100644 --- a/pkg/kernel/lib/transformations/reify/transformation/transformer.dart +++ b/pkg/kernel/lib/transformations/reify/transformation/transformer.dart
@@ -103,6 +103,8 @@ // TODO(karlklose): find a way to get rid of this state in the visitor. TransformationContext context; + static const String genericMethodTypeParametersName = r"$typeParameters"; + bool libraryShouldBeTransformed(Library library) { return libraryToTransform == null || libraryToTransform == library; } @@ -180,6 +182,9 @@ // Intercept calls to factories of classes we do not transform return interceptInstantiation(invocation, target); } + + addTypeArgumentToGenericInvocation(invocation); + return invocation; } @@ -419,6 +424,8 @@ FunctionNode visitFunctionNode(FunctionNode node) { trace(node); + addTypeArgumentToGenericDeclaration(node); + // If we have a [TransformationContext] with a runtime type field and we // translate a constructor or factory, we need a parameter that the code of // initializers or the factory body can use to access type arguments. @@ -572,4 +579,46 @@ new InterfaceType(builder.coreTypes.mapClass, <DartType>[node.keyType, node.valueType])); } + + Expression visitMethodInvocation(MethodInvocation node) { + node.transformChildren(this); + addTypeArgumentToGenericInvocation(node); + return node; + } + + bool isGenericMethod(FunctionNode node) { + if (node.parent is Member) { + Member member = node.parent; + if (member is Constructor || + member is Procedure && member.kind == ProcedureKind.Factory) { + return member.enclosingClass.typeParameters.length < + node.typeParameters.length; + } + } + return node.typeParameters.isNotEmpty; + } + + void addTypeArgumentToGenericInvocation(InvocationExpression expression) { + if (expression.arguments.types.length > 0) { + ListLiteral genericMethodTypeParameters = new ListLiteral( + expression.arguments.types + .map(createRuntimeType) + .toList(growable: false), + typeArgument: rtiLibrary.typeType); + expression.arguments.named.add(new NamedExpression( + genericMethodTypeParametersName, genericMethodTypeParameters) + ..parent = expression.arguments); + } + } + + void addTypeArgumentToGenericDeclaration(FunctionNode node) { + if (isGenericMethod(node)) { + VariableDeclaration genericMethodTypeParameters = new VariableDeclaration( + genericMethodTypeParametersName, + type: new InterfaceType( + builder.coreTypes.listClass, <DartType>[rtiLibrary.typeType])); + genericMethodTypeParameters.parent = node; + node.namedParameters.insert(0, genericMethodTypeParameters); + } + } }
diff --git a/pkg/kernel/lib/visitor.dart b/pkg/kernel/lib/visitor.dart index 4790e73..dc2c6c3 100644 --- a/pkg/kernel/lib/visitor.dart +++ b/pkg/kernel/lib/visitor.dart
@@ -381,3 +381,42 @@ R visitCheckLibraryIsLoaded(CheckLibraryIsLoaded node, arg) => defaultExpression(node, arg); } + +abstract class StatementVisitor1<R> { + R defaultStatement(Statement node, arg) => null; + + R visitInvalidStatement(InvalidStatement node, arg) => + defaultStatement(node, arg); + R visitExpressionStatement(ExpressionStatement node, arg) => + defaultStatement(node, arg); + R visitBlock(Block node, arg) => defaultStatement(node, arg); + R visitEmptyStatement(EmptyStatement node, arg) => + defaultStatement(node, arg); + R visitAssertStatement(AssertStatement node, arg) => + defaultStatement(node, arg); + R visitLabeledStatement(LabeledStatement node, arg) => + defaultStatement(node, arg); + R visitBreakStatement(BreakStatement node, arg) => + defaultStatement(node, arg); + R visitWhileStatement(WhileStatement node, arg) => + defaultStatement(node, arg); + R visitDoStatement(DoStatement node, arg) => defaultStatement(node, arg); + R visitForStatement(ForStatement node, arg) => defaultStatement(node, arg); + R visitForInStatement(ForInStatement node, arg) => + defaultStatement(node, arg); + R visitSwitchStatement(SwitchStatement node, arg) => + defaultStatement(node, arg); + R visitContinueSwitchStatement(ContinueSwitchStatement node, arg) => + defaultStatement(node, arg); + R visitIfStatement(IfStatement node, arg) => defaultStatement(node, arg); + R visitReturnStatement(ReturnStatement node, arg) => + defaultStatement(node, arg); + R visitTryCatch(TryCatch node, arg) => defaultStatement(node, arg); + R visitTryFinally(TryFinally node, arg) => defaultStatement(node, arg); + R visitYieldStatement(YieldStatement node, arg) => + defaultStatement(node, arg); + R visitVariableDeclaration(VariableDeclaration node, arg) => + defaultStatement(node, arg); + R visitFunctionDeclaration(FunctionDeclaration node, arg) => + defaultStatement(node, arg); +}
diff --git a/pkg/kernel/test/reify/suite.dart b/pkg/kernel/test/reify/suite.dart index 337e3ae..aa04009 100644 --- a/pkg/kernel/test/reify/suite.dart +++ b/pkg/kernel/test/reify/suite.dart
@@ -15,6 +15,8 @@ import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; +import 'package:kernel/target/vmcc.dart' show VmClosureConvertedTarget; + import 'kernel_chain.dart' show MatchExpectation, Print, ReadDill, SanityCheck, WriteDill; @@ -30,9 +32,6 @@ import 'package:kernel/ast.dart' show Program; -import 'package:kernel/transformations/closure_conversion.dart' - as closure_conversion; - import 'package:kernel/transformations/generic_types_reification.dart' as generic_types_reification; @@ -57,10 +56,9 @@ sdk: sdk, packagePath: packages.toFilePath()), steps = <Step>[ - const Kernel(), + const NotReifiedKernel(), const Print(), const SanityCheck(), - const ClosureConversion(), const GenericTypesReification(), const Print(), const SanityCheck(), @@ -126,14 +124,51 @@ Uri vm = Uri.base.resolve("out/ReleaseX64/dart"); Uri packages = Uri.base.resolve(".packages"); - bool strongMode = false; - bool updateExpectations = environment["updateExpectations"] == "true"; + // Strong mode is required to keep the type arguments in invocations of + // generic methods. + bool strongMode = true; + bool updateExpectations = const String.fromEnvironment("updateExpectations", + defaultValue: "false") == + "true"; return new TestContext(sdk, vm, packages, strongMode, createDartSdk(sdk, strongMode: strongMode), updateExpectations); } -class Kernel extends Step<TestDescription, Program, TestContext> { - const Kernel(); +// [NotReifiedTarget] is intended to work as the [Target] class that +// [VmGenericTypesReifiedTarget] inherits from, but with some transformations +// disabled. Those include tree shaking and generic types information erasure +// passes. +// [NotReifiedTarget] also adds the necessary runtime libraries. +class NotReifiedTarget extends VmClosureConvertedTarget { + NotReifiedTarget(TargetFlags flags) : super(flags); + + @override + String get name => "not reified target"; + + // Tree shaking needs to be disabled, because Generic Types Reification + // transformation relies on certain runtime libraries to be present in + // the program that is being transformed. If the tree shaker is enabled, + // it just deletes everything from those libraries, because they aren't + // used in the program being transform prior to the transformation. + @override + void performTreeShaking(Program program) {} + + // Erasure needs to be disabled, because it removes the necessary information + // about type arguments for generic methods. + @override + void performErasure(Program program) {} + + // Adds the necessary runtime libraries. + @override + List<String> get extraRequiredLibraries { + Target reifyTarget = getTarget("vmreify", this.flags); + var x = reifyTarget.extraRequiredLibraries; + return x; + } +} + +class NotReifiedKernel extends Step<TestDescription, Program, TestContext> { + const NotReifiedKernel(); String get name => "kernel"; @@ -142,19 +177,15 @@ try { DartLoader loader = await testContext.createLoader(); - Target target = getTarget( - "vm", new TargetFlags(strongMode: testContext.options.strongMode)); - // reifyTarget is used to add the GTR-specific runtime libraries - // when the program is being loaded - Target reifyTarget = getTarget( - "vmreify", - new TargetFlags( - strongMode: testContext.options.strongMode, - kernelRuntime: Platform.script.resolve('../../runtime/'))); + // Strong mode is required to keep the type arguments in invocations of + // generic methods. + Target target = new NotReifiedTarget(new TargetFlags( + strongMode: true, + kernelRuntime: Platform.script.resolve("../../runtime/"))); String path = description.file.path; Uri uri = Uri.base.resolve(path); - loader.loadProgram(uri, target: reifyTarget); + loader.loadProgram(uri, target: target); var program = loader.program; for (var error in loader.errors) { return fail(program, "$error"); @@ -169,21 +200,6 @@ } } -class ClosureConversion extends Step<Program, Program, TestContext> { - const ClosureConversion(); - - String get name => "closure conversion"; - - Future<Result<Program>> run(Program program, TestContext testContext) async { - try { - program = closure_conversion.transformProgram(program); - return pass(program); - } catch (e, s) { - return crash(e, s); - } - } -} - class GenericTypesReification extends Step<Program, Program, TestContext> { const GenericTypesReification();
diff --git a/pkg/kernel/testcases/reify/closure2_test.dart.expect b/pkg/kernel/testcases/reify/closure2_test.dart.expect index a6c537a..3c547f5 100644 --- a/pkg/kernel/testcases/reify/closure2_test.dart.expect +++ b/pkg/kernel/testcases/reify/closure2_test.dart.expect
@@ -41,7 +41,7 @@ constructor •(typ::ReifiedType $type, final mock::Context context) → dynamic : self::Closure#A#fun#function::$type = $type, self::Closure#A#fun#function::context = context ; - method call(dynamic o) → dynamic { + method call(dynamic o) → core::bool { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#A#fun#function::context}; return typ::isSubtypeOf(int::type(o), this.$Closure#A#fun#function$T); @@ -53,7 +53,7 @@ } static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> { dec::init(d, 0, new typ::Interface::•(d.[](17))); - dec::init(d, 1, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19))], new typ::FunctionType::•(new typ::Interface::•(d.[](19)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 1, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19))], new typ::FunctionType::•(new typ::Interface::•(d.[](19)), new typ::Interface::•(d.[](5)), 0, <dynamic>[const typ::Dynamic::•()])); dec::init(d, 2, new typ::Interface::•(d.[](17))); dec::init(d, 3, new typ::Interface::•(d.[](17))); dec::init(d, 4, new typ::Interface::•(d.[](17))); @@ -79,7 +79,7 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["A", "Closure#A#fun#function", "X", "Y", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Function", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - dynamic tester = new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])).fun(); + dynamic tester = new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])).{self::A::fun}(); tes::expectTrue(tester.call(new self::X::•())); tes::expectFalse(tester.call(new self::Y::•())); }
diff --git a/pkg/kernel/testcases/reify/closure_test.dart.expect b/pkg/kernel/testcases/reify/closure_test.dart.expect index 50134be..0b759eb 100644 --- a/pkg/kernel/testcases/reify/closure_test.dart.expect +++ b/pkg/kernel/testcases/reify/closure_test.dart.expect
@@ -58,84 +58,44 @@ get $type() → typ::ReifiedType return new typ::Interface::•(self::$declarations.[](4)); } -class Closure#bar extends core::Object implements core::Function, int::HasRuntimeTypeGetter { +class Closure#baz extends core::Object implements core::Function, int::HasRuntimeTypeGetter { field core::String note = "This is temporary. The VM doesn't need closure classes."; constructor •() → dynamic ; - method call(self::A a) → dynamic - return self::bar(a); + method call(dynamic a) → self::B + return self::baz(a); get $type() → typ::ReifiedType return new typ::Interface::•(self::$declarations.[](5)); } -class Closure#baz extends core::Object implements core::Function, int::HasRuntimeTypeGetter { - field core::String note = "This is temporary. The VM doesn't need closure classes."; - constructor •() → dynamic - ; - method call(dynamic a) → self::B - return self::baz(a); - get $type() → typ::ReifiedType - return new typ::Interface::•(self::$declarations.[](6)); -} -class Closure#baz extends core::Object implements core::Function, int::HasRuntimeTypeGetter { - field core::String note = "This is temporary. The VM doesn't need closure classes."; - constructor •() → dynamic - ; - method call(dynamic a) → self::B - return self::baz(a); - get $type() → typ::ReifiedType - return new typ::Interface::•(self::$declarations.[](7)); -} -class Closure#bar extends core::Object implements core::Function, int::HasRuntimeTypeGetter { - field core::String note = "This is temporary. The VM doesn't need closure classes."; - constructor •() → dynamic - ; - method call(self::A a) → dynamic - return self::bar(a); - get $type() → typ::ReifiedType - return new typ::Interface::•(self::$declarations.[](8)); -} -class Closure#baz extends core::Object implements core::Function, int::HasRuntimeTypeGetter { - field core::String note = "This is temporary. The VM doesn't need closure classes."; - constructor •() → dynamic - ; - method call(dynamic a) → self::B - return self::baz(a); - get $type() → typ::ReifiedType - return new typ::Interface::•(self::$declarations.[](9)); -} static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> { - dec::init(d, 0, new typ::Interface::•(d.[](24))); - dec::init(d, 1, new typ::Interface::•(d.[](24))); - dec::init(d, 2, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), new typ::Interface::•(d.[](1)), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 3, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), new typ::Interface::•(d.[](0)), 0, <dynamic>[new typ::Interface::•(d.[](1))])); - dec::init(d, 4, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), const typ::Dynamic::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 5, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), const typ::Dynamic::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 6, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), new typ::Interface::•(d.[](1)), 0, <dynamic>[const typ::Dynamic::•()])); - dec::init(d, 7, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), new typ::Interface::•(d.[](1)), 0, <dynamic>[const typ::Dynamic::•()])); - dec::init(d, 8, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), const typ::Dynamic::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 9, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](10))], new typ::FunctionType::•(new typ::Interface::•(d.[](10)), new typ::Interface::•(d.[](1)), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 0, new typ::Interface::•(d.[](20))); + dec::init(d, 1, new typ::Interface::•(d.[](20))); + dec::init(d, 2, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), new typ::Interface::•(d.[](1)), 0, <dynamic>[new typ::Interface::•(d.[](0))])); + dec::init(d, 3, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), new typ::Interface::•(d.[](0)), 0, <dynamic>[new typ::Interface::•(d.[](1))])); + dec::init(d, 4, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), const typ::Dynamic::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); + dec::init(d, 5, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), new typ::Interface::•(d.[](1)), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 6, new typ::Interface::•(d.[](20))); + dec::init(d, 7, new typ::Interface::•(d.[](20))); + dec::init(d, 8, new typ::Interface::•(d.[](20))); + dec::init(d, 9, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22), <dynamic>[new typ::Interface::•(d.[](9))]), new typ::Interface::•(d.[](23))]); dec::init(d, 10, new typ::Interface::•(d.[](24))); dec::init(d, 11, new typ::Interface::•(d.[](24))); - dec::init(d, 12, new typ::Interface::•(d.[](24))); - dec::init(d, 13, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](26), <dynamic>[new typ::Interface::•(d.[](13))]), new typ::Interface::•(d.[](27))]); - dec::init(d, 14, new typ::Interface::•(d.[](28))); - dec::init(d, 15, new typ::Interface::•(d.[](28))); - dec::init(d, 16, new typ::Interface::•(d.[](24))); - dec::init(d, 17, new typ::Interface::•(d.[](29))); - dec::init(d, 18, new typ::Interface::•(d.[](29))); - dec::init(d, 19, new typ::Interface::•(d.[](29))); - dec::init(d, 20, new typ::Interface::•(d.[](29))); - dec::init(d, 21, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](30))]); - dec::init(d, 22, new typ::Interface::•(d.[](23))); - dec::init(d, 23, new typ::Interface::•(d.[](29))); - dec::init(d, 24, null); - dec::init(d, 26, new typ::Interface::•(d.[](24))); - dec::init(d, 27, new typ::Interface::•(d.[](24))); - dec::init(d, 28, new typ::Interface::•(d.[](24)), <dynamic>[new typ::Interface::•(d.[](26), <dynamic>[new typ::Interface::•(d.[](28))])]); - dec::init(d, 29, new typ::Interface::•(d.[](24))); - dec::init(d, 30, new typ::Interface::•(d.[](24))); + dec::init(d, 12, new typ::Interface::•(d.[](20))); + dec::init(d, 13, new typ::Interface::•(d.[](25))); + dec::init(d, 14, new typ::Interface::•(d.[](25))); + dec::init(d, 15, new typ::Interface::•(d.[](25))); + dec::init(d, 16, new typ::Interface::•(d.[](25))); + dec::init(d, 17, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](26))]); + dec::init(d, 18, new typ::Interface::•(d.[](19))); + dec::init(d, 19, new typ::Interface::•(d.[](25))); + dec::init(d, 20, null); + dec::init(d, 22, new typ::Interface::•(d.[](20))); + dec::init(d, 23, new typ::Interface::•(d.[](20))); + dec::init(d, 24, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22), <dynamic>[new typ::Interface::•(d.[](24))])]); + dec::init(d, 25, new typ::Interface::•(d.[](20))); + dec::init(d, 26, new typ::Interface::•(d.[](20))); return d; -}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Closure#main#foo", "Closure#main#qux", "Closure#bar", "Closure#bar", "Closure#baz", "Closure#baz", "Closure#bar", "Closure#baz", "Function", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); +}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Closure#main#foo", "Closure#main#qux", "Closure#bar", "Closure#baz", "Function", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method bar(self::A a) → dynamic { return null; } @@ -145,18 +105,18 @@ static method main() → dynamic { final (self::A) → self::B foo = new self::Closure#main#foo::•(null); final (self::B) → self::A qux = new self::Closure#main#qux::•(null); - tes::expectTrue(typ::isSubtypeOf(int::type(foo), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); - tes::expectTrue(!typ::isSubtypeOf(int::type(qux), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); - tes::expectTrue(!typ::isSubtypeOf(int::type(foo), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); - tes::expectTrue(typ::isSubtypeOf(int::type(qux), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); - tes::expectTrue(typ::isSubtypeOf(int::type(new self::Closure#bar::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); - tes::expectTrue(!typ::isSubtypeOf(int::type(new self::Closure#bar::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); - tes::expectTrue(typ::isSubtypeOf(int::type(new self::Closure#baz::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); - tes::expectTrue(!typ::isSubtypeOf(int::type(new self::Closure#baz::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); - dynamic rab = new self::Closure#bar::•(); - dynamic zab = new self::Closure#baz::•(); - tes::expectTrue(typ::isSubtypeOf(int::type(rab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); - tes::expectTrue(!typ::isSubtypeOf(int::type(rab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); - tes::expectTrue(typ::isSubtypeOf(int::type(zab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); - tes::expectTrue(!typ::isSubtypeOf(int::type(zab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](10)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); + tes::expectTrue(typ::isSubtypeOf(int::type(foo), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); + tes::expectTrue(!typ::isSubtypeOf(int::type(qux), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); + tes::expectTrue(!typ::isSubtypeOf(int::type(foo), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); + tes::expectTrue(typ::isSubtypeOf(int::type(qux), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); + tes::expectTrue(typ::isSubtypeOf(int::type(new self::Closure#bar::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); + tes::expectTrue(!typ::isSubtypeOf(int::type(new self::Closure#bar::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); + tes::expectTrue(typ::isSubtypeOf(int::type(new self::Closure#baz::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); + tes::expectTrue(!typ::isSubtypeOf(int::type(new self::Closure#baz::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); + (self::A) → dynamic rab = new self::Closure#bar::•(); + (dynamic) → self::B zab = new self::Closure#baz::•(); + tes::expectTrue(typ::isSubtypeOf(int::type(rab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); + tes::expectTrue(!typ::isSubtypeOf(int::type(rab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); + tes::expectTrue(typ::isSubtypeOf(int::type(zab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))); + tes::expectTrue(!typ::isSubtypeOf(int::type(zab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))); }
diff --git a/pkg/kernel/testcases/reify/field_initializer2_test.dart.expect b/pkg/kernel/testcases/reify/field_initializer2_test.dart.expect index e27360d..93f4456 100644 --- a/pkg/kernel/testcases/reify/field_initializer2_test.dart.expect +++ b/pkg/kernel/testcases/reify/field_initializer2_test.dart.expect
@@ -19,12 +19,15 @@ return this.{=self::A::$type}; } class B extends core::Object implements int::HasRuntimeTypeGetter { - field dynamic x; + field self::A x; field dynamic y; final field typ::ReifiedType $type; constructor •(typ::ReifiedType $type) → void : self::B::x = self::B::$init$x($type), self::B::$type = $type, self::B::y = new self::A::•(new typ::Interface::•(self::$declarations.[](0), typ::getTypeArguments(typ::asInstanceOf($type, self::$declarations.[](1))))), super core::Object::•() ; + set x$cc(self::A x_) → dynamic { + this.{=self::B::x} = x_ as self::A; + } get $B$T() → typ::ReifiedType return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0); get $is$A() → core::bool @@ -59,9 +62,9 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - dynamic b = new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])])); - tes::expectTrue(let dynamic #t1 = b.x in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t1.$type, #t2))); - tes::expectTrue(let dynamic #t3 = b.y in #t3 is int::HasRuntimeTypeGetter && #t3.$is$A && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t3.$type, #t4))); - tes::expectFalse(let dynamic #t5 = b.x in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t5.$type, #t6))); - tes::expectFalse(let dynamic #t7 = b.y in #t7 is int::HasRuntimeTypeGetter && #t7.$is$A && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t7.$type, #t8))); + self::B b = new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])])); + tes::expectTrue(let dynamic #t1 = b.{self::B::x} in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t1.$type, #t2))); + tes::expectTrue(let dynamic #t3 = b.{self::B::y} in #t3 is int::HasRuntimeTypeGetter && #t3.$is$A && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t3.$type, #t4))); + tes::expectFalse(let dynamic #t5 = b.{self::B::x} in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t5.$type, #t6))); + tes::expectFalse(let dynamic #t7 = b.{self::B::y} in #t7 is int::HasRuntimeTypeGetter && #t7.$is$A && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t7.$type, #t8))); }
diff --git a/pkg/kernel/testcases/reify/field_initializer_test.dart.expect b/pkg/kernel/testcases/reify/field_initializer_test.dart.expect index f5ad332..8490bf3 100644 --- a/pkg/kernel/testcases/reify/field_initializer_test.dart.expect +++ b/pkg/kernel/testcases/reify/field_initializer_test.dart.expect
@@ -60,6 +60,6 @@ return x; } static method main() → dynamic { - dynamic b = new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])); + self::B b = new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])); tes::expectOutput("b1\nb2\nb3\nb4\na1\na2\nA\nB"); }
diff --git a/pkg/kernel/testcases/reify/function_type_test.dart.expect b/pkg/kernel/testcases/reify/function_type_test.dart.expect index 7d49eff..c953f80 100644 --- a/pkg/kernel/testcases/reify/function_type_test.dart.expect +++ b/pkg/kernel/testcases/reify/function_type_test.dart.expect
@@ -156,46 +156,46 @@ return false; } static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> { - dec::init(d, 0, new typ::Interface::•(d.[](30))); + dec::init(d, 0, new typ::Interface::•(d.[](17))); dec::init(d, 1, new typ::Interface::•(d.[](0))); dec::init(d, 2, new typ::Interface::•(d.[](0))); - dec::init(d, 3, new typ::Interface::•(d.[](30)), <dynamic>[new typ::Interface::•(d.[](15))], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Interface::•(d.[](1)), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 4, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 5, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 6, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1))])); - dec::init(d, 7, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 4, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), new typ::Interface::•(d.[](2))])); - dec::init(d, 8, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), new typ::Interface::•(d.[](2))])); - dec::init(d, 9, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>["a", new typ::Interface::•(d.[](0))])); - dec::init(d, 10, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); - dec::init(d, 11, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(d.[](0)), "b", new typ::Interface::•(d.[](1))])); - dec::init(d, 12, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 5, <dynamic>[new typ::Interface::•(d.[](0)), "b", new typ::Interface::•(d.[](1)), "c", new typ::Interface::•(d.[](2))])); - dec::init(d, 13, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), "c", new typ::Interface::•(d.[](2))])); - dec::init(d, 14, new typ::Interface::•(d.[](30)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 17, <dynamic>["kE", const typ::Dynamic::•(), "ii", const typ::Dynamic::•(), "oP", const typ::Dynamic::•(), "Ij", const typ::Dynamic::•(), "pA", const typ::Dynamic::•(), "zD", const typ::Dynamic::•(), "aZ", const typ::Dynamic::•(), "UU", const typ::Dynamic::•()])); - dec::init(d, 15, new typ::Interface::•(d.[](30))); - dec::init(d, 16, new typ::Interface::•(d.[](30)), <dynamic>[new typ::Interface::•(d.[](32), <dynamic>[d.[](16).variables.[](0)])]); - dec::init(d, 17, new typ::Interface::•(d.[](30))); - dec::init(d, 18, new typ::Interface::•(d.[](30))); - dec::init(d, 19, new typ::Interface::•(d.[](30)), <dynamic>[new typ::Interface::•(d.[](33), <dynamic>[new typ::Interface::•(d.[](19))]), new typ::Interface::•(d.[](34))]); - dec::init(d, 20, new typ::Interface::•(d.[](35))); + dec::init(d, 3, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](15))], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Interface::•(d.[](1)), 0, <dynamic>[new typ::Interface::•(d.[](0))])); + dec::init(d, 4, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0))])); + dec::init(d, 5, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); + dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1))])); + dec::init(d, 7, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 4, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), new typ::Interface::•(d.[](2))])); + dec::init(d, 8, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), new typ::Interface::•(d.[](2))])); + dec::init(d, 9, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>["a", new typ::Interface::•(d.[](0))])); + dec::init(d, 10, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))])); + dec::init(d, 11, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(d.[](0)), "b", new typ::Interface::•(d.[](1))])); + dec::init(d, 12, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 5, <dynamic>[new typ::Interface::•(d.[](0)), "b", new typ::Interface::•(d.[](1)), "c", new typ::Interface::•(d.[](2))])); + dec::init(d, 13, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), "c", new typ::Interface::•(d.[](2))])); + dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 17, <dynamic>["kE", const typ::Dynamic::•(), "ii", const typ::Dynamic::•(), "oP", const typ::Dynamic::•(), "Ij", const typ::Dynamic::•(), "pA", const typ::Dynamic::•(), "zD", const typ::Dynamic::•(), "aZ", const typ::Dynamic::•(), "UU", const typ::Dynamic::•()])); + dec::init(d, 15, new typ::Interface::•(d.[](17))); + dec::init(d, 16, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](32), <dynamic>[d.[](16).variables.[](0)])]); + dec::init(d, 17, null); + dec::init(d, 18, new typ::Interface::•(d.[](17))); + dec::init(d, 19, new typ::Interface::•(d.[](17))); + dec::init(d, 20, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](33), <dynamic>[new typ::Interface::•(d.[](20))]), new typ::Interface::•(d.[](34))]); dec::init(d, 21, new typ::Interface::•(d.[](35))); - dec::init(d, 22, new typ::Interface::•(d.[](30))); - dec::init(d, 23, new typ::Interface::•(d.[](36))); + dec::init(d, 22, new typ::Interface::•(d.[](35))); + dec::init(d, 23, new typ::Interface::•(d.[](17))); dec::init(d, 24, new typ::Interface::•(d.[](36))); dec::init(d, 25, new typ::Interface::•(d.[](36))); dec::init(d, 26, new typ::Interface::•(d.[](36))); - dec::init(d, 27, new typ::Interface::•(d.[](30)), <dynamic>[new typ::Interface::•(d.[](37))]); - dec::init(d, 28, new typ::Interface::•(d.[](29))); - dec::init(d, 29, new typ::Interface::•(d.[](36))); - dec::init(d, 30, null); + dec::init(d, 27, new typ::Interface::•(d.[](36))); + dec::init(d, 28, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](37))]); + dec::init(d, 29, new typ::Interface::•(d.[](30))); + dec::init(d, 30, new typ::Interface::•(d.[](36))); dec::init(d, 32, new typ::Interface::•(d.[](38), <dynamic>[d.[](32).variables.[](0)])); - dec::init(d, 33, new typ::Interface::•(d.[](30))); - dec::init(d, 34, new typ::Interface::•(d.[](30))); - dec::init(d, 35, new typ::Interface::•(d.[](30)), <dynamic>[new typ::Interface::•(d.[](33), <dynamic>[new typ::Interface::•(d.[](35))])]); - dec::init(d, 36, new typ::Interface::•(d.[](30))); - dec::init(d, 37, new typ::Interface::•(d.[](30))); - dec::init(d, 38, new typ::Interface::•(d.[](30))); + dec::init(d, 33, new typ::Interface::•(d.[](17))); + dec::init(d, 34, new typ::Interface::•(d.[](17))); + dec::init(d, 35, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](33), <dynamic>[new typ::Interface::•(d.[](35))])]); + dec::init(d, 36, new typ::Interface::•(d.[](17))); + dec::init(d, 37, new typ::Interface::•(d.[](17))); + dec::init(d, 38, new typ::Interface::•(d.[](17))); return d; -}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "D", "ER0P1", "ER1P0", "ER1P1", "ER1P2", "ER2P1", "ER0N1", "ER1N0", "ER1N1", "ER1N2", "ER2N1", "ER0N8", "Function", "List", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "EfficientLengthIterable", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1])); +}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "D", "ER0P1", "ER1P0", "ER1P1", "ER1P2", "ER2P1", "ER0N1", "ER1N0", "ER1N1", "ER1N2", "ER2N1", "ER0N8", "Function", "List", "Object", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "HasRuntimeTypeGetter", "EfficientLengthIterable", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1])); static method foo(self::A a) → self::C { return null; } @@ -216,7 +216,7 @@ } static method main() → dynamic { self::test(new self::D::•()); - for (dynamic c in int::attachType(<dynamic>[new self::ER0P1::•(), new self::ER1P0::•(), new self::ER1P1::•(), new self::ER1P2::•(), new self::ER2P1::•(), new self::ER0N1::•(), new self::ER1N0::•(), new self::ER1N1::•(), new self::ER1N2::•(), new self::ER2N1::•()], new typ::Interface::•(self::$declarations.[](16), <dynamic>[const typ::Dynamic::•()]))) { + for (core::Object c in int::attachType(<core::Object>[new self::ER0P1::•(), new self::ER1P0::•(), new self::ER1P1::•(), new self::ER1P2::•(), new self::ER2P1::•(), new self::ER0N1::•(), new self::ER1N0::•(), new self::ER1N1::•(), new self::ER1N2::•(), new self::ER2N1::•()], new typ::Interface::•(self::$declarations.[](16), <dynamic>[new typ::Interface::•(self::$declarations.[](17))]))) { self::test(c); } tes::expectOutput("true\ntrue\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\ntrue\ntrue\ntrue\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\ntrue\ntrue\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue");
diff --git a/pkg/kernel/testcases/reify/generic_methods_simple_test.dart b/pkg/kernel/testcases/reify/generic_methods_simple_test.dart new file mode 100644 index 0000000..f2e13d8 --- /dev/null +++ b/pkg/kernel/testcases/reify/generic_methods_simple_test.dart
@@ -0,0 +1,15 @@ +// Copyright (c) 2017, 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. + +library generic_methods_simple_test; + +import 'test_base.dart'; + +bool fun<T>(int s) { + return true; +} + +main() { + expectTrue(fun<double>(2)); +}
diff --git a/pkg/kernel/testcases/reify/generic_methods_simple_test.dart.expect b/pkg/kernel/testcases/reify/generic_methods_simple_test.dart.expect new file mode 100644 index 0000000..53c2725 --- /dev/null +++ b/pkg/kernel/testcases/reify/generic_methods_simple_test.dart.expect
@@ -0,0 +1,35 @@ +library generic_methods_simple_test; +import self as self; +import "dart:core" as core; +import "../../runtime/reify/types.dart" as typ; +import "./test_base.dart" as tes; +import "../../runtime/reify/declarations.dart" as dec; + +static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> { + dec::init(d, 0, new typ::Interface::•(d.[](13))); + dec::init(d, 1, new typ::Interface::•(d.[](14))); + dec::init(d, 2, new typ::Interface::•(d.[](14))); + dec::init(d, 3, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](15), <dynamic>[new typ::Interface::•(d.[](3))]), new typ::Interface::•(d.[](16))]); + dec::init(d, 4, new typ::Interface::•(d.[](13))); + dec::init(d, 5, new typ::Interface::•(d.[](14))); + dec::init(d, 6, new typ::Interface::•(d.[](17))); + dec::init(d, 7, new typ::Interface::•(d.[](17))); + dec::init(d, 8, new typ::Interface::•(d.[](17))); + dec::init(d, 9, new typ::Interface::•(d.[](17))); + dec::init(d, 10, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](18))]); + dec::init(d, 11, new typ::Interface::•(d.[](12))); + dec::init(d, 12, new typ::Interface::•(d.[](17))); + dec::init(d, 13, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](15), <dynamic>[new typ::Interface::•(d.[](13))])]); + dec::init(d, 14, null); + dec::init(d, 15, new typ::Interface::•(d.[](14))); + dec::init(d, 16, new typ::Interface::•(d.[](14))); + dec::init(d, 17, new typ::Interface::•(d.[](14))); + dec::init(d, 18, new typ::Interface::•(d.[](14))); + return d; +}.call(dec::allocateDeclarations(<dynamic>["double", "Null", "bool", "String", "int", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "num", "Object", "Comparable", "Pattern", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0])); +static method fun(core::int s, {core::List<typ::ReifiedType> $typeParameters}) → core::bool { + return true; +} +static method main() → dynamic { + tes::expectTrue(self::fun(2, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](0))])); +}
diff --git a/pkg/kernel/testcases/reify/is1_test.dart.expect b/pkg/kernel/testcases/reify/is1_test.dart.expect index 7f3642a..020cdc3 100644 --- a/pkg/kernel/testcases/reify/is1_test.dart.expect +++ b/pkg/kernel/testcases/reify/is1_test.dart.expect
@@ -72,11 +72,11 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["N", "I", "D", "A", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - dynamic x = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])); + self::A x = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])); tes::expectTrue(let dynamic #t1 = x in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t1.$type, #t2))); tes::expectTrue(let dynamic #t3 = x in #t3 is int::HasRuntimeTypeGetter && #t3.$is$A && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t3.$type, #t4))); tes::expectFalse(let dynamic #t5 = x in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t5.$type, #t6))); - dynamic y = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[const typ::Dynamic::•()])); + self::A y = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[const typ::Dynamic::•()])); tes::expectTrue(let dynamic #t7 = y in #t7 is int::HasRuntimeTypeGetter && #t7.$is$A && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t7.$type, #t8))); tes::expectTrue(let dynamic #t9 = y in #t9 is int::HasRuntimeTypeGetter && #t9.$is$A && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t9.$type, #t10))); tes::expectTrue(let dynamic #t11 = y in #t11 is int::HasRuntimeTypeGetter && #t11.$is$A && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t11.$type, #t12)));
diff --git a/pkg/kernel/testcases/reify/native_types_test.dart.expect b/pkg/kernel/testcases/reify/native_types_test.dart.expect index 0000d2f..ca0fa91 100644 --- a/pkg/kernel/testcases/reify/native_types_test.dart.expect +++ b/pkg/kernel/testcases/reify/native_types_test.dart.expect
@@ -79,7 +79,7 @@ constructor •(final mock::Context context) → dynamic : self::Closure#main#function::context = context ; - method call() → dynamic { + method call() → self::C { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#main#function::context}; return throw int::attachType(new core::AbstractClassInstantiationError::•("C"), new typ::Interface::•(self::$declarations.[](3))); @@ -119,7 +119,7 @@ constructor •(final mock::Context context) → dynamic : self::Closure#main#function#1::context = context ; - method call(dynamic e) → dynamic { + method call(dynamic e) → core::bool { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#main#function#1::context}; return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](3))); @@ -199,7 +199,7 @@ constructor •(final mock::Context context) → dynamic : self::Closure#main#function#3::context = context ; - method call(dynamic e) → dynamic { + method call(dynamic e) → core::bool { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#main#function#3::context}; return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](7))); @@ -279,7 +279,7 @@ constructor •(final mock::Context context) → dynamic : self::Closure#main#function#5::context = context ; - method call(dynamic e) → dynamic { + method call(dynamic e) → core::bool { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#main#function#5::context}; return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](10))); @@ -322,7 +322,7 @@ method call() → dynamic { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#main#function#6::context}; - return int::attachType(<dynamic>[], new typ::Interface::•(self::$declarations.[](12), <dynamic>[const typ::Dynamic::•()])).[](1); + return int::attachType(<dynamic>[], new typ::Interface::•(self::$declarations.[](12), <dynamic>[const typ::Dynamic::•()])).{core::List::[]}(1); } get $type() → typ::ReifiedType return new typ::Interface::•(self::$declarations.[](11)); @@ -359,7 +359,7 @@ constructor •(final mock::Context context) → dynamic : self::Closure#main#function#7::context = context ; - method call(dynamic e) → dynamic { + method call(dynamic e) → core::bool { "This is a temporary solution. In the VM, this will become an additional parameter."; final mock::Context #contextParameter = this.{self::Closure#main#function#7::context}; return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](14))); @@ -398,18 +398,18 @@ static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> { dec::init(d, 0, new typ::Interface::•(d.[](18))); dec::init(d, 1, new typ::Interface::•(d.[](18))); - dec::init(d, 2, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[])); + dec::init(d, 2, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](0)), 0, <dynamic>[])); dec::init(d, 3, new typ::Interface::•(d.[](27))); - dec::init(d, 4, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 4, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()])); dec::init(d, 5, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[])); - dec::init(d, 6, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 6, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()])); dec::init(d, 7, new typ::Interface::•(d.[](27))); dec::init(d, 8, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[])); - dec::init(d, 9, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 9, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()])); dec::init(d, 10, new typ::Interface::•(d.[](27))); dec::init(d, 11, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[])); dec::init(d, 12, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](28), <dynamic>[d.[](12).variables.[](0)])]); - dec::init(d, 13, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()])); + dec::init(d, 13, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()])); dec::init(d, 14, new typ::Interface::•(d.[](21))); dec::init(d, 15, new typ::Interface::•(d.[](29))); dec::init(d, 16, new typ::Interface::•(d.[](29)));
diff --git a/pkg/kernel/testcases/reify/reuse_type_variables_test.dart.expect b/pkg/kernel/testcases/reify/reuse_type_variables_test.dart.expect index ebdfa26..473772b 100644 --- a/pkg/kernel/testcases/reify/reuse_type_variables_test.dart.expect +++ b/pkg/kernel/testcases/reify/reuse_type_variables_test.dart.expect
@@ -147,15 +147,15 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["X", "Y", "Z", "C", "D", "E", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - dynamic c = new self::C::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))])); - dynamic d = c.foo(); + self::C c = new self::C::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))])); + dynamic d = c.{self::C::foo}(); tes::expectTrue(let dynamic #t1 = d in #t1 is int::HasRuntimeTypeGetter && #t1.$is$D && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t1.$type, #t2))); - d = c.hest(); + d = c.{self::C::hest}(); tes::expectTrue(!(let dynamic #t3 = d in #t3 is int::HasRuntimeTypeGetter && #t3.$is$D && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t3.$type, #t4)))); tes::expectTrue(let dynamic #t5 = d in #t5 is int::HasRuntimeTypeGetter && #t5.$is$D && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2)), new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t5.$type, #t6))); c = d.baz(); tes::expectTrue(let dynamic #t7 = c in #t7 is int::HasRuntimeTypeGetter && #t7.$is$C && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2)), new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t7.$type, #t8))); - dynamic e = c.bar(); + dynamic e = c.{self::C::bar}(); tes::expectTrue(let dynamic #t9 = e in #t9 is int::HasRuntimeTypeGetter && #t9.$is$E && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t9.$type, #t10))); c = e.qux(); tes::expectTrue(let dynamic #t11 = c in #t11 is int::HasRuntimeTypeGetter && #t11.$is$C && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t11.$type, #t12)));
diff --git a/pkg/kernel/testcases/reify/simple_test.dart.expect b/pkg/kernel/testcases/reify/simple_test.dart.expect index 3023fe3..3b1c713 100644 --- a/pkg/kernel/testcases/reify/simple_test.dart.expect +++ b/pkg/kernel/testcases/reify/simple_test.dart.expect
@@ -145,8 +145,8 @@ tes::write(!(let dynamic #t8 = o in #t8 is int::HasRuntimeTypeGetter && #t8.$is$D)); } static method main() → dynamic { - dynamic objects = int::attachType(<dynamic>[new self::A::•(), new self::B::•(), new self::C::•(), new self::D::•()], new typ::Interface::•(self::$declarations.[](6), <dynamic>[const typ::Dynamic::•()])); - objects.forEach(new self::Closure#testIs::•()); - objects.forEach(new self::Closure#testIsNot::•()); + core::List<self::C> objects = int::attachType(<self::C>[new self::A::•(), new self::B::•(), new self::C::•(), new self::D::•()], new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])); + objects.{core::Iterable::forEach}(new self::Closure#testIs::•()); + objects.{core::Iterable::forEach}(new self::Closure#testIsNot::•()); tes::expectOutput("true\nfalse\ntrue\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\ntrue\ntrue\ntrue\nfalse\ntrue\nfalse\ntrue\ntrue\nfalse\nfalse\ntrue\ntrue\ntrue\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse"); }
diff --git a/pkg/kernel/testcases/reify/subclass_test.dart.expect b/pkg/kernel/testcases/reify/subclass_test.dart.expect index 55d42f8..2317bb7 100644 --- a/pkg/kernel/testcases/reify/subclass_test.dart.expect +++ b/pkg/kernel/testcases/reify/subclass_test.dart.expect
@@ -108,12 +108,12 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["X", "Y", "R", "A", "B", "C", "D", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - tes::expectTrue(let dynamic #t1 = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t1 is int::HasRuntimeTypeGetter && #t1.$is$R && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t1.$type, #t2))); - tes::expectTrue(let dynamic #t3 = new self::B::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t3 is int::HasRuntimeTypeGetter && #t3.$is$R && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t3.$type, #t4))); - tes::expectTrue(let dynamic #t5 = new self::C::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t5 is int::HasRuntimeTypeGetter && #t5.$is$R && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t5.$type, #t6))); - tes::expectTrue(let dynamic #t7 = new self::D::•(new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t7 is int::HasRuntimeTypeGetter && #t7.$is$R && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])]) in typ::isSubtypeOf(#t7.$type, #t8))); - tes::expectTrue(!(let dynamic #t9 = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t9 is int::HasRuntimeTypeGetter && #t9.$is$R && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t9.$type, #t10)))); - tes::expectTrue(!(let dynamic #t11 = new self::B::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t11 is int::HasRuntimeTypeGetter && #t11.$is$R && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t11.$type, #t12)))); - tes::expectTrue(!(let dynamic #t13 = new self::C::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t13 is int::HasRuntimeTypeGetter && #t13.$is$R && (let dynamic #t14 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t13.$type, #t14)))); - tes::expectTrue(!(let dynamic #t15 = new self::D::•(new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).foo() in #t15 is int::HasRuntimeTypeGetter && #t15.$is$R && (let dynamic #t16 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])]) in typ::isSubtypeOf(#t15.$type, #t16)))); + tes::expectTrue(let dynamic #t1 = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t1 is int::HasRuntimeTypeGetter && #t1.$is$R && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t1.$type, #t2))); + tes::expectTrue(let dynamic #t3 = new self::B::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t3 is int::HasRuntimeTypeGetter && #t3.$is$R && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t3.$type, #t4))); + tes::expectTrue(let dynamic #t5 = new self::C::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t5 is int::HasRuntimeTypeGetter && #t5.$is$R && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t5.$type, #t6))); + tes::expectTrue(let dynamic #t7 = new self::D::•(new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t7 is int::HasRuntimeTypeGetter && #t7.$is$R && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])]) in typ::isSubtypeOf(#t7.$type, #t8))); + tes::expectTrue(!(let dynamic #t9 = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t9 is int::HasRuntimeTypeGetter && #t9.$is$R && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t9.$type, #t10)))); + tes::expectTrue(!(let dynamic #t11 = new self::B::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t11 is int::HasRuntimeTypeGetter && #t11.$is$R && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t11.$type, #t12)))); + tes::expectTrue(!(let dynamic #t13 = new self::C::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t13 is int::HasRuntimeTypeGetter && #t13.$is$R && (let dynamic #t14 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t13.$type, #t14)))); + tes::expectTrue(!(let dynamic #t15 = new self::D::•(new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t15 is int::HasRuntimeTypeGetter && #t15.$is$R && (let dynamic #t16 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])]) in typ::isSubtypeOf(#t15.$type, #t16)))); }
diff --git a/pkg/kernel/testcases/reify/super1_test.dart.expect b/pkg/kernel/testcases/reify/super1_test.dart.expect index 8b3d20d..3879cd4 100644 --- a/pkg/kernel/testcases/reify/super1_test.dart.expect +++ b/pkg/kernel/testcases/reify/super1_test.dart.expect
@@ -3,6 +3,7 @@ import "dart:core" as core; import "../../runtime/reify/interceptors.dart" as int; import "../../runtime/reify/types.dart" as typ; +import "dart:mock" as mock; import "../../runtime/reify/declarations.dart" as dec; class A extends core::Object implements int::HasRuntimeTypeGetter { @@ -18,7 +19,7 @@ class B extends self::A implements int::HasRuntimeTypeGetter { field core::int i; constructor •(typ::ReifiedType $type, core::int i) → void - : self::B::i = i, super self::A::•($type) + : self::B::i = let final mock::Context #context = int::attachType(new mock::Context::•(1), new typ::Interface::•(self::$declarations.[](2))) in let dynamic #t1 = #context.[]=(0, i) in #context.[](0), super self::A::•($type) ; constructor redirect(typ::ReifiedType $type) → void : this self::B::•($type, 42) @@ -27,27 +28,28 @@ return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0); } static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> { - dec::init(d, 0, new typ::Interface::•(d.[](15))); + dec::init(d, 0, new typ::Interface::•(d.[](16))); dec::init(d, 1, new typ::Interface::•(d.[](0), <dynamic>[d.[](1).variables.[](0)])); - dec::init(d, 2, new typ::Interface::•(d.[](15))); - dec::init(d, 3, new typ::Interface::•(d.[](15))); - dec::init(d, 4, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](4))]), new typ::Interface::•(d.[](18))]); - dec::init(d, 5, new typ::Interface::•(d.[](19))); - dec::init(d, 6, new typ::Interface::•(d.[](19))); - dec::init(d, 7, new typ::Interface::•(d.[](15))); - dec::init(d, 8, new typ::Interface::•(d.[](20))); - dec::init(d, 9, new typ::Interface::•(d.[](20))); - dec::init(d, 10, new typ::Interface::•(d.[](20))); - dec::init(d, 11, new typ::Interface::•(d.[](20))); - dec::init(d, 12, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](21))]); - dec::init(d, 13, new typ::Interface::•(d.[](14))); - dec::init(d, 14, new typ::Interface::•(d.[](20))); - dec::init(d, 15, null); - dec::init(d, 17, new typ::Interface::•(d.[](15))); - dec::init(d, 18, new typ::Interface::•(d.[](15))); - dec::init(d, 19, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](19))])]); - dec::init(d, 20, new typ::Interface::•(d.[](15))); - dec::init(d, 21, new typ::Interface::•(d.[](15))); + dec::init(d, 2, new typ::Interface::•(d.[](16))); + dec::init(d, 3, new typ::Interface::•(d.[](16))); + dec::init(d, 4, new typ::Interface::•(d.[](16))); + dec::init(d, 5, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](5))]), new typ::Interface::•(d.[](19))]); + dec::init(d, 6, new typ::Interface::•(d.[](20))); + dec::init(d, 7, new typ::Interface::•(d.[](20))); + dec::init(d, 8, new typ::Interface::•(d.[](16))); + dec::init(d, 9, new typ::Interface::•(d.[](21))); + dec::init(d, 10, new typ::Interface::•(d.[](21))); + dec::init(d, 11, new typ::Interface::•(d.[](21))); + dec::init(d, 12, new typ::Interface::•(d.[](21))); + dec::init(d, 13, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](22))]); + dec::init(d, 14, new typ::Interface::•(d.[](15))); + dec::init(d, 15, new typ::Interface::•(d.[](21))); + dec::init(d, 16, null); + dec::init(d, 18, new typ::Interface::•(d.[](16))); + dec::init(d, 19, new typ::Interface::•(d.[](16))); + dec::init(d, 20, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](20))])]); + dec::init(d, 21, new typ::Interface::•(d.[](16))); + dec::init(d, 22, new typ::Interface::•(d.[](16))); return d; -}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); +}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Context", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic {}
diff --git a/pkg/kernel/testcases/reify/super3_test.dart.expect b/pkg/kernel/testcases/reify/super3_test.dart.expect index 7ced8ac..6ec46e7 100644 --- a/pkg/kernel/testcases/reify/super3_test.dart.expect +++ b/pkg/kernel/testcases/reify/super3_test.dart.expect
@@ -53,6 +53,6 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - new self::B::•().foo; + new self::B::•().{self::A::foo}; new self::B::redirect(); }
diff --git a/pkg/kernel/testcases/reify/typevariable1_test.dart.expect b/pkg/kernel/testcases/reify/typevariable1_test.dart.expect index 6feca7a..d6856ba 100644 --- a/pkg/kernel/testcases/reify/typevariable1_test.dart.expect +++ b/pkg/kernel/testcases/reify/typevariable1_test.dart.expect
@@ -56,6 +56,6 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["Z", "N", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - dynamic one = new self::Z::•().succ; + dynamic one = new self::Z::•().{self::Z::succ}; dynamic two = one.succ; }
diff --git a/pkg/kernel/testcases/reify/typevariable3_test.dart.expect b/pkg/kernel/testcases/reify/typevariable3_test.dart.expect index c8e09ce..a6f8ff2 100644 --- a/pkg/kernel/testcases/reify/typevariable3_test.dart.expect +++ b/pkg/kernel/testcases/reify/typevariable3_test.dart.expect
@@ -14,6 +14,9 @@ dynamic temp = t; return temp; } + method foo$cc(core::Object t) → dynamic { + return this.{=self::C::foo}(t as dynamic); + } get $C$T() → typ::ReifiedType return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0); get runtimeType() → core::Type @@ -43,5 +46,5 @@ return d; }.call(dec::allocateDeclarations(<dynamic>["C", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0])); static method main() → dynamic { - self::C c = new self::C::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])])).foo(new self::C::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()]))); + self::C c = new self::C::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])])).{self::C::foo}(new self::C::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()]))); }
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc index 41eb3d6..2c16279 100644 --- a/runtime/vm/kernel_to_il.cc +++ b/runtime/vm/kernel_to_il.cc
@@ -2748,6 +2748,23 @@ } +Fragment FlowGraphBuilder::StringInterpolateSingle(TokenPosition position) { + const int kNumberOfArguments = 1; + const Array& kNoArgumentNames = Object::null_array(); + const dart::Class& cls = dart::Class::Handle( + dart::Library::LookupCoreClass(Symbols::StringBase())); + ASSERT(!cls.IsNull()); + const Function& function = dart::Function::ZoneHandle( + Z, dart::Resolver::ResolveStatic(cls, dart::Library::PrivateCoreLibName( + Symbols::InterpolateSingle()), + kNumberOfArguments, kNoArgumentNames)); + Fragment instructions; + instructions += PushArgument(); + instructions += StaticCall(position, function, 1); + return instructions; +} + + Fragment FlowGraphBuilder::ThrowTypeError() { const dart::Class& klass = dart::Class::ZoneHandle( Z, dart::Library::LookupCoreClass(Symbols::TypeError())); @@ -5161,22 +5178,26 @@ Fragment instructions; - // The type arguments for CreateArray. - instructions += Constant(TypeArguments::ZoneHandle(Z)); - instructions += IntConstant(expressions.length()); - instructions += CreateArray(); - LocalVariable* array = MakeTemporary(); + if (node->expressions().length() == 1) { + instructions += TranslateExpression(node->expressions()[0]); + instructions += StringInterpolateSingle(node->position()); + } else { + // The type arguments for CreateArray. + instructions += Constant(TypeArguments::ZoneHandle(Z)); + instructions += IntConstant(expressions.length()); + instructions += CreateArray(); + LocalVariable* array = MakeTemporary(); - for (intptr_t i = 0; i < node->expressions().length(); i++) { - instructions += LoadLocal(array); - instructions += IntConstant(i); - instructions += TranslateExpression(node->expressions()[i]); - instructions += StoreIndexed(kArrayCid); - instructions += Drop(); + for (intptr_t i = 0; i < node->expressions().length(); i++) { + instructions += LoadLocal(array); + instructions += IntConstant(i); + instructions += TranslateExpression(node->expressions()[i]); + instructions += StoreIndexed(kArrayCid); + instructions += Drop(); + } + + instructions += StringInterpolate(node->position()); } - - instructions += StringInterpolate(node->position()); - fragment_ = instructions; }
diff --git a/runtime/vm/kernel_to_il.h b/runtime/vm/kernel_to_il.h index 6093f4b..d019cda 100644 --- a/runtime/vm/kernel_to_il.h +++ b/runtime/vm/kernel_to_il.h
@@ -876,6 +876,7 @@ Fragment StoreLocal(TokenPosition position, LocalVariable* variable); Fragment StoreStaticField(TokenPosition position, const dart::Field& field); Fragment StringInterpolate(TokenPosition position); + Fragment StringInterpolateSingle(TokenPosition position); Fragment ThrowTypeError(); Fragment ThrowNoSuchMethodError(); Fragment BuildImplicitClosureCreation(const Function& target);
diff --git a/sdk/lib/io/socket.dart b/sdk/lib/io/socket.dart index 0a112d5..1f733ba 100644 --- a/sdk/lib/io/socket.dart +++ b/sdk/lib/io/socket.dart
@@ -695,7 +695,7 @@ * If an error occur when trying to join the multicast group an * exception is thrown. */ - void joinMulticast(InternetAddress group, {NetworkInterface interface}); + void joinMulticast(InternetAddress group, [NetworkInterface interface]); /** * Leave a multicast group. @@ -703,7 +703,7 @@ * If an error occur when trying to join the multicase group an * exception is thrown. */ - void leaveMulticast(InternetAddress group, {NetworkInterface interface}); + void leaveMulticast(InternetAddress group, [NetworkInterface interface]); }
diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status index 74ca448..9007166 100644 --- a/tests/co19/co19-dart2js.status +++ b/tests/co19/co19-dart2js.status
@@ -92,28 +92,7 @@ Language/Expressions/Function_Invocation/async_generator_invokation_t08: Timeout, Skip # Issue 25967 Language/Expressions/Function_Invocation/async_generator_invokation_t10: Timeout, Skip # Issue 25967 Language/Expressions/Function_Invocation/async_invokation_t04: RuntimeError, Pass # co19 issue 57 -Language/Expressions/Identifier_Reference/built_in_identifier_t35: MissingCompileTimeError # Issue 25732 -Language/Expressions/Identifier_Reference/built_in_identifier_t36: MissingCompileTimeError # Issue 25732 -Language/Expressions/Identifier_Reference/built_in_identifier_t37: MissingCompileTimeError # Issue 25732 -Language/Expressions/Identifier_Reference/built_in_identifier_t53: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t54: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t55: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t56: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t57: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t58: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t59: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t60: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t61: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t62: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t63: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t64: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t65: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t66: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t67: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_identifier_t68: MissingCompileTimeError # Issue 25733 -Language/Expressions/Identifier_Reference/built_in_not_dynamic_t14: MissingCompileTimeError # Issue 25732 Language/Expressions/Identifier_Reference/built_in_not_dynamic_t15: MissingCompileTimeError # Issue 26581 -Language/Expressions/Identifier_Reference/built_in_not_dynamic_t19: MissingCompileTimeError # Issue 25732 Language/Expressions/Identifier_Reference/syntax_built_in_t01: fail # Issue 21154 Language/Expressions/Instance_Creation/New/evaluation_t19: RuntimeError # Please triage this failure Language/Expressions/Instance_Creation/New/evaluation_t20: RuntimeError # Please triage this failure
diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status index a5620a6..aed2c9d 100644 --- a/tests/co19/co19-kernel.status +++ b/tests/co19/co19-kernel.status
@@ -52,6 +52,8 @@ Language/Classes/Getters/syntax_t04: MissingCompileTimeError Language/Classes/Getters/syntax_t05: MissingCompileTimeError Language/Classes/Getters/syntax_t07: MissingCompileTimeError +Language/Classes/Getters/type_object_t01: RuntimeError # Issue 23721 +Language/Classes/Getters/type_object_t02: RuntimeError # Issue 23721 Language/Classes/Instance_Methods/Operators/arity_0_or_1_t02: MissingCompileTimeError Language/Classes/Instance_Methods/Operators/arity_0_t02: MissingCompileTimeError Language/Classes/Instance_Methods/Operators/arity_1_t01: MissingCompileTimeError @@ -98,8 +100,12 @@ Language/Classes/Setters/syntax_t01: RuntimeError Language/Classes/Setters/syntax_t03: MissingCompileTimeError Language/Classes/Setters/syntax_t04: RuntimeError +Language/Classes/Setters/type_object_t01: RuntimeError # Issue 23721 +Language/Classes/Setters/type_object_t02: RuntimeError # Issue 23721 Language/Classes/Static_Methods/declaration_t01: MissingCompileTimeError Language/Classes/Static_Methods/same_name_method_and_setter_t01: CompileTimeError +Language/Classes/Static_Methods/type_object_t01: RuntimeError # Issue 23721 +Language/Classes/Static_Methods/type_object_t02: RuntimeError # Issue 23721 Language/Classes/Superclasses/Inheritance_and_Overriding/inheritance_t03: RuntimeError Language/Classes/Superclasses/superclass_of_itself_t01: MissingCompileTimeError Language/Classes/Superclasses/superclass_of_itself_t02: MissingCompileTimeError @@ -149,6 +155,7 @@ Language/Expressions/Assignment/static_warning_t03/none: RuntimeError Language/Expressions/Assignment/super_assignment_failed_t01: RuntimeError Language/Expressions/Assignment/super_assignment_failed_t02: RuntimeError +Language/Expressions/Assignment/super_assignment_failed_t05: RuntimeError # Issue 25671 Language/Expressions/Assignment/super_assignment_value_t02: RuntimeError Language/Expressions/Await_Expressions/syntax_t06: Crash Language/Expressions/Constants/bitwise_operators_t02: Crash @@ -212,6 +219,8 @@ Language/Expressions/Function_Invocation/Binding_Actuals_to_Formals/same_name_arguments_t01: MissingCompileTimeError Language/Expressions/Function_Invocation/Unqualified_Invocation/instance_context_invocation_t03: MissingCompileTimeError Language/Expressions/Function_Invocation/Unqualified_Invocation/instance_context_invocation_t04: MissingCompileTimeError +Language/Expressions/Function_Invocation/async_generator_invokation_t08: Fail # Issue 25967 +Language/Expressions/Function_Invocation/async_generator_invokation_t10: Fail # Issue 25967 Language/Expressions/Identifier_Reference/async_and_generator_t02: MissingCompileTimeError Language/Expressions/Identifier_Reference/async_and_generator_t03: MissingCompileTimeError Language/Expressions/Identifier_Reference/async_and_generator_t04: MissingCompileTimeError @@ -221,15 +230,8 @@ Language/Expressions/Identifier_Reference/async_and_generator_t08: MissingCompileTimeError Language/Expressions/Identifier_Reference/async_and_generator_t09: MissingCompileTimeError Language/Expressions/Identifier_Reference/async_and_generator_t10: MissingCompileTimeError -Language/Expressions/Identifier_Reference/built_in_identifier_t08: MissingCompileTimeError -Language/Expressions/Identifier_Reference/built_in_identifier_t09: MissingCompileTimeError -Language/Expressions/Identifier_Reference/built_in_identifier_t10: MissingCompileTimeError -Language/Expressions/Identifier_Reference/built_in_identifier_t35: Pass # OK, Issue 25732 -Language/Expressions/Identifier_Reference/built_in_identifier_t36: Pass # OK, Issue 25732 -Language/Expressions/Identifier_Reference/built_in_identifier_t37: Pass # OK, Issue 25732 Language/Expressions/Identifier_Reference/built_in_not_dynamic_t01: MissingCompileTimeError Language/Expressions/Identifier_Reference/built_in_not_dynamic_t12: MissingCompileTimeError -Language/Expressions/Identifier_Reference/built_in_not_dynamic_t14: Pass # OK, Issue 25732 Language/Expressions/Identifier_Reference/built_in_not_dynamic_t15: MissingCompileTimeError Language/Expressions/Identifier_Reference/evaluation_static_t02: Crash Language/Expressions/Identifier_Reference/syntax_built_in_t01: CompileTimeError @@ -274,6 +276,8 @@ Language/Expressions/Method_Invocation/Ordinary_Invocation/evaluation_t07: RuntimeError # Dartk Issue 28562 Language/Expressions/Method_Invocation/Ordinary_Invocation/method_lookup_failed_t17: RuntimeError Language/Expressions/Method_Invocation/Ordinary_Invocation/method_lookup_failed_t18: RuntimeError # Dartk Issue 28562 +Language/Expressions/Method_Invocation/Ordinary_Invocation/object_method_invocation_t01: MissingCompileTimeError # Issue 25496 +Language/Expressions/Method_Invocation/Ordinary_Invocation/object_method_invocation_t02: MissingCompileTimeError # Issue 25496 Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t01: RuntimeError Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t02: RuntimeError Language/Expressions/Method_Invocation/Super_Invocation/getter_lookup_failed_t03: RuntimeError @@ -281,6 +285,14 @@ Language/Expressions/Method_Invocation/Super_Invocation/invocation_t02: MissingCompileTimeError Language/Expressions/Method_Invocation/Super_Invocation/invocation_t03: MissingCompileTimeError Language/Expressions/Postfix_Expressions/syntax_t06: MissingCompileTimeError +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t01: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t02: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t03: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t04: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t05: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t06: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t07: MissingCompileTimeError # Issue 24332 +Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t08: MissingCompileTimeError # Issue 24332 Language/Expressions/Property_Extraction/Super_Getter_Access_and_Method_Closurization/no_such_method_t01: RuntimeError Language/Expressions/Property_Extraction/Super_Getter_Access_and_Method_Closurization/no_such_method_t02: RuntimeError Language/Expressions/This/placement_t04: MissingCompileTimeError @@ -407,6 +419,7 @@ Language/Metadata/compilation_t11: MissingCompileTimeError Language/Mixins/Mixin_Application/deferred_t01: MissingCompileTimeError Language/Mixins/Mixin_Application/syntax_t15: MissingCompileTimeError +Language/Mixins/Mixin_Application/syntax_t16: CompileTimeError # Issue 25765 Language/Mixins/Mixin_Application/wrong_mixin_type_t01: MissingCompileTimeError Language/Mixins/Mixin_Application/wrong_mixin_type_t02: MissingCompileTimeError Language/Mixins/Mixin_Application/wrong_mixin_type_t07: MissingCompileTimeError @@ -418,6 +431,8 @@ Language/Mixins/declaring_constructor_t02: MissingCompileTimeError Language/Mixins/declaring_constructor_t03: MissingCompileTimeError Language/Mixins/declaring_constructor_t04: MissingCompileTimeError +Language/Mixins/declaring_constructor_t05: MissingCompileTimeError # Issue 24767 +Language/Mixins/declaring_constructor_t06: MissingCompileTimeError # Issue 24767 Language/Mixins/declaring_constructor_t07: MissingCompileTimeError Language/Mixins/declaring_constructor_t08: MissingCompileTimeError Language/Mixins/declaring_constructor_t09: MissingCompileTimeError @@ -503,8 +518,15 @@ Language/Statements/Yield_and_Yield_Each/Yield/location_t02: MissingCompileTimeError Language/Statements/Yield_and_Yield_Each/Yield/location_t04: MissingCompileTimeError Language/Statements/Yield_and_Yield_Each/Yield/location_t06: MissingCompileTimeError +Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t08: RuntimeError # Issue 25748 +Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t09: RuntimeError # Issue 25748 +Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_async_t10: RuntimeError # Issue 25748 +Language/Statements/Yield_and_Yield_Each/Yield_Each/execution_sync_t05: RuntimeError # Issue 25662,25634 +Language/Statements/Yield_and_Yield_Each/Yield_Each/location_t01: MissingCompileTimeError # Issue 25495 Language/Statements/Yield_and_Yield_Each/Yield_Each/location_t02: MissingCompileTimeError +Language/Statements/Yield_and_Yield_Each/Yield_Each/location_t03: MissingCompileTimeError # Issue 25495 Language/Statements/Yield_and_Yield_Each/Yield_Each/location_t04: MissingCompileTimeError +Language/Statements/Yield_and_Yield_Each/Yield_Each/location_t05: MissingCompileTimeError # Issue 25495 Language/Statements/Yield_and_Yield_Each/Yield_Each/location_t06: MissingCompileTimeError Language/Types/Static_Types/deferred_type_t01: RuntimeError # Kernel Issue 28335 (deferred libraries) Language/Types/Static_Types/malformed_type_t01: RuntimeError
diff --git a/tests/co19/co19-runtime.status b/tests/co19/co19-runtime.status index 9d88cfc..0444d35 100644 --- a/tests/co19/co19-runtime.status +++ b/tests/co19/co19-runtime.status
@@ -91,7 +91,7 @@ [ ($runtime == vm || $runtime == dart_precompiled) && $mode == debug && $builder_tag == asan ] Language/Types/Interface_Types/subtype_t27: Skip # Issue 21174. -[ $runtime == vm || $runtime == dart_precompiled ] +[ ($runtime == vm || $runtime == dart_precompiled) && $compiler != dartk && $compiler != dartkp ] # co19 update Sep 29, 2015 (3ed795ea02e022ef19c77cf1b6095b7c8f5584d0) Language/Classes/Getters/type_object_t01: RuntimeError # Issue 23721 Language/Classes/Getters/type_object_t02: RuntimeError # Issue 23721
diff --git a/tests/compiler/dart2js/kernel/closed_world_test.dart b/tests/compiler/dart2js/kernel/closed_world_test.dart index 4054692..71639d7 100644 --- a/tests/compiler/dart2js/kernel/closed_world_test.dart +++ b/tests/compiler/dart2js/kernel/closed_world_test.dart
@@ -137,7 +137,7 @@ backend.interceptorDataBuilder, backend.backendUsageBuilder, backend.rtiNeedBuilder, - backend.mirrorsData, + backend.mirrorsDataBuilder, backend.noSuchMethodRegistry, backend.customElementsResolutionAnalysis, backend.lookupMapResolutionAnalysis,
diff --git a/tests/language/language_kernel.status b/tests/language/language_kernel.status index 5965f94..c90d371 100644 --- a/tests/language/language_kernel.status +++ b/tests/language/language_kernel.status
@@ -56,21 +56,6 @@ bad_raw_string_negative_test: Fail black_listed_test/13: MissingCompileTimeError body_less_constructor_wrong_arg_negative_test: Crash -built_in_identifier_illegal_test/01: MissingCompileTimeError -built_in_identifier_illegal_test/04: MissingCompileTimeError -built_in_identifier_illegal_test/05: MissingCompileTimeError -built_in_identifier_illegal_test/06: MissingCompileTimeError -built_in_identifier_illegal_test/07: MissingCompileTimeError -built_in_identifier_illegal_test/08: MissingCompileTimeError -built_in_identifier_illegal_test/10: MissingCompileTimeError -built_in_identifier_illegal_test/12: MissingCompileTimeError -built_in_identifier_illegal_test/13: MissingCompileTimeError -built_in_identifier_illegal_test/15: MissingCompileTimeError -built_in_identifier_illegal_test/16: MissingCompileTimeError -built_in_identifier_illegal_test/17: MissingCompileTimeError -built_in_identifier_illegal_test/18: MissingCompileTimeError -built_in_identifier_illegal_test/19: MissingCompileTimeError -built_in_identifier_illegal_test/20: MissingCompileTimeError built_in_identifier_test/01: CompileTimeError call_nonexistent_static_test/01: CompileTimeError call_nonexistent_static_test/04: CompileTimeError
diff --git a/tools/VERSION b/tools/VERSION index 7487bd8..6605793 100644 --- a/tools/VERSION +++ b/tools/VERSION
@@ -27,5 +27,5 @@ MAJOR 1 MINOR 23 PATCH 0 -PRERELEASE 8 +PRERELEASE 9 PRERELEASE_PATCH 0
diff --git a/tools/create_sdk.py b/tools/create_sdk.py index 9c1e51f..1d47170 100755 --- a/tools/create_sdk.py +++ b/tools/create_sdk.py
@@ -61,6 +61,7 @@ # ......isolate/ # ......js/ # ......js_util/ +# ......kernel/ # ......math/ # ......mirrors/ # ......typed_data/ @@ -166,7 +167,7 @@ join(sdk_root, 'bin', 'snapshots', snapshot)) def CopyAnalyzerSources(home, lib_dir): - for library in ['analyzer', 'analysis_server', 'front_end']: + for library in ['analyzer', 'analysis_server', 'front_end', 'kernel']: copytree(join(home, 'pkg', library), join(lib_dir, library), ignore=ignore_patterns('*.svn', 'doc', '*.py', '*.gypi', '*.sh', '.gitignore', 'packages'))