From 4880a2876e02f0764a8b4faada9f44dc1fcc80f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20von=20der=20Ahe=CC=81?= Date: Tue, 9 May 2017 09:22:55 +0200 Subject: [PATCH] Rewrite mixin application handling in Fasta. R=johnniwinther@google.com Review-Url: https://codereview.chromium.org/2862223002 . --- docs/language/dartLangSpec.tex | 10 +- .../lib/src/fasta/builder/builder.dart | 4 +- .../lib/src/fasta/builder/class_builder.dart | 54 ++- .../src/fasta/builder/modifier_builder.dart | 12 +- .../named_mixin_application_builder.dart | 44 --- .../src/fasta/builder/named_type_builder.dart | 3 +- .../builder/type_declaration_builder.dart | 2 + .../src/fasta/dill/dill_class_builder.dart | 4 + .../src/fasta/dill/dill_member_builder.dart | 7 + .../lib/src/fasta/kernel/kernel_builder.dart | 3 - .../fasta/kernel/kernel_class_builder.dart | 6 + .../fasta/kernel/kernel_library_builder.dart | 341 +++++++++++++++++- .../kernel_mixin_application_builder.dart | 78 +--- ...ernel_named_mixin_application_builder.dart | 53 --- .../lib/src/fasta/kernel/kernel_target.dart | 69 ++-- pkg/front_end/lib/src/fasta/modifier.dart | 6 +- .../lib/src/fasta/source/outline_builder.dart | 4 - .../fasta/source/source_class_builder.dart | 2 +- .../lib/src/fasta/source/source_loader.dart | 68 +++- .../testcases/mixin.dart.direct.expect | 36 +- .../testcases/mixin.dart.outline.expect | 14 +- .../rasta/class_hierarchy.dart.outline.expect | 6 +- .../duplicated_mixin.dart.outline.expect | 8 +- .../rasta/issue_000007.dart.direct.expect | 10 +- .../rasta/issue_000007.dart.outline.expect | 4 +- .../rasta/issue_000048.dart.direct.expect | 9 +- .../rasta/issue_000048.dart.outline.expect | 4 +- .../rasta/issue_000080.dart.direct.expect | 16 +- .../rasta/issue_000080.dart.outline.expect | 4 +- .../redirecting_factory.dart.outline.expect | 4 +- tests/co19/co19-kernel.status | 29 +- tests/language/language_kernel.status | 267 +++++++------- .../mixin_mixin_type_arguments_test.dart | 86 +++++ tests/lib/lib.status | 2 + 34 files changed, 790 insertions(+), 479 deletions(-) delete mode 100644 pkg/front_end/lib/src/fasta/builder/named_mixin_application_builder.dart delete mode 100644 pkg/front_end/lib/src/fasta/kernel/kernel_named_mixin_application_builder.dart create mode 100644 tests/language/mixin_mixin_type_arguments_test.dart diff --git a/docs/language/dartLangSpec.tex b/docs/language/dartLangSpec.tex index 7efe14607b8..f643ef1b4c5 100644 --- a/docs/language/dartLangSpec.tex +++ b/docs/language/dartLangSpec.tex @@ -3594,7 +3594,7 @@ If $e$ is of the form \CONST{} $T.id(a_1, \ldots , a_n, x_{n+1}: a_{n+1}, \ldots \LMHash{} In all of the above cases, it is a compile-time error if $a_i, i\in 1 .. n + k$, is not a compile-time constant expression. -%If $T$ is a parameterized type (\ref{parameterizedTypes}) $S$, let $R = S$. It is a compile-time error if $T$ is is malformed. If $T$ is not a parameterized type, let $R = T$. +%If $T$ is a parameterized type (\ref{parameterizedTypes}) $S$, let $R = S$. It is a compile-time error if $T$ is malformed. If $T$ is not a parameterized type, let $R = T$. %Finally, % If $T$ is a generic with $l$ retype parameters, then for all $ i \in 1 .. l$, let $V_i = \DYNAMIC{}$. @@ -3911,7 +3911,7 @@ If $e_f$ is a type literal, then it is equivalent to the expression $(e_f)$. The expression $(e_f)$ where $e_f$ is a type literal always evaluates to an instance of class \code{Type} which is not a function. This ensures that a runtime error occurs when trying to call a type literal. } -If $e_f$ is a property extraction expression (\ref{propertyExtraction}), then $i$ is is not a function expression invocation and is instead recognized as an ordinary method invocation (\ref{ordinaryInvocation}). +If $e_f$ is a property extraction expression (\ref{propertyExtraction}), then $i$ isn't a function expression invocation and is instead recognized as an ordinary method invocation (\ref{ordinaryInvocation}). \commentary{ \code{$a.b(x)$} is parsed as a method invocation of method \code{$b()$} on object \code{$a$}, not as an invocation of getter \code{$b$} on \code{$a$} followed by a function call \code{$(a.b)(x)$}. If a method or getter \code{$b$} exists, the two will be equivalent. However, if \code{$b$} is not defined on \code{$a$}, the resulting invocation of \code{noSuchMethod()} would differ. The \code{Invocation} passed to \code{noSuchMethod()} would describe a call to a method \code{$b$} with argument \code{$x$} in the former case, and a call to a getter \code{$b$} (with no arguments) in the latter. @@ -6886,7 +6886,7 @@ If $I$ is a deferred import, no evaluation takes place. Instead, a mapping of th The deferred prefix object has the following methods: \begin{itemize} -\item \code{loadLibrary}. This method returns a future $f$. When called, the method causes an immediate import $I'$ to be executed at some future time, where $I'$ is is derived from $I$ by eliding the word \DEFERRED{} and adding a \HIDE{} \code{loadLibrary} combinator clause. When $I'$ executes without error, $f$ completes successfully. If $I'$ executes without error, we say that the call to \code{loadLibrary} has succeeded, otherwise we say the call has failed. +\item \code{loadLibrary}. This method returns a future $f$. When called, the method causes an immediate import $I'$ to be executed at some future time, where $I'$ is derived from $I$ by eliding the word \DEFERRED{} and adding a \HIDE{} \code{loadLibrary} combinator clause. When $I'$ executes without error, $f$ completes successfully. If $I'$ executes without error, we say that the call to \code{loadLibrary} has succeeded, otherwise we say the call has failed. \item For every top level function $f$ named $id$ in the imported library $B$, a corresponding method named $id$ with the same signature as $f$. Calling the method results in a runtime error. \item For every top level getter $g$ named $id$ in $B$, a corresponding getter named $id$ with the same signature as $g$. Calling the method results in a runtime error. \item For every top level setter $s$ named $id$ in $B$, a corresponding setter named $id$ with the same signature as $s$. Calling the method results in a runtime error. @@ -7441,7 +7441,9 @@ A {\em type alias} declares a name for a type expression. \end{grammar} \LMHash{} - The effect of a type alias of the form \code{\TYPEDEF{} $T$ $id (T_1$ $p_1, \ldots, T_n$ $p_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}])$} declared in a library $L$ is is to introduce the name $id$ into the scope of $L$, bound to the function type $(T_1, \ldots, T_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}]) \rightarrow T$. The effect of a type alias of the form \code{\TYPEDEF{} $T$ $id (T_1$ $p_1, \ldots, T_n$ $p_n, \{T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}\})$} declared in a library $L$ is is to introduce the name $id$ into the scope of $L$, bound to the function type $(T_1, \ldots, T_n, \{T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}\}) \rightarrow T$. . In either case, iff no return type is specified, it is taken to be \DYNAMIC{}. Likewise, if a type annotation is omitted on a formal parameter, it is taken to be \DYNAMIC{}. + The effect of a type alias of the form \code{\TYPEDEF{} $T$ $id (T_1$ $p_1, \ldots, T_n$ $p_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}])$} declared in a library $L$ is to introduce the name $id$ into the scope of $L$, bound to the function type $(T_1, \ldots, T_n, [T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}]) \rightarrow T$. +The effect of a type alias of the form \code{\TYPEDEF{} $T$ $id (T_1$ $p_1, \ldots, T_n$ $p_n, \{T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}\})$} declared in a library $L$ is to introduce the name $id$ into the scope of $L$, bound to the function type $(T_1, \ldots, T_n, \{T_{n+1}$ $p_{n+1}, \ldots, T_{n+k}$ $p_{n+k}\}) \rightarrow T$. +In either case, iff no return type is specified, it is taken to be \DYNAMIC{}. Likewise, if a type annotation is omitted on a formal parameter, it is taken to be \DYNAMIC{}. \LMHash{} It is a compile-time error if any default values are specified in the signature of a function type alias. diff --git a/pkg/front_end/lib/src/fasta/builder/builder.dart b/pkg/front_end/lib/src/fasta/builder/builder.dart index 90e4ffda163..dffdfec22bc 100644 --- a/pkg/front_end/lib/src/fasta/builder/builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/builder.dart @@ -24,8 +24,6 @@ export 'type_variable_builder.dart' show TypeVariableBuilder; export 'function_type_alias_builder.dart' show FunctionTypeAliasBuilder; -export 'named_mixin_application_builder.dart' show NamedMixinApplicationBuilder; - export 'mixin_application_builder.dart' show MixinApplicationBuilder; export 'enum_builder.dart' show EnumBuilder; @@ -124,6 +122,8 @@ abstract class Builder { bool get isConst => false; + bool get isSynthetic => false; + get target => internalError("Unsupported operation $runtimeType."); bool get hasProblem => false; diff --git a/pkg/front_end/lib/src/fasta/builder/class_builder.dart b/pkg/front_end/lib/src/fasta/builder/class_builder.dart index 6cbecb53381..26f5db8f392 100644 --- a/pkg/front_end/lib/src/fasta/builder/class_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/class_builder.dart @@ -56,8 +56,14 @@ abstract class ClassBuilder /// superclass. bool get isMixinApplication => mixedInType != null; + bool get isNamedMixinApplication { + return isMixinApplication && super.isNamedMixinApplication; + } + T get mixedInType; + void set mixedInType(T mixin); + List get constructorReferences => null; LibraryBuilder get library { @@ -115,30 +121,52 @@ abstract class ClassBuilder List arguments; List variables; Builder builder; - while (builder != superclass) { - if (supertype is NamedTypeBuilder) { - NamedTypeBuilder t = supertype; - builder = t.builder; - arguments = t.arguments; - if (builder is ClassBuilder) { - variables = builder.typeVariables; - if (builder != superclass) { - supertype = builder.supertype; - } + + /// If [application] is mixing in [superclass] directly or via other named + /// mixin applications, return it. + NamedTypeBuilder findSuperclass(MixinApplicationBuilder application) { + for (TypeBuilder t in application.mixins) { + if (t is NamedTypeBuilder) { + if (t.builder == superclass) return t; + } else if (t is MixinApplicationBuilder) { + NamedTypeBuilder s = findSuperclass(t); + if (s != null) return s; } + } + return null; + } + + void handleNamedTypeBuilder(NamedTypeBuilder t) { + builder = t.builder; + arguments = t.arguments ?? const []; + if (builder is ClassBuilder) { + ClassBuilder cls = builder; + variables = cls.typeVariables; + supertype = cls.supertype; + } + } + + while (builder != superclass) { + variables = null; + if (supertype is NamedTypeBuilder) { + handleNamedTypeBuilder(supertype); } else if (supertype is MixinApplicationBuilder) { MixinApplicationBuilder t = supertype; + NamedTypeBuilder s = findSuperclass(t); + if (s != null) { + handleNamedTypeBuilder(s); + } supertype = t.supertype; } else { - internalError("Superclass not found.", fileUri, charOffset); + internalError("Superclass not found '${superclass.fullNameForErrors}'.", + fileUri, charOffset); } if (variables != null) { Map directSubstitutionMap = {}; - arguments ??= const []; for (int i = 0; i < variables.length; i++) { TypeBuilder argument = - arguments.length < i ? arguments[i] : dynamicType; + i < arguments.length ? arguments[i] : dynamicType; if (substitutionMap != null) { argument = argument.subst(substitutionMap); } diff --git a/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart b/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart index d03aa446e0e..2efe75377ad 100644 --- a/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/modifier_builder.dart @@ -5,7 +5,13 @@ library fasta.modifier_builder; import '../modifier.dart' - show abstractMask, constMask, externalMask, finalMask, staticMask; + show + abstractMask, + constMask, + externalMask, + finalMask, + namedMixinApplicationMask, + staticMask; import 'builder.dart' show Builder; @@ -26,4 +32,8 @@ abstract class ModifierBuilder extends Builder { bool get isFinal => (modifiers & finalMask) != 0; bool get isStatic => (modifiers & staticMask) != 0; + + bool get isNamedMixinApplication { + return (modifiers & namedMixinApplicationMask) != 0; + } } diff --git a/pkg/front_end/lib/src/fasta/builder/named_mixin_application_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_mixin_application_builder.dart deleted file mode 100644 index 3fff6d28595..00000000000 --- a/pkg/front_end/lib/src/fasta/builder/named_mixin_application_builder.dart +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library fasta.named_mixin_application_builder; - -import 'builder.dart' - show - ClassBuilder, - LibraryBuilder, - MemberBuilder, - MetadataBuilder, - Scope, - TypeBuilder, - TypeVariableBuilder; - -abstract class NamedMixinApplicationBuilder - extends ClassBuilder { - NamedMixinApplicationBuilder( - List metadata, - String name, - List typeVariables, - int modifiers, - T supertype, - List interfaces, - LibraryBuilder parent, - int charOffset) - : super( - metadata, - modifiers, - name, - typeVariables, - supertype, - interfaces, - new Scope({}, {}, - parent.scope.withTypeVariables(typeVariables), - isModifiable: false), - new Scope({}, null, null, - isModifiable: false), - parent, - charOffset); - - T get mixinApplication => supertype; -} diff --git a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart index 9c302758aa9..62a65df3f4c 100644 --- a/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/named_type_builder.dart @@ -30,6 +30,7 @@ abstract class NamedTypeBuilder extends TypeBuilder { } void resolveIn(Scope scope) { + if (builder != null) return; Builder member = scope.lookup(name, charOffset, fileUri); if (member is TypeDeclarationBuilder) { builder = member; @@ -55,7 +56,7 @@ abstract class NamedTypeBuilder extends TypeBuilder { StringBuffer printOn(StringBuffer buffer) { buffer.write(name); - if (arguments == null) return buffer; + if (arguments?.isEmpty ?? true) return buffer; buffer.write("<"); bool first = true; for (T t in arguments) { diff --git a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart index 230abc7f1a8..59de1cfa09c 100644 --- a/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/type_declaration_builder.dart @@ -32,6 +32,8 @@ abstract class TypeDeclarationBuilder bool get isTypeDeclaration => true; + bool get isMixinApplication => false; + R buildType(LibraryBuilder library, List arguments); /// [arguments] have already been built. diff --git a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart index 52eb599699b..123f079e1ca 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_class_builder.dart @@ -53,6 +53,10 @@ class DillClassBuilder extends KernelClassBuilder { bool get isMixinApplication => cls.isMixinApplication; KernelTypeBuilder get mixedInType => internalError("Not implemented."); + + void set mixedInType(KernelTypeBuilder mixin) { + internalError("Not implemented."); + } } int computeModifiers(Class cls) { diff --git a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart index 1c666068d43..688738807d9 100644 --- a/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart +++ b/pkg/front_end/lib/src/fasta/dill/dill_member_builder.dart @@ -53,6 +53,13 @@ class DillMemberBuilder extends MemberBuilder { return isConstructor && isRedirectingGenerativeConstructorImplementation(member); } + + bool get isSynthetic { + // TODO(ahe): Kernel should eventually support a synthetic bit. + return isConstructor && + name == "" && + (charOffset == parent.charOffset || charOffset == -1); + } } int computeModifiers(Member member) { diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_builder.dart index e84f7de75c6..e2111dcb1c6 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_builder.dart @@ -24,9 +24,6 @@ export 'kernel_library_builder.dart' show KernelLibraryBuilder; export 'kernel_mixin_application_builder.dart' show KernelMixinApplicationBuilder; -export 'kernel_named_mixin_application_builder.dart' - show KernelNamedMixinApplicationBuilder; - export 'kernel_procedure_builder.dart' show KernelConstructorBuilder, 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 b81da23bd02..c334fa203b3 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 @@ -272,4 +272,10 @@ abstract class KernelClassBuilder } } } + + String get fullNameForErrors { + return isMixinApplication + ? "${supertype.fullNameForErrors} with ${mixedInType.fullNameForErrors}" + : name; + } } 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 1cecfe5d279..64739bd3bd3 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 @@ -14,7 +14,8 @@ import '../errors.dart' show internalError; import '../loader.dart' show Loader; -import '../modifier.dart' show abstractMask, staticMask; +import '../modifier.dart' + show abstractMask, namedMixinApplicationMask, staticMask; import '../source/source_library_builder.dart' show DeclarationBuilder, SourceLibraryBuilder; @@ -41,7 +42,6 @@ import 'kernel_builder.dart' KernelFunctionTypeBuilder, KernelInvalidTypeBuilder, KernelMixinApplicationBuilder, - KernelNamedMixinApplicationBuilder, KernelNamedTypeBuilder, KernelProcedureBuilder, KernelTypeBuilder, @@ -49,7 +49,7 @@ import 'kernel_builder.dart' LibraryBuilder, MemberBuilder, MetadataBuilder, - NamedMixinApplicationBuilder, + NamedTypeBuilder, PrefixBuilder, ProcedureBuilder, Scope, @@ -104,10 +104,12 @@ class KernelLibraryBuilder KernelTypeBuilder supertype, List interfaces, int charOffset) { - assert(currentDeclaration.parent == libraryDeclaration); - Map members = currentDeclaration.members; - Map constructors = currentDeclaration.constructors; - Map setters = currentDeclaration.setters; + // Nested declaration began in `OutlineBuilder.beginClassDeclaration`. + var declaration = endNestedDeclaration()..resolveTypes(typeVariables, this); + assert(declaration.parent == libraryDeclaration); + Map members = declaration.members; + Map constructors = declaration.constructors; + Map setters = declaration.setters; Scope classScope = new Scope( members, setters, scope.withTypeVariables(typeVariables), @@ -122,7 +124,8 @@ class KernelLibraryBuilder modifiers, className, typeVariables, - supertype, + applyMixins(supertype, + subclassName: className, typeVariables: typeVariables), interfaces, classScope, constructorScope, @@ -130,6 +133,8 @@ class KernelLibraryBuilder new List.from(constructorReferences), charOffset); constructorReferences.clear(); + Map typeVariablesByName = + checkTypeVariables(typeVariables, cls); void setParent(String name, MemberBuilder member) { while (member != null) { member.parent = cls; @@ -137,14 +142,305 @@ class KernelLibraryBuilder } } - members.forEach(setParent); - constructors.forEach(setParent); + void setParentAndCheckConflicts(String name, MemberBuilder member) { + if (typeVariablesByName != null) { + TypeVariableBuilder tv = typeVariablesByName[name]; + if (tv != null) { + cls.addCompileTimeError( + member.charOffset, "Conflict with type variable '$name'."); + cls.addCompileTimeError(tv.charOffset, "This is the type variable."); + } + } + setParent(name, member); + } + + members.forEach(setParentAndCheckConflicts); + constructors.forEach(setParentAndCheckConflicts); + // Formally, a setter has the name `id=`, so it can never conflict with a + // type variable. setters.forEach(setParent); - // Nested declaration began in `OutlineBuilder.beginClassDeclaration`. - endNestedDeclaration().resolveTypes(typeVariables, this); addBuilder(className, cls, charOffset); } + Map checkTypeVariables( + List typeVariables, Builder owner) { + if (typeVariables?.isEmpty ?? true) return null; + Map typeVariablesByName = + {}; + for (TypeVariableBuilder tv in typeVariables) { + TypeVariableBuilder existing = typeVariablesByName[tv.name]; + if (existing != null) { + addCompileTimeError(tv.charOffset, + "A type variable can't have the same name as another."); + addCompileTimeError( + existing.charOffset, "The other type variable named '${tv.name}'."); + } else { + typeVariablesByName[tv.name] = tv; + if (owner is ClassBuilder) { + // Only classes and type variables can't have the same name. See + // [#29555](https://github.com/dart-lang/sdk/issues/29555). + if (tv.name == owner.name) { + addCompileTimeError( + tv.charOffset, + "A type variable can't have the same name as its enclosing " + "declaration."); + } + } + } + } + return typeVariablesByName; + } + + KernelTypeBuilder applyMixin( + KernelTypeBuilder supertype, KernelTypeBuilder mixin, String signature, + {List metadata, + String name, + List typeVariables, + int modifiers: abstractMask, + List interfaces, + int charOffset: -1}) { + var constructors = {}; + bool isNamed = name != null; + SourceClassBuilder builder; + if (isNamed) { + modifiers |= namedMixinApplicationMask; + } else { + name = supertype.name; + int index = name.indexOf("^"); + if (index != -1) { + name = name.substring(0, index); + } + name = "$name&${mixin.name}$signature"; + builder = mixinApplicationClasses[name]; + } + if (builder == null) { + builder = new SourceClassBuilder( + metadata, + modifiers, + name, + typeVariables, + supertype, + interfaces, + new Scope({}, {}, + scope.withTypeVariables(typeVariables), + isModifiable: false), + new Scope(constructors, null, null, isModifiable: false), + this, + [], + charOffset, + null, + mixin); + addBuilder(name, builder, charOffset); + if (!isNamed) { + mixinApplicationClasses[name] = builder; + } + } + return addNamedType(name, [], charOffset) + ..bind(isNamed ? builder : null); + } + + KernelTypeBuilder applyMixins(KernelTypeBuilder type, + {List metadata, + String name, + String subclassName, + List typeVariables, + int modifiers: abstractMask, + List interfaces, + int charOffset: -1}) { + if (type is KernelMixinApplicationBuilder) { + subclassName ??= name; + List> signatureParts = >[]; + Map unresolved = {}; + Map unresolvedReversed = {}; + int unresolvedCount = 0; + Map freeTypes = {}; + + if (name == null || type.mixins.length != 1) { + TypeBuilder last = type.mixins.last; + + /// Compute a signature of the type arguments used by the supertype and + /// mixins. These types are free variables. At this point we can't + /// trust that the number of type arguments match the type parameters, + /// so we also need to be able to detect missing type arguments. To do + /// so, we separate each list of type arguments by `^` and type + /// arguments by `&`. For example, the mixin `C with M` would + /// look like this: + /// + /// ^#U0^#U1&#U2 + /// + /// Where `#U0`, `#U1`, and `#U2` are the free variables arising from + /// `S`, `T`, and `U` respectively. + /// + /// As we can resolve any type parameters used at this point, those are + /// named `#T0` and so forth. This reduces the number of free variables + /// which is crucial for memory usage and the Dart VM's bootstrap + /// sequence. + /// + /// For example, consider this use of mixin applications: + /// + /// class _InternalLinkedHashMap extends _HashVMBase + /// with + /// MapMixin, + /// _LinkedHashMapMixin, + /// _HashBase, + /// _OperatorEqualsAndHashCode {} + /// + /// In this case, only two variables are free, and we produce this + /// signature: `^^#T0&#T1^#T0&#T1^^`. Assume another class uses the + /// sames mixins but with missing type arguments for `MapMixin`, its + /// signature would be: `^^^#T0&#T1^^`. + /// + /// Note that we do not need to compute a signature for a named mixin + /// application with only one mixin as we don't have to invent a name + /// for any classes in this situation. + void analyzeArguments(TypeBuilder type) { + if (name != null && type == last) { + // The last mixin of a named mixin application doesn't contribute + // to free variables. + return; + } + if (type is NamedTypeBuilder) { + List part = []; + for (int i = 0; i < (type.arguments?.length ?? 0); i++) { + var argument = type.arguments[i]; + String name; + if (argument is NamedTypeBuilder) { + if (argument.builder != null) { + int index = typeVariables?.indexOf(argument.builder) ?? -1; + if (index != -1) { + name = "#T${index}"; + } + } else if (argument.arguments == null) { + name = unresolved[argument.name] ??= "#U${unresolvedCount++}"; + } + } + name ??= "#U${unresolvedCount++}"; + unresolvedReversed[name] = argument.name; + freeTypes[name] = argument; + part.add(name); + type.arguments[i] = + new KernelNamedTypeBuilder(name, null, -1, fileUri); + } + signatureParts.add(part); + } + } + + analyzeArguments(type.supertype); + type.mixins.forEach(analyzeArguments); + } + KernelTypeBuilder supertype = type.supertype; + List> currentSignatureParts = >[]; + int currentSignatureCount = 0; + String computeSignature() { + if (freeTypes.isEmpty) return ""; + currentSignatureParts.add(signatureParts[currentSignatureCount++]); + if (currentSignatureParts.any((l) => l.isNotEmpty)) { + return "^${currentSignatureParts.map((l) => l.join('&')).join('^')}"; + } else { + return ""; + } + } + + Map computeTypeVariables() { + Map variables = + {}; + for (List strings in currentSignatureParts) { + for (String name in strings) { + variables[name] ??= addTypeVariable(name, null, -1); + } + } + return variables; + } + + checkArguments(t) { + for (var argument in t.arguments ?? const []) { + if (argument.builder == null && argument.name.startsWith("#")) { + throw "No builder on ${argument.name}"; + } + } + } + + computeSignature(); // This combines the supertype with the first mixin. + for (int i = 0; i < type.mixins.length - 1; i++) { + Set supertypeArguments = new Set(); + for (var part in currentSignatureParts) { + supertypeArguments.addAll(part); + } + String signature = computeSignature(); + var variables = computeTypeVariables(); + if (supertypeArguments.isNotEmpty) { + supertype = addNamedType( + supertype.name, + supertypeArguments + .map((n) => addNamedType(n, null, -1)..bind(variables[n])) + .toList(), + -1); + } + KernelNamedTypeBuilder mixin = type.mixins[i]; + for (var type in mixin.arguments ?? const []) { + type.bind(variables[type.name]); + } + checkArguments(supertype); + checkArguments(mixin); + supertype = applyMixin(supertype, mixin, signature, + typeVariables: + new List.from(variables.values)); + } + KernelNamedTypeBuilder mixin = type.mixins.last; + + Set supertypeArguments = new Set(); + for (var part in currentSignatureParts) { + supertypeArguments.addAll(part); + } + String signature = name == null ? computeSignature() : ""; + var variables; + if (name == null) { + variables = computeTypeVariables(); + typeVariables = new List.from(variables.values); + if (supertypeArguments.isNotEmpty) { + supertype = addNamedType( + supertype.name, + supertypeArguments + .map((n) => addNamedType(n, null, -1)..bind(variables[n])) + .toList(), + -1); + } + } else { + if (supertypeArguments.isNotEmpty) { + supertype = addNamedType(supertype.name, + supertypeArguments.map((n) => freeTypes[n]).toList(), -1); + } + } + + if (name == null) { + for (var type in mixin.arguments ?? const []) { + type.bind(variables[type.name]); + } + } + checkArguments(supertype); + checkArguments(mixin); + + KernelNamedTypeBuilder t = applyMixin(supertype, mixin, signature, + metadata: metadata, + name: name, + typeVariables: typeVariables, + modifiers: modifiers, + interfaces: interfaces, + charOffset: charOffset); + if (name == null) { + var builder = t.builder; + t = addNamedType( + t.name, freeTypes.keys.map((k) => freeTypes[k]).toList(), -1); + if (builder != null) { + t.bind(builder); + } + } + return t; + } else { + return type; + } + } + void addNamedMixinApplication( List metadata, String name, @@ -153,12 +449,16 @@ class KernelLibraryBuilder KernelTypeBuilder mixinApplication, List interfaces, int charOffset) { - NamedMixinApplicationBuilder builder = - new KernelNamedMixinApplicationBuilder(metadata, name, typeVariables, - modifiers, mixinApplication, interfaces, this, charOffset); // Nested declaration began in `OutlineBuilder.beginNamedMixinApplication`. endNestedDeclaration().resolveTypes(typeVariables, this); - addBuilder(name, builder, charOffset); + KernelNamedTypeBuilder supertype = applyMixins(mixinApplication, + metadata: metadata, + name: name, + typeVariables: typeVariables, + modifiers: modifiers, + interfaces: interfaces, + charOffset: charOffset); + checkTypeVariables(typeVariables, supertype.builder); } void addField(List metadata, int modifiers, @@ -542,9 +842,16 @@ class KernelLibraryBuilder @override void includePart(covariant KernelLibraryBuilder part) { + part.mixinApplicationClasses + .forEach((String name, SourceClassBuilder builder) { + SourceClassBuilder existing = + mixinApplicationClasses.putIfAbsent(name, () => builder); + if (existing != builder) { + part.scope.local.remove(name); + } + }); super.includePart(part); nativeMethods.addAll(part.nativeMethods); boundlessTypeVariables.addAll(part.boundlessTypeVariables); - assert(mixinApplicationClasses.isEmpty); } } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_mixin_application_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_mixin_application_builder.dart index 9c46ba8cda3..1978c66b745 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_mixin_application_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_mixin_application_builder.dart @@ -4,26 +4,18 @@ library fasta.kernel_mixin_application_builder; -import 'package:kernel/ast.dart' show InterfaceType, Supertype, setParents; +import 'package:kernel/ast.dart' show InterfaceType, Supertype; -import '../modifier.dart' show abstractMask; - -import '../source/source_class_builder.dart' show SourceClassBuilder; +import '../errors.dart' show internalError; import '../util/relativize.dart' show relativizeUri; import 'kernel_builder.dart' show - ConstructorReferenceBuilder, KernelLibraryBuilder, - KernelNamedTypeBuilder, KernelTypeBuilder, - KernelTypeVariableBuilder, LibraryBuilder, - MemberBuilder, MixinApplicationBuilder, - Scope, - TypeBuilder, TypeVariableBuilder; class KernelMixinApplicationBuilder @@ -48,72 +40,10 @@ class KernelMixinApplicationBuilder super(supertype, mixins, charOffset, fileUri); InterfaceType build(LibraryBuilder library) { - return buildSupertype(library)?.asInterfaceType; + return internalError("Unsupported operation."); } Supertype buildSupertype(LibraryBuilder library) { - if (builtType != null) return builtType; - KernelTypeBuilder s = this.supertype; - for (KernelTypeBuilder builder in mixins) { - s = applyMixin(s, builder); - } - builtType = s.buildSupertype(library); - return builtType; - } - - TypeBuilder applyMixin(TypeBuilder supertype, TypeBuilder mixin) { - KernelLibraryBuilder library = this.library.partOfLibrary ?? this.library; - List typeArguments; - List newTypeVariables; - if (typeVariables != null) { - assert(subclassName != null); - newTypeVariables = library.copyTypeVariables(typeVariables); - Map substitution = - {}; - typeArguments = []; - for (int i = 0; i < typeVariables.length; i++) { - substitution[typeVariables[i]] = newTypeVariables[i].asTypeBuilder(); - typeArguments.add(typeVariables[i].asTypeBuilder()); - } - supertype = supertype.subst(substitution); - mixin = mixin.subst(substitution); - } - // To reduce diff against dartk, we create a different name for mixin - // applications that have free type variables. We do this by setting - // [subclassName] when setting typeVariables. - String name = subclassName != null - ? "${subclassName}^${mixin.name}" - : "${supertype.name}&${mixin.name}"; - - SourceClassBuilder cls = - library.mixinApplicationClasses.putIfAbsent(name, () { - SourceClassBuilder cls = new SourceClassBuilder( - null, - abstractMask, - name, - newTypeVariables, - supertype, - null, - new Scope({}, {}, - library.scope.withTypeVariables(newTypeVariables), - isModifiable: false), - new Scope({}, null, null, isModifiable: false), - library, - [], - charOffset, - null, - mixin); - library.addImplementationBuilder(name, cls, charOffset); - if (newTypeVariables != null) { - for (KernelTypeVariableBuilder t in newTypeVariables) { - cls.cls.typeParameters.add(t.parameter); - } - setParents(cls.cls.typeParameters, cls.cls); - } - return cls; - }); - return new KernelNamedTypeBuilder( - name, typeArguments, charOffset, library.fileUri) - ..builder = cls; + return internalError("Unsupported operation."); } } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_named_mixin_application_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_named_mixin_application_builder.dart deleted file mode 100644 index 5ad745e157c..00000000000 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_named_mixin_application_builder.dart +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -library fasta.kernel_named_mixin_application_builder; - -import 'package:kernel/ast.dart' show InterfaceType; - -import '../source/source_class_builder.dart' show SourceClassBuilder; - -import 'kernel_builder.dart' - show - KernelTypeBuilder, - LibraryBuilder, - MemberBuilder, - MetadataBuilder, - NamedMixinApplicationBuilder, - Scope, - TypeVariableBuilder; - -class KernelNamedMixinApplicationBuilder extends SourceClassBuilder - implements NamedMixinApplicationBuilder { - KernelNamedMixinApplicationBuilder( - List metadata, - String name, - List typeVariables, - int modifiers, - KernelTypeBuilder mixinApplication, - List interfaces, - LibraryBuilder parent, - int charOffset) - : super( - metadata, - modifiers, - name, - typeVariables, - mixinApplication, - interfaces, - new Scope({}, {}, - parent.scope.withTypeVariables(typeVariables), - isModifiable: false), - new Scope({}, null, null, - isModifiable: false), - parent, - null, - charOffset); - - KernelTypeBuilder get mixinApplication => supertype; - - // TODO(ahe): This is a bit odd, as it means this answers false to - // [isMixinApplication], but its superclass is the mixin application. - KernelTypeBuilder get mixedInType => null; -} 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 ea33e1870e7..fbb3a9abfbd 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart @@ -81,10 +81,9 @@ import 'kernel_builder.dart' KernelProcedureBuilder, LibraryBuilder, MemberBuilder, - MixinApplicationBuilder, - NamedMixinApplicationBuilder, NamedTypeBuilder, TypeBuilder, + TypeDeclarationBuilder, TypeVariableBuilder; import 'verifier.dart' show verifyProgram; @@ -148,33 +147,34 @@ class KernelTarget extends TargetImplementation { return new KernelLibraryBuilder(uri, fileUri, loader); } - void addDirectSupertype(ClassBuilder cls, Set set) { - if (cls == null) return; + void forEachDirectSupertype(ClassBuilder cls, void f(NamedTypeBuilder type)) { TypeBuilder supertype = cls.supertype; - add(NamedTypeBuilder type) { - Builder builder = type.builder; - if (builder is ClassBuilder) { - set.add(builder); - } - } - - if (supertype == null) { - // OK. - } else if (supertype is MixinApplicationBuilder) { - add(supertype.supertype); - for (NamedTypeBuilder t in supertype.mixins) { - add(t); - } - } else if (supertype is NamedTypeBuilder) { - add(supertype); - } else { + if (supertype is NamedTypeBuilder) { + f(supertype); + } else if (supertype != null) { internalError("Unhandled: ${supertype.runtimeType}"); } if (cls.interfaces != null) { for (NamedTypeBuilder t in cls.interfaces) { - add(t); + f(t); } } + if (cls.library.loader == loader && + // TODO(ahe): Implement DillClassBuilder.mixedInType and remove the + // above check. + cls.mixedInType != null) { + f(cls.mixedInType); + } + } + + void addDirectSupertype(ClassBuilder cls, Set set) { + if (cls == null) return; + forEachDirectSupertype(cls, (NamedTypeBuilder type) { + Builder builder = type.builder; + if (builder is ClassBuilder) { + set.add(builder); + } + }); } List collectAllClasses() { @@ -214,6 +214,7 @@ class KernelTarget extends TargetImplementation { builder.charOffset, builder.fileUri ?? Uri.parse(cls.fileUri)) ..builder = objectClassBuilder; builder.interfaces = null; + builder.mixedInType = null; } Future handleInputError(Uri uri, InputError error, @@ -240,8 +241,8 @@ class KernelTarget extends TargetImplementation { loader.resolveParts(); loader.computeLibraryScopes(); loader.resolveTypes(); - loader.buildProgram(); loader.checkSemantics(); + loader.buildProgram(); List sourceClasses = collectAllSourceClasses(); installDefaultSupertypes(); installDefaultConstructors(sourceClasses); @@ -447,19 +448,13 @@ class KernelTarget extends TargetImplementation { /// If [builder] doesn't have a constructors, install the defaults. void installDefaultConstructor(SourceClassBuilder builder) { - if (builder.cls.isMixinApplication) { - // We have to test if builder.cls is a mixin application. [builder] may - // think it's a mixin application, but if its mixed-in type couldn't be - // resolved, the target class won't be a mixin application and we need - // to add a default constructor to complete error recovery. - return; - } + if (builder.isMixinApplication && !builder.isNamedMixinApplication) return; if (builder.constructors.local.isNotEmpty) return; /// Quotes below are from [Dart Programming Language Specification, 4th /// Edition]( /// https://ecma-international.org/publications/files/ECMA-ST/ECMA-408.pdf): - if (builder is NamedMixinApplicationBuilder) { + if (builder.isNamedMixinApplication) { /// >A mixin application of the form S with M; defines a class C with /// >superclass S. /// >... @@ -469,14 +464,10 @@ class KernelTarget extends TargetImplementation { /// >that is accessible to LM , C has an implicitly declared constructor /// >named q'i = [C/S]qi of the form q'i(ai1,...,aiki) : /// >super(ai1,...,aiki);. - Builder supertype = builder; - while (supertype is NamedMixinApplicationBuilder) { - NamedMixinApplicationBuilder named = supertype; - TypeBuilder type = named.mixinApplication; - if (type is MixinApplicationBuilder) { - MixinApplicationBuilder t = type; - type = t.supertype; - } + TypeDeclarationBuilder supertype = builder; + while (supertype.isMixinApplication) { + SourceClassBuilder named = supertype; + TypeBuilder type = named.supertype; if (type is NamedTypeBuilder) { supertype = type.builder; } else { diff --git a/pkg/front_end/lib/src/fasta/modifier.dart b/pkg/front_end/lib/src/fasta/modifier.dart index ff895e8039d..ac6fce6f393 100644 --- a/pkg/front_end/lib/src/fasta/modifier.dart +++ b/pkg/front_end/lib/src/fasta/modifier.dart @@ -27,8 +27,10 @@ const int finalMask = externalMask << 1; const int staticMask = finalMask << 1; -/// Not a real modifier, and by setting it to null, it is automatically -/// ignored by [Modifier.validate] below. +const int namedMixinApplicationMask = staticMask << 1; + +/// Not a real modifier, and by setting it to zero, it is automatically ignored +/// by [Modifier.validate] below. const int varMask = 0; const Modifier Abstract = const Modifier(ModifierEnum.Abstract, abstractMask); diff --git a/pkg/front_end/lib/src/fasta/source/outline_builder.dart b/pkg/front_end/lib/src/fasta/source/outline_builder.dart index 930766550c6..4cffd0ea693 100644 --- a/pkg/front_end/lib/src/fasta/source/outline_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/outline_builder.dart @@ -436,10 +436,6 @@ class OutlineBuilder extends UnhandledListener { List typeVariables = pop(); int charOffset = pop(); String name = pop(); - if (typeVariables != null && mixinApplication is MixinApplicationBuilder) { - mixinApplication.typeVariables = typeVariables; - mixinApplication.subclassName = name; - } int modifiers = Modifier.validate(pop()); List metadata = pop(); library.addNamedMixinApplication(metadata, name, typeVariables, modifiers, diff --git a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart index 9f1ef765d35..7b6c27af767 100644 --- a/pkg/front_end/lib/src/fasta/source/source_class_builder.dart +++ b/pkg/front_end/lib/src/fasta/source/source_class_builder.dart @@ -50,7 +50,7 @@ class SourceClassBuilder extends KernelClassBuilder { final List constructorReferences; - final KernelTypeBuilder mixedInType; + KernelTypeBuilder mixedInType; SourceClassBuilder( List metadata, 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 a83e6bb3d7a..47a43b20de1 100644 --- a/pkg/front_end/lib/src/fasta/source/source_loader.dart +++ b/pkg/front_end/lib/src/fasta/source/source_loader.dart @@ -31,7 +31,14 @@ import 'package:kernel/class_hierarchy.dart' show ClassHierarchy; import 'package:kernel/core_types.dart' show CoreTypes; -import '../builder/builder.dart' show Builder, ClassBuilder, LibraryBuilder; +import '../builder/builder.dart' + show + Builder, + ClassBuilder, + EnumBuilder, + LibraryBuilder, + NamedTypeBuilder, + TypeBuilder; import '../compiler_context.dart' show CompilerContext; @@ -358,13 +365,68 @@ class SourceLoader extends Loader { reported.add(cls); } } + String involvedString = + involved.map((c) => c.fullNameForErrors).join("', '"); cls.addCompileTimeError( cls.charOffset, - "'${cls.name}' is a supertype of " - "itself via '${involved.map((c) => c.name).join(' ')}'."); + "'${cls.fullNameForErrors}' is a supertype of itself via " + "'$involvedString'."); } }); ticker.logMs("Found cycles"); + Set blackListedClasses = new Set.from([ + coreLibrary["bool"], + coreLibrary["int"], + coreLibrary["num"], + coreLibrary["double"], + coreLibrary["String"], + ]); + for (ClassBuilder cls in allClasses) { + if (cls.library.loader != this) continue; + Set directSupertypes = new Set(); + target.addDirectSupertype(cls, directSupertypes); + for (ClassBuilder supertype in directSupertypes) { + if (supertype is EnumBuilder) { + cls.addCompileTimeError( + cls.charOffset, + "'${supertype.name}' is an enum and can't be extended or " + "implemented."); + } else if (cls.library != coreLibrary && + blackListedClasses.contains(supertype)) { + cls.addCompileTimeError( + cls.charOffset, + "'${supertype.name}' is restricted and can't be extended or " + "implemented."); + } + } + TypeBuilder mixedInType = cls.mixedInType; + if (mixedInType != null) { + bool isClassBuilder = false; + if (mixedInType is NamedTypeBuilder) { + var builder = mixedInType.builder; + if (builder is ClassBuilder) { + isClassBuilder = true; + for (Builder constructory in builder.constructors.local.values) { + if (constructory.isConstructor && !constructory.isSynthetic) { + cls.addCompileTimeError( + cls.charOffset, + "Can't use '${builder.fullNameForErrors}' as a mixin " + "because it has constructors."); + builder.addCompileTimeError( + constructory.charOffset, + "This constructor prevents using " + "'${builder.fullNameForErrors}' as a mixin."); + } + } + } + } + if (!isClassBuilder) { + cls.addCompileTimeError(cls.charOffset, + "The type '${mixedInType.fullNameForErrors}' can't be mixed in."); + } + } + } + ticker.logMs("Checked restricted supertypes"); } void buildProgram() { diff --git a/pkg/front_end/testcases/mixin.dart.direct.expect b/pkg/front_end/testcases/mixin.dart.direct.expect index 7d6b06e7fee..7a39b22c784 100644 --- a/pkg/front_end/testcases/mixin.dart.direct.expect +++ b/pkg/front_end/testcases/mixin.dart.direct.expect @@ -2,6 +2,20 @@ library; import self as self; import "dart:core" as core; +abstract class Object&M1 extends core::Object implements self::M1 { + constructor •() → void + : super core::Object::•() + ; + method m() → dynamic + return core::print("M1"); +} +abstract class Object&M1&M2 extends self::Object&M1 implements self::M2 { + constructor •() → void + : super self::Object&M1::•() + ; + method m() → dynamic + return core::print("M2"); +} class B extends self::Object&M1&M2 { constructor •(dynamic value) → void : super self::Object&M1&M2::•() @@ -33,31 +47,17 @@ abstract class G1 extends core::Object { method m() → dynamic return core::print(self::G1::T); } -class D extends self::D^G1 { - constructor •() → void - : super self::D^G1::•() - ; -} -abstract class Object&M1 extends core::Object implements self::M1 { +abstract class Object&G1^^#T0<#T0 extends core::Object> extends core::Object implements self::G1 { constructor •() → void : super core::Object::•() ; method m() → dynamic - return core::print("M1"); + return core::print(self::Object&G1^^#T0::#T0); } -abstract class Object&M1&M2 extends self::Object&M1 implements self::M2 { +class D extends self::Object&G1^^#T0 { constructor •() → void - : super self::Object&M1::•() + : super self::Object&G1^^#T0::•() ; - method m() → dynamic - return core::print("M2"); -} -abstract class D^G1 extends core::Object implements self::G1 { - constructor •() → void - : super core::Object::•() - ; - method m() → dynamic - return core::print(self::D^G1::S); } static method main() → dynamic { new self::B::•(null).m(); diff --git a/pkg/front_end/testcases/mixin.dart.outline.expect b/pkg/front_end/testcases/mixin.dart.outline.expect index cdba6feedc4..3dc6a7bf420 100644 --- a/pkg/front_end/testcases/mixin.dart.outline.expect +++ b/pkg/front_end/testcases/mixin.dart.outline.expect @@ -2,6 +2,10 @@ library; import self as self; import "dart:core" as core; +abstract class Object&M1 = core::Object with self::M1 { +} +abstract class Object&M1&M2 = self::Object&M1 with self::M2 { +} class B extends self::Object&M1&M2 { constructor •(dynamic value) → void ; @@ -28,15 +32,11 @@ abstract class G1 extends core::Object { method m() → dynamic ; } -class D extends self::D^G1 { +abstract class Object&G1^^#T0<#T0 extends core::Object> = core::Object with self::G1 { +} +class D extends self::Object&G1^^#T0 { constructor •() → void ; } -abstract class Object&M1 = core::Object with self::M1 { -} -abstract class Object&M1&M2 = self::Object&M1 with self::M2 { -} -abstract class D^G1 = core::Object with self::G1 { -} static method main() → dynamic ; diff --git a/pkg/front_end/testcases/rasta/class_hierarchy.dart.outline.expect b/pkg/front_end/testcases/rasta/class_hierarchy.dart.outline.expect index f77dde69478..90616a9dc8f 100644 --- a/pkg/front_end/testcases/rasta/class_hierarchy.dart.outline.expect +++ b/pkg/front_end/testcases/rasta/class_hierarchy.dart.outline.expect @@ -10,7 +10,7 @@ class B extends core::Object { constructor •() → void ; } -class C extends self::Object&Missing { +class C extends core::Object { constructor •() → void : super core::Object::•() ; @@ -20,9 +20,5 @@ class D extends core::Object { static factory •() → dynamic throw "Redirection constructor target not found: Missing"; } -abstract class Object&Missing extends core::Object { - constructor •() → void - ; -} static method main() → void ; diff --git a/pkg/front_end/testcases/rasta/duplicated_mixin.dart.outline.expect b/pkg/front_end/testcases/rasta/duplicated_mixin.dart.outline.expect index eb523ab3024..1c4d84df864 100644 --- a/pkg/front_end/testcases/rasta/duplicated_mixin.dart.outline.expect +++ b/pkg/front_end/testcases/rasta/duplicated_mixin.dart.outline.expect @@ -7,11 +7,11 @@ class Mixin extends core::Object { constructor •() → void ; } -class A extends self::Object&Mixin&Mixin { - constructor •() → void - ; -} abstract class Object&Mixin = core::Object with self::Mixin { } abstract class Object&Mixin&Mixin = self::Object&Mixin with self::Mixin { } +class A extends self::Object&Mixin&Mixin { + constructor •() → void + ; +} diff --git a/pkg/front_end/testcases/rasta/issue_000007.dart.direct.expect b/pkg/front_end/testcases/rasta/issue_000007.dart.direct.expect index dc735b036e9..8116f3fa5b4 100644 --- a/pkg/front_end/testcases/rasta/issue_000007.dart.direct.expect +++ b/pkg/front_end/testcases/rasta/issue_000007.dart.direct.expect @@ -14,11 +14,6 @@ class Mixin extends core::Object { method foo() → dynamic return core::print("foo"); } -class Sub extends self::Base&Mixin { - constructor •() → void - : super self::Base&Mixin::•() - ; -} abstract class Base&Mixin extends self::Base implements self::Mixin { constructor •() → void : super self::Base::•() @@ -26,6 +21,11 @@ abstract class Base&Mixin extends self::Base implements self::Mixin { method foo() → dynamic return core::print("foo"); } +class Sub extends self::Base&Mixin { + constructor •() → void + : super self::Base&Mixin::•() + ; +} static method main() → dynamic { new self::Sub::•().foo(); } diff --git a/pkg/front_end/testcases/rasta/issue_000007.dart.outline.expect b/pkg/front_end/testcases/rasta/issue_000007.dart.outline.expect index b279d88d5af..ed5fd1f40f0 100644 --- a/pkg/front_end/testcases/rasta/issue_000007.dart.outline.expect +++ b/pkg/front_end/testcases/rasta/issue_000007.dart.outline.expect @@ -12,11 +12,11 @@ class Mixin extends core::Object { method foo() → dynamic ; } +abstract class Base&Mixin = self::Base with self::Mixin { +} class Sub extends self::Base&Mixin { constructor •() → void ; } -abstract class Base&Mixin = self::Base with self::Mixin { -} static method main() → dynamic ; diff --git a/pkg/front_end/testcases/rasta/issue_000048.dart.direct.expect b/pkg/front_end/testcases/rasta/issue_000048.dart.direct.expect index bd4dca530b0..33c7e1d9deb 100644 --- a/pkg/front_end/testcases/rasta/issue_000048.dart.direct.expect +++ b/pkg/front_end/testcases/rasta/issue_000048.dart.direct.expect @@ -15,14 +15,9 @@ class M1 extends core::Object { : super core::Object::•() ; } -class C extends self::A&M1 { - constructor •(core::bool v1, core::num v2) → void - : super self::A&M1::•(v1, v2) - ; -} -abstract class A&M1 extends self::A implements self::M1 { +class C extends self::A implements self::M1 { field core::num v2 = 0; - constructor •(final core::bool v1, final core::num v2) → void + constructor •(core::bool v1, core::num v2) → void : super self::A::•(v1, v2) ; } diff --git a/pkg/front_end/testcases/rasta/issue_000048.dart.outline.expect b/pkg/front_end/testcases/rasta/issue_000048.dart.outline.expect index 219634af506..a7bda3a80dd 100644 --- a/pkg/front_end/testcases/rasta/issue_000048.dart.outline.expect +++ b/pkg/front_end/testcases/rasta/issue_000048.dart.outline.expect @@ -13,12 +13,10 @@ class M1 extends core::Object { constructor •() → void ; } -class C extends self::A&M1 { +class C = self::A with self::M1 { constructor •(core::bool v1, core::num v2) → void : super self::A::•(v1, v2) ; } -abstract class A&M1 = self::A with self::M1 { -} static method main() → dynamic ; diff --git a/pkg/front_end/testcases/rasta/issue_000080.dart.direct.expect b/pkg/front_end/testcases/rasta/issue_000080.dart.direct.expect index 48863d761d6..8c241096b98 100644 --- a/pkg/front_end/testcases/rasta/issue_000080.dart.direct.expect +++ b/pkg/front_end/testcases/rasta/issue_000080.dart.direct.expect @@ -10,6 +10,14 @@ class Mixin extends core::Object { method foo() → dynamic return 87; } +abstract class Object&Mixin extends core::Object implements self::Mixin { + field dynamic field = null; + constructor •() → void + : super core::Object::•() + ; + method foo() → dynamic + return 87; +} class Foo extends self::Object&Mixin { constructor •() → void : super self::Object&Mixin::•() @@ -19,14 +27,6 @@ class Foo extends self::Object&Mixin { method bar() → dynamic return this.{=self::Object&Mixin::field}; } -abstract class Object&Mixin extends core::Object implements self::Mixin { - field dynamic field = null; - constructor •() → void - : super core::Object::•() - ; - method foo() → dynamic - return 87; -} static method main() → dynamic { dynamic f = new self::Foo::•(); f.field = 42; diff --git a/pkg/front_end/testcases/rasta/issue_000080.dart.outline.expect b/pkg/front_end/testcases/rasta/issue_000080.dart.outline.expect index ac14e5bda75..585c3d5e0bb 100644 --- a/pkg/front_end/testcases/rasta/issue_000080.dart.outline.expect +++ b/pkg/front_end/testcases/rasta/issue_000080.dart.outline.expect @@ -9,6 +9,8 @@ class Mixin extends core::Object { method foo() → dynamic ; } +abstract class Object&Mixin = core::Object with self::Mixin { +} class Foo extends self::Object&Mixin { constructor •() → void ; @@ -17,7 +19,5 @@ class Foo extends self::Object&Mixin { method bar() → dynamic ; } -abstract class Object&Mixin = core::Object with self::Mixin { -} static method main() → dynamic ; diff --git a/pkg/front_end/testcases/redirecting_factory.dart.outline.expect b/pkg/front_end/testcases/redirecting_factory.dart.outline.expect index cf4e8e262e0..bd411a5aab4 100644 --- a/pkg/front_end/testcases/redirecting_factory.dart.outline.expect +++ b/pkg/front_end/testcases/redirecting_factory.dart.outline.expect @@ -46,12 +46,10 @@ class Mixin extends core::Object { constructor •() → void ; } -class Mix extends self::Mix^Mixin { +class Mix = self::Base with self::Mixin { constructor •() → void : super self::Base::•() ; } -abstract class Mix^Mixin = self::Base with self::Mixin { -} static method main() → dynamic ; diff --git a/tests/co19/co19-kernel.status b/tests/co19/co19-kernel.status index 5de9ba5dc38..39c9c01e688 100644 --- a/tests/co19/co19-kernel.status +++ b/tests/co19/co19-kernel.status @@ -54,7 +54,6 @@ Language/Classes/Setters/parameter_t08: MissingCompileTimeError Language/Classes/Setters/syntax_t03: MissingCompileTimeError Language/Classes/Static_Methods/declaration_t01: MissingCompileTimeError Language/Classes/Superclasses/wrong_superclass_t08: MissingCompileTimeError -Language/Classes/Superinterfaces/wrong_type_t04: MissingCompileTimeError Language/Classes/Superinterfaces/wrong_type_t05: MissingCompileTimeError Language/Classes/declarations_t02: MissingCompileTimeError Language/Classes/declarations_t03: MissingCompileTimeError @@ -62,21 +61,9 @@ Language/Classes/declarations_t04: MissingCompileTimeError Language/Classes/declarations_t06: MissingCompileTimeError Language/Classes/declarations_t08: MissingCompileTimeError Language/Classes/declarations_t33: MissingCompileTimeError +Language/Classes/definition_t23: CompileTimeError Language/Classes/same_name_member_and_class_t01: MissingCompileTimeError Language/Classes/same_name_member_and_class_t03: MissingCompileTimeError -Language/Classes/same_name_type_variable_t01: MissingCompileTimeError -Language/Classes/same_name_type_variable_t02: MissingCompileTimeError -Language/Classes/same_name_type_variable_t03: MissingCompileTimeError -Language/Classes/same_name_type_variable_t05: MissingCompileTimeError -Language/Classes/same_name_type_variable_t06: MissingCompileTimeError -Language/Classes/same_name_type_variable_t08: MissingCompileTimeError -Language/Classes/same_name_type_variable_t09: MissingCompileTimeError -Language/Enums/restrictions_t02: MissingCompileTimeError -Language/Enums/restrictions_t03: MissingCompileTimeError -Language/Enums/restrictions_t04: MissingCompileTimeError -Language/Enums/restrictions_t05: MissingCompileTimeError -Language/Enums/restrictions_t06: MissingCompileTimeError -Language/Enums/restrictions_t07: MissingCompileTimeError Language/Enums/restrictions_t08: MissingCompileTimeError Language/Expressions/Assignment/expression_assignment_failed_t03: CompileTimeError Language/Expressions/Assignment/expression_assignment_t07: CompileTimeError @@ -233,21 +220,8 @@ Language/Metadata/compilation_t10: MissingCompileTimeError Language/Metadata/compilation_t11: MissingCompileTimeError Language/Mixins/Mixin_Application/deferred_t01: MissingCompileTimeError Language/Mixins/Mixin_Application/syntax_t16: CompileTimeError # Issue 25765 -Language/Mixins/Mixin_Application/wrong_mixin_type_t01: MissingCompileTimeError -Language/Mixins/Mixin_Application/wrong_mixin_type_t02: MissingCompileTimeError -Language/Mixins/Mixin_Application/wrong_mixin_type_t07: MissingCompileTimeError -Language/Mixins/Mixin_Application/wrong_type_t01: MissingCompileTimeError -Language/Mixins/Mixin_Application/wrong_type_t05: MissingCompileTimeError -Language/Mixins/declaring_constructor_t01: MissingCompileTimeError -Language/Mixins/declaring_constructor_t02: MissingCompileTimeError -Language/Mixins/declaring_constructor_t03: MissingCompileTimeError -Language/Mixins/declaring_constructor_t04: MissingCompileTimeError Language/Mixins/declaring_constructor_t05: MissingCompileTimeError # Issue 24767 Language/Mixins/declaring_constructor_t06: MissingCompileTimeError # Issue 24767 -Language/Mixins/declaring_constructor_t07: MissingCompileTimeError -Language/Mixins/declaring_constructor_t08: MissingCompileTimeError -Language/Mixins/declaring_constructor_t09: MissingCompileTimeError -Language/Mixins/declaring_constructor_t10: MissingCompileTimeError Language/Overview/Privacy/private_and_public_t06: RuntimeError Language/Overview/Privacy/private_and_public_t09: RuntimeError Language/Overview/Privacy/private_and_public_t10: RuntimeError @@ -262,7 +236,6 @@ Language/Overview/Scoping/conflicting_names_t27: Crash Language/Overview/Scoping/conflicting_names_t31: MissingCompileTimeError Language/Overview/Scoping/conflicting_names_t32: MissingCompileTimeError Language/Overview/Scoping/conflicting_names_t33: MissingCompileTimeError -Language/Overview/Scoping/conflicting_names_t34: MissingCompileTimeError Language/Overview/Scoping/conflicting_names_t35: MissingCompileTimeError Language/Overview/Scoping/conflicting_names_t37: Crash Language/Overview/Scoping/conflicting_names_t38: Crash diff --git a/tests/language/language_kernel.status b/tests/language/language_kernel.status index d83f68f4b74..644617e4a7d 100644 --- a/tests/language/language_kernel.status +++ b/tests/language/language_kernel.status @@ -13,48 +13,28 @@ multiline_newline_test/06r: MissingCompileTimeError # Fixed in ahe's dev-branch built_in_identifier_test/01: CompileTimeError call_nonexistent_static_test/01: CompileTimeError call_nonexistent_static_test/04: CompileTimeError -compile_time_constant_c_test/02: MissingCompileTimeError compile_time_constant_c_test/03: MissingCompileTimeError -compile_time_constant_k_test/01: RuntimeError -compile_time_constant_k_test/02: RuntimeError -compile_time_constant_k_test/03: RuntimeError -compile_time_constant_o_test/01: RuntimeError -compile_time_constant_o_test/02: RuntimeError compile_time_constant_test/01: MissingCompileTimeError conditional_method_invocation_test/11: MissingCompileTimeError conditional_property_access_test/09: MissingCompileTimeError conditional_property_assignment_test/20: MissingCompileTimeError conditional_property_assignment_test/21: MissingCompileTimeError conditional_property_assignment_test/22: MissingCompileTimeError -config_import_corelib_test: RuntimeError -config_import_test: RuntimeError -const_conditional_test/08: MissingCompileTimeError const_constructor_mixin2_test/01: MissingCompileTimeError const_constructor_mixin3_test/01: MissingCompileTimeError const_constructor_mixin_test/01: MissingCompileTimeError -const_constructor_nonconst_field_test/01: MissingCompileTimeError const_constructor_super_test/01: MissingCompileTimeError const_constructor_syntax_test/01: MissingCompileTimeError const_constructor_syntax_test/02: MissingCompileTimeError const_constructor_syntax_test/03: MissingCompileTimeError const_constructor_test/01: MissingCompileTimeError -const_dynamic_type_literal_test/02: RuntimeError const_error_multiply_initialized_test/01: MissingCompileTimeError const_error_multiply_initialized_test/02: RuntimeError const_error_multiply_initialized_test/03: MissingCompileTimeError const_error_multiply_initialized_test/04: RuntimeError -const_evaluation_test/01: RuntimeError -const_factory_with_body_test/01: MissingCompileTimeError const_for_in_variable_test/01: MissingCompileTimeError -const_instance_field_test/01: MissingCompileTimeError -const_map2_test/00: MissingCompileTimeError -const_map3_test/00: MissingCompileTimeError -const_nested_test: RuntimeError -const_optional_args_negative_test: Fail -const_switch2_test/01: MissingCompileTimeError const_syntax_test/01: MissingCompileTimeError const_syntax_test/02: MissingCompileTimeError -const_syntax_test/05: MissingCompileTimeError const_types_test/23: MissingCompileTimeError const_types_test/24: MissingCompileTimeError const_types_test/25: MissingCompileTimeError @@ -64,14 +44,10 @@ const_types_test/28: MissingCompileTimeError const_types_test/29: MissingCompileTimeError const_types_test/30: MissingCompileTimeError const_types_test/41: MissingCompileTimeError -constant_expression_test/01: MissingCompileTimeError -constant_expression_test/03: MissingCompileTimeError constant_locals_test/01: MissingCompileTimeError constructor_duplicate_final_test/01: MissingRuntimeError constructor_duplicate_final_test/02: MissingRuntimeError constructor_duplicate_initializers_test/03: MissingCompileTimeError -constructor_redirect2_test/01: MissingCompileTimeError -constructor_redirect_test/01: MissingCompileTimeError covariant_test/02: MissingCompileTimeError covariant_test/08: MissingCompileTimeError covariant_test/12: MissingCompileTimeError @@ -87,10 +63,6 @@ covariant_test/39: MissingCompileTimeError covariant_test/46: MissingCompileTimeError covariant_test/46b: MissingCompileTimeError covariant_test/59: MissingCompileTimeError -cyclic_constructor_test/01: MissingCompileTimeError -cyclic_type_test/00: RuntimeError -cyclic_type_test/01: RuntimeError -cyclic_type_test/03: RuntimeError cyclic_typedef_test/01: MissingCompileTimeError cyclic_typedef_test/02: MissingCompileTimeError cyclic_typedef_test/03: MissingCompileTimeError @@ -100,8 +72,6 @@ cyclic_typedef_test/06: MissingCompileTimeError cyclic_typedef_test/07: MissingCompileTimeError cyclic_typedef_test/08: MissingCompileTimeError cyclic_typedef_test/09: MissingCompileTimeError -cyclic_typedef_test/10: MissingCompileTimeError -cyclic_typedef_test/11: MissingCompileTimeError deferred_call_empty_before_load_test: RuntimeError # Deferred Loading Issue 28335 deferred_duplicate_prefix1_test/01: MissingCompileTimeError deferred_duplicate_prefix2_test/01: MissingCompileTimeError @@ -113,19 +83,12 @@ deferred_inheritance_constraints_test/redirecting_constructor: RuntimeError deferred_no_prefix_test/01: MissingCompileTimeError deferred_not_loaded_check_test: RuntimeError deferred_shadow_load_library_test: RuntimeError -dynamic_prefix_core_test/01: RuntimeError enum_private_test/02: RuntimeError enum_syntax_test/06: MissingCompileTimeError -enum_syntax_test/21: MissingCompileTimeError enum_syntax_test/30: MissingCompileTimeError -evaluation_redirecting_constructor_test: RuntimeError -export_double_same_main_test: CompileTimeError -export_main_test: CompileTimeError export_private_test/01: MissingCompileTimeError external_test/11: MissingCompileTimeError external_test/12: MissingCompileTimeError -external_test/13: MissingRuntimeError -external_test/20: MissingRuntimeError external_test/21: MissingCompileTimeError external_test/22: MissingCompileTimeError external_test/23: MissingCompileTimeError @@ -133,7 +96,6 @@ external_test/24: MissingCompileTimeError external_test/25: MissingCompileTimeError external_test/30: MissingCompileTimeError external_test/31: MissingCompileTimeError -factory_redirection_test/07: MissingCompileTimeError field_decl_missing_var_type_test/01: MissingCompileTimeError final_initializer_instance_reference_test/01: MissingCompileTimeError final_super_field_set_test/01: RuntimeError @@ -141,18 +103,8 @@ final_syntax_test/01: MissingCompileTimeError final_syntax_test/02: MissingCompileTimeError final_syntax_test/03: MissingCompileTimeError final_syntax_test/04: MissingCompileTimeError -for2_test: RuntimeError -for_variable_capture_test: RuntimeError function_subtype0_test: RuntimeError function_subtype1_test: RuntimeError -function_subtype2_test: RuntimeError -function_subtype_bound_closure3_test: RuntimeError -function_subtype_bound_closure4_test: RuntimeError -function_subtype_cast1_test: RuntimeError -function_subtype_inline0_test: RuntimeError -function_subtype_local3_test: RuntimeError -function_subtype_local4_test: RuntimeError -function_subtype_not1_test: RuntimeError function_syntax_test/00: MissingCompileTimeError function_syntax_test/01: MissingCompileTimeError function_syntax_test/22: MissingCompileTimeError @@ -163,9 +115,6 @@ function_syntax_test/69: MissingCompileTimeError function_syntax_test/71: MissingCompileTimeError function_syntax_test/73: MissingCompileTimeError function_syntax_test/74: MissingCompileTimeError -function_type_alias2_test: RuntimeError -function_type_alias3_test: RuntimeError -function_type_alias4_test: RuntimeError function_type_alias5_test/00: MissingCompileTimeError function_type_alias5_test/01: MissingCompileTimeError function_type_alias5_test/02: MissingCompileTimeError @@ -173,17 +122,7 @@ function_type_alias6_test/00: MissingCompileTimeError function_type_alias7_test/00: MissingCompileTimeError function_type_alias7_test/02: MissingCompileTimeError function_type_alias9_test/00: MissingCompileTimeError -function_type_parameter2_negative_test: Crash -function_type_parameter_negative_test: Crash function_type/*: DartkCrash -generic_closure_test: RuntimeError -generic_field_mixin2_test: RuntimeError -generic_field_mixin3_test: RuntimeError -generic_field_mixin4_test: RuntimeError -generic_field_mixin5_test: RuntimeError -generic_field_mixin_test: RuntimeError -generic_metadata_test/02: MissingCompileTimeError -generic_metadata_test/03: MissingCompileTimeError generic_method_types_test: Pass, RuntimeError getter_closure_execution_order_test: RuntimeError getter_parameters_test/01: MissingCompileTimeError @@ -205,53 +144,17 @@ is_malformed_type_test/98: RuntimeError is_malformed_type_test/99: RuntimeError is_not_class2_test: RuntimeError isnot_malformed_type_test: RuntimeError -large_class_declaration_test: SkipSlow # KernelVM Issue 28312 library_ambiguous_test/00: MissingRuntimeError library_ambiguous_test/04: MissingRuntimeError -library_env_test/has_html_support: RuntimeError -library_env_test/has_no_io_support: RuntimeError -list_literal4_test: RuntimeError malformed2_test/00: RuntimeError -malformed_inheritance_test/09: MissingCompileTimeError -malformed_inheritance_test/10: MissingCompileTimeError -malformed_test/none: RuntimeError -map_literal3_test: RuntimeError -map_literal6_test: RuntimeError metadata_test: CompileTimeError method_name_test: CompileTimeError method_override_test: RuntimeError mixin_forwarding_constructor4_test/01: MissingCompileTimeError mixin_forwarding_constructor4_test/02: MissingCompileTimeError mixin_forwarding_constructor4_test/03: MissingCompileTimeError -mixin_illegal_constructor_test/01: MissingCompileTimeError -mixin_illegal_constructor_test/02: MissingCompileTimeError -mixin_illegal_constructor_test/03: MissingCompileTimeError -mixin_illegal_constructor_test/04: MissingCompileTimeError -mixin_illegal_constructor_test/05: MissingCompileTimeError -mixin_illegal_constructor_test/06: MissingCompileTimeError -mixin_illegal_constructor_test/07: MissingCompileTimeError -mixin_illegal_constructor_test/08: MissingCompileTimeError -mixin_illegal_constructor_test/09: MissingCompileTimeError -mixin_illegal_constructor_test/10: MissingCompileTimeError -mixin_illegal_constructor_test/11: MissingCompileTimeError -mixin_illegal_constructor_test/12: MissingCompileTimeError -mixin_illegal_object_test/01: MissingCompileTimeError -mixin_illegal_object_test/02: MissingCompileTimeError -mixin_issue10216_2_test: RuntimeError -mixin_mixin2_test: RuntimeError -mixin_mixin3_test: RuntimeError -mixin_mixin4_test: RuntimeError -mixin_mixin5_test: RuntimeError -mixin_mixin6_test: RuntimeError -mixin_mixin7_test: RuntimeError -mixin_mixin_bound2_test: RuntimeError -mixin_mixin_bound_test: RuntimeError -mixin_mixin_test: RuntimeError -mixin_of_mixin_test/03: RuntimeError -mixin_of_mixin_test/14: RuntimeError mixin_super_constructor_named_test/01: MissingCompileTimeError mixin_super_constructor_positionals_test/01: MissingCompileTimeError -mixin_super_test: RuntimeError mixin_type_parameters_super_extends_test: RuntimeError mixin_type_parameters_super_test: RuntimeError named_constructor_test/01: MissingRuntimeError @@ -259,16 +162,10 @@ named_parameters_aggregated_test/01: MissingCompileTimeError named_parameters_aggregated_test/03: MissingCompileTimeError named_parameters_aggregated_test/04: MissingCompileTimeError named_parameters_default_eq_test/01: MissingCompileTimeError -named_parameters_default_eq_test/02: MissingCompileTimeError on_catch_malformed_type_test: RuntimeError parameter_initializer6_negative_test: Fail private_access_test/05: RuntimeError private_access_test/06: RuntimeError -private_super_constructor_test/01: MissingCompileTimeError -redirecting_constructor_initializer_test: RuntimeError -redirecting_factory_default_values_test/01: MissingCompileTimeError -redirecting_factory_default_values_test/02: MissingCompileTimeError -redirecting_factory_long_test: RuntimeError ref_before_declaration_test/00: MissingCompileTimeError ref_before_declaration_test/01: MissingCompileTimeError ref_before_declaration_test/02: MissingCompileTimeError @@ -278,13 +175,8 @@ ref_before_declaration_test/05: MissingCompileTimeError ref_before_declaration_test/06: MissingCompileTimeError ref_before_declaration_test/07: MissingCompileTimeError regress_13494_test: CompileTimeError -regress_20394_test/01: MissingCompileTimeError regress_22438_test: RuntimeError -regress_27617_test/1: MissingCompileTimeError -regress_28217_test/01: MissingCompileTimeError -regress_28217_test/none: MissingCompileTimeError regress_29243_test: Crash -runtime_type_function_test: RuntimeError scope_variable_test/01: MissingCompileTimeError static_field3_test/03: CompileTimeError static_field3_test/04: CompileTimeError @@ -324,11 +216,6 @@ super_no_such_method3_test/01: RuntimeError super_no_such_method4_test/01: RuntimeError super_no_such_method5_test/01: RuntimeError switch1_negative_test: Fail -switch_bad_case_test/01: MissingCompileTimeError -switch_bad_case_test/02: MissingCompileTimeError -switch_case_test/00: MissingCompileTimeError -switch_case_test/01: MissingCompileTimeError -switch_case_test/02: MissingCompileTimeError syntax_test/02: MissingCompileTimeError syntax_test/03: MissingCompileTimeError syntax_test/27: MissingCompileTimeError @@ -339,20 +226,148 @@ try_catch_syntax_test/09: MissingCompileTimeError try_catch_syntax_test/10: MissingCompileTimeError try_catch_syntax_test/11: MissingCompileTimeError try_catch_syntax_test/12: MissingCompileTimeError -type_variable_conflict_test/01: MissingCompileTimeError -type_variable_conflict_test/02: MissingCompileTimeError -type_variable_conflict_test/03: MissingCompileTimeError -type_variable_conflict_test/04: MissingCompileTimeError -type_variable_conflict_test/05: MissingCompileTimeError -type_variable_conflict_test/06: MissingCompileTimeError -type_variable_function_type_test: RuntimeError -type_variable_scope3_test/00: MissingCompileTimeError -vm/closure_memory_retention_test: Skip # Hits OOM -vm/debug_break_enabled_vm_test/01: CompileTimeError -vm/debug_break_enabled_vm_test/none: CompileTimeError vm/regress_27201_test: CompileTimeError -vm/regress_27671_test: RuntimeError -vm/type_vm_test: RuntimeError + +config_import_corelib_test: RuntimeError # KernelVM bug: Configurable imports. +config_import_test: RuntimeError # KernelVM bug: Configurable imports. +library_env_test/has_html_support: RuntimeError # KernelVM bug: Configurable imports. +library_env_test/has_no_io_support: RuntimeError # KernelVM bug: Configurable imports. + +compile_time_constant_c_test/02: MissingCompileTimeError # KernelVM bug: Constant evaluation. +const_conditional_test/08: MissingCompileTimeError # KernelVM bug: Constant evaluation. +const_map2_test/00: MissingCompileTimeError # KernelVM bug: Constant evaluation. +const_map3_test/00: MissingCompileTimeError # KernelVM bug: Constant evaluation. +const_nested_test: RuntimeError # KernelVM bug: Constant evaluation. +const_switch2_test/01: MissingCompileTimeError # KernelVM bug: Constant evaluation. +const_syntax_test/05: MissingCompileTimeError # KernelVM bug: Constant evaluation. +constant_expression_test/01: MissingCompileTimeError # KernelVM bug: Constant evaluation. +constant_expression_test/03: MissingCompileTimeError # KernelVM bug: Constant evaluation. +function_type_parameter2_negative_test: Crash # KernelVM bug: Constant evaluation. +function_type_parameter_negative_test: Crash # KernelVM bug: Constant evaluation. +multiline_newline_test/04: MissingCompileTimeError # KernelVM bug: Constant evaluation. +multiline_newline_test/04r: MissingCompileTimeError # KernelVM bug: Constant evaluation. +multiline_newline_test/05: MissingCompileTimeError # KernelVM bug: Constant evaluation. +multiline_newline_test/05r: MissingCompileTimeError # KernelVM bug: Constant evaluation. +multiline_newline_test/06: MissingCompileTimeError # KernelVM bug: Constant evaluation. +multiline_newline_test/06r: MissingCompileTimeError # KernelVM bug: Constant evaluation. +switch_bad_case_test/01: MissingCompileTimeError # KernelVM bug: Constant evaluation. +switch_bad_case_test/02: MissingCompileTimeError # KernelVM bug: Constant evaluation. +switch_case_test/00: MissingCompileTimeError # KernelVM bug: Constant evaluation. +switch_case_test/01: MissingCompileTimeError # KernelVM bug: Constant evaluation. +switch_case_test/02: MissingCompileTimeError # KernelVM bug: Constant evaluation. + +compile_time_constant_k_test/01: RuntimeError # KernelVM bug: Constant map duplicated key. +compile_time_constant_k_test/02: RuntimeError # KernelVM bug: Constant map duplicated key. +compile_time_constant_k_test/03: RuntimeError # KernelVM bug: Constant map duplicated key. +compile_time_constant_o_test/01: RuntimeError # KernelVM bug: Constant map duplicated key. +compile_time_constant_o_test/02: RuntimeError # KernelVM bug: Constant map duplicated key. +const_dynamic_type_literal_test/02: RuntimeError # KernelVM bug: Constant map duplicated key. +map_literal3_test: RuntimeError # KernelVM bug: Constant map duplicated key. +map_literal6_test: RuntimeError # KernelVM bug: Constant map duplicated key. + +const_evaluation_test/01: RuntimeError # KernelVM bug: Reflecting on metadata. + +cyclic_type_test/00: RuntimeError # KernelVM bug: Incorrect type argument. +cyclic_type_test/01: RuntimeError # KernelVM bug: Incorrect type argument. +cyclic_type_test/03: RuntimeError # KernelVM bug: Incorrect type argument. + +dynamic_prefix_core_test/01: RuntimeError # KernelVM bug: Blocked on language issue 29125. + +for2_test: RuntimeError # KernelVM bug: Closure conversion? +for_variable_capture_test: RuntimeError # KernelVM bug: Closure conversion? + +external_test/13: MissingRuntimeError # KernelVM bug: Unbound external. +external_test/20: MissingRuntimeError # KernelVM bug: Unbound external. + +function_subtype2_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_bound_closure3_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_bound_closure4_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_cast1_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_inline0_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_local3_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_local4_test: RuntimeError # KernelVM bug: Issue 29409 +function_subtype_not1_test: RuntimeError # KernelVM bug: Issue 29409 +function_type_alias2_test: RuntimeError # KernelVM bug: Issue 29409 +function_type_alias3_test: RuntimeError # KernelVM bug: Issue 29409 +function_type_alias4_test: RuntimeError # KernelVM bug: Issue 29409 +generic_closure_test: RuntimeError # KernelVM bug: Issue 29409 +generic_method_types_test/01: RuntimeError # KernelVM bug: Issue 29409 +generic_method_types_test/02: RuntimeError # KernelVM bug: Issue 29409 +method_override_test: RuntimeError # KernelVM bug: Issue 29409 +runtime_type_function_test: RuntimeError # KernelVM bug: Issue 29409 +type_variable_function_type_test: RuntimeError # KernelVM bug: Issue 29409 + +large_class_declaration_test: SkipSlow # KernelVM bug: KernelVM Issue 28312 + +mixin_forwarding_constructor4_test/01: MissingCompileTimeError # KernelVM bug: Issue 15101 +mixin_forwarding_constructor4_test/02: MissingCompileTimeError # KernelVM bug: Issue 15101 +mixin_forwarding_constructor4_test/03: MissingCompileTimeError # KernelVM bug: Issue 15101 +mixin_super_constructor_named_test/01: MissingCompileTimeError # KernelVM bug: Issue 15101 +mixin_super_constructor_positionals_test/01: MissingCompileTimeError # KernelVM bug: Issue 15101 + +mixin_mixin_type_arguments_test: RuntimeError # KernelVM bug: Issue 29537 +mixin_type_parameters_mixin_extends_test: RuntimeError # KernelVM bug: Issue 29537 +mixin_type_parameters_super_extends_test: RuntimeError # KernelVM bug: Issue 29537 +mixin_type_parameters_super_test: RuntimeError # KernelVM bug: Issue 29537 + +evaluation_redirecting_constructor_test: RuntimeError # KernelVM bug: Field initializers evaluated multiple times +redirecting_constructor_initializer_test: RuntimeError # KernelVM bug: Field initializers evaluated multiple times + +vm/regress_27671_test: RuntimeError # KernelVM bug: Problem with checked mode or other VMOptions? + +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/closure_memory_retention_test: Skip # KernelVM bug: Hits OOM + +list_literal4_test: RuntimeError # KernelVM bug: Checked mode problem: list literals aren't checked. + +generic_field_mixin4_test: RuntimeError # KernelVM bug: Issue 29553 + +redirecting_factory_long_test: RuntimeError # Fasta bug: Bad compilation of type arguments for redirecting factory. + +factory_redirection_test/07: MissingCompileTimeError # Fasta bug: Bad constructor redirection. +regress_27617_test/1: MissingCompileTimeError # Fasta bug: Bad constructor redirection. +regress_28217_test/01: MissingCompileTimeError # Fasta bug: Bad constructor redirection. +regress_28217_test/none: MissingCompileTimeError # Fasta bug: Bad constructor redirection. + +vm/type_vm_test: RuntimeError # Fasta bug: Bad position information in stack trace. + +constructor_redirect2_test/01: MissingCompileTimeError # Fasta bug: Body on redirecting constructor. + +const_factory_with_body_test/01: MissingCompileTimeError # Fasta bug: Const factory with body. + +const_instance_field_test/01: MissingCompileTimeError # Fasta bug: Const instance field. + +cyclic_constructor_test/01: MissingCompileTimeError # Fasta bug: Cyclic constructor redirection. + +cyclic_typedef_test/10: MissingCompileTimeError # Fasta bug: Cyclic typedef via type variable. +cyclic_typedef_test/11: MissingCompileTimeError # Fasta bug: Cyclic typedef via type variable. + +const_optional_args_negative_test: Fail # Fasta bug: Default parameter values must be const. + +named_parameters_default_eq_test/02: MissingCompileTimeError # Fasta bug: Default values are not allowed on redirecting factory constructors. +redirecting_factory_default_values_test/01: MissingCompileTimeError # Fasta bug: Default values are not allowed on redirecting factory constructors. +redirecting_factory_default_values_test/02: MissingCompileTimeError # Fasta bug: Default values are not allowed on redirecting factory constructors. + +private_super_constructor_test/01: MissingCompileTimeError # Fasta bug: Illegal access to private constructor. +regress_20394_test/01: MissingCompileTimeError # Fasta bug: Illegal access to private constructor. + +constructor_redirect_test/01: MissingCompileTimeError # Fasta bug: Initializer refers to this. + +malformed_test/none: RuntimeError # Fasta bug: Leads to assertion error in Fasta. + +export_double_same_main_test: CompileTimeError # Fasta bug: Main is exported. +export_main_test: CompileTimeError # Fasta bug: Main is exported. + +const_constructor_nonconst_field_test/01: MissingCompileTimeError # Fasta bug: Non-const expression in field initializer. + +method_name_test: CompileTimeError # Fasta bug: Parser bug. + +generic_metadata_test/02: MissingCompileTimeError # Fasta bug: Type arguments aren't allowed on metadata?! +generic_metadata_test/03: MissingCompileTimeError # Fasta bug: Type arguments aren't allowed on metadata?! + +named_constructor_test/01: MissingRuntimeError # Fasta bug: Bad compilation of constructor reference. # dartk: JIT & AOT failures (debug) [ ($compiler == dartk || $compiler == dartkp) && $mode == debug ] diff --git a/tests/language/mixin_mixin_type_arguments_test.dart b/tests/language/mixin_mixin_type_arguments_test.dart new file mode 100644 index 00000000000..55d796f13dd --- /dev/null +++ b/tests/language/mixin_mixin_type_arguments_test.dart @@ -0,0 +1,86 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart' show Expect; + +class A {} + +class B {} + +class C {} + +class D {} + +class E {} + +class F {} + +class M1 { + m1() => "M1<$Tm1>"; +} + +class M2 { + m2() => "M2<$Tm2>"; +} + +class M3 { + m3() => "M3<$Tm3>"; +} + +class M4 { + m4() => "M4<$Tm4>"; +} + +class M5 { + m5() => "M5<$Tm5>"; +} + +class C1 = Object with M1, M2, M3, M4, M5; + +class C2 = Object with M1, M2, M3, M4, M5; + +class C3 = Object with M1, M2, M3, M4, M5; + +class C4 extends Object with M1, M2, M3, M4, M5 {} + +class C5 extends Object with M1, M2, M3, M4, M5 {} + +class C6 extends Object with M1, M2, M3, M4, M5 {} + +class C7 = Object with M1, M2, M3, M4, M5; + +class C8 extends Object with M1, M2, M3, M4, M5 {} + +class C9 = Object + with M1>, M2>, M3>, M4>, M5>; + +class CA extends Object + with M1>, M2>, M3>, M4>, M5> {} + +trace(x) => "${x.m1()}, ${x.m2()}, ${x.m3()}, ${x.m4()}, ${x.m5()}"; + +main() { + Expect.stringEquals( + "M1, M2, M3, M4, M5", trace(new C1())); + Expect.stringEquals("M1, M2, M3, M4, M5", trace(new C2())); + Expect.stringEquals( + "M1, M2, M3, M4, M5", trace(new C3())); + Expect.stringEquals( + "M1, M2, M3, M4, M5", trace(new C3())); + Expect.stringEquals( + "M1, M2, M3, M4, M5", trace(new C4())); + Expect.stringEquals("M1, M2, M3, M4, M5", trace(new C5())); + Expect.stringEquals( + "M1, M2, M3, M4, M5", trace(new C6())); + Expect.stringEquals( + "M1, M2, M3, M4, M5", trace(new C6())); + Expect.stringEquals("M1, M2, M3, M4, M5", trace(new C7())); + Expect.stringEquals("M1, M2, M3, M4, M5", trace(new C8())); + Expect.stringEquals( + "M1>, M2>, M3>, M4>, M5>", + trace(new C9())); + Expect.stringEquals( + "M1>, M2>, M3>, M4>, M5>", + trace(new CA())); +} diff --git a/tests/lib/lib.status b/tests/lib/lib.status index 3eb1d1fcea0..7835c3c8e5d 100644 --- a/tests/lib/lib.status +++ b/tests/lib/lib.status @@ -497,6 +497,8 @@ mirrors/function_type_mirror_test: RuntimeError mirrors/generic_class_declaration_test: RuntimeError mirrors/generic_f_bounded_mixin_application_test: RuntimeError mirrors/generic_function_typedef_test: RuntimeError +mirrors/generic_interface_test/01: RuntimeError +mirrors/generic_interface_test/none: RuntimeError mirrors/generic_local_function_test: RuntimeError mirrors/generic_mixin_applications_test: RuntimeError mirrors/generic_mixin_test: RuntimeError