diff --git a/pkg/front_end/lib/src/fasta/dill/dill_typedef_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_typedef_builder.dart index a395dcac51c..63616f8608c 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_typedef_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_typedef_builder.dart @@ -4,7 +4,7 @@ library fasta.dill_typedef_builder; -import 'package:kernel/ast.dart' show DartType, Typedef; +import 'package:kernel/ast.dart' show DartType, FunctionType, Typedef; import '../kernel/kernel_builder.dart' show @@ -36,7 +36,17 @@ class DillFunctionTypeAliasBuilder extends KernelFunctionTypeAliasBuilder { } @override - DartType buildThisType(LibraryBuilder library) => thisType ??= target.type; + DartType buildThisType(LibraryBuilder library) { + if (thisType != null) return thisType; + + DartType targetType = target.type; + if (targetType is FunctionType) { + // TODO(34655): The line below is a workaround. Find the place where the + // reference is lost and fix it. + targetType.typedefReference = target.reference; + } + return thisType = targetType; + } @override List buildTypeArguments( diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart index b2f3d1eec35..74e08a66280 100644 --- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart +++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart @@ -674,41 +674,6 @@ const MessageCode messageCantUsePrefixWithNullAware = const MessageCode( message: r"""A prefix can't be used with null-aware operators.""", tip: r"""It should be safe to remove the '?' as a prefix is never null."""); -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Template - templateCantUseSuperBoundedTypeForInstanceCreation = - const Template( - messageTemplate: - r"""Can't use a super-bounded type for instance creation. Got '#type'.""", - tipTemplate: - r"""Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference.""", - withArguments: - _withArgumentsCantUseSuperBoundedTypeForInstanceCreation); - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -const Code - codeCantUseSuperBoundedTypeForInstanceCreation = - const Code( - "CantUseSuperBoundedTypeForInstanceCreation", - templateCantUseSuperBoundedTypeForInstanceCreation, -); - -// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. -Message _withArgumentsCantUseSuperBoundedTypeForInstanceCreation( - DartType _type) { - NameSystem nameSystem = new NameSystem(); - StringBuffer buffer; - buffer = new StringBuffer(); - new Printer(buffer, syntheticNames: nameSystem).writeNode(_type); - String type = '$buffer'; - - return new Message(codeCantUseSuperBoundedTypeForInstanceCreation, - message: - """Can't use a super-bounded type for instance creation. Got '${type}'.""", - tip: """Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference.""", - arguments: {'type': _type}); -} - // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Code codeCatchSyntax = messageCatchSyntax; @@ -4099,6 +4064,229 @@ Message _withArgumentsImportHidesImport(String name, Uri uri_, Uri uri2_) { arguments: {'name': name, 'uri': uri_, 'uri2': uri2_}); } +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template< + Message Function( + DartType _type, + String + name)> templateIncorrectTypeArgument = const Template< + Message Function(DartType _type, String name)>( + messageTemplate: + r"""Type argument '#type' violates the corresponding type variable bound of '#name'.""", + tipTemplate: + r"""Try changing type arguments so that they conform to the bounds.""", + withArguments: _withArgumentsIncorrectTypeArgument); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code + codeIncorrectTypeArgument = + const Code( + "IncorrectTypeArgument", templateIncorrectTypeArgument, + analyzerCodes: ["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsIncorrectTypeArgument(DartType _type, String name) { + NameSystem nameSystem = new NameSystem(); + StringBuffer buffer; + buffer = new StringBuffer(); + new Printer(buffer, syntheticNames: nameSystem).writeNode(_type); + String type = '$buffer'; + + if (name.isEmpty) throw 'No name provided'; + name = demangleMixinApplicationName(name); + return new Message(codeIncorrectTypeArgument, + message: + """Type argument '${type}' violates the corresponding type variable bound of '${name}'.""", + tip: """Try changing type arguments so that they conform to the bounds.""", + arguments: {'type': _type, 'name': name}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template< + Message Function( + DartType _type, + String + name)> templateIncorrectTypeArgumentInReturnType = const Template< + Message Function(DartType _type, String name)>( + messageTemplate: + r"""Type argument '#type' violates the corresponding type variable bound of '#name' in the return type.""", + tipTemplate: + r"""Try changing type arguments so that they conform to the bounds.""", + withArguments: _withArgumentsIncorrectTypeArgumentInReturnType); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code + codeIncorrectTypeArgumentInReturnType = + const Code( + "IncorrectTypeArgumentInReturnType", + templateIncorrectTypeArgumentInReturnType, + analyzerCodes: ["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsIncorrectTypeArgumentInReturnType( + DartType _type, String name) { + NameSystem nameSystem = new NameSystem(); + StringBuffer buffer; + buffer = new StringBuffer(); + new Printer(buffer, syntheticNames: nameSystem).writeNode(_type); + String type = '$buffer'; + + if (name.isEmpty) throw 'No name provided'; + name = demangleMixinApplicationName(name); + return new Message(codeIncorrectTypeArgumentInReturnType, + message: + """Type argument '${type}' violates the corresponding type variable bound of '${name}' in the return type.""", + tip: """Try changing type arguments so that they conform to the bounds.""", + arguments: {'type': _type, 'name': name}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template< + Message Function( + DartType _type, + String name, + String name2, + String + name3)> templateIncorrectTypeArgumentInSupertype = const Template< + Message Function( + DartType _type, String name, String name2, String name3)>( + messageTemplate: + r"""Type argument '#type' violates the corresponding type variable bound of '#name' in the supertype '#name2' of class '#name3'.""", + tipTemplate: + r"""Try changing type arguments so that they conform to the bounds.""", + withArguments: _withArgumentsIncorrectTypeArgumentInSupertype); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code< + Message Function( + DartType _type, String name, String name2, String name3)> + codeIncorrectTypeArgumentInSupertype = const Code< + Message Function( + DartType _type, String name, String name2, String name3)>( + "IncorrectTypeArgumentInSupertype", + templateIncorrectTypeArgumentInSupertype, + analyzerCodes: ["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsIncorrectTypeArgumentInSupertype( + DartType _type, String name, String name2, String name3) { + NameSystem nameSystem = new NameSystem(); + StringBuffer buffer; + buffer = new StringBuffer(); + new Printer(buffer, syntheticNames: nameSystem).writeNode(_type); + String type = '$buffer'; + + if (name.isEmpty) throw 'No name provided'; + name = demangleMixinApplicationName(name); + if (name2.isEmpty) throw 'No name provided'; + name2 = demangleMixinApplicationName(name2); + if (name3.isEmpty) throw 'No name provided'; + name3 = demangleMixinApplicationName(name3); + return new Message(codeIncorrectTypeArgumentInSupertype, + message: + """Type argument '${type}' violates the corresponding type variable bound of '${name}' in the supertype '${name2}' of class '${name3}'.""", + tip: """Try changing type arguments so that they conform to the bounds.""", + arguments: {'type': _type, 'name': name, 'name2': name2, 'name3': name3}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template< + Message Function( + DartType _type, + String name, + String name2, + String + name3)> templateIncorrectTypeArgumentInSupertypeInferred = const Template< + Message Function(DartType _type, String name, String name2, + String name3)>( + messageTemplate: + r"""Inferred type argument '#type' violates the corresponding type variable bound of '#name' in the supertype '#name2' of class '#name3'.""", + tipTemplate: + r"""Try specifying type arguments explicitly so that they conform to the bounds.""", + withArguments: _withArgumentsIncorrectTypeArgumentInSupertypeInferred); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code< + Message Function( + DartType _type, String name, String name2, String name3)> + codeIncorrectTypeArgumentInSupertypeInferred = const Code< + Message Function( + DartType _type, String name, String name2, String name3)>( + "IncorrectTypeArgumentInSupertypeInferred", + templateIncorrectTypeArgumentInSupertypeInferred, + analyzerCodes: ["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsIncorrectTypeArgumentInSupertypeInferred( + DartType _type, String name, String name2, String name3) { + NameSystem nameSystem = new NameSystem(); + StringBuffer buffer; + buffer = new StringBuffer(); + new Printer(buffer, syntheticNames: nameSystem).writeNode(_type); + String type = '$buffer'; + + if (name.isEmpty) throw 'No name provided'; + name = demangleMixinApplicationName(name); + if (name2.isEmpty) throw 'No name provided'; + name2 = demangleMixinApplicationName(name2); + if (name3.isEmpty) throw 'No name provided'; + name3 = demangleMixinApplicationName(name3); + return new Message(codeIncorrectTypeArgumentInSupertypeInferred, + message: + """Inferred type argument '${type}' violates the corresponding type variable bound of '${name}' in the supertype '${name2}' of class '${name3}'.""", + tip: """Try specifying type arguments explicitly so that they conform to the bounds.""", + arguments: {'type': _type, 'name': name, 'name2': name2, 'name3': name3}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template< + Message Function( + DartType _type, + String + name)> templateIncorrectTypeArgumentInferred = const Template< + Message Function(DartType _type, + String name)>( + messageTemplate: + r"""Inferred type argument '#type' violates the corresponding type variable bound of '#name'.""", + tipTemplate: + r"""Try specifying type arguments explicitly so that they conform to the bounds.""", + withArguments: _withArgumentsIncorrectTypeArgumentInferred); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code + codeIncorrectTypeArgumentInferred = + const Code( + "IncorrectTypeArgumentInferred", templateIncorrectTypeArgumentInferred, + analyzerCodes: ["TYPE_ARGUMENT_NOT_MATCHING_BOUNDS"]); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsIncorrectTypeArgumentInferred( + DartType _type, String name) { + NameSystem nameSystem = new NameSystem(); + StringBuffer buffer; + buffer = new StringBuffer(); + new Printer(buffer, syntheticNames: nameSystem).writeNode(_type); + String type = '$buffer'; + + if (name.isEmpty) throw 'No name provided'; + name = demangleMixinApplicationName(name); + return new Message(codeIncorrectTypeArgumentInferred, + message: + """Inferred type argument '${type}' violates the corresponding type variable bound of '${name}'.""", + tip: """Try specifying type arguments explicitly so that they conform to the bounds.""", + arguments: {'type': _type, 'name': name}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code codeIncorrectTypeArgumentVariable = + messageIncorrectTypeArgumentVariable; + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const MessageCode messageIncorrectTypeArgumentVariable = const MessageCode( + "IncorrectTypeArgumentVariable", + severity: Severity.context, + message: r"""Bound of this variable is violated."""); + // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Code codeInheritedMembersConflict = messageInheritedMembersConflict; 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 b9f060597fe..65c335457b2 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -267,6 +267,8 @@ abstract class BodyBuilder extends ScopeListener return isInstanceMember || member is KernelConstructorBuilder; } + TypeEnvironment get typeEnvironment => _typeInferrer?.typeSchemaEnvironment; + @override void push(Object node) { if (node is DartType) { @@ -717,9 +719,9 @@ abstract class BodyBuilder extends ScopeListener // enabled for two reasons: // 1) the [isSubtypeOf] predicate produces false-negatives when [strongMode] // is false. - // 2) the member [_typeInferrer.typeSchemaEnvironment] might be null when - // [strongMode] is false. This particular behaviour can be observed when - // running the fasta perf benchmarks. + // 2) the member [typeEnvironment] might be null when [strongMode] is false. + // This particular behaviour can be observed when running the fasta perf + // benchmarks. bool strongMode = library.loader.target.strongMode; if (strongMode && builder.returnType != null) { DartType returnType = builder.function.returnType; @@ -733,8 +735,7 @@ abstract class BodyBuilder extends ScopeListener switch (asyncModifier) { case AsyncMarker.Async: DartType futureBottomType = library.loader.futureOfBottom; - if (!_typeInferrer.typeSchemaEnvironment - .isSubtypeOf(futureBottomType, returnType)) { + if (!typeEnvironment.isSubtypeOf(futureBottomType, returnType)) { problem = fasta.messageIllegalAsyncReturnType; } break; @@ -743,8 +744,8 @@ abstract class BodyBuilder extends ScopeListener DartType streamBottomType = library.loader.streamOfBottom; if (returnType is VoidType) { problem = fasta.messageIllegalAsyncGeneratorVoidReturnType; - } else if (!_typeInferrer.typeSchemaEnvironment - .isSubtypeOf(streamBottomType, returnType)) { + } else if (!typeEnvironment.isSubtypeOf( + streamBottomType, returnType)) { problem = fasta.messageIllegalAsyncGeneratorReturnType; } break; @@ -753,8 +754,8 @@ abstract class BodyBuilder extends ScopeListener DartType iterableBottomType = library.loader.iterableOfBottom; if (returnType is VoidType) { problem = fasta.messageIllegalSyncGeneratorVoidReturnType; - } else if (!_typeInferrer.typeSchemaEnvironment - .isSubtypeOf(iterableBottomType, returnType)) { + } else if (!typeEnvironment.isSubtypeOf( + iterableBottomType, returnType)) { problem = fasta.messageIllegalSyncGeneratorReturnType; } break; @@ -1954,14 +1955,17 @@ abstract class BodyBuilder extends ScopeListener bool isConst = (currentLocalVariableModifiers & constMask) != 0; bool isFinal = (currentLocalVariableModifiers & finalMask) != 0; assert(isConst == (constantContext == ConstantContext.inferred)); - push(new VariableDeclarationJudgment(identifier.name, functionNestingLevel, + VariableDeclaration variable = new VariableDeclarationJudgment( + identifier.name, functionNestingLevel, forSyntheticToken: deprecated_extractToken(identifier).isSynthetic, initializer: initializer, type: buildDartType(currentLocalVariableType), isFinal: isFinal, isConst: isConst) ..fileOffset = identifier.charOffset - ..fileEqualsOffset = offsetForToken(equalsToken)); + ..fileEqualsOffset = offsetForToken(equalsToken); + library.checkBoundsInVariableDeclaration(variable, typeEnvironment); + push(variable); } @override @@ -2231,14 +2235,16 @@ abstract class BodyBuilder extends ScopeListener } } } - push(forest.literalList( + Expression node = forest.literalList( constKeyword, constKeyword != null || constantContext == ConstantContext.inferred, typeArgument, typeArguments, leftBracket, expressions, - rightBracket)); + rightBracket); + library.checkBoundsInListLiteral(node, typeEnvironment); + push(node); } @override @@ -2285,8 +2291,7 @@ abstract class BodyBuilder extends ScopeListener } } } - - push(forest.literalMap( + Expression node = forest.literalMap( constKeyword, constKeyword != null || constantContext == ConstantContext.inferred, keyType, @@ -2294,7 +2299,9 @@ abstract class BodyBuilder extends ScopeListener typeArguments, leftBrace, entries, - rightBrace)); + rightBrace); + library.checkBoundsInMapLiteral(node, typeEnvironment); + push(node); } @override @@ -2448,7 +2455,8 @@ abstract class BodyBuilder extends ScopeListener @override void handleAsOperator(Token operator) { debugEvent("AsOperator"); - UnresolvedType type = pop(); + DartType type = buildDartType(pop()); + library.checkBoundsInType(type, typeEnvironment, operator.charOffset); Expression expression = popForValue(); if (constantContext != ConstantContext.none) { push(buildProblem( @@ -2458,7 +2466,8 @@ abstract class BodyBuilder extends ScopeListener operator.length) .desugared); } else { - push(forest.asExpression(expression, buildDartType(type), operator)); + Expression node = forest.asExpression(expression, type, operator); + push(node); } } @@ -2470,6 +2479,7 @@ abstract class BodyBuilder extends ScopeListener bool isInverted = not != null; Expression isExpression = forest.isExpression(operand, isOperator, not, type); + library.checkBoundsInType(type, typeEnvironment, isOperator.charOffset); if (operand is VariableGet) { typePromoter.handleIsCheck(isExpression, isInverted, operand.variable, type, functionNestingLevel); @@ -3032,10 +3042,12 @@ abstract class BodyBuilder extends ScopeListener target, arguments); } - return new ConstructorInvocationJudgment( + ConstructorInvocation node = new ConstructorInvocationJudgment( target, forest.castArguments(arguments), isConst: isConst) ..fileOffset = charOffset; + library.checkBoundsInConstructorInvocation(node, typeEnvironment); + return node; } else { Procedure procedure = target; if (procedure.isFactory) { @@ -3049,15 +3061,19 @@ abstract class BodyBuilder extends ScopeListener target, arguments); } - return new FactoryConstructorInvocationJudgment( + StaticInvocation node = FactoryConstructorInvocationJudgment( target, forest.castArguments(arguments), isConst: isConst) ..fileOffset = charOffset; + library.checkBoundsInFactoryInvocation(node, typeEnvironment); + return node; } else { - return new StaticInvocationJudgment( + StaticInvocation node = new StaticInvocationJudgment( target, forest.castArguments(arguments), desugaredError: error, isConst: isConst) ..fileOffset = charOffset; + library.checkBoundsInStaticInvocation(node, typeEnvironment); + return node; } } } @@ -3095,10 +3111,13 @@ abstract class BodyBuilder extends ScopeListener List types = forest.argumentsTypeArguments(arguments); if (typeParameters.length != types.length) { if (types.length == 0) { - // Expected `typeParameters.length` type arguments, but none given, - // so we fill in dynamic. - for (int i = 0; i < typeParameters.length; i++) { - types.add(const DynamicType()); + // Expected `typeParameters.length` type arguments, but none given, so + // we fill in dynamic in legacy mode, and use type inference in strong + // mode. + if (!library.loader.target.strongMode) { + for (int i = 0; i < typeParameters.length; i++) { + types.add(const DynamicType()); + } } } else { // A wrong (non-zero) amount of type arguments given. That's an error. @@ -4326,8 +4345,7 @@ abstract class BodyBuilder extends ScopeListener } else { if (library.loader.target.strongMode && formalType != null && - !_typeInferrer.typeSchemaEnvironment - .isSubtypeOf(formalType, builder.field.type)) { + !typeEnvironment.isSubtypeOf(formalType, builder.field.type)) { library.addProblem( fasta.templateInitializingFormalTypeMismatch .withArguments(name, formalType, builder.field.type), @@ -4523,10 +4541,13 @@ abstract class BodyBuilder extends ScopeListener receiver = new SuperPropertyGetJudgment(name, interfaceTarget: target, desugaredError: error) ..fileOffset = offset; - return new MethodInvocationJudgment( + MethodInvocation node = new MethodInvocationJudgment( receiver, callName, forest.castArguments(arguments), isImplicitCall: true, desugaredError: error) ..fileOffset = forest.readOffset(arguments); + library.checkBoundsInMethodInvocation( + node, classBuilder?.target, typeEnvironment); + return node; } if (isNullAware) { @@ -4545,12 +4566,15 @@ abstract class BodyBuilder extends ScopeListener desugaredError: error) ..fileOffset = offset; } else { - return new MethodInvocationJudgment( + MethodInvocation node = new MethodInvocationJudgment( receiver, name, forest.castArguments(arguments), isImplicitCall: isImplicitCall, interfaceTarget: interfaceTarget, desugaredError: error) ..fileOffset = offset; + library.checkBoundsInMethodInvocation( + node, classBuilder?.target, typeEnvironment); + return node; } } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_api.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_api.dart index 01526958dab..fd26c01cc55 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_api.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_api.dart @@ -6,7 +6,7 @@ library fasta.kernel_api; export 'package:kernel/type_algebra.dart' - show instantiateToBounds, Substitution; + show Substitution, instantiateToBounds, substitute; export 'package:kernel/class_hierarchy.dart' show ClassHierarchy; @@ -18,6 +18,8 @@ export 'package:kernel/transformations/flags.dart' show TransformerFlag; export 'package:kernel/text/ast_to_text.dart' show NameSystem; +export 'package:kernel/type_environment.dart' show TypeEnvironment; + import 'package:kernel/text/ast_to_text.dart' show NameSystem, Printer; import 'package:kernel/ast.dart' show Class, Member, Node; diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart index a7e9319fca7..6ddfdf1948f 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_ast_api.dart @@ -9,6 +9,7 @@ library fasta.kernel_ast_api; export 'package:kernel/ast.dart' show Arguments, + AsExpression, AssertStatement, AsyncMarker, Block, @@ -33,6 +34,7 @@ export 'package:kernel/ast.dart' InterfaceType, InvalidExpression, InvalidType, + IsExpression, LabeledStatement, Let, Library, @@ -41,6 +43,7 @@ export 'package:kernel/ast.dart' ListLiteral, Location, MapEntry, + MapLiteral, Member, MethodInvocation, Name, @@ -61,11 +64,13 @@ export 'package:kernel/ast.dart' SuperMethodInvocation, SuperPropertySet, SwitchCase, + ThisExpression, Throw, TreeNode, TypeParameter, TypeParameterType, Typedef, + TypedefType, VariableDeclaration, VariableGet, VariableSet, diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart index 35adb8a5548..05c16b3e2fa 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart @@ -20,6 +20,7 @@ import 'package:kernel/ast.dart' Member, Name, Procedure, + RedirectingFactoryConstructor, ReturnStatement, VoidType, MethodInvocation, @@ -62,6 +63,9 @@ import '../fasta_codes.dart' templateImplementsSuperClass, templateImplicitMixinOverrideContext, templateInterfaceCheckContext, + templateIncorrectTypeArgument, + templateIncorrectTypeArgumentInSupertype, + templateIncorrectTypeArgumentInSupertypeInferred, templateMissingImplementationCause, templateMissingImplementationNotAbstract, templateNamedMixinOverrideContext, @@ -160,6 +164,9 @@ abstract class KernelClassBuilder for (int i = 0; i < result.length; ++i) { result[i] = typeVariables[i].defaultType.build(library); } + if (library is KernelLibraryBuilder) { + library.inferredTypes.addAll(result); + } return result; } @@ -269,6 +276,99 @@ abstract class KernelClassBuilder } } + void checkBoundsInSupertype( + Supertype supertype, TypeEnvironment typeEnvironment) { + KernelLibraryBuilder library = this.library; + + List boundViolations = typeEnvironment.findBoundViolations( + new InterfaceType(supertype.classNode, supertype.typeArguments), + allowSuperBounded: false, + typedefInstantiations: library.typedefInstantiations); + if (boundViolations != null) { + for (int i = 0; i < boundViolations.length; i += 3) { + DartType argument = boundViolations[i]; + TypeParameter variable = boundViolations[i + 1]; + DartType enclosingType = boundViolations[i + 2]; + Message message = library.inferredTypes.contains(argument) + ? templateIncorrectTypeArgumentInSupertypeInferred.withArguments( + argument, + typeEnvironment.getGenericTypeName(enclosingType), + supertype.classNode.name, + name) + : templateIncorrectTypeArgumentInSupertype.withArguments( + argument, + typeEnvironment.getGenericTypeName(enclosingType), + supertype.classNode.name, + name); + library.reportBoundViolation(message, charOffset, variable); + } + } + } + + void checkBoundsInOutline(TypeEnvironment typeEnvironment) { + KernelLibraryBuilder library = this.library; + + // Check in bounds of own type variables. + for (TypeParameter parameter in cls.typeParameters) { + List violations = typeEnvironment.findBoundViolations( + parameter.bound, + allowSuperBounded: false, + typedefInstantiations: library.typedefInstantiations); + if (violations != null) { + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + if (library.inferredTypes.contains(argument)) { + // Inference in type expressions in the supertypes boils down to + // instantiate-to-bound which shouldn't produce anything that breaks + // the bounds after the non-simplicity checks are done. So, any + // violation here is the result of non-simple bounds, and the error + // is reported elsewhere. + continue; + } + library.reportBoundViolation( + templateIncorrectTypeArgument.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)), + parameter.fileOffset, + variable); + } + } + } + + // Check in supers. + if (cls.supertype != null) { + checkBoundsInSupertype(cls.supertype, typeEnvironment); + } + if (cls.mixedInType != null) { + checkBoundsInSupertype(cls.mixedInType, typeEnvironment); + } + if (cls.implementedTypes != null) { + for (Supertype supertype in cls.implementedTypes) { + checkBoundsInSupertype(supertype, typeEnvironment); + } + } + + // Check in members. + for (Field field in cls.fields) { + library.checkBoundsInField(field, typeEnvironment); + } + for (Procedure procedure in cls.procedures) { + library.checkBoundsInFunctionNode(procedure.function, typeEnvironment); + } + for (Constructor constructor in cls.constructors) { + library.checkBoundsInFunctionNode(constructor.function, typeEnvironment); + } + for (RedirectingFactoryConstructor redirecting + in cls.redirectingFactoryConstructors) { + library.checkBoundsInFunctionNodeParts( + typeEnvironment, redirecting.fileOffset, + typeParameters: redirecting.typeParameters, + positionalParameters: redirecting.positionalParameters, + namedParameters: redirecting.namedParameters); + } + } + @override int resolveConstructors(LibraryBuilder library) { int count = super.resolveConstructors(library); diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart index 1242efff27c..de60d54fdcb 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_function_type_alias_builder.dart @@ -27,6 +27,7 @@ import 'kernel_builder.dart' FunctionTypeAliasBuilder, KernelFormalParameterBuilder, KernelFunctionTypeBuilder, + KernelLibraryBuilder, KernelTypeBuilder, KernelTypeVariableBuilder, LibraryBuilder, @@ -120,7 +121,11 @@ class KernelFunctionTypeAliasBuilder for (int i = 0; i < target.typeParameters.length; i++) { substitution[target.typeParameters[i]] = arguments[i]; } - return substitute(result, substitution); + result = substitute(result, substitution); + if (library is KernelLibraryBuilder) { + library.typedefInstantiations[result] = arguments; + } + return result; } List buildTypeArguments( @@ -135,6 +140,9 @@ class KernelFunctionTypeAliasBuilder for (int i = 0; i < result.length; ++i) { result[i] = typeVariables[i].defaultType.build(library); } + if (library is KernelLibraryBuilder) { + library.inferredTypes.addAll(result); + } return result; } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart index c742c327553..9d72b9692cc 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_library_builder.dart @@ -10,15 +10,22 @@ import 'package:kernel/ast.dart' show Arguments, Class, + Constructor, ConstructorInvocation, DartType, DynamicType, Expression, Field, + FunctionNode, + FunctionType, + InterfaceType, Library, LibraryDependency, LibraryPart, + ListLiteral, + MapLiteral, Member, + MethodInvocation, Name, Procedure, ProcedureKind, @@ -26,11 +33,17 @@ import 'package:kernel/ast.dart' StringLiteral, TreeNode, Typedef, + TypeParameter, + TypeParameterType, VariableDeclaration, VoidType; import 'package:kernel/clone.dart' show CloneVisitor; +import 'package:kernel/type_algebra.dart' show substitute; + +import 'package:kernel/type_environment.dart' show TypeEnvironment; + import '../../scanner/token.dart' show Token; import '../export.dart' show Export; @@ -41,6 +54,7 @@ import '../fasta_codes.dart' Message, messageConflictsWithTypeVariableCause, messageGenericFunctionTypeInBound, + messageIncorrectTypeArgumentVariable, messageTypeVariableDuplicatedName, messageTypeVariableSameNameAsEnclosing, noLength, @@ -51,6 +65,9 @@ import '../fasta_codes.dart' templateDuplicatedImportInType, templateExportHidesExport, templateImportHidesImport, + templateIncorrectTypeArgument, + templateIncorrectTypeArgumentInReturnType, + templateIncorrectTypeArgumentInferred, templateLoadLibraryHidesMember, templateLocalDefinitionHidesExport, templateLocalDefinitionHidesImport, @@ -143,6 +160,17 @@ class KernelLibraryBuilder // built. final List forwardersOrigins = []; + // List of types inferred in the outline. Errors in these should be reported + // differently than for specified types. + // TODO(dmitryas): Find a way to mark inferred types. + final Set inferredTypes = new Set.identity(); + + // List of typedef instantiations built for this library. They are needed to + // perform type argument checks. + // TODO(dmitryas): Find a way to keep type arguments of typedefs around. + final Map> typedefInstantiations = + new Map>.identity(); + /// Exports that can't be serialized. /// /// The key is the name of the exported member. @@ -386,32 +414,20 @@ class KernelLibraryBuilder } } - /// The type variables used in [supertype] and the current mixin. - Map usedTypeVariables; - - /// Helper function that updates [usedTypeVariables]. It needs to be - /// called twice per iteration: once on supertype and once on the current - /// mixin. - void computeUsedTypeVariables(KernelNamedTypeBuilder type) { + /// Helper function that returns `true` if a type variable with a name + /// from [typeVariableNames] is referenced in [type]. + bool usesTypeVariables(KernelNamedTypeBuilder type) { List typeArguments = type.arguments; if (typeArguments != null && typeVariables != null) { for (KernelTypeBuilder argument in typeArguments) { if (typeVariableNames.contains(argument.name)) { - usedTypeVariables ??= {}; - KernelTypeVariableBuilder freshTypeVariable = - (usedTypeVariables[argument.name] ??= - addTypeVariable(argument.name, null, charOffset)); - // Notice that [argument] may have been created below as part of - // [applicationTypeArguments] and have to be rebound now - // (otherwise it would refer to a type variable in the subclass). - argument.bind(freshTypeVariable); - } else { - if (argument is KernelNamedTypeBuilder) { - computeUsedTypeVariables(argument); - } + return true; + } else if (argument is KernelNamedTypeBuilder) { + if (usesTypeVariables(argument)) return true; } } } + return false; } /// Iterate over the mixins from left to right. At the end of each @@ -420,14 +436,14 @@ class KernelLibraryBuilder for (int i = 0; i < type.mixins.length; i++) { KernelTypeBuilder mixin = type.mixins[i]; isNamedMixinApplication = name != null && mixin == type.mixins.last; - usedTypeVariables = null; + bool isGeneric = false; if (!isNamedMixinApplication) { if (supertype is KernelNamedTypeBuilder) { - computeUsedTypeVariables(supertype); + isGeneric = isGeneric || usesTypeVariables(supertype); } if (mixin is KernelNamedTypeBuilder) { runningName += "&${extractName(mixin.name)}"; - computeUsedTypeVariables(mixin); + isGeneric = isGeneric || usesTypeVariables(mixin); } } String fullname = @@ -441,20 +457,42 @@ class KernelLibraryBuilder } else { // Otherwise, we pass the fresh type variables to the mixin // application in the same order as they're declared on the subclass. - if (usedTypeVariables != null) { - applicationTypeVariables = []; + if (isGeneric) { + this.beginNestedDeclaration("mixin application"); + + applicationTypeVariables = + copyTypeVariables(typeVariables, currentDeclaration); + + List newTypes = []; + if (supertype is KernelNamedTypeBuilder && + supertype.arguments != null) { + for (int i = 0; i < supertype.arguments.length; ++i) { + supertype.arguments[i] = supertype.arguments[i].clone(newTypes); + } + } + if (mixin is KernelNamedTypeBuilder && mixin.arguments != null) { + for (int i = 0; i < mixin.arguments.length; ++i) { + mixin.arguments[i] = mixin.arguments[i].clone(newTypes); + } + } + for (TypeBuilder newType in newTypes) { + currentDeclaration.addType( + new UnresolvedType(newType, -1, null)); + } + + DeclarationBuilder mixinDeclaration = + this.endNestedDeclaration("mixin application"); + mixinDeclaration.resolveTypes(applicationTypeVariables, this); + applicationTypeArguments = []; for (TypeVariableBuilder typeVariable in typeVariables) { - TypeVariableBuilder freshTypeVariable = - usedTypeVariables[typeVariable.name]; - if (freshTypeVariable != null) { - applicationTypeVariables.add(freshTypeVariable); - applicationTypeArguments.add( - addNamedType(typeVariable.name, null, charOffset)..bind( - // This may be rebound in the next iteration when - // calling [computeUsedTypeVariables]. - typeVariable)); - } + applicationTypeArguments + .add(addNamedType(typeVariable.name, null, charOffset)..bind( + // The type variable types passed as arguments to the + // generic class representing the anonymous mixin + // application should refer back to the type variables of + // the class that extend the anonymous mixin application. + typeVariable)); } } } @@ -1316,6 +1354,407 @@ class KernelLibraryBuilder (!member.isSetter && scope.local[name] == null)); addToExportScope(name, member); } + + void reportBoundViolation( + Message message, int fileOffset, TypeParameter violated) { + List context; + if (violated.fileOffset != -1) { + // It looks like when parameters come from patch files, they don't + // have a reportable location. + context = [ + messageIncorrectTypeArgumentVariable.withLocation( + violated.location.file, violated.fileOffset, noLength) + ]; + } + addProblem(message, fileOffset, noLength, fileUri, context: context); + } + + void checkBoundsInField(Field field, TypeEnvironment typeEnvironment) { + if (!loader.target.strongMode) return; + List boundViolations = typeEnvironment.findBoundViolations( + field.type, + allowSuperBounded: true, + typedefInstantiations: typedefInstantiations); + if (boundViolations != null) { + for (int i = 0; i < boundViolations.length; i += 3) { + DartType argument = boundViolations[i]; + TypeParameter variable = boundViolations[i + 1]; + DartType enclosingType = boundViolations[i + 2]; + Message message = inferredTypes.contains(argument) + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)) + : templateIncorrectTypeArgument.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)); + reportBoundViolation(message, field.fileOffset, variable); + } + } + } + + void checkBoundsInFunctionNodeParts( + TypeEnvironment typeEnvironment, int fileOffset, + {List typeParameters, + List positionalParameters, + List namedParameters, + DartType returnType}) { + if (!loader.target.strongMode) return; + if (typeParameters != null) { + for (TypeParameter parameter in typeParameters) { + List violations = typeEnvironment.findBoundViolations( + parameter.bound, + allowSuperBounded: false, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + int offset = parameter.fileOffset; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + Message message = inferredTypes.contains(argument) + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)) + : templateIncorrectTypeArgument.withArguments(argument, + typeEnvironment.getGenericTypeName(enclosingType)); + reportBoundViolation(message, offset, variable); + } + } + } + } + if (positionalParameters != null) { + for (VariableDeclaration formal in positionalParameters) { + List violations = typeEnvironment.findBoundViolations( + formal.type, + allowSuperBounded: true, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + int offset = formal.fileOffset; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + Message message = inferredTypes.contains(argument) + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)) + : templateIncorrectTypeArgument.withArguments(argument, + typeEnvironment.getGenericTypeName(enclosingType)); + reportBoundViolation(message, offset, variable); + } + } + } + } + if (namedParameters != null) { + for (VariableDeclaration named in namedParameters) { + List violations = typeEnvironment.findBoundViolations( + named.type, + allowSuperBounded: true, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + int offset = named.fileOffset; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + Message message = inferredTypes.contains(argument) + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)) + : templateIncorrectTypeArgument.withArguments(argument, + typeEnvironment.getGenericTypeName(enclosingType)); + reportBoundViolation(message, offset, variable); + } + } + } + } + if (returnType != null) { + List violations = typeEnvironment.findBoundViolations(returnType, + allowSuperBounded: true, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + int offset = fileOffset; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + // We don't need to check if [argument] was inferred or specified + // here, because inference in return types boils down to instantiate- + // -to-bound, and it can't provide a type that violates the bound. + reportBoundViolation( + templateIncorrectTypeArgumentInReturnType.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)), + offset, + variable); + } + } + } + } + + void checkBoundsInFunctionNode( + FunctionNode function, TypeEnvironment typeEnvironment) { + if (!loader.target.strongMode) return; + checkBoundsInFunctionNodeParts(typeEnvironment, function.fileOffset, + typeParameters: function.typeParameters, + positionalParameters: function.positionalParameters, + namedParameters: function.namedParameters, + returnType: function.returnType); + } + + void checkBoundsInListLiteral( + ListLiteral node, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + checkBoundsInType(node.typeArgument, typeEnvironment, node.fileOffset, + inferred: inferred, allowSuperBounded: true); + } + + void checkBoundsInMapLiteral(MapLiteral node, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + checkBoundsInType(node.keyType, typeEnvironment, node.fileOffset, + inferred: inferred, allowSuperBounded: true); + checkBoundsInType(node.valueType, typeEnvironment, node.fileOffset, + inferred: inferred, allowSuperBounded: true); + } + + void checkBoundsInType( + DartType type, TypeEnvironment typeEnvironment, int offset, + {bool inferred = false, bool allowSuperBounded = true}) { + if (!loader.target.strongMode) return; + List violations = typeEnvironment.findBoundViolations(type, + allowSuperBounded: allowSuperBounded, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + Message message = inferred + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)) + : templateIncorrectTypeArgument.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)); + reportBoundViolation(message, offset, variable); + } + } + } + + void checkBoundsInVariableDeclaration( + VariableDeclaration node, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + if (node.type == null) return; + List violations = typeEnvironment.findBoundViolations(node.type, + allowSuperBounded: true, typedefInstantiations: typedefInstantiations); + if (violations != null) { + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + Message message = inferred + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)) + : templateIncorrectTypeArgument.withArguments( + argument, typeEnvironment.getGenericTypeName(enclosingType)); + reportBoundViolation(message, node.fileOffset, variable); + } + } + } + + void checkBoundsInConstructorInvocation( + ConstructorInvocation node, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + if (node.arguments.types.isEmpty) return; + Constructor constructor = node.target; + Class klass = constructor.enclosingClass; + DartType constructedType = new InterfaceType(klass, node.arguments.types); + List violations = typeEnvironment.findBoundViolations( + constructedType, + allowSuperBounded: false, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + String constructedTypeName = "${klass.name}::${constructor.name.name}"; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + String enclosingName = enclosingType == constructedType + ? constructedTypeName + : typeEnvironment.getGenericTypeName(enclosingType); + Message message = inferred + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, enclosingName) + : templateIncorrectTypeArgument.withArguments( + argument, enclosingName); + reportBoundViolation(message, node.fileOffset, variable); + } + } + } + + void checkBoundsInFactoryInvocation( + StaticInvocation node, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + if (node.arguments.types.isEmpty) return; + Procedure factory = node.target; + assert(factory.isFactory); + Class klass = factory.enclosingClass; + DartType constructedType = new InterfaceType(klass, node.arguments.types); + List violations = typeEnvironment.findBoundViolations( + constructedType, + allowSuperBounded: false, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + String constructedTypeName = "${klass.name}::${factory.name.name}"; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + String enclosingName = enclosingType == constructedType + ? constructedTypeName + : typeEnvironment.getGenericTypeName(enclosingType); + Message message = inferred + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, enclosingName) + : templateIncorrectTypeArgument.withArguments( + argument, enclosingName); + reportBoundViolation(message, node.fileOffset, variable); + } + } + } + + void checkBoundsInStaticInvocation( + StaticInvocation node, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + if (node.arguments.types.isEmpty) return; + Class klass = node.target.enclosingClass; + List parameters = node.target.function.typeParameters; + List arguments = node.arguments.types; + // The following error is to be reported elsewhere. + if (parameters.length != arguments.length) return; + List violations = typeEnvironment.findBoundViolationsElementwise( + parameters, arguments, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + String targetName; + if (klass == null) { + targetName = "${node.target.name.name}"; + } else { + targetName = "${klass.name}::${node.target.name.name}"; + } + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + String enclosingName = enclosingType == null + ? targetName + : typeEnvironment.getGenericTypeName(enclosingType); + Message message = inferred + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, enclosingName) + : templateIncorrectTypeArgument.withArguments( + argument, enclosingName); + reportBoundViolation(message, node.fileOffset, variable); + } + } + } + + void checkBoundsInMethodInvocation( + MethodInvocation node, Class thisClass, TypeEnvironment typeEnvironment, + {bool inferred = false}) { + if (!loader.target.strongMode) return; + if (node.arguments.types.isEmpty) return; + DartType savedThisType = typeEnvironment.thisType; + if (thisClass != null) { + typeEnvironment.thisType = new InterfaceType( + thisClass, + thisClass.typeParameters + .map((p) => new TypeParameterType(p)) + .toList()); + } + DartType receiverType; + try { + receiverType = node.receiver.getStaticType(typeEnvironment); + } finally { + typeEnvironment.thisType = savedThisType; + } + Class klass; + List klassArguments; + if (receiverType is InterfaceType) { + klass = receiverType.classNode; + klassArguments = receiverType.typeArguments; + } else { + return; + } + Map substitutionMap = {}; + for (int i = 0; i < klassArguments.length; ++i) { + substitutionMap[klass.typeParameters[i]] = klassArguments[i]; + } + // TODO(dmitryas): Find a better way than relying on [interfaceTarget]. + Member method = + typeEnvironment.hierarchy.getDispatchTarget(klass, node.name) ?? + node.interfaceTarget; + if (method == null || method is! Procedure) { + return; + } + List methodParameters = method.function.typeParameters; + // The error is to be reported elsewhere. + if (methodParameters.length != node.arguments.types.length) return; + List instantiatedMethodParameters = + new List.filled(methodParameters.length, null); + for (int i = 0; i < instantiatedMethodParameters.length; ++i) { + instantiatedMethodParameters[i] = + new TypeParameter(methodParameters[i].name); + substitutionMap[methodParameters[i]] = + new TypeParameterType(instantiatedMethodParameters[i]); + } + for (int i = 0; i < instantiatedMethodParameters.length; ++i) { + instantiatedMethodParameters[i].bound = + substitute(methodParameters[i].bound, substitutionMap); + } + List violations = typeEnvironment.findBoundViolationsElementwise( + instantiatedMethodParameters, node.arguments.types, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + String targetName = "${klass.name}"; + if (klassArguments.length > 0) { + targetName += "<${klassArguments[0]}"; + for (int i = 1; i < klassArguments.length; ++i) { + targetName += ", ${klassArguments[i]}"; + } + targetName += ">"; + } + targetName += "::${node.name.name}"; + for (int i = 0; i < violations.length; i += 3) { + DartType argument = violations[i]; + TypeParameter variable = violations[i + 1]; + DartType enclosingType = violations[i + 2]; + String enclosingName = enclosingType == null + ? targetName + : typeEnvironment.getGenericTypeName(enclosingType); + Message message = inferred + ? templateIncorrectTypeArgumentInferred.withArguments( + argument, enclosingName) + : templateIncorrectTypeArgument.withArguments( + argument, enclosingName); + reportBoundViolation(message, node.fileOffset, variable); + } + } + } + + void checkBoundsInOutline(TypeEnvironment typeEnvironment) { + if (!loader.target.strongMode) return; + forEach((String name, Declaration declaration) { + if (declaration is KernelFieldBuilder) { + checkBoundsInField(declaration.target, typeEnvironment); + } else if (declaration is KernelProcedureBuilder) { + checkBoundsInFunctionNode(declaration.target.function, typeEnvironment); + } else if (declaration is KernelClassBuilder) { + declaration.checkBoundsInOutline(typeEnvironment); + } + }); + + typedefInstantiations.clear(); + inferredTypes.clear(); + } } Uri computeLibraryUri(Declaration declaration) { diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart index c7a11ce2846..8d2e37d9b25 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart @@ -41,13 +41,14 @@ import '../fasta_codes.dart' messageVoidExpression, noLength, templateCantInferTypeDueToCircularity, - templateCantUseSuperBoundedTypeForInstanceCreation, templateForInLoopElementTypeNotAssignable, templateForInLoopTypeNotIterable, templateIntegerLiteralIsOutOfRange, templateSwitchExpressionNotAssignable, templateWebLiteralCannotBeRepresentedExactly; +import '../kernel/kernel_library_builder.dart' show KernelLibraryBuilder; + import '../problems.dart' show unhandled, unsupported; import '../source/source_class_builder.dart' show SourceClassBuilder; @@ -716,6 +717,8 @@ class ConstructorInvocationJudgment extends ConstructorInvocation } inferrer.engine.beingInferred.remove(target); } + bool hasExplicitTypeArguments = + getExplicitTypeArguments(argumentJudgments) != null; var inferenceResult = inferrer.inferInvocation( typeContext, fileOffset, @@ -725,14 +728,11 @@ class ConstructorInvocationJudgment extends ConstructorInvocation isConst: isConst); var inferredType = inferenceResult.type; this.inferredType = inferredType; - if (inferrer.strongMode && - !inferrer.isTopLevel && - inferrer.typeSchemaEnvironment.isSuperBounded(inferredType)) { - inferrer.helper.addProblem( - templateCantUseSuperBoundedTypeForInstanceCreation - .withArguments(inferredType), - fileOffset, - noLength); + SourceLibraryBuilder inferrerLibrary = inferrer.library; + if (!hasExplicitTypeArguments && inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInConstructorInvocation( + this, inferrer.typeSchemaEnvironment, + inferred: true); } return null; } @@ -854,6 +854,7 @@ class FactoryConstructorInvocationJudgment extends StaticInvocation @override Expression infer(ShadowTypeInferrer inferrer, DartType typeContext) { + bool hadExplicitTypeArguments = getExplicitTypeArguments(arguments) != null; var inferenceResult = inferrer.inferInvocation( typeContext, fileOffset, @@ -862,6 +863,12 @@ class FactoryConstructorInvocationJudgment extends StaticInvocation argumentJudgments, isConst: isConst); inferredType = inferenceResult.type; + SourceLibraryBuilder inferrerLibrary = inferrer.library; + if (!hadExplicitTypeArguments && inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInFactoryInvocation( + this, inferrer.typeSchemaEnvironment, + inferred: true); + } return null; } } @@ -1653,6 +1660,13 @@ class ListLiteralJudgment extends ListLiteral implements ExpressionJudgment { } } inferredType = new InterfaceType(listClass, [inferredTypeArgument]); + SourceLibraryBuilder inferrerLibrary = inferrer.library; + if (_declaredTypeArgument == null && + inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInListLiteral( + this, inferrer.typeSchemaEnvironment, + inferred: true); + } return null; } } @@ -1806,6 +1820,14 @@ class MapLiteralJudgment extends MapLiteral implements ExpressionJudgment { } inferredType = new InterfaceType(mapClass, [inferredKeyType, inferredValueType]); + SourceLibraryBuilder inferrerLibrary = inferrer.library; + // Either both [_declaredKeyType] and [_declaredValueType] are omitted or + // none of them, so we may just check one. + if (_declaredKeyType == null && inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInMapLiteral( + this, inferrer.typeSchemaEnvironment, + inferred: true); + } return null; } } @@ -1920,6 +1942,7 @@ class MethodInvocationJudgment extends MethodInvocation } } } + bool hadExplicitTypeArguments = getExplicitTypeArguments(arguments) != null; var inferenceResult = inferrer.inferMethodInvocation( this, receiver, fileOffset, _isImplicitCall, typeContext, desugaredInvocation: this); @@ -1928,6 +1951,12 @@ class MethodInvocationJudgment extends MethodInvocation parent.replaceChild(this, desugaredError); parent = null; } + SourceLibraryBuilder inferrerLibrary = inferrer.library; + if (!hadExplicitTypeArguments && inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInMethodInvocation( + this, inferrer.thisType?.classNode, inferrer.typeSchemaEnvironment, + inferred: true); + } return null; } } @@ -2336,6 +2365,8 @@ class StaticInvocationJudgment extends StaticInvocation FunctionType calleeType = target != null ? target.function.functionType : new FunctionType([], const DynamicType()); + bool hadExplicitTypeArguments = + getExplicitTypeArguments(argumentJudgments) != null; var inferenceResult = inferrer.inferInvocation(typeContext, fileOffset, calleeType, calleeType.returnType, argumentJudgments); inferredType = inferenceResult.type; @@ -2343,6 +2374,14 @@ class StaticInvocationJudgment extends StaticInvocation parent.replaceChild(this, desugaredError); parent = null; } + SourceLibraryBuilder inferrerLibrary = inferrer.library; + if (!hadExplicitTypeArguments && + target != null && + inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInStaticInvocation( + this, inferrer.typeSchemaEnvironment, + inferred: true); + } return null; } } @@ -3133,6 +3172,12 @@ class VariableDeclarationJudgment extends VariableDeclaration initializer = replacedInitializer; } } + SourceLibraryBuilder inferrerLibrary = inferrer.library; + if (_implicitlyTyped && inferrerLibrary is KernelLibraryBuilder) { + inferrerLibrary.checkBoundsInVariableDeclaration( + this, inferrer.typeSchemaEnvironment, + inferred: true); + } } /// Determine whether the given [VariableDeclarationJudgment] had an implicit diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart index 772b960cab8..aae05980307 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart @@ -262,6 +262,7 @@ class KernelTarget extends TargetImplementation { loader.computeHierarchy(); loader.performTopLevelInference(myClasses); loader.checkSupertypes(myClasses); + loader.checkBounds(); loader.checkOverrides(myClasses); loader.checkAbstractMembers(myClasses); loader.checkRedirectingFactories(myClasses); diff --git a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart index 0baa13bb05b..1006ad916e3 100644 --- a/pkg/front_end/lib/src/fasta/source/source_library_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_library_builder.dart @@ -842,6 +842,8 @@ abstract class SourceLibraryBuilder accessProblem = message; } } + + void checkBoundsInOutline(covariant typeEnvironment); } /// Unlike [Scope], this scope is used during construction of builders to diff --git a/pkg/front_end/lib/src/fasta/source/source_loader.dart b/pkg/front_end/lib/src/fasta/source/source_loader.dart index b7a0016131b..702bea4b4ac 100644 --- a/pkg/front_end/lib/src/fasta/source/source_loader.dart +++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart @@ -831,6 +831,17 @@ class SourceLoader extends Loader { ticker.logMs("Checked overrides"); } + void checkBounds() { + if (!target.strongMode) return; + + builders.forEach((Uri uri, LibraryBuilder library) { + if (library is SourceLibraryBuilder) { + library.checkBoundsInOutline(typeInferenceEngine.typeSchemaEnvironment); + } + }); + ticker.logMs("Checked type arguments of supers against the bounds"); + } + void checkOverrides(List sourceClasses) { assert(hierarchy != null); for (SourceClassBuilder builder in sourceClasses) { diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart index 2ad0724fc2b..c6c79dee126 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart @@ -1177,7 +1177,7 @@ abstract class TypeInferrerImpl extends TypeInferrer { bool isConst: false}) { lastInferredSubstitution = null; lastCalleeType = null; - var calleeTypeParameters = calleeType.typeParameters; + List calleeTypeParameters = calleeType.typeParameters; if (calleeTypeParameters.isNotEmpty) { // It's possible that one of the callee type parameters might match a type // that already exists as part of inference (e.g. the type of an diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index 971f4b207a0..d80e07b9285 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -2833,10 +2833,6 @@ AmbiguousSupertypes: template: "'#name' can't implement both '#type' and '#type2'" analyzerCode: AMBIGUOUS_SUPERTYPES -CantUseSuperBoundedTypeForInstanceCreation: - template: "Can't use a super-bounded type for instance creation. Got '#type'." - tip: "Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference." - MixinInferenceNoMatchingClass: template: "Type parameters could not be inferred for the mixin '#name' because '#name2' does not implement the mixin's supertype constraint '#type'." analyzerCode: MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION @@ -3166,3 +3162,47 @@ RedirectingFactoryIncompatibleTypeArgument: SyntheticToken: template: "This couldn't be parsed." frontendInternal: true + +IncorrectTypeArgument: + template: "Type argument '#type' violates the corresponding type variable bound of '#name'." + tip: "Try changing type arguments so that they conform to the bounds." + analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS + script: > + class C {} + main() { new C(); } + +IncorrectTypeArgumentInSupertype: + template: "Type argument '#type' violates the corresponding type variable bound of '#name' in the supertype '#name2' of class '#name3'." + tip: "Try changing type arguments so that they conform to the bounds." + analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS + script: > + class A {} + class B extends A {} + +IncorrectTypeArgumentInReturnType: + template: "Type argument '#type' violates the corresponding type variable bound of '#name' in the return type." + tip: "Try changing type arguments so that they conform to the bounds." + analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS + script: > + class A {} + A foo() => null; + +IncorrectTypeArgumentInferred: + template: "Inferred type argument '#type' violates the corresponding type variable bound of '#name'." + tip: "Try specifying type arguments explicitly so that they conform to the bounds." + analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS + script: > + void foo(T t) {} + main() { foo("bar"); } + +IncorrectTypeArgumentInSupertypeInferred: + template: "Inferred type argument '#type' violates the corresponding type variable bound of '#name' in the supertype '#name2' of class '#name3'." + tip: "Try specifying type arguments explicitly so that they conform to the bounds." + analyzerCode: TYPE_ARGUMENT_NOT_MATCHING_BOUNDS + script: > + class A> {} + class B extends A {} + +IncorrectTypeArgumentVariable: + template: "Bound of this variable is violated." + severity: CONTEXT diff --git a/pkg/front_end/testcases/expression/class_type_param_bound_illegal.expression.yaml.expect b/pkg/front_end/testcases/expression/class_type_param_bound_illegal.expression.yaml.expect index 99f4ec91e3a..0e5380156dc 100644 --- a/pkg/front_end/testcases/expression/class_type_param_bound_illegal.expression.yaml.expect +++ b/pkg/front_end/testcases/expression/class_type_param_bound_illegal.expression.yaml.expect @@ -1,4 +1,6 @@ Errors: { + Type argument 'main::A::T' violates the corresponding type variable bound of 'hasBound'. (@0) + Bound of this variable is violated. (@637) } method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic return main::hasBound(); diff --git a/pkg/front_end/testcases/expression/type_param_bound.expression.yaml.expect b/pkg/front_end/testcases/expression/type_param_bound.expression.yaml.expect index b18dd2660e9..9647d9948c4 100644 --- a/pkg/front_end/testcases/expression/type_param_bound.expression.yaml.expect +++ b/pkg/front_end/testcases/expression/type_param_bound.expression.yaml.expect @@ -1,4 +1,6 @@ Errors: { + Type argument 'T' violates the corresponding type variable bound of 'hasBound'. (@0) + Bound of this variable is violated. (@637) } method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic return main::hasBound<#lib1::debugExpr::T>(); diff --git a/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.outline.expect b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.outline.expect new file mode 100644 index 00000000000..ee55e815636 --- /dev/null +++ b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.outline.expect @@ -0,0 +1,21 @@ +library test; +import self as self; +import "dart:core" as core; + +typedef F = () → T; +class A extends core::Object { + synthetic constructor •() → self::A + ; +} +class C extends core::Object { + constructor •(() → self::C::T f) → self::C + ; +} +class NotA extends core::Object { + synthetic constructor •() → self::NotA + ; +} +static method myF() → self::NotA + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.strong.expect b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.strong.expect index 6ab45c4e986..7baa4a150d4 100644 --- a/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.strong.expect +++ b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart.strong.expect @@ -1,3 +1,33 @@ +// Formatted problems: +// +// pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart:22:56: Error: Inferred type argument 'test::NotA' violates the corresponding type variable bound of 'C::'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// new /*error:COULD_NOT_INFER*/ /*@typeArgs=NotA*/ C(myF); +// ^ +// pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart:12:9: Context: Bound of this variable is violated. +// class C { +// ^ +// +// pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart:21:25: Error: Inferred type argument 'test::NotA' violates the corresponding type variable bound of 'C'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// var /*@type=C*/ x = +// ^ +// pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart:12:9: Context: Bound of this variable is violated. +// class C { +// ^ + +// Unhandled errors: +// +// pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart:22:56: Error: Inferred type argument 'test::NotA' violates the corresponding type variable bound of 'C::'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// new /*error:COULD_NOT_INFER*/ /*@typeArgs=NotA*/ C(myF); +// ^ +// +// pkg/front_end/testcases/inference/constructors_infer_from_arguments_argument_not_assignable.dart:21:25: Error: Inferred type argument 'test::NotA' violates the corresponding type variable bound of 'C'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// var /*@type=C*/ x = +// ^ + library test; import self as self; import "dart:core" as core; diff --git a/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.outline.expect b/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.outline.expect new file mode 100644 index 00000000000..006b8a2905a --- /dev/null +++ b/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.outline.expect @@ -0,0 +1,20 @@ +library test; +import self as self; +import "dart:core" as core; + +class Clonable extends core::Object { + synthetic constructor •() → self::Clonable + ; +} +class Pair = dynamic, U extends self::Clonable = dynamic> extends core::Object { + field self::Pair::T t; + field self::Pair::U u; + constructor •(self::Pair::T t, self::Pair::U u) → self::Pair + ; + constructor _() → self::Pair + ; + get reversed() → self::Pair + ; +} +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.expect b/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.expect index a3489bf65a5..60f56e55c9f 100644 --- a/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.expect +++ b/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.expect @@ -1,14 +1,30 @@ // Formatted problems: // -// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Can't use a super-bounded type for instance creation. Got 'test::Pair, test::Clonable>'. -// Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference. +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Inferred type argument 'test::Clonable' violates the corresponding type variable bound of 'Pair::_'. +// Try specifying type arguments explicitly so that they conform to the bounds. // new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/ /*@typeArgs=Clonable, Clonable*/ Pair // ^ +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:10:12: Context: Bound of this variable is violated. +// class Pair, U extends Clonable> { +// ^ +// +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Inferred type argument 'test::Clonable' violates the corresponding type variable bound of 'Pair::_'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/ /*@typeArgs=Clonable, Clonable*/ Pair +// ^ +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:10:35: Context: Bound of this variable is violated. +// class Pair, U extends Clonable> { +// ^ // Unhandled errors: // -// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Can't use a super-bounded type for instance creation. Got 'test::Pair, test::Clonable>'. -// Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference. +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Inferred type argument 'test::Clonable' violates the corresponding type variable bound of 'Pair::_'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/ /*@typeArgs=Clonable, Clonable*/ Pair +// ^ +// +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Inferred type argument 'test::Clonable' violates the corresponding type variable bound of 'Pair::_'. +// Try specifying type arguments explicitly so that they conform to the bounds. // new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/ /*@typeArgs=Clonable, Clonable*/ Pair // ^ diff --git a/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.transformed.expect index 512ffbc9878..f618f377a59 100644 --- a/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart.strong.transformed.expect @@ -1,7 +1,12 @@ // Unhandled errors: // -// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Can't use a super-bounded type for instance creation. Got 'test::Pair, test::Clonable>'. -// Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference. +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Inferred type argument 'test::Clonable' violates the corresponding type variable bound of 'Pair::_'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/ /*@typeArgs=Clonable, Clonable*/ Pair +// ^ +// +// pkg/front_end/testcases/inference/constructors_inference_f_bounded.dart:22:110: Error: Inferred type argument 'test::Clonable' violates the corresponding type variable bound of 'Pair::_'. +// Try specifying type arguments explicitly so that they conform to the bounds. // new /*error:COULD_NOT_INFER,error:COULD_NOT_INFER*/ /*@typeArgs=Clonable, Clonable*/ Pair // ^ diff --git a/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.outline.expect b/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.outline.expect new file mode 100644 index 00000000000..b08cbd0d1a7 --- /dev/null +++ b/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.outline.expect @@ -0,0 +1,7 @@ +library test; +import self as self; + +static method f() → dynamic + ; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.expect b/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.expect index 43da43692c3..089353ff423 100644 --- a/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.expect +++ b/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.expect @@ -1,3 +1,27 @@ +// Formatted problems: +// +// pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart:21:63: Error: Inferred type argument 'dynamic' violates the corresponding type variable bound of 'max'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// dynamic c = /*error:COULD_NOT_INFER*/ /*@typeArgs=dynamic*/ max(x, y); +// ^ +// +// pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart:22:77: Error: Inferred type argument 'dynamic' violates the corresponding type variable bound of 'max'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// var /*@type=dynamic*/ d = /*error:COULD_NOT_INFER*/ /*@typeArgs=dynamic*/ max( +// ^ + +// Unhandled errors: +// +// pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart:21:63: Error: Inferred type argument 'dynamic' violates the corresponding type variable bound of 'max'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// dynamic c = /*error:COULD_NOT_INFER*/ /*@typeArgs=dynamic*/ max(x, y); +// ^ +// +// pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart:22:77: Error: Inferred type argument 'dynamic' violates the corresponding type variable bound of 'max'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// var /*@type=dynamic*/ d = /*error:COULD_NOT_INFER*/ /*@typeArgs=dynamic*/ max( +// ^ + library test; import self as self; import "dart:core" as core; diff --git a/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.transformed.expect index 43da43692c3..b259dbfc3c3 100644 --- a/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart.strong.transformed.expect @@ -1,3 +1,15 @@ +// Unhandled errors: +// +// pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart:21:63: Error: Inferred type argument 'dynamic' violates the corresponding type variable bound of 'max'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// dynamic c = /*error:COULD_NOT_INFER*/ /*@typeArgs=dynamic*/ max(x, y); +// ^ +// +// pkg/front_end/testcases/inference/downward_inference_fixes_no_upwards_errors.dart:22:77: Error: Inferred type argument 'dynamic' violates the corresponding type variable bound of 'max'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// var /*@type=dynamic*/ d = /*error:COULD_NOT_INFER*/ /*@typeArgs=dynamic*/ max( +// ^ + library test; import self as self; import "dart:core" as core; diff --git a/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.outline.expect b/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.outline.expect new file mode 100644 index 00000000000..93dfbdf9946 --- /dev/null +++ b/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.outline.expect @@ -0,0 +1,12 @@ +library test; +import self as self; +import "dart:core" as core; + +class Foo extends core::Object { + synthetic constructor •() → self::Foo + ; + method method(self::Foo::method::U u) → self::Foo::method::U + ; +} +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.strong.expect b/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.strong.expect index 1b93d99b3d7..f83187e0ab8 100644 --- a/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.strong.expect +++ b/pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart.strong.expect @@ -1,3 +1,17 @@ +// Formatted problems: +// +// pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart:26:77: Error: Inferred type argument 'dart.core::int' violates the corresponding type variable bound of 'Foo::method'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// . /*error:COULD_NOT_INFER*/ /*@typeArgs=int*/ /*@target=Foo::method*/ method( +// ^ + +// Unhandled errors: +// +// pkg/front_end/testcases/inference/generic_methods_correctly_recognize_generic_upper_bound.dart:26:77: Error: Inferred type argument 'dart.core::int' violates the corresponding type variable bound of 'Foo::method'. +// Try specifying type arguments explicitly so that they conform to the bounds. +// . /*error:COULD_NOT_INFER*/ /*@typeArgs=int*/ /*@target=Foo::method*/ method( +// ^ + library test; import self as self; import "dart:core" as core; diff --git a/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.expect b/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.expect index d731a050802..48a8469f4cd 100644 --- a/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.expect +++ b/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.expect @@ -1,3 +1,20 @@ +// Formatted problems: +// +// pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart:13:7: Error: Type argument 'dart.core::Comparable' violates the corresponding type variable bound of 'M0' in the supertype 'M0' of class 'M1 with M0'. +// Try changing type arguments so that they conform to the bounds. +// class A extends M1 with M0 {} +// ^ +// pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart:7:13: Context: Bound of this variable is violated. +// class M0> extends I {} +// ^ + +// Unhandled errors: +// +// pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart:13:7: Error: Type argument 'dart.core::Comparable' violates the corresponding type variable bound of 'M0' in the supertype 'M0' of class 'M1 with M0'. +// Try changing type arguments so that they conform to the bounds. +// class A extends M1 with M0 {} +// ^ + library; import self as self; import "dart:core" as core; diff --git a/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.transformed.expect index 906bdda65fe..8cb262c63f2 100644 --- a/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart.strong.transformed.expect @@ -1,3 +1,10 @@ +// Unhandled errors: +// +// pkg/front_end/testcases/inference/mixin_inference_instantiate_to_bounds_3.dart:13:7: Error: Type argument 'dart.core::Comparable' violates the corresponding type variable bound of 'M0' in the supertype 'M0' of class 'M1 with M0'. +// Try changing type arguments so that they conform to the bounds. +// class A extends M1 with M0 {} +// ^ + library; import self as self; import "dart:core" as core; diff --git a/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.expect b/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.expect index d787a25fa86..f930013fe81 100644 --- a/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.expect +++ b/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.expect @@ -1,14 +1,17 @@ // Formatted problems: // -// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:11:13: Error: Can't use a super-bounded type for instance creation. Got '#lib1::B>'. -// Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference. +// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:11:13: Error: Inferred type argument 'dart.core::Comparable' violates the corresponding type variable bound of 'B::'. +// Try specifying type arguments explicitly so that they conform to the bounds. // var y = new B(); // ^ +// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:9:9: Context: Bound of this variable is violated. +// class B> {} +// ^ // Unhandled errors: // -// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:11:13: Error: Can't use a super-bounded type for instance creation. Got '#lib1::B>'. -// Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference. +// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:11:13: Error: Inferred type argument 'dart.core::Comparable' violates the corresponding type variable bound of 'B::'. +// Try specifying type arguments explicitly so that they conform to the bounds. // var y = new B(); // ^ diff --git a/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.transformed.expect b/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.transformed.expect index 635fc89b122..2049a0ba3a9 100644 --- a/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart.strong.transformed.expect @@ -1,7 +1,7 @@ // Unhandled errors: // -// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:11:13: Error: Can't use a super-bounded type for instance creation. Got '#lib1::B>'. -// Specify a regular-bounded type instead of the super-bounded type. Note that the latter may be due to type inference. +// pkg/front_end/testcases/instantiate_to_bound/inference_super_bounded_rejected.dart:11:13: Error: Inferred type argument 'dart.core::Comparable' violates the corresponding type variable bound of 'B::'. +// Try specifying type arguments explicitly so that they conform to the bounds. // var y = new B(); // ^ diff --git a/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.expect b/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.expect index 1abbde32e71..61da753888c 100644 --- a/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.expect +++ b/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.expect @@ -4,6 +4,11 @@ // Try providing type arguments to 'LinkedListEntry' here. // class Hest {} // ^ +// +// pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart:15:12: Error: Type argument 'dart.collection::LinkedListEntry' violates the corresponding type variable bound of 'LinkedListEntry'. +// Try changing type arguments so that they conform to the bounds. +// class Hest {} +// ^ // Unhandled errors: // @@ -11,6 +16,11 @@ // Try providing type arguments to 'LinkedListEntry' here. // class Hest {} // ^ +// +// pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart:15:12: Error: Type argument 'dart.collection::LinkedListEntry' violates the corresponding type variable bound of 'LinkedListEntry'. +// Try changing type arguments so that they conform to the bounds. +// class Hest {} +// ^ library; import self as self; diff --git a/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.transformed.expect b/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.transformed.expect index 9c68c653403..5f76923c6e6 100644 --- a/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart.strong.transformed.expect @@ -4,6 +4,11 @@ // Try providing type arguments to 'LinkedListEntry' here. // class Hest {} // ^ +// +// pkg/front_end/testcases/instantiate_to_bound/non_simple_from_compiled.dart:15:12: Error: Type argument 'dart.collection::LinkedListEntry' violates the corresponding type variable bound of 'LinkedListEntry'. +// Try changing type arguments so that they conform to the bounds. +// class Hest {} +// ^ library; import self as self; diff --git a/pkg/front_end/testcases/outline.status b/pkg/front_end/testcases/outline.status index aeed5cf671c..3199cdba8d7 100644 --- a/pkg/front_end/testcases/outline.status +++ b/pkg/front_end/testcases/outline.status @@ -35,7 +35,6 @@ inference/conflicts_can_happen: Fail inference/conflicts_can_happen2: Fail inference/constructors_downwards_with_constraint: Fail inference/constructors_infer_from_arguments: Fail -inference/constructors_infer_from_arguments_argument_not_assignable: Fail inference/constructors_infer_from_arguments_const: Fail inference/constructors_infer_from_arguments_const_with_upper_bound: Fail inference/constructors_infer_from_arguments_downwards_from_constructor: Fail @@ -45,14 +44,12 @@ inference/constructors_infer_from_arguments_named: Fail inference/constructors_infer_from_arguments_named_factory: Fail inference/constructors_infer_from_arguments_redirecting: Fail inference/constructors_infer_from_arguments_redirecting_factory: Fail -inference/constructors_inference_f_bounded: Fail inference/constructors_reverse_type_parameters: Fail inference/constructors_too_many_positional_arguments: Fail inference/do_not_infer_overridden_fields_that_explicitly_say_dynamic_infer: Fail inference/dont_infer_field_type_when_initializer_is_null: Fail inference/dont_infer_type_on_dynamic: Fail inference/dont_infer_type_when_initializer_is_null: Fail -inference/downward_inference_fixes_no_upwards_errors: Fail inference/downward_inference_miscellaneous: Fail inference/downwards_inference_assignment_statements: Fail inference/downwards_inference_async_await: Fail @@ -76,7 +73,6 @@ inference/field_refers_to_top_level_getter: Fail inference/future_or_subtyping: Fail inference/generic_functions_return_typedef: Fail inference/generic_methods_basic_downward_inference: Fail -inference/generic_methods_correctly_recognize_generic_upper_bound: Fail inference/generic_methods_dart_math_min_max: Fail inference/generic_methods_do_not_infer_invalid_override_of_generic_method: Fail inference/generic_methods_downwards_inference_affects_arguments: Fail diff --git a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect index 5a266d2c3a8..b8cd86eddf5 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect +++ b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.expect @@ -4,6 +4,18 @@ // Try changing the type of the parameter, or casting the argument to 'test::C::g1::U'. // this.f(1.5); // ^ +// +// pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:20:16: Error: Type argument 'dart.core::num' violates the corresponding type variable bound of 'C::g1'. +// Try changing type arguments so that they conform to the bounds. +// new C().g1(); +// ^ + +// Unhandled errors: +// +// pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:20:16: Error: Type argument 'dart.core::num' violates the corresponding type variable bound of 'C::g1'. +// Try changing type arguments so that they conform to the bounds. +// new C().g1(); +// ^ library test; import self as self; diff --git a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect index f8c0eb9a67d..2d982f12e01 100644 --- a/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart.strong.transformed.expect @@ -1,3 +1,10 @@ +// Unhandled errors: +// +// pkg/front_end/testcases/runtime_checks/covariant_generic_method_type_parameter.dart:20:16: Error: Type argument 'dart.core::num' violates the corresponding type variable bound of 'C::g1'. +// Try changing type arguments so that they conform to the bounds. +// new C().g1(); +// ^ + library test; import self as self; import "dart:core" as core; diff --git a/pkg/kernel/lib/type_environment.dart b/pkg/kernel/lib/type_environment.dart index 0e50c51b1b7..58ce58bdea3 100644 --- a/pkg/kernel/lib/type_environment.dart +++ b/pkg/kernel/lib/type_environment.dart @@ -152,53 +152,60 @@ class TypeEnvironment extends SubtypeTester { return !hierarchy.hasProperSubtypes(class_); } + bool isObject(DartType type) { + return type is InterfaceType && type.classNode == objectType.classNode; + } + + bool isNull(DartType type) { + return type is InterfaceType && type.classNode == nullType.classNode; + } + /// Replaces all covariant occurrences of `dynamic`, `Object`, and `void` with - /// `Null` and all contravariant occurrences of `Null` with `Object`. - DartType replaceTopAndBottom(DartType type, {bool isCovariant = true}) { - if (type is DynamicType && isCovariant) { - return const BottomType(); - } else if (type is InterfaceType && - type.classNode == objectType.classNode && + /// [BottomType] and all contravariant occurrences of `Null` and [BottomType] + /// with `Object`. + DartType convertSuperBoundedToRegularBounded(DartType type, + {bool isCovariant = true}) { + if ((type is DynamicType || type is VoidType || isObject(type)) && isCovariant) { return const BottomType(); + } else if ((type is BottomType || isNull(type)) && !isCovariant) { + return objectType; } else if (type is InterfaceType && type.classNode.typeParameters != null) { - List typeArguments = type.typeArguments ?? - calculateBounds(type.classNode.typeParameters, objectType.classNode); List replacedTypeArguments = - new List(typeArguments.length); + new List(type.typeArguments.length); for (int i = 0; i < replacedTypeArguments.length; i++) { - replacedTypeArguments[i] = - replaceTopAndBottom(typeArguments[i], isCovariant: true); + replacedTypeArguments[i] = convertSuperBoundedToRegularBounded( + type.typeArguments[i], + isCovariant: isCovariant); } return new InterfaceType(type.classNode, replacedTypeArguments); } else if (type is TypedefType && type.typedefNode.typeParameters != null) { - List typeArguments = type.typeArguments ?? - calculateBounds( - type.typedefNode.typeParameters, objectType.classNode); List replacedTypeArguments = - new List(typeArguments.length); + new List(type.typeArguments.length); for (int i = 0; i < replacedTypeArguments.length; i++) { - replacedTypeArguments[i] = - replaceTopAndBottom(typeArguments[i], isCovariant: true); + replacedTypeArguments[i] = convertSuperBoundedToRegularBounded( + type.typeArguments[i], + isCovariant: isCovariant); } return new TypedefType(type.typedefNode, replacedTypeArguments); } else if (type is FunctionType) { - var replacedReturnType = - replaceTopAndBottom(type.returnType, isCovariant: true); + var replacedReturnType = convertSuperBoundedToRegularBounded( + type.returnType, + isCovariant: isCovariant); var replacedPositionalParameters = new List(type.positionalParameters.length); for (int i = 0; i < replacedPositionalParameters.length; i++) { - replacedPositionalParameters[i] = replaceTopAndBottom( + replacedPositionalParameters[i] = convertSuperBoundedToRegularBounded( type.positionalParameters[i], - isCovariant: false); + isCovariant: !isCovariant); } var replacedNamedParameters = new List(type.namedParameters.length); for (int i = 0; i < replacedNamedParameters.length; i++) { replacedNamedParameters[i] = new NamedType( type.namedParameters[i].name, - replaceTopAndBottom(type.namedParameters[i].type, - isCovariant: false)); + convertSuperBoundedToRegularBounded(type.namedParameters[i].type, + isCovariant: !isCovariant)); } return new FunctionType(replacedPositionalParameters, replacedReturnType, namedParameters: replacedNamedParameters, @@ -209,71 +216,177 @@ class TypeEnvironment extends SubtypeTester { return type; } - bool isSuperBounded(DartType type) { - List typeParameters; - List typeArguments; + // TODO(dmitryas): Remove [typedefInstantiations] when type arguments passed + // to typedefs are preserved in the Kernel output. + List findBoundViolations(DartType type, + {bool allowSuperBounded = false, + bool isCovariant = true, + Map> typedefInstantiations}) { + List variables; + List arguments; + List typedefRhsResult; - if (type is InterfaceType && type.classNode.typeParameters != null) { - typeParameters = type.classNode.typeParameters; - typeArguments = type.typeArguments; - } else if (type is TypedefType && type.typedefNode.typeParameters != null) { - typeParameters = type.typedefNode.typeParameters; - typeArguments = type.typeArguments; + if (typedefInstantiations != null && + typedefInstantiations.containsKey(type)) { + // [type] is a function type that is an application of a parametrized + // typedef. We need to check both the l.h.s. and the r.h.s. of the + // definition in that case. For details, see [link] + // (https://github.com/dart-lang/sdk/blob/master/docs/language/informal/super-bounded-types.md). + FunctionType functionType = type; + FunctionType cloned = new FunctionType( + functionType.positionalParameters, functionType.returnType, + namedParameters: functionType.namedParameters, + typeParameters: functionType.typeParameters, + requiredParameterCount: functionType.requiredParameterCount, + typedefReference: null); + typedefRhsResult = findBoundViolations(cloned, + allowSuperBounded: true, + isCovariant: isCovariant, + typedefInstantiations: typedefInstantiations); + type = new TypedefType(functionType.typedef, typedefInstantiations[type]); } - if (typeParameters == null) { - return false; + if (type is InterfaceType) { + variables = type.classNode.typeParameters; + arguments = type.typeArguments; + } else if (type is TypedefType) { + variables = type.typedefNode.typeParameters; + arguments = type.typeArguments; + } else if (type is FunctionType) { + List result = []; + for (DartType formal in type.positionalParameters) { + result.addAll(findBoundViolations(formal, + allowSuperBounded: true, + isCovariant: !isCovariant, + typedefInstantiations: typedefInstantiations) ?? + const []); + } + for (NamedType named in type.namedParameters) { + result.addAll(findBoundViolations(named.type, + allowSuperBounded: true, + isCovariant: !isCovariant, + typedefInstantiations: typedefInstantiations) ?? + const []); + } + result.addAll(findBoundViolations(type.returnType, + allowSuperBounded: true, + isCovariant: isCovariant, + typedefInstantiations: typedefInstantiations) ?? + const []); + return result.isEmpty ? null : result; + } else { + return null; } - typeArguments = - typeArguments ?? calculateBounds(typeParameters, objectType.classNode); + if (variables == null) return null; - var substitution = {}; - for (int i = 0; i < typeParameters.length; i++) { - substitution[typeParameters[i]] = typeArguments[i]; - } - var substitutedBounds = new List(typeParameters.length); - for (int i = 0; i < typeParameters.length; i++) { - substitutedBounds[i] = substitute(typeParameters[i].bound, substitution); - } + List result; + List argumentsResult; - bool isViolated = false; - for (int i = 0; i < typeArguments.length; i++) { - if (!isSubtypeOf(typeArguments[i], substitutedBounds[i])) { - isViolated = true; + Map substitutionMap = + new Map.fromIterables(variables, arguments); + for (int i = 0; i < arguments.length; ++i) { + if (!isSubtypeOf( + arguments[i], substitute(variables[i].bound, substitutionMap))) { + result ??= []; + result.add(arguments[i]); + result.add(variables[i]); + result.add(type); + } + + List violations = findBoundViolations(arguments[i], + allowSuperBounded: true, + isCovariant: isCovariant, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + argumentsResult ??= []; + argumentsResult.addAll(violations); } } - if (!isViolated) { - return false; + if (argumentsResult != null) { + result ??= []; + result.addAll(argumentsResult); + } + if (typedefRhsResult != null) { + result ??= []; + result.addAll(typedefRhsResult); } - var replaced = replaceTopAndBottom(type); - List replacedArguments; - if (replaced is InterfaceType) { - replacedArguments = replaced.typeArguments; - } else if (replaced is TypedefType) { - replacedArguments = replaced.typeArguments; - } + // [type] is regular-bounded. + if (result == null) return null; + if (!allowSuperBounded) return result; - if (replacedArguments == null) { - return false; + result = null; + type = convertSuperBoundedToRegularBounded(type, isCovariant: isCovariant); + List argumentsToReport = arguments.toList(); + if (type is InterfaceType) { + variables = type.classNode.typeParameters; + arguments = type.typeArguments; + } else if (type is TypedefType) { + variables = type.typedefNode.typeParameters; + arguments = type.typeArguments; } - - var replacedSubstitution = {}; - for (int i = 0; i < typeParameters.length; i++) { - replacedSubstitution[typeParameters[i]] = replacedArguments[i]; - } - var replacedBounds = new List(typeParameters.length); - for (int i = 0; i < typeParameters.length; i++) { - replacedBounds[i] = - substitute(typeParameters[i].bound, replacedSubstitution); - } - for (int i = 0; i < replacedArguments.length; i++) { - if (!isSubtypeOf(replacedArguments[i], replacedBounds[i])) { - return false; + substitutionMap = + new Map.fromIterables(variables, arguments); + for (int i = 0; i < arguments.length; ++i) { + if (!isSubtypeOf( + arguments[i], substitute(variables[i].bound, substitutionMap))) { + result ??= []; + result.add(argumentsToReport[i]); + result.add(variables[i]); + result.add(type); } } - return true; + if (argumentsResult != null) { + result ??= []; + result.addAll(argumentsResult); + } + if (typedefRhsResult != null) { + result ??= []; + result.addAll(typedefRhsResult); + } + return result; + } + + // TODO(dmitryas): Remove [typedefInstantiations] when type arguments passed + // to typedefs are preserved in the Kernel output. + List findBoundViolationsElementwise( + List parameters, List arguments, + {Map> typedefInstantiations}) { + assert(arguments.length == parameters.length); + List result; + var substitutionMap = {}; + for (int i = 0; i < arguments.length; ++i) { + substitutionMap[parameters[i]] = arguments[i]; + } + for (int i = 0; i < arguments.length; ++i) { + if (!isSubtypeOf( + arguments[i], substitute(parameters[i].bound, substitutionMap))) { + result ??= []; + result.add(arguments[i]); + result.add(parameters[i]); + result.add(null); + } + + List violations = findBoundViolations(arguments[i], + allowSuperBounded: true, + isCovariant: true, + typedefInstantiations: typedefInstantiations); + if (violations != null) { + result ??= []; + result.addAll(violations); + } + } + return result; + } + + String getGenericTypeName(DartType type) { + if (type is InterfaceType) { + return type.classNode.name; + } else if (type is TypedefType) { + return type.typedefNode.name; + } + return type.toString(); } } diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status index b96fc7375e8..a2584593e5c 100644 --- a/tests/co19/co19-kernel.status +++ b/tests/co19/co19-kernel.status @@ -561,7 +561,7 @@ Language/Expressions/Instance_Creation/New/execution_t11: CompileTimeError Language/Expressions/Instance_Creation/New/execution_t13: CompileTimeError Language/Expressions/Instance_Creation/New/named_constructor_t01: CompileTimeError Language/Expressions/Instance_Creation/New/named_constructor_t02: CompileTimeError -Language/Expressions/Instance_Creation/New/redirecting_factory_constructor_t01: CompileTimeError # Issue 33308 +Language/Expressions/Instance_Creation/New/redirecting_factory_constructor_t01: CompileTimeError Language/Expressions/Instance_Creation/New/redirecting_factory_constructor_t02: CompileTimeError Language/Expressions/Instance_Creation/New/type_argument_t01: CompileTimeError Language/Expressions/Instance_Creation/New/type_t01: CompileTimeError diff --git a/tests/co19_2/co19_2-analyzer.status b/tests/co19_2/co19_2-analyzer.status index 202713e8207..3d852c44027 100644 --- a/tests/co19_2/co19_2-analyzer.status +++ b/tests/co19_2/co19_2-analyzer.status @@ -216,8 +216,8 @@ LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t08: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t09: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t19: CompileTimeError # Issue 33995 -LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t01: MissingCompileTimeError # Issue 33995 -LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t02: MissingCompileTimeError # Issue 33308 +LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t01: MissingCompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t02: MissingCompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/mixin/mixin_neg_l1_t02: MissingCompileTimeError # Issue 33596 LanguageFeatures/Instantiate-to-bound/typedef/typedef_named_extends_neg_l2_t02: MissingCompileTimeError # Bad test LanguageFeatures/Instantiate-to-bound/typedef/typedef_named_extends_pos_l2_t01: CompileTimeError # Bad test diff --git a/tests/co19_2/co19_2-dart2js.status b/tests/co19_2/co19_2-dart2js.status index be656d43f0a..50d948691ac 100644 --- a/tests/co19_2/co19_2-dart2js.status +++ b/tests/co19_2/co19_2-dart2js.status @@ -3509,8 +3509,6 @@ Language/Types/Interface_Types/subtype_t06: RuntimeError Language/Types/Interface_Types/subtype_t21: RuntimeError Language/Types/Interface_Types/subtype_t23: RuntimeError Language/Variables/constant_variable_t09: RuntimeError -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t01: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t01: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t03: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t04: MissingCompileTimeError @@ -3522,15 +3520,8 @@ LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t10: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/check_types/typedef_param_t02: RuntimeError LanguageFeatures/Instantiate-to-bound/class/class_extends_neg_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t04: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t06: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t13: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t15: MissingCompileTimeError LanguageFeatures/Subtyping/dynamic/generated/named_function_types_fail_arguments_binding_fail_A51_t01: RuntimeError LanguageFeatures/Subtyping/dynamic/generated/named_function_types_fail_arguments_binding_fail_A51_t02: RuntimeError LanguageFeatures/Subtyping/dynamic/generated/named_function_types_fail_arguments_binding_fail_A53_t01: RuntimeError diff --git a/tests/co19_2/co19_2-kernel.status b/tests/co19_2/co19_2-kernel.status index 0e70aa478f4..04746cbf1ea 100644 --- a/tests/co19_2/co19_2-kernel.status +++ b/tests/co19_2/co19_2-kernel.status @@ -159,13 +159,7 @@ Language/Expressions/Function_Invocation/async_cleanup_t08: CompileTimeError Language/Expressions/Instance_Creation/Const/arguments_t03: MissingCompileTimeError # Legal because of implicit const Language/Expressions/Instance_Creation/Const/parameterized_type_t01: CompileTimeError Language/Expressions/Instance_Creation/Const/parameterized_type_t02: CompileTimeError -Language/Expressions/Instance_Creation/New/evaluation_t16: MissingCompileTimeError # Issue 33308 -Language/Expressions/Instance_Creation/New/evaluation_t17: MissingCompileTimeError # Issue 33308 -Language/Expressions/Instance_Creation/New/evaluation_t18: MissingCompileTimeError # Issue 33308 -Language/Expressions/Instance_Creation/New/redirecting_factory_constructor_t02: MissingCompileTimeError # Issue 33308 Language/Expressions/Instance_Creation/New/syntax_t04: MissingCompileTimeError # Legal because of implicit new -Language/Expressions/Instance_Creation/New/type_argument_t01: MissingCompileTimeError # Issue 33308 -Language/Expressions/Instance_Creation/malformed_or_malbounded_t07: MissingCompileTimeError # Issue 33308 Language/Expressions/Lists/constant_list_t01: CompileTimeError Language/Expressions/Maps/constant_map_t02: MissingCompileTimeError Language/Expressions/Maps/constant_map_type_t01: CompileTimeError @@ -190,10 +184,8 @@ Language/Expressions/Unary_Expressions/syntax_t10: CompileTimeError Language/Expressions/Unary_Expressions/syntax_t27: CompileTimeError Language/Functions/Formal_Parameters/Optional_Formals/default_value_t01: MissingCompileTimeError # 32912 Language/Functions/Formal_Parameters/Optional_Formals/default_value_t02: MissingCompileTimeError # 32912 -Language/Generics/scope_t06: MissingCompileTimeError # Issue 33308 Language/Generics/syntax_t02: CompileTimeError Language/Generics/syntax_t03: CompileTimeError -Language/Generics/upper_bound_t01: MissingCompileTimeError # Issue 33308 Language/Libraries_and_Scripts/Imports/library_name_t01: MissingCompileTimeError # Expects an error, but this is a warning in Dart 2 Language/Mixins/Mixin_Application/deferred_t01: MissingCompileTimeError # Issue 30273 Language/Mixins/Mixin_Application/static_warning_t01: MissingCompileTimeError # Mixin super equirement @@ -222,51 +214,8 @@ Language/Statements/Continue/label_t07: MissingCompileTimeError # Issue 34206 Language/Statements/Switch/equal_operator_t01: MissingCompileTimeError # Issue 32557 Language/Statements/Switch/equal_operator_t02: MissingCompileTimeError # Issue 32557 Language/Statements/Try/catch_scope_t01: CompileTimeError -Language/Types/Dynamic_Type_System/malbounded_type_error_t01: MissingCompileTimeError # Issue 33308 Language/Types/Interface_Types/subtype_t30: CompileTimeError -Language/Types/Parameterized_Types/malbounded_t01: MissingCompileTimeError # Issue 33308 -Language/Types/Parameterized_Types/malbounded_t02: MissingCompileTimeError # Issue 33308 -Language/Types/Parameterized_Types/malbounded_t03: MissingCompileTimeError # Issue 33308 -Language/Types/Parameterized_Types/malbounded_t04: MissingCompileTimeError # Issue 33308 -Language/Types/Parameterized_Types/malbounded_t05: MissingCompileTimeError # Issue 33308 -Language/Types/Parameterized_Types/malbounded_t06: MissingCompileTimeError # Issue 33308 -Language/Types/Static_Types/malformed_type_t01/04: MissingCompileTimeError # Issue 33308 -Language/Types/Static_Types/malformed_type_t01/05: MissingCompileTimeError # Issue 33308 -Language/Types/Static_Types/malformed_type_t01/06: MissingCompileTimeError # Issue 33308 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t01: MissingCompileTimeError # Please triage this failure -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t03: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t04: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t05: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t06: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t07: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t08: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t09: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t10: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t11: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_named_extends_neg_assign_l1_t12: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t01: MissingCompileTimeError # Please triage this failure -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t03: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t04: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t05: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t06: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t07: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t08: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t09: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t10: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t11: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_optparam_extends_neg_assign_l1_t12: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t01: MissingCompileTimeError # Please triage this failure -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t03: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t04: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t05: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t06: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t07: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t08: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t09: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t10: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t11: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_param_extends_neg_assign_l1_t12: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t01: MissingCompileTimeError # Issue 33308 +LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t01: MissingCompileTimeError # Issue 34637 LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t03: MissingCompileTimeError # Issue 33805 LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t04: MissingCompileTimeError # Issue 33805 LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t05: MissingCompileTimeError # Issue 33805 @@ -275,62 +224,23 @@ LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t08: MissingCompileTimeError # Issue 33597 LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t09: MissingCompileTimeError # Issue 33597 LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t10: MissingCompileTimeError # Issue 33597 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t12: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t13: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t14: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t15: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t16: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t17: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t18: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t19: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t20: MissingCompileTimeError # Issue 34087 -LanguageFeatures/Instantiate-to-bound/Callable/Callable_ret_extends_neg_assign_l1_t21: MissingCompileTimeError # Issue 34087 +LanguageFeatures/Instantiate-to-bound/check_types/typedef_param_t02: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/class/class_extends_FutureOr_pos_l1_t01: CompileTimeError # Issue 34626 LanguageFeatures/Instantiate-to-bound/class/class_extends_neg_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/class/custom_extends_neg_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t04: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t06: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t04: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t06: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t08: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t09: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t04: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t06: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_neg_assign_l1_t08: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t04: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t06: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t08: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t09: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t04: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t06: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_neg_assign_l1_t08: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t03: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t04: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t06: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t08: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t09: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_pos_l1_t05: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_pos_l1_t06: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_named_extends_neg_assign_l1_t10: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_named_extends_pos_l1_t05: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_named_extends_pos_l1_t06: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_pos_l1_t05: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_Future_pos_l1_t06: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_neg_assign_l1_t10: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_pos_l1_t05: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_optparam_extends_pos_l1_t06: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_param_extends_Future_pos_l1_t05: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_param_extends_neg_assign_l1_t10: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_param_extends_pos_l1_t05: CompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/function/function_pos_l1_t01: CompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t01: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t02: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t03: MissingCompileTimeError @@ -340,16 +250,7 @@ LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_a LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t07: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t08: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t09: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t11: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t12: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t13: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t14: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t15: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t16: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t17: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t18: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t20: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t21: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t19: CompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t01: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t02: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t03: MissingCompileTimeError @@ -359,32 +260,20 @@ LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t07: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t08: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t09: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t11: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t12: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t13: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t14: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t15: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t16: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t17: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t18: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t20: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t21: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_assign_l1_t19: CompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_neg_l1_t02: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t02: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t01: MissingCompileTimeError # Issue 34613 +LanguageFeatures/Instantiate-to-bound/interface/interface_neg_assign_l2_t02: MissingCompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/mixin/mixin_extends_neg_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/mixin/mixin_neg_assign_l2_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/mixin/mixin_neg_l1_t07: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/mixin/mixin_neg_l2_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/typedef/typedef_named_extends_neg_l1_t03: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/typedef/typedef_named_extends_neg_l2_t02: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/typedef/typedef_optparam_extends_neg_l1_t03: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/typedef/typedef_named_extends_pos_l2_t01: CompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/typedef/typedef_optparam_extends_neg_l2_t02: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/typedef/typedef_param_extends_neg_l1_t04: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/typedef/typedef_optparam_extends_pos_l2_t01: CompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/typedef/typedef_param_extends_neg_l2_t02: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/typedef/typedef_ret_extends_neg_l1_t04: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/typedef/typedef_param_extends_pos_l2_t01: CompileTimeError # Issue 34613 LanguageFeatures/Instantiate-to-bound/typedef/typedef_ret_extends_neg_l1_t05: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/typedef/typedef_ret_extends_neg_l2_t02: MissingCompileTimeError +LanguageFeatures/Instantiate-to-bound/typedef/typedef_ret_extends_pos_l2_t01: CompileTimeError # Issue 34613 LanguageFeatures/Super_Mixins/declarations_neg_t01/none: CompileTimeError LanguageFeatures/Super_Mixins/mixin_application_neg_t01/none: CompileTimeError LanguageFeatures/Super_Mixins/mixin_application_neg_t03/none: CompileTimeError @@ -589,7 +478,6 @@ LibTest/isolate/ReceivePort/transform_A01_t01: RuntimeError [ $runtime != vm && $fasta ] Language/Classes/Constructors/Constant_Constructors/potentially_constant_expression_t01: MissingCompileTimeError # Issue 34192 LanguageFeatures/Instantiate-to-bound/class/class_extends_FutureOr_neg_l3_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/class/class_extends_Future_neg_l3_t01: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/class/class_extends_neg_l3_t01: MissingCompileTimeError LanguageFeatures/Instantiate-to-bound/mixin/mixin_neg_l1_t02: MissingCompileTimeError @@ -802,8 +690,6 @@ Language/Variables/constant_initialization_t03: RuntimeError Language/Variables/constant_variable_t09: RuntimeError LanguageFeatures/Instantiate-to-bound/check_types/typedef_param_t02: RuntimeError LanguageFeatures/Instantiate-to-bound/class/class_extends_neg_l1_t05: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_named_extends_Future_neg_assign_l1_t01: MissingCompileTimeError -LanguageFeatures/Instantiate-to-bound/function/function_ret_extends_Future_neg_assign_l1_t21: MissingCompileTimeError LanguageFeatures/Super_Mixins/mixin_application_neg_t01/none: CompileTimeError LibTest/async/Future/asStream_A01_t02: RuntimeError LibTest/async/Stream/Stream.fromFutures_A04_t02: RuntimeError diff --git a/tests/compiler/dart2js/model/subtype_test.dart b/tests/compiler/dart2js/model/subtype_test.dart index 9a43a69fc33..40907d7300f 100644 --- a/tests/compiler/dart2js/model/subtype_test.dart +++ b/tests/compiler/dart2js/model/subtype_test.dart @@ -613,7 +613,7 @@ Future testTypeVariableSubtype() async { new B(); new C(); new D(); - new E(); + new E(); new F(); } """, expectNoErrors: true).then((env) { diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status index 79e1714fc6d..d9e3cbbd7b8 100644 --- a/tests/language_2/language_2_dart2js.status +++ b/tests/language_2/language_2_dart2js.status @@ -30,7 +30,6 @@ external_test/10: CompileTimeError # External non-js-interop function are treate external_test/13: CompileTimeError # External non-js-interop function are treated as compile-time errors. external_test/20: CompileTimeError # External non-js-interop function are treated as compile-time errors. function_propagation_test: RuntimeError -generic_test/01: MissingCompileTimeError # front end does not validate `extends` guess_cid_test: CompileTimeError, OK # Error if web int literal cannot be represented exactly, see http://dartbug.com/33351 identical_closure2_test: CompileTimeError, OK # Error if web int literal cannot be represented exactly, see http://dartbug.com/33351 instantiate_tearoff_of_call_test: RuntimeError @@ -452,7 +451,6 @@ identical_const_test/01: MissingCompileTimeError identical_const_test/02: MissingCompileTimeError identical_const_test/03: MissingCompileTimeError identical_const_test/04: MissingCompileTimeError -issue18628_2_test/01: MissingCompileTimeError issue23244_test: Crash # 'file:*/pkg/compiler/lib/src/js_emitter/runtime_type_generator.dart': Failed assertion: line 208 pos 18: '!(_useKernel && _strongMode && !_disableRtiOptimization) || library_env_test/has_no_html_support: RuntimeError library_env_test/has_no_io_support: RuntimeError @@ -467,7 +465,6 @@ regress_13462_1_test: RuntimeError regress_18535_test: RuntimeError type_literal_prefix_call_test/00: MissingCompileTimeError type_promotion_logical_and_test/01: MissingCompileTimeError -type_variable_bounds_test/02: Crash # NoSuchMethodError: The method 'accept' was called on null. [ $compiler == dart2js && $minified ] cyclic_type2_test: RuntimeError # Issue 31054 @@ -504,7 +501,6 @@ identical_const_test/03: MissingCompileTimeError identical_const_test/04: MissingCompileTimeError invocation_mirror2_test: RuntimeError # mirrors not supported invocation_mirror_test: RuntimeError -issue18628_2_test/01: MissingCompileTimeError issue23244_test: Crash # Interpolated value #1 is not an Expression or List of Expressions: [VariableUse(f), Instance of 'LiteralNull', null] library_env_test/has_no_html_support: RuntimeError many_overridden_no_such_method_test: RuntimeError @@ -524,7 +520,6 @@ stack_trace_test: RuntimeError, OK # Stack trace not preserved in minified code. symbol_conflict_test: RuntimeError # Issue 23857 type_literal_prefix_call_test/00: MissingCompileTimeError type_promotion_logical_and_test/01: MissingCompileTimeError -type_variable_bounds_test/02: Crash # NoSuchMethodError: The method 'accept' was called on null. [ $compiler == dart2js && $strong ] async_await_test/02: RuntimeError diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status index 269ed1ccd69..ee242e030b3 100644 --- a/tests/language_2/language_2_dartdevc.status +++ b/tests/language_2/language_2_dartdevc.status @@ -272,7 +272,6 @@ generic_function_bounds_test: RuntimeError generic_methods_generic_function_result_test/01: MissingCompileTimeError generic_no_such_method_dispatcher_simple_test: CompileTimeError # Warning: Superclass has no method named 'foo'. generic_no_such_method_dispatcher_test: CompileTimeError # Issue 31533 -generic_test/01: MissingCompileTimeError # front end does not validate `extends` identical_const_test/01: MissingCompileTimeError identical_const_test/02: MissingCompileTimeError identical_const_test/03: MissingCompileTimeError @@ -289,14 +288,12 @@ implicit_creation/implicit_const_not_default_values_test/e30: Pass implicit_creation/implicit_const_not_default_values_test/e6: Pass implicit_creation/implicit_const_not_default_values_test/e9: Pass instantiate_tearoff_of_call_test: CompileTimeError -issue18628_2_test/01: MissingCompileTimeError issue31596_super_test/01: CompileTimeError issue31596_super_test/03: CompileTimeError issue31596_super_test/05: RuntimeError map_literal3_test/01: MissingCompileTimeError map_literal3_test/02: MissingCompileTimeError map_literal3_test/03: MissingCompileTimeError -mixin_declaration/mixin_declaration_inference_invalid_07_test: MissingCompileTimeError # https://github.com/dart-lang/sdk/issues/34165 mixin_declaration/mixin_declaration_invalid_override_test/08: MissingCompileTimeError mixin_declaration/mixin_declaration_invalid_syntax_test/none: CompileTimeError mixin_declaration/mixin_declaration_invalid_usage_test/03: MissingCompileTimeError diff --git a/tests/language_2/language_2_kernel.status b/tests/language_2/language_2_kernel.status index 349ebbc8aa3..baf4d4d00fb 100644 --- a/tests/language_2/language_2_kernel.status +++ b/tests/language_2/language_2_kernel.status @@ -71,7 +71,6 @@ generic_is_check_test: RuntimeError generic_no_such_method_dispatcher_simple_test: CompileTimeError generic_no_such_method_dispatcher_test: CompileTimeError generic_tearoff_test: CompileTimeError -generic_test/01: MissingCompileTimeError instantiate_tearoff_of_call_test: CompileTimeError issue31596_super_test/01: CompileTimeError issue31596_super_test/03: CompileTimeError @@ -174,7 +173,6 @@ assertion_initializer_const_error2_test/cc09: MissingCompileTimeError assertion_initializer_const_error2_test/cc10: MissingCompileTimeError const_cast1_test/02: MissingCompileTimeError const_constructor_nonconst_param_test/01: MissingCompileTimeError -generic_test/01: MissingCompileTimeError implicit_creation/implicit_const_not_default_values_test/e1: MissingCompileTimeError implicit_creation/implicit_const_not_default_values_test/e10: MissingCompileTimeError implicit_creation/implicit_const_not_default_values_test/e11: MissingCompileTimeError @@ -211,16 +209,13 @@ constructor_reference_test/27: MissingCompileTimeError # Issue 34403 deferred_inheritance_constraints_test/extends: MissingCompileTimeError # Fasta/KernelVM bug: Deferred loading kernel issue 30273. deferred_inheritance_constraints_test/implements: MissingCompileTimeError # Fasta/KernelVM bug: Deferred loading kernel issue 30273. deferred_inheritance_constraints_test/mixin: MissingCompileTimeError # Fasta/KernelVM bug: Deferred loading kernel issue 30273. -f_bounded_quantification_test/01: MissingCompileTimeError # Issue 33308 -f_bounded_quantification_test/02: MissingCompileTimeError # Issue 33308 -generic_methods_bounds_test/01: MissingCompileTimeError # Issue 33308 -generic_methods_recursive_bound_test/02: MissingCompileTimeError # Issue 33308 -instantiate_to_bounds_super_bounded_test/14: MissingCompileTimeError # Issue 33308 -instantiate_to_bounds_super_bounded_test/15: MissingCompileTimeError # Issue 33308 -instantiate_to_bounds_super_bounded_test/17: MissingCompileTimeError # Issue 33308 -instantiate_to_bounds_super_bounded_test/18: MissingCompileTimeError # Issue 33308 -instantiate_to_bounds_super_bounded_test/20: MissingCompileTimeError # Issue 33308 -instantiate_to_bounds_super_bounded_test/21: MissingCompileTimeError # Issue 33308 +f_bounded_quantification2_test: CompileTimeError # Issue 34583 +f_bounded_quantification4_test: CompileTimeError # Issue 34583 +instantiate_to_bounds_super_bounded_test/54: CompileTimeError # Issue 34613 +instantiate_to_bounds_super_bounded_test/55: CompileTimeError # Issue 34613 +instantiate_to_bounds_super_bounded_test/56: CompileTimeError # Issue 34613 +instantiate_to_bounds_super_bounded_test/57: CompileTimeError # Issue 34613 +instantiate_to_bounds_super_bounded_test/58: CompileTimeError # Issue 34613 issue31596_super_test/02: MissingCompileTimeError # Issue 31596 issue31596_super_test/04: MissingCompileTimeError # Issue 31596 issue34488_test/01: MissingCompileTimeError # Issue 34488 @@ -230,23 +225,6 @@ issue34488_test/04: MissingCompileTimeError # Issue 34488 issue34488_test/05: MissingCompileTimeError # Issue 34488 issue34488_test/06: MissingCompileTimeError # Issue 34488 issue34498_test: MissingCompileTimeError # Issue 34498 -issue34532_test: MissingCompileTimeError # Issue 33308 -malbounded_instantiation_test/01: MissingCompileTimeError # Issue 33308 -malbounded_instantiation_test/02: MissingCompileTimeError # Issue 33308 -malbounded_instantiation_test/03: MissingCompileTimeError # Issue 33308 -malbounded_redirecting_factory_test/03: MissingCompileTimeError # Issue 33308 -malbounded_redirecting_factory_test/04: MissingCompileTimeError # Issue 33308 -malbounded_redirecting_factory_test/05: MissingCompileTimeError # Issue 33308 -malbounded_type_cast2_test: MissingCompileTimeError # Issue 33308 -malbounded_type_cast_test/00: MissingCompileTimeError # Issue 33308 -malbounded_type_cast_test/01: MissingCompileTimeError # Issue 33308 -malbounded_type_cast_test/02: MissingCompileTimeError # Issue 33308 -malbounded_type_literal_test/00: MissingCompileTimeError # Issue 33308 -malbounded_type_test2_test/00: MissingCompileTimeError # Issue 33308 -malbounded_type_test_test/00: MissingCompileTimeError # Issue 33308 -malbounded_type_test_test/01: MissingCompileTimeError # Issue 33308 -malbounded_type_test_test/02: MissingCompileTimeError # Issue 33308 -mixin_declaration/mixin_declaration_inference_invalid_07_test: MissingCompileTimeError mixin_declaration/mixin_declaration_invalid_application_supertype_test/05: MissingCompileTimeError mixin_declaration/mixin_declaration_invalid_application_supertype_test/06: MissingCompileTimeError mixin_declaration/mixin_declaration_invalid_application_supertype_test/07: MissingCompileTimeError @@ -257,32 +235,7 @@ mixin_declaration/mixin_declaration_superinvocation_application_test/05: Missing mixin_declaration/mixin_declaration_superinvocation_application_test/06: MissingCompileTimeError mixin_declaration/mixin_declaration_superinvocation_application_test/07: MissingCompileTimeError mixin_declaration/mixin_declaration_superinvocation_application_test/08: MissingCompileTimeError -mixin_invalid_bound2_test/02: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/03: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/04: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/05: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/06: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/07: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/08: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/09: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/10: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/11: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/12: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/13: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/14: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound2_test/15: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/02: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/03: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/04: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/05: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/06: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/07: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/08: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/09: MissingCompileTimeError # Issue 33308 -mixin_invalid_bound_test/10: MissingCompileTimeError # Issue 33308 mixin_method_override_test/G5: Crash # Issue 34354 -mixin_super_bound_test/01: MissingCompileTimeError # Issue 33308 -mixin_super_bound_test/02: MissingCompileTimeError # Issue 33308 regress_22976_test/*: CompileTimeError # Issue 31935 syntax_test/28: MissingCompileTimeError # Issue 29763 - low priority syntax_test/29: MissingCompileTimeError # Issue 29763 - low priority @@ -292,18 +245,6 @@ syntax_test/32: MissingCompileTimeError # Issue 29763 - low priority syntax_test/33: MissingCompileTimeError # Issue 29763 - low priority syntax_test/60: MissingCompileTimeError # Issue 30470 syntax_test/61: MissingCompileTimeError # Issue 30470 -type_variable_bounds2_test: MissingCompileTimeError # Issue 33308 -type_variable_bounds3_test/00: MissingCompileTimeError # Issue 33308 -type_variable_bounds4_test/01: MissingCompileTimeError # Issue 33308 -type_variable_bounds_test/01: MissingCompileTimeError # Issue 33308 -type_variable_bounds_test/02: MissingCompileTimeError # Issue 33308 -type_variable_bounds_test/03: MissingCompileTimeError # Issue 33308 -type_variable_bounds_test/04: MissingCompileTimeError # Issue 33308 -type_variable_bounds_test/05: MissingCompileTimeError # Issue 33308 -type_variable_bounds_test/06: MissingCompileTimeError # Issue 33308 -typedef_check_bounds_generic_test: MissingCompileTimeError -typedef_check_bounds_test: MissingCompileTimeError -typedef_check_bounds_unused_test: MissingCompileTimeError vm/debug_break_enabled_vm_test/01: CompileTimeError # KernelVM bug: Bad test using extended break syntax. vm/debug_break_enabled_vm_test/none: CompileTimeError # KernelVM bug: Bad test using extended break syntax. vm/regress_27201_test: CompileTimeError # Fasta/KernelVM bug: Deferred loading kernel issue 30273. @@ -614,7 +555,6 @@ instantiate_tearoff_of_call_test: CompileTimeError invocation_mirror2_test: SkipByDesign invocation_mirror_invoke_on2_test: SkipByDesign invocation_mirror_invoke_on_test: SkipByDesign -issue18628_2_test/01: MissingCompileTimeError issue21079_test: SkipByDesign issue31596_super_test/01: CompileTimeError issue31596_super_test/03: CompileTimeError @@ -1169,7 +1109,6 @@ generic_no_such_method_dispatcher_test: CompileTimeError # Issue 31533 generic_tearoff_test: CompileTimeError, RuntimeError if_null_evaluation_order_test: Pass instantiate_tearoff_of_call_test: CompileTimeError -issue18628_2_test/01: MissingCompileTimeError issue31596_super_test/01: CompileTimeError issue31596_super_test/03: CompileTimeError issue31596_super_test/05: RuntimeError @@ -1246,8 +1185,6 @@ assertion_initializer_const_error2_test/cc09: Pass # Works in --checked mode but assertion_initializer_const_error2_test/cc10: Pass # Works in --checked mode but not in --strong mode. [ $fasta && $strong ] -issue18628_2_test/01: MissingCompileTimeError -redirecting_factory_bounds_test/02: MissingCompileTimeError # Related to issue 33308 type_promotion_logical_and_test/01: MissingCompileTimeError [ $fasta && !$strong ] @@ -2073,4 +2010,3 @@ async_star_test/none: Skip # Timeout [ $compiler == dartk || $compiler == dartkb || $compiler == dartkp ] generic_function_bounds_test: RuntimeError # Issue 32076 -generic_test/01: MissingCompileTimeError diff --git a/tests/lib_2/lib_2_kernel.status b/tests/lib_2/lib_2_kernel.status index 1583199ad89..45716f42042 100644 --- a/tests/lib_2/lib_2_kernel.status +++ b/tests/lib_2/lib_2_kernel.status @@ -32,15 +32,13 @@ isolate/browser/*: Skip # TODO(ahe): Make dart:html available. js/*: Skip # TODO(ahe): Make dart:js available. [ $fasta ] +async/future_or_type_test: CompileTimeError # Issue 34626 mirrors/deferred_constraints_constants_test/default_argument2: MissingCompileTimeError -mirrors/generic_bounded_by_type_parameter_test/02: MissingCompileTimeError -mirrors/generic_bounded_test/01: MissingCompileTimeError -mirrors/generic_bounded_test/02: MissingCompileTimeError -mirrors/generic_interface_test/01: MissingCompileTimeError +mirrors/generic_f_bounded_mixin_application_test: CompileTimeError # Issue 34613 mirrors/metadata_allowed_values_test/13: MissingCompileTimeError mirrors/metadata_allowed_values_test/14: MissingCompileTimeError -mirrors/redirecting_factory_test/01: CompileTimeError # Issue 33308 -mirrors/redirecting_factory_test/none: CompileTimeError # Issue 33308 +mirrors/redirecting_factory_test/01: CompileTimeError # Issue 34714 +mirrors/redirecting_factory_test/none: CompileTimeError # Issue 34714 [ $arch == simarm64 && $strong && ($compiler == dartk || $compiler == dartkb) ] isolate/mint_maker_test: Timeout # Please triage. @@ -163,7 +161,6 @@ mirrors/function_apply_test: RuntimeError, OK mirrors/function_type_mirror_test: RuntimeError mirrors/generic_f_bounded_mixin_application_test: RuntimeError mirrors/generic_function_typedef_test: RuntimeError -mirrors/generic_interface_test/01: RuntimeError mirrors/generic_mixin_applications_test: RuntimeError mirrors/invocation_fuzz_test: RuntimeError, Crash mirrors/library_declarations_test/none: RuntimeError # Issue 31402 (Invocation arguments)