Skip to content

Commit

Permalink
Version 3.2.0-35.0.dev
Browse files Browse the repository at this point in the history
Merge 698b544 into dev
  • Loading branch information
Dart CI committed Aug 3, 2023
2 parents e3d2b4a + 698b544 commit eb76707
Show file tree
Hide file tree
Showing 22 changed files with 1,155 additions and 42 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ vars = {
# Pinned browser versions used by the testing infrastructure. These are not
# meant to be downloaded by users for local testing.
"download_chrome": False,
"chrome_tag": "113.0.5672.63+2",
"chrome_tag": "115.0.5790.170",
"download_firefox": False,
"firefox_tag": "112.0.2",

Expand Down
12 changes: 12 additions & 0 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10082,6 +10082,18 @@ const MessageCode messageNonConstFactory = const MessageCode("NonConstFactory",
correctionMessage:
r"""Try using a constructor or factory that is 'const'.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeNonCovariantTypeParameterInRepresentationType =
messageNonCovariantTypeParameterInRepresentationType;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageNonCovariantTypeParameterInRepresentationType =
const MessageCode("NonCovariantTypeParameterInRepresentationType",
problemMessage:
r"""An extension type parameter can't be used non-covariantly in its representation type.""",
correctionMessage:
r"""Try removing the type parameters from function parameter types and type parameter bounds.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
Expand Down
31 changes: 21 additions & 10 deletions pkg/dart2wasm/lib/intrinsics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ class Intrinsifier {
if (cls == translator.wasmAnyRefClass && name == "toObject") {
w.Label succeed = b.block(const [], [translator.topInfo.nonNullableType]);
codeGen.wrap(receiver, const w.RefType.any(nullable: false));
b.br_on_cast(translator.topInfo.nonNullableType, succeed);
b.br_on_cast(succeed, const w.RefType.any(nullable: false),
translator.topInfo.nonNullableType);
codeGen.throwWasmRefError("a Dart object");
b.end(); // succeed
return translator.topInfo.nonNullableType;
Expand Down Expand Up @@ -925,7 +926,7 @@ class Intrinsifier {
w.RefType resultType = typeOfExp(node) as w.RefType;
w.Label succeed = b.block(const [], [resultType]);
codeGen.wrap(ref, w.RefType.func(nullable: false));
b.br_on_cast(resultType, succeed);
b.br_on_cast(succeed, w.RefType.func(nullable: false), resultType);
codeGen.throwWasmRefError("a function with the expected signature");
b.end(); // succeed
return resultType;
Expand Down Expand Up @@ -1391,7 +1392,8 @@ class Intrinsifier {
ClassInfo intInfo = translator.classInfo[translator.boxedIntClass]!;
w.Label intArg = b.block(const [], [intInfo.nonNullableType]);
b.local_get(function.locals[1]);
b.br_on_cast(intInfo.nonNullableType, intArg);
b.br_on_cast(intArg, function.locals[1].type as w.RefType,
intInfo.nonNullableType);
// double argument
b.drop();
b.local_get(function.locals[0]);
Expand Down Expand Up @@ -1545,14 +1547,15 @@ class Intrinsifier {
b.block([], [w.RefType.struct(nullable: false)]);
b.local_get(fun1);
b.struct_get(closureBaseStruct, FieldIndex.closureContext);
b.br_on_cast_fail(instantiationContextBase, fun1NotInstantiationBlock);
b.br_on_cast_fail(fun1NotInstantiationBlock,
const w.RefType.struct(nullable: false), instantiationContextBase);
b.struct_get(translator.closureLayouter.instantiationContextBaseStruct,
FieldIndex.instantiationContextInner);
b.struct_get(closureBaseStruct, FieldIndex.closureVtable);
b.local_get(fun2);
b.struct_get(closureBaseStruct, FieldIndex.closureContext);
b.br_on_cast_fail(
instantiationContextBase, fun1InstantiationFun2NotInstantiationBlock);
b.br_on_cast_fail(fun1InstantiationFun2NotInstantiationBlock,
const w.RefType.struct(nullable: false), instantiationContextBase);
b.struct_get(translator.closureLayouter.instantiationContextBaseStruct,
FieldIndex.instantiationContextInner);
b.struct_get(closureBaseStruct, FieldIndex.closureVtable);
Expand Down Expand Up @@ -1586,7 +1589,8 @@ class Intrinsifier {

b.local_get(fun1);
b.struct_get(closureBaseStruct, FieldIndex.closureContext);
b.br_on_cast_fail(instantiationContextBase, notInstantiationBlock);
b.br_on_cast_fail(notInstantiationBlock,
const w.RefType.struct(nullable: false), instantiationContextBase);

// Closures are instantiations. Compare inner function vtables to check
// that instantiations are for the same generic function.
Expand Down Expand Up @@ -1641,11 +1645,17 @@ class Intrinsifier {
final contextCheckFail = b.block([], [w.RefType.struct(nullable: false)]);
b.local_get(fun1);
b.struct_get(closureBaseStruct, FieldIndex.closureContext);
b.br_on_cast_fail(translator.topInfo.nonNullableType, contextCheckFail);
b.br_on_cast_fail(
contextCheckFail,
const w.RefType.struct(nullable: false),
translator.topInfo.nonNullableType);

b.local_get(fun2);
b.struct_get(closureBaseStruct, FieldIndex.closureContext);
b.br_on_cast_fail(translator.topInfo.nonNullableType, contextCheckFail);
b.br_on_cast_fail(
contextCheckFail,
const w.RefType.struct(nullable: false),
translator.topInfo.nonNullableType);

// Both contexts are objects, compare for equality with `identical`. This
// handles identical `this` values in instance tear-offs.
Expand Down Expand Up @@ -1754,7 +1764,8 @@ class Intrinsifier {
final stackTraceFieldIndex =
translator.fieldIndex[translator.errorClassStackTraceField]!;
b.local_get(objectLocal);
b.br_on_cast_fail(errorRefType, notErrorBlock);
b.br_on_cast_fail(
notErrorBlock, objectLocal.type as w.RefType, errorRefType);

// Binaryen can merge struct types, so we need to check class ID in the
// slow path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import '../kernel/kernel_helper.dart';
import '../messages.dart';
import '../problems.dart';
import '../scope.dart';
import '../type_inference/type_inference_engine.dart';
import '../util/helpers.dart';
import 'class_declaration.dart';
import 'source_builder_mixins.dart';
Expand Down Expand Up @@ -220,6 +221,21 @@ class SourceExtensionTypeDeclarationBuilder
if (typeBuilder.isExplicit) {
representationType =
typeBuilder.build(libraryBuilder, TypeUse.fieldType);
if (typeParameters != null) {
IncludesTypeParametersNonCovariantly checker =
new IncludesTypeParametersNonCovariantly(
extensionTypeDeclaration.typeParameters,
// We are checking the returned type (field/getter type or return
// type of a method) and this is a covariant position.
initialVariance: Variance.covariant);
if (representationType.accept(checker)) {
libraryBuilder.addProblem(
messageNonCovariantTypeParameterInRepresentationType,
typeBuilder.charOffset!,
noLength,
typeBuilder.fileUri);
}
}
} else {
representationType = const DynamicType();
}
Expand Down
1 change: 1 addition & 0 deletions pkg/front_end/messages.status
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ NonAugmentationLibraryMemberConflict/analyzerCode: Fail
NonAugmentationLibraryMemberConflict/part_wrapped_script: Fail # Uses imports
NonConstConstructor/example: Fail
NonConstFactory/example: Fail
NonCovariantTypeParameterInRepresentationType/analyzerCode: Fail
NonInstanceTypeVariableUse/example: Fail
NonNullAwareSpreadIsNull/analyzerCode: Fail # There's no analyzer code for that error yet.
NonNullableInNullAware/analyzerCode: Fail
Expand Down
7 changes: 7 additions & 0 deletions pkg/front_end/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7058,3 +7058,10 @@ UnsupportedMacroApplication:
ScriptTagInPartFile:
problemMessage: "A part file cannot have script tag."
correctionMessage: "Try removing the script tag or the 'part of' directive."

NonCovariantTypeParameterInRepresentationType:
problemMessage: "An extension type parameter can't be used non-covariantly in its representation type."
correctionMessage: "Try removing the type parameters from function parameter types and type parameter bounds."
experiments: inline-class
script: |
extension type E<T>(void Function(T) f) {}
1 change: 1 addition & 0 deletions pkg/front_end/test/spell_checking_list_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ besides
beta
bigger
bitmask
bivariant
bkonyi
bla
blah
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2023, 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.

typedef Contravariant<T> = void Function(T);
typedef Invariant<T> = void Function<S extends T>();
typedef Covariant<T> = T Function();
typedef Bivariant<T> = T Function(T);

extension type ET_Contravariant<T>(void Function(T) f) /* Error */ {}

extension type ET_Invariant<T>(void Function<S extends T>() f) /* Error */ {}

extension type ET_Covariant<T>(T Function() f) /* Ok */ {}

extension type ET_Bivariant<T>(T Function(T) f) /* Error */ {}

extension type ET_ContravariantAlias<T>(Contravariant<T> f) /* Error */ {}

extension type ET_InvariantAlias<T>(Invariant<T> f) /* Error */ {}

extension type ET_CovariantAlias<T>(Covariant<T> f) /* Ok */ {}

extension type ET_BivariantAlias<T>(Bivariant<T> f) /* Error */ {}

extension type ET_ContravariantAlias1<T>
(Contravariant<T> Function() f) /* Error */ {}

extension type ET_ContravariantAlias2<T>
(void Function(Covariant<T>) f) /* Error */ {}

extension type ET_CovariantAlias1<T>
(Covariant<T> Function() f) /* Ok */ {}

extension type ET_CovariantAlias2<T>
(void Function(Contravariant<T>) f) /* Ok */ {}
Loading

0 comments on commit eb76707

Please sign in to comment.