[cfe] Handle potentially constant types in instantiations

Part of https://github.com/dart-lang/sdk/issues/46232

Closes #47154

Change-Id: I71fe16d26facf29bdae1b98971c4ccfe18f95e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213772
Reviewed-by: Chloe Stefantsova <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2021-09-23 09:04:12 +00:00 committed by commit-bot@chromium.org
parent 93d2f90383
commit 2fa89236d7
26 changed files with 2402 additions and 164 deletions

View file

@ -69,6 +69,7 @@ enum NullValue {
TypeList,
TypeVariable,
TypeVariables,
UnresolvedType,
VarFinalOrConstToken,
WithClause,
}
@ -374,7 +375,7 @@ abstract class StackListener extends Listener {
@override
void handleNoType(Token lastConsumed) {
debugEvent("NoType");
push(NullValue.Type);
push(NullValue.UnresolvedType);
}
@override

View file

@ -56,7 +56,6 @@ import '../builder/enum_builder.dart';
import '../builder/extension_builder.dart';
import '../builder/factory_builder.dart';
import '../builder/field_builder.dart';
import '../builder/fixed_type_builder.dart';
import '../builder/formal_parameter_builder.dart';
import '../builder/function_builder.dart';
import '../builder/function_type_builder.dart';
@ -219,7 +218,10 @@ class BodyBuilder extends ScopeListener<JumpTarget>
/// When parsing this initializer `x = x`, `x` must be resolved in two
/// different scopes. The first `x` must be resolved in the class' scope, the
/// second in the formal parameter scope.
bool inInitializer = false;
bool inInitializerLeftHandSide = false;
/// This is set to true when we are parsing constructor initializers.
bool inConstructorInitializer = false;
/// Set to `true` when we are parsing a field initializer either directly
/// or within an initializer list.
@ -264,7 +266,6 @@ class BodyBuilder extends ScopeListener<JumpTarget>
Link<bool> _isOrAsOperatorTypeState = const Link<bool>().prepend(false);
@override
bool get inIsOrAsOperatorType => _isOrAsOperatorTypeState.head;
Link<bool> _localInitializerState = const Link<bool>().prepend(false);
@ -294,7 +295,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
@override
ConstantContext constantContext = ConstantContext.none;
UnresolvedType? currentLocalVariableType;
DartType? currentLocalVariableType;
// Using non-null value to initialize this field based on performance advice
// from VM engineers. TODO(ahe): Does this still apply?
@ -478,7 +479,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (node is DartType) {
unhandled("DartType", "push", -1, uri);
}
inInitializer = false;
inInitializerLeftHandSide = false;
super.push(node);
}
@ -852,7 +853,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
// `invalid-type`.
UnresolvedType? type = pop() as UnresolvedType?;
if (type != null) {
buildDartType(type);
buildDartType(type, allowPotentiallyConstantType: false);
}
}
pop(); // Annotations.
@ -956,6 +957,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (functionNestingLevel == 0) {
prepareInitializers();
}
inConstructorInitializer = true;
}
@override
@ -964,12 +966,13 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (functionNestingLevel == 0) {
scope = formalParameterScope ?? new Scope.immutable();
}
inConstructorInitializer = false;
}
@override
void beginInitializer(Token token) {
debugEvent("beginInitializer");
inInitializer = true;
inInitializerLeftHandSide = true;
inFieldInitializer = true;
}
@ -985,7 +988,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
debugEvent("endInitializer");
inFieldInitializer = false;
assert(!inInitializer);
assert(!inInitializerLeftHandSide);
Object? node = pop();
List<Initializer> initializers;
@ -1805,7 +1808,9 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (isInForest) {
assert(forest.argumentsTypeArguments(arguments).isEmpty);
forest.argumentsSetTypeArguments(
arguments, buildDartTypeArguments(typeArguments));
arguments,
buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: false));
} else {
assert(typeArguments == null ||
(receiver is TypeUseGenerator &&
@ -2357,25 +2362,15 @@ class BodyBuilder extends ScopeListener<JumpTarget>
debugEvent("handleIdentifier");
String name = token.lexeme;
if (context.isScopeReference) {
assert(!inInitializer ||
assert(!inInitializerLeftHandSide ||
this.scope == enclosingScope ||
this.scope.parent == enclosingScope);
// This deals with this kind of initializer: `C(a) : a = a;`
Scope scope = inInitializer ? enclosingScope : this.scope;
Scope scope = inInitializerLeftHandSide ? enclosingScope : this.scope;
push(scopeLookup(scope, name, token));
} else {
if (context.inDeclaration) {
if (context == IdentifierContext.topLevelVariableDeclaration ||
context == IdentifierContext.fieldDeclaration) {
constantContext = member.isConst
? ConstantContext.inferred
: !member.isStatic &&
classBuilder != null &&
classBuilder!.declaresConstConstructor
? ConstantContext.required
: ConstantContext.none;
}
} else if (constantContext != ConstantContext.none &&
if (!context.inDeclaration &&
constantContext != ConstantContext.none &&
!context.allowedInConstantExpression) {
addProblem(fasta.messageNotAConstantExpression, token.charOffset,
token.length);
@ -2446,7 +2441,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (declaration != null &&
declaration.isDeclarationInstanceMember &&
(inFieldInitializer && !inLateFieldInitializer) &&
!inInitializer) {
!inInitializerLeftHandSide) {
// We cannot access a class instance member in an initializer of a
// field.
//
@ -2469,7 +2464,8 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (!isQualified && isDeclarationInstanceContext) {
assert(declaration == null);
if (constantContext != ConstantContext.none ||
(inFieldInitializer && !inLateFieldInitializer) && !inInitializer) {
(inFieldInitializer && !inLateFieldInitializer) &&
!inInitializerLeftHandSide) {
return new UnresolvedNameGenerator(this, token, n,
unresolvedReadKind: UnresolvedKind.Unknown);
}
@ -2521,7 +2517,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
}
} else if (declaration.isClassInstanceMember) {
if (constantContext != ConstantContext.none &&
!inInitializer &&
!inInitializerLeftHandSide &&
// TODO(ahe): This is a hack because Fasta sets up the scope
// "this.field" parameters according to old semantics. Under the new
// semantics, such parameters introduces a new parameter with that
@ -2884,9 +2880,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
identifier.name, functionNestingLevel,
forSyntheticToken: identifier.token.isSynthetic,
initializer: initializer,
type: currentLocalVariableType != null
? buildDartType(currentLocalVariableType!)
: null,
type: currentLocalVariableType,
isFinal: isFinal,
isConst: isConst,
isLate: isLate,
@ -2906,6 +2900,13 @@ class BodyBuilder extends ScopeListener<JumpTarget>
@override
void beginFieldInitializer(Token token) {
inFieldInitializer = true;
constantContext = member.isConst
? ConstantContext.inferred
: !member.isStatic &&
classBuilder != null &&
classBuilder!.declaresConstConstructor
? ConstantContext.required
: ConstantContext.none;
if (member is FieldBuilder) {
FieldBuilder fieldBuilder = member as FieldBuilder;
inLateFieldInitializer = fieldBuilder.isLate;
@ -2928,17 +2929,26 @@ class BodyBuilder extends ScopeListener<JumpTarget>
inLateFieldInitializer = false;
assert(assignmentOperator.stringValue == "=");
push(popForValue());
constantContext = ConstantContext.none;
}
@override
void handleNoFieldInitializer(Token token) {
debugEvent("NoFieldInitializer");
constantContext = member.isConst
? ConstantContext.inferred
: !member.isStatic &&
classBuilder != null &&
classBuilder!.declaresConstConstructor
? ConstantContext.required
: ConstantContext.none;
if (constantContext == ConstantContext.inferred) {
// Creating a null value to prevent the Dart VM from crashing.
push(forest.createNullLiteral(offsetForToken(token)));
} else {
push(NullValue.FieldInitializer);
}
constantContext = ConstantContext.none;
}
@override
@ -2963,7 +2973,11 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (!libraryBuilder.isNonNullableByDefault) {
reportNonNullableModifierError(lateToken);
}
UnresolvedType? type = pop() as UnresolvedType?;
UnresolvedType? unresolvedType =
pop(NullValue.UnresolvedType) as UnresolvedType?;
DartType? type = unresolvedType != null
? buildDartType(unresolvedType, allowPotentiallyConstantType: false)
: null;
int modifiers = (lateToken != null ? lateMask : 0) |
Modifier.validateVarFinalOrConst(varFinalOrConst?.lexeme);
_enterLocalState(inLateLocalInitializer: lateToken != null);
@ -2983,7 +2997,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (count == 1) {
Object? node = pop();
constantContext = pop() as ConstantContext;
currentLocalVariableType = pop() as UnresolvedType?;
currentLocalVariableType = pop(NullValue.Type) as DartType?;
currentLocalVariableModifiers = pop() as int;
List<Expression>? annotations = pop() as List<Expression>?;
if (node is ParserRecovery) {
@ -3003,7 +3017,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
const FixedNullableList<VariableDeclaration>()
.popNonNullable(stack, count, dummyVariableDeclaration);
constantContext = pop() as ConstantContext;
currentLocalVariableType = pop() as UnresolvedType?;
currentLocalVariableType = pop(NullValue.Type) as DartType?;
currentLocalVariableModifiers = pop() as int;
List<Expression>? annotations = pop() as List<Expression>?;
if (variables == null) {
@ -3404,7 +3418,8 @@ class BodyBuilder extends ScopeListener<JumpTarget>
lengthOfSpan(leftBracket, leftBracket.endGroup));
typeArgument = const InvalidType();
} else {
typeArgument = buildDartType(typeArguments.single);
typeArgument = buildDartType(typeArguments.single,
allowPotentiallyConstantType: false);
typeArgument = instantiateToBounds(
typeArgument, coreTypes.objectClass, libraryBuilder.library);
}
@ -3428,7 +3443,8 @@ class BodyBuilder extends ScopeListener<JumpTarget>
Token leftBrace, List<dynamic>? setOrMapEntries) {
DartType typeArgument;
if (typeArguments != null) {
typeArgument = buildDartType(typeArguments.single);
typeArgument = buildDartType(typeArguments.single,
allowPotentiallyConstantType: false);
typeArgument = instantiateToBounds(
typeArgument, coreTypes.objectClass, libraryBuilder.library);
} else {
@ -3568,8 +3584,10 @@ class BodyBuilder extends ScopeListener<JumpTarget>
keyType = const InvalidType();
valueType = const InvalidType();
} else {
keyType = buildDartType(typeArguments[0]);
valueType = buildDartType(typeArguments[1]);
keyType = buildDartType(typeArguments[0],
allowPotentiallyConstantType: false);
valueType = buildDartType(typeArguments[1],
allowPotentiallyConstantType: false);
keyType = instantiateToBounds(
keyType, coreTypes.objectClass, libraryBuilder.library);
valueType = instantiateToBounds(
@ -3698,8 +3716,19 @@ class BodyBuilder extends ScopeListener<JumpTarget>
}
TypeBuilder? result;
if (name is Generator) {
bool allowPotentiallyConstantType;
if (libraryBuilder.isNonNullableByDefault) {
if (enableConstructorTearOffsInLibrary) {
allowPotentiallyConstantType = true;
} else {
allowPotentiallyConstantType = inIsOrAsOperatorType;
}
} else {
allowPotentiallyConstantType = false;
}
result = name.buildTypeWithResolvedArguments(
libraryBuilder.nullableBuilderIfTrue(isMarkedAsNullable), arguments);
libraryBuilder.nullableBuilderIfTrue(isMarkedAsNullable), arguments,
allowPotentiallyConstantType: allowPotentiallyConstantType);
// ignore: unnecessary_null_comparison
if (result == null) {
unhandled("null", "result", beginToken.charOffset, uri);
@ -3944,7 +3973,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
// where not calling [buildDartType] leads to a missing compile-time
// error. Also, notice that the type of the problematic parameter isn't
// `invalid-type`.
buildDartType(type);
buildDartType(type, allowPotentiallyConstantType: false);
}
int modifiers = pop() as int;
if (inCatchClause) {
@ -4152,7 +4181,8 @@ class BodyBuilder extends ScopeListener<JumpTarget>
popIfNotNull(onKeyword) as UnresolvedType?;
DartType exceptionType;
if (unresolvedExceptionType != null) {
exceptionType = buildDartType(unresolvedExceptionType);
exceptionType = buildDartType(unresolvedExceptionType,
allowPotentiallyConstantType: false);
} else {
exceptionType = (libraryBuilder.isNonNullableByDefault
? coreTypes.objectNonNullableRawType
@ -4855,8 +4885,11 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (enableConstructorTearOffsInLibrary && inImplicitCreationContext) {
Expression receiver = receiverFunction();
if (typeArguments != null) {
receiver = forest.createInstantiation(instantiationOffset, receiver,
buildDartTypeArguments(typeArguments));
receiver = forest.createInstantiation(
instantiationOffset,
receiver,
buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: true));
}
return forest.createMethodInvocation(invocationOffset, receiver,
new Name(constructorName, libraryBuilder.nameOrigin), arguments);
@ -4864,7 +4897,9 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (typeArguments != null) {
assert(forest.argumentsTypeArguments(arguments).isEmpty);
forest.argumentsSetTypeArguments(
arguments, buildDartTypeArguments(typeArguments));
arguments,
buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: false));
}
return buildUnresolvedError(
forest.createNullLiteral(instantiationOffset),
@ -5085,7 +5120,9 @@ class BodyBuilder extends ScopeListener<JumpTarget>
if (typeArguments != null && !isTypeArgumentsInForest) {
assert(forest.argumentsTypeArguments(arguments).isEmpty);
forest.argumentsSetTypeArguments(
arguments, buildDartTypeArguments(typeArguments));
arguments,
buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: false));
}
}
if (type is ClassBuilder) {
@ -5319,7 +5356,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
push(_createReadOnlyVariableAccess(extensionThis!, token,
offsetForToken(token), 'this', ReadOnlyAccessKind.ExtensionThis));
} else {
push(new ThisAccessGenerator(this, token, inInitializer,
push(new ThisAccessGenerator(this, token, inInitializerLeftHandSide,
inFieldInitializer, inLateFieldInitializer));
}
} else {
@ -5336,7 +5373,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
extensionThis == null) {
MemberBuilder memberBuilder = member as MemberBuilder;
memberBuilder.member.transformerFlags |= TransformerFlag.superCalls;
push(new ThisAccessGenerator(this, token, inInitializer,
push(new ThisAccessGenerator(this, token, inInitializerLeftHandSide,
inFieldInitializer, inLateFieldInitializer,
isSuper: true));
} else {
@ -5979,7 +6016,7 @@ class BodyBuilder extends ScopeListener<JumpTarget>
// If in an assert initializer, make sure [inInitializer] is false so we
// use the formal parameter scope. If this is any other kind of assert,
// inInitializer should be false anyway.
inInitializer = false;
inInitializerLeftHandSide = false;
}
@override
@ -6765,7 +6802,9 @@ class BodyBuilder extends ScopeListener<JumpTarget>
openAngleBracket.charOffset, noLength));
} else {
push(new Instantiation(
toValue(operand), buildDartTypeArguments(typeArguments))
toValue(operand),
buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: true))
..fileOffset = openAngleBracket.charOffset);
}
} else {
@ -6780,95 +6819,73 @@ class BodyBuilder extends ScopeListener<JumpTarget>
}
@override
UnresolvedType validateTypeUse(UnresolvedType unresolved,
{required bool nonInstanceAccessIsError,
required bool allowPotentiallyConstantType}) {
// ignore: unnecessary_null_comparison
assert(nonInstanceAccessIsError != null);
UnresolvedType validateTypeVariableUse(UnresolvedType unresolved,
{required bool allowPotentiallyConstantType}) {
// ignore: unnecessary_null_comparison
assert(allowPotentiallyConstantType != null);
TypeBuilder builder = unresolved.builder;
if (builder is NamedTypeBuilder && builder.declaration!.isTypeVariable) {
TypeVariableBuilder typeParameterBuilder =
builder.declaration as TypeVariableBuilder;
TypeParameter typeParameter = typeParameterBuilder.parameter;
LocatedMessage? message = _validateTypeUseIsInternal(
builder, unresolved.fileUri, unresolved.charOffset,
_validateTypeVariableUseInternal(
unresolved.builder, unresolved.fileUri, unresolved.charOffset,
allowPotentiallyConstantType: allowPotentiallyConstantType);
if (message == null) return unresolved;
return new UnresolvedType(
new NamedTypeBuilder(typeParameter.name!, builder.nullabilityBuilder,
/* arguments = */ null, unresolved.fileUri, unresolved.charOffset)
..bind(new InvalidTypeDeclarationBuilder(
typeParameter.name!, message)),
unresolved.charOffset,
unresolved.fileUri);
} else if (builder is FunctionTypeBuilder) {
LocatedMessage? message = _validateTypeUseIsInternal(
builder, unresolved.fileUri, unresolved.charOffset,
allowPotentiallyConstantType: allowPotentiallyConstantType);
if (message == null) return unresolved;
// TODO(johnniwinther): We should either remove this method completely and
// fully handle this with `nonInstanceContext`, or fully handle all types
// and remove `nonInstanceContext`.
return new UnresolvedType(
new FixedTypeBuilder(
const InvalidType(), unresolved.fileUri, unresolved.charOffset),
unresolved.charOffset,
unresolved.fileUri);
}
return unresolved;
}
LocatedMessage? _validateTypeUseIsInternal(
void _validateTypeVariableUseInternal(
TypeBuilder? builder, Uri fileUri, int charOffset,
{required bool allowPotentiallyConstantType}) {
// ignore: unnecessary_null_comparison
assert(allowPotentiallyConstantType != null);
if (builder is NamedTypeBuilder && builder.declaration!.isTypeVariable) {
if (builder is NamedTypeBuilder) {
if (builder.declaration!.isTypeVariable) {
TypeVariableBuilder typeParameterBuilder =
builder.declaration as TypeVariableBuilder;
TypeParameter typeParameter = typeParameterBuilder.parameter;
LocatedMessage message;
bool extensionField =
member.isExtensionMember && member.isField && !member.isExternal;
if ((extensionField || !isDeclarationInstanceContext) &&
(typeParameter.parent is Class ||
typeParameter.parent is Extension)) {
message = fasta.messageTypeVariableInStaticContext.withLocation(
builder.fileUri ?? fileUri,
builder.charOffset ?? charOffset,
typeParameter.name!.length);
} else if (constantContext == ConstantContext.inferred &&
!allowPotentiallyConstantType) {
message = fasta.messageTypeVariableInConstantContext
.withLocation(fileUri, charOffset, typeParameter.name!.length);
} else {
return null;
}
// TODO(johnniwinther): Can we unify this check with the similar check
// in NamedTypeBuilder.buildTypeInternal. If we skip it here, the
// error below (type variable in constant context) will be emitted
// _instead_ of this (type variable in static context), which seems
// like an odd prioritization.
LocatedMessage message = fasta.messageTypeVariableInStaticContext
.withLocation(builder.fileUri ?? fileUri,
builder.charOffset ?? charOffset, typeParameter.name!.length);
builder.bind(
new InvalidTypeDeclarationBuilder(typeParameter.name!, message));
addProblem(message.messageObject, message.charOffset, message.length);
} else if (constantContext != ConstantContext.none &&
(!inConstructorInitializer || !allowPotentiallyConstantType)) {
LocatedMessage message = fasta.messageTypeVariableInConstantContext
.withLocation(fileUri, charOffset, typeParameter.name!.length);
builder.bind(
new InvalidTypeDeclarationBuilder(typeParameter.name!, message));
addProblem(message.messageObject, message.charOffset, message.length);
return message;
} else if (builder is FunctionTypeBuilder) {
LocatedMessage? result = _validateTypeUseIsInternal(
builder.returnType, fileUri, charOffset,
allowPotentiallyConstantType: allowPotentiallyConstantType);
if (result != null) {
return result;
}
}
if (builder.arguments != null) {
for (TypeBuilder typeBuilder in builder.arguments!) {
_validateTypeVariableUseInternal(
typeBuilder,
typeBuilder.fileUri ?? fileUri,
typeBuilder.charOffset ?? charOffset,
allowPotentiallyConstantType: allowPotentiallyConstantType);
}
}
} else if (builder is FunctionTypeBuilder) {
_validateTypeVariableUseInternal(builder.returnType, fileUri, charOffset,
allowPotentiallyConstantType: allowPotentiallyConstantType);
if (builder.formals != null) {
for (FormalParameterBuilder formalParameterBuilder
in builder.formals!) {
result = _validateTypeUseIsInternal(
_validateTypeVariableUseInternal(
formalParameterBuilder.type, fileUri, charOffset,
allowPotentiallyConstantType: allowPotentiallyConstantType);
if (result != null) {
return result;
}
}
}
}
return null;
}
@override
Expression evaluateArgumentsBefore(
@ -7026,10 +7043,8 @@ class BodyBuilder extends ScopeListener<JumpTarget>
@override
DartType buildDartType(UnresolvedType unresolvedType,
{bool nonInstanceAccessIsError: false,
bool allowPotentiallyConstantType: false}) {
return validateTypeUse(unresolvedType,
nonInstanceAccessIsError: nonInstanceAccessIsError,
{required bool allowPotentiallyConstantType}) {
return validateTypeVariableUse(unresolvedType,
allowPotentiallyConstantType: allowPotentiallyConstantType)
.builder
.build(libraryBuilder);
@ -7037,20 +7052,21 @@ class BodyBuilder extends ScopeListener<JumpTarget>
@override
DartType buildTypeLiteralDartType(UnresolvedType unresolvedType,
{bool nonInstanceAccessIsError: false,
bool allowPotentiallyConstantType: false}) {
return validateTypeUse(unresolvedType,
nonInstanceAccessIsError: nonInstanceAccessIsError,
{required bool allowPotentiallyConstantType}) {
return validateTypeVariableUse(unresolvedType,
allowPotentiallyConstantType: allowPotentiallyConstantType)
.builder
.buildTypeLiteralType(libraryBuilder);
}
@override
List<DartType> buildDartTypeArguments(List<UnresolvedType>? unresolvedTypes) {
List<DartType> buildDartTypeArguments(List<UnresolvedType>? unresolvedTypes,
{required bool allowPotentiallyConstantType}) {
if (unresolvedTypes == null) return <DartType>[];
return new List<DartType>.generate(
unresolvedTypes.length, (int i) => buildDartType(unresolvedTypes[i]),
unresolvedTypes.length,
(int i) => buildDartType(unresolvedTypes[i],
allowPotentiallyConstantType: allowPotentiallyConstantType),
growable: true);
}

View file

@ -260,7 +260,9 @@ abstract class Generator {
Expression_Generator applyTypeArguments(
int fileOffset, List<UnresolvedType>? typeArguments) {
return new Instantiation(
buildSimpleRead(), _helper.buildDartTypeArguments(typeArguments))
buildSimpleRead(),
_helper.buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: true))
..fileOffset = fileOffset;
}
@ -270,7 +272,8 @@ abstract class Generator {
/// The type arguments have not been resolved and should be resolved to
/// create a [TypeBuilder] for a valid type.
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments) {
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments,
{required bool allowPotentiallyConstantType}) {
// TODO(johnniwinther): Could we use a FixedTypeBuilder(InvalidType()) here?
NamedTypeBuilder result = new NamedTypeBuilder(
token.lexeme,
@ -2897,11 +2900,13 @@ class DeferredAccessGenerator extends Generator {
@override
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments) {
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments,
{required bool allowPotentiallyConstantType}) {
String name = "${prefixGenerator._plainNameForRead}."
"${suffixGenerator._plainNameForRead}";
TypeBuilder type = suffixGenerator.buildTypeWithResolvedArguments(
nullabilityBuilder, arguments);
nullabilityBuilder, arguments,
allowPotentiallyConstantType: allowPotentiallyConstantType);
LocatedMessage message;
if (type is NamedTypeBuilder &&
type.declaration is InvalidTypeDeclarationBuilder) {
@ -2912,7 +2917,8 @@ class DeferredAccessGenerator extends Generator {
int charOffset = offsetForToken(prefixGenerator.token);
message = templateDeferredTypeAnnotation
.withArguments(
_helper.buildDartType(new UnresolvedType(type, charOffset, _uri)),
_helper.buildDartType(new UnresolvedType(type, charOffset, _uri),
allowPotentiallyConstantType: allowPotentiallyConstantType),
prefixGenerator._plainNameForRead,
_helper.libraryBuilder.isNonNullableByDefault)
.withLocation(
@ -3022,17 +3028,19 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
@override
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments) {
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments,
{required bool allowPotentiallyConstantType}) {
if (declaration.isExtension && !_helper.enableExtensionTypesInLibrary) {
// Extension declarations cannot be used as types.
return super
.buildTypeWithResolvedArguments(nullabilityBuilder, arguments);
return super.buildTypeWithResolvedArguments(nullabilityBuilder, arguments,
allowPotentiallyConstantType: allowPotentiallyConstantType);
}
if (arguments != null) {
int expected = declaration.typeVariablesCount;
if (arguments.length != expected) {
// Build the type arguments to report any errors they may have.
_helper.buildDartTypeArguments(arguments);
_helper.buildDartTypeArguments(arguments,
allowPotentiallyConstantType: allowPotentiallyConstantType);
_helper.warnTypeArgumentsMismatch(
declaration.name, expected, fileOffset);
// We ignore the provided arguments, which will in turn return the
@ -3048,11 +3056,8 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
argumentBuilders =
new List<TypeBuilder>.generate(arguments.length, (int i) {
return _helper
.validateTypeUse(arguments![i],
nonInstanceAccessIsError: false,
allowPotentiallyConstantType:
_helper.libraryBuilder.isNonNullableByDefault &&
_helper.inIsOrAsOperatorType)
.validateTypeVariableUse(arguments![i],
allowPotentiallyConstantType: allowPotentiallyConstantType)
.builder;
}, growable: false);
}
@ -3105,10 +3110,12 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
new UnresolvedType(
buildTypeWithResolvedArguments(
_helper.libraryBuilder.nonNullableBuilder,
typeArguments),
typeArguments,
allowPotentiallyConstantType: true),
fileOffset,
_uri),
nonInstanceAccessIsError: true));
allowPotentiallyConstantType:
_helper.enableConstructorTearOffsInLibrary));
}
}
return _expression!;
@ -3131,8 +3138,16 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
isUsedAsClass: true,
usedAsClassCharOffset: this.fileOffset,
usedAsClassFileUri: _uri);
List<TypeBuilder>? aliasedTypeArguments =
typeArguments?.map((unknownType) => unknownType.builder).toList();
bool isConstructorTearOff = send is PropertySelector &&
_helper.enableConstructorTearOffsInLibrary &&
declarationBuilder is ClassBuilder;
List<TypeBuilder>? aliasedTypeArguments = typeArguments
?.map((unknownType) => _helper
.validateTypeVariableUse(unknownType,
allowPotentiallyConstantType: isConstructorTearOff)
.builder)
.toList();
if (aliasedTypeArguments != null &&
aliasedTypeArguments.length != aliasBuilder.typeVariablesCount) {
_helper.libraryBuilder.addProblem(
@ -3236,8 +3251,9 @@ class TypeUseGenerator extends AbstractReadOnlyAccessGenerator {
_helper.libraryBuilder, unaliasedTypeArguments);
}
} else if (typeArguments != null) {
builtTypeArguments =
_helper.buildDartTypeArguments(typeArguments);
builtTypeArguments = _helper.buildDartTypeArguments(
typeArguments,
allowPotentiallyConstantType: true);
}
if (isGenericTypedefTearOff) {
if (isProperRenameForClass(_helper.typeEnvironment,
@ -3670,7 +3686,9 @@ abstract class ErroneousExpressionGenerator extends Generator {
if (typeArguments != null) {
assert(_forest.argumentsTypeArguments(arguments).isEmpty);
_forest.argumentsSetTypeArguments(
arguments, _helper.buildDartTypeArguments(typeArguments));
arguments,
_helper.buildDartTypeArguments(typeArguments,
allowPotentiallyConstantType: false));
}
return buildError(arguments, kind: UnresolvedKind.Constructor);
}
@ -4145,7 +4163,8 @@ class UnexpectedQualifiedUseGenerator extends Generator {
@override
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments) {
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments,
{required bool allowPotentiallyConstantType}) {
Template<Message Function(String, String)> template = isUnresolved
? templateUnresolvedPrefixInTypeAnnotation
: templateNotAPrefixInTypeAnnotation;
@ -4269,7 +4288,8 @@ class ParserErrorGenerator extends Generator {
@override
TypeBuilder buildTypeWithResolvedArguments(
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments) {
NullabilityBuilder nullabilityBuilder, List<UnresolvedType>? arguments,
{required bool allowPotentiallyConstantType}) {
// TODO(johnniwinther): Could we use a FixedTypeBuilder(InvalidType()) here?
NamedTypeBuilder result = new NamedTypeBuilder(
token.lexeme,

View file

@ -48,9 +48,6 @@ abstract class ExpressionGeneratorHelper implements InferenceHelper {
Member? lookupInstanceMember(Name name, {bool isSetter, bool isSuper});
/// `true` if we are in the type of an as expression.
bool get inIsOrAsOperatorType;
bool get enableExtensionTypesInLibrary;
bool get enableConstFunctionsInLibrary;
@ -125,9 +122,8 @@ abstract class ExpressionGeneratorHelper implements InferenceHelper {
TypeDeclarationBuilder? typeAliasBuilder,
required UnresolvedKind unresolvedKind});
UnresolvedType validateTypeUse(UnresolvedType unresolved,
{required bool nonInstanceAccessIsError,
required bool allowPotentiallyConstantType});
UnresolvedType validateTypeVariableUse(UnresolvedType unresolved,
{required bool allowPotentiallyConstantType});
void addProblemErrorIfConst(Message message, int charOffset, int length);
@ -150,12 +146,13 @@ abstract class ExpressionGeneratorHelper implements InferenceHelper {
Arguments arguments, Expression expression);
DartType buildDartType(UnresolvedType unresolvedType,
{bool nonInstanceAccessIsError: false});
{required bool allowPotentiallyConstantType});
DartType buildTypeLiteralDartType(UnresolvedType unresolvedType,
{bool nonInstanceAccessIsError});
{required bool allowPotentiallyConstantType});
List<DartType> buildDartTypeArguments(List<UnresolvedType>? unresolvedTypes);
List<DartType> buildDartTypeArguments(List<UnresolvedType>? unresolvedTypes,
{required bool allowPotentiallyConstantType});
void reportDuplicatedDeclaration(
Builder existing, String name, int charOffset);

View file

@ -108,7 +108,7 @@ class ValueKinds {
static const ValueKind TokenOrNull =
const SingleValueKind<type.Token>(NullValue.Token);
static const ValueKind TypeOrNull =
const SingleValueKind<type.UnresolvedType>(NullValue.Type);
const SingleValueKind<type.UnresolvedType>(NullValue.UnresolvedType);
static const ValueKind TypeArguments =
const SingleValueKind<List<type.UnresolvedType>>();
static const ValueKind TypeArgumentsOrNull =
@ -116,7 +116,7 @@ class ValueKinds {
static const ValueKind TypeBuilder =
const SingleValueKind<type.TypeBuilder>();
static const ValueKind TypeBuilderOrNull =
const SingleValueKind<type.TypeBuilder>(NullValue.Type);
const SingleValueKind<type.TypeBuilder>(NullValue.UnresolvedType);
static const ValueKind TypeBuilderListOrNull =
const SingleValueKind<List<type.TypeBuilder>>(NullValue.TypeBuilderList);
static const ValueKind TypeVariableListOrNull =

View file

@ -935,6 +935,7 @@ prime
printer
printf
println
prioritization
proc
producers
product

View file

@ -0,0 +1,32 @@
// Copyright (c) 2021, 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.
// A potentially constant type expression is supported for `as` (and `is`)
class A<X> {
final List<X> x;
const A(x) : x = x is List<X> ? x : x as List<X>;
}
void m<X>(X x) {}
// Generic function instantiation to a type parameter is supported implicitly.
class B<X> {
final void Function(X) f;
const B() : f = m;
}
// But it is not supported explicitly.
class C<X> {
final f;
const C() : f = m<X>; // Error, but should be accepted.
}
void main() {
const A<int>(<int>[1]); // OK.
const b = B<String>(); // OK.
print(b.f.runtimeType); // OK: 'String => void'.
const c = C<
String>(); // Compile-time error in `C`, but should be accepted when it works.
print(c.f.runtimeType); // (Never executed, so we don't know).
}

View file

@ -0,0 +1,46 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field core::List<self::A::X%> x;
const constructor •(dynamic x) → self::A<self::A::X%>
: self::A::x = x is{ForNonNullableByDefault} core::List<self::A::X%> ?{core::List<self::A::X%>} x{core::List<self::A::X%>} : x as{ForNonNullableByDefault} core::List<self::A::X%>, super core::Object::•()
;
}
class B<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field (self::B::X%) → void f;
const constructor •() → self::B<self::B::X%>
: self::B::f = #C1<self::B::X%>, super core::Object::•()
;
}
class C<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic f;
const constructor •() → self::C<self::C::X%>
: self::C::f = #C1<self::C::X%>, super core::Object::•()
;
}
static method m<X extends core::Object? = dynamic>(self::m::X% x) → void {}
static method main() → void {
#C4;
core::print((#C6.{self::B::f}{(core::String) → void} as{TypeError,CovarianceCheck,ForNonNullableByDefault} (core::String) → void).{core::Object::runtimeType}{core::Type});
core::print(#C7.{self::C::f}{dynamic}.{core::Object::runtimeType}{core::Type});
}
constants {
#C1 = static-tearoff self::m
#C2 = 1
#C3 = <core::int>[#C2]
#C4 = self::A<core::int> {x:#C3}
#C5 = instantiation self::m <core::String>
#C6 = self::B<core::String> {f:#C5}
#C7 = self::C<core::String> {f:#C5}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue47154c.dart:
- A. (from org-dartlang-testcase:///issue47154c.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
- B. (from org-dartlang-testcase:///issue47154c.dart:16:9)
- C. (from org-dartlang-testcase:///issue47154c.dart:22:9)

View file

@ -0,0 +1,46 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field core::List<self::A::X%> x;
const constructor •(dynamic x) → self::A<self::A::X%>
: self::A::x = x is{ForNonNullableByDefault} core::List<self::A::X%> ?{core::List<self::A::X%>} x{core::List<self::A::X%>} : x as{ForNonNullableByDefault} core::List<self::A::X%>, super core::Object::•()
;
}
class B<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field (self::B::X%) → void f;
const constructor •() → self::B<self::B::X%>
: self::B::f = #C1<self::B::X%>, super core::Object::•()
;
}
class C<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic f;
const constructor •() → self::C<self::C::X%>
: self::C::f = #C1<self::C::X%>, super core::Object::•()
;
}
static method m<X extends core::Object? = dynamic>(self::m::X% x) → void {}
static method main() → void {
#C4;
core::print((#C6.{self::B::f}{(core::String) → void} as{TypeError,CovarianceCheck,ForNonNullableByDefault} (core::String) → void).{core::Object::runtimeType}{core::Type});
core::print(#C7.{self::C::f}{dynamic}.{core::Object::runtimeType}{core::Type});
}
constants {
#C1 = static-tearoff self::m
#C2 = 1
#C3 = <core::int>[#C2]
#C4 = self::A<core::int> {x:#C3}
#C5 = instantiation self::m <core::String>
#C6 = self::B<core::String> {f:#C5}
#C7 = self::C<core::String> {f:#C5}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue47154c.dart:
- A. (from org-dartlang-testcase:///issue47154c.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
- B. (from org-dartlang-testcase:///issue47154c.dart:16:9)
- C. (from org-dartlang-testcase:///issue47154c.dart:22:9)

View file

@ -0,0 +1,18 @@
class A<X> {
final List<X> x;
const A(x) : x = x is List<X> ? x : x as List<X>;
}
void m<X>(X x) {}
class B<X> {
final void Function(X) f;
const B() : f = m;
}
class C<X> {
final f;
const C() : f = m<X>;
}
void main() {}

View file

@ -0,0 +1,17 @@
class A<X> {
const A(x) : x = x is List<X> ? x : x as List<X>;
final List<X> x;
}
class B<X> {
const B() : f = m;
final void Function(X) f;
}
class C<X> {
const C() : f = m<X>;
final f;
}
void m<X>(X x) {}
void main() {}

View file

@ -0,0 +1,46 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field core::List<self::A::X%> x;
const constructor •(dynamic x) → self::A<self::A::X%>
: self::A::x = x is{ForNonNullableByDefault} core::List<self::A::X%> ?{core::List<self::A::X%>} x{core::List<self::A::X%>} : x as{ForNonNullableByDefault} core::List<self::A::X%>, super core::Object::•()
;
}
class B<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field (self::B::X%) → void f;
const constructor •() → self::B<self::B::X%>
: self::B::f = #C1<self::B::X%>, super core::Object::•()
;
}
class C<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic f;
const constructor •() → self::C<self::C::X%>
: self::C::f = #C1<self::C::X%>, super core::Object::•()
;
}
static method m<X extends core::Object? = dynamic>(self::m::X% x) → void {}
static method main() → void {
#C4;
core::print((#C6.{self::B::f}{(core::String) → void} as{TypeError,CovarianceCheck,ForNonNullableByDefault} (core::String) → void).{core::Object::runtimeType}{core::Type});
core::print(#C7.{self::C::f}{dynamic}.{core::Object::runtimeType}{core::Type});
}
constants {
#C1 = static-tearoff self::m
#C2 = 1
#C3 = <core::int*>[#C2]
#C4 = self::A<core::int*> {x:#C3}
#C5 = instantiation self::m <core::String*>
#C6 = self::B<core::String*> {f:#C5}
#C7 = self::C<core::String*> {f:#C5}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue47154c.dart:
- A. (from org-dartlang-testcase:///issue47154c.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
- B. (from org-dartlang-testcase:///issue47154c.dart:16:9)
- C. (from org-dartlang-testcase:///issue47154c.dart:22:9)

View file

@ -0,0 +1,32 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field core::List<self::A::X%> x;
const constructor •(dynamic x) → self::A<self::A::X%>
: self::A::x = x is{ForNonNullableByDefault} core::List<self::A::X%> ?{core::List<self::A::X%>} x{core::List<self::A::X%>} : x as{ForNonNullableByDefault} core::List<self::A::X%>, super core::Object::•()
;
}
class B<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field (self::B::X%) → void f;
const constructor •() → self::B<self::B::X%>
: self::B::f = self::m<self::B::X%>, super core::Object::•()
;
}
class C<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic f;
const constructor •() → self::C<self::C::X%>
: self::C::f = self::m<self::C::X%>, super core::Object::•()
;
}
static method m<X extends core::Object? = dynamic>(self::m::X% x) → void
;
static method main() → void
;
Extra constant evaluation status:
Evaluated: StaticTearOff @ org-dartlang-testcase:///issue47154c.dart:16:19 -> StaticTearOffConstant(m)
Evaluated: StaticTearOff @ org-dartlang-testcase:///issue47154c.dart:22:19 -> StaticTearOffConstant(m)
Extra constant evaluation: evaluated: 10, effectively constant: 2

View file

@ -0,0 +1,46 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field core::List<self::A::X%> x;
const constructor •(dynamic x) → self::A<self::A::X%>
: self::A::x = x is{ForNonNullableByDefault} core::List<self::A::X%> ?{core::List<self::A::X%>} x{core::List<self::A::X%>} : x as{ForNonNullableByDefault} core::List<self::A::X%>, super core::Object::•()
;
}
class B<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field (self::B::X%) → void f;
const constructor •() → self::B<self::B::X%>
: self::B::f = #C1<self::B::X%>, super core::Object::•()
;
}
class C<X extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic f;
const constructor •() → self::C<self::C::X%>
: self::C::f = #C1<self::C::X%>, super core::Object::•()
;
}
static method m<X extends core::Object? = dynamic>(self::m::X% x) → void {}
static method main() → void {
#C4;
core::print((#C6.{self::B::f}{(core::String) → void} as{TypeError,CovarianceCheck,ForNonNullableByDefault} (core::String) → void).{core::Object::runtimeType}{core::Type});
core::print(#C7.{self::C::f}{dynamic}.{core::Object::runtimeType}{core::Type});
}
constants {
#C1 = static-tearoff self::m
#C2 = 1
#C3 = <core::int*>[#C2]
#C4 = self::A<core::int*> {x:#C3}
#C5 = instantiation self::m <core::String*>
#C6 = self::B<core::String*> {f:#C5}
#C7 = self::C<core::String*> {f:#C5}
}
Constructor coverage from constants:
org-dartlang-testcase:///issue47154c.dart:
- A. (from org-dartlang-testcase:///issue47154c.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9)
- B. (from org-dartlang-testcase:///issue47154c.dart:16:9)
- C. (from org-dartlang-testcase:///issue47154c.dart:22:9)

View file

@ -0,0 +1,75 @@
// Copyright (c) 2021, 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.
// Pre-nnbd language version
// @dart=2.9
import 'potentially_constant_type_lib1.dart';
import 'potentially_constant_type_lib2.dart';
T id<T>(T t) => t;
class Class<T> {
final field1;
final field5;
final field6;
final field7;
final field8;
final field9;
final field10;
final field11;
final field15;
const Class(o)
// Potentially constant context:
: field1 = T,
field5 = <T>[],
field6 = <T>{},
field7 = <T, T>{},
field8 = o is T,
field9 = o is Class<T>,
field10 = o as T,
field11 = o as Class<T>,
field15 = <Class<T>>[];
void method() {
const o = null;
// Required constant context:
const local1 = T;
const local5 = <T>[];
const local6 = <T>{};
const local7 = <T, T>{};
const local8 = o is T;
const local9 = o is Class<T>;
const local10 = o as T;
const local11 = o as Class<T>;
const local15 = <Class<T>>[];
const List<T> listOfNever = []; // ok
print(local1);
print(local5);
print(local6);
print(local7);
print(local8);
print(local9);
print(local10);
print(local11);
print(local15);
print(listOfNever);
// Inferred constant context:
print(const [T]);
print(const [<T>[]]);
print(const [<T>{}]);
print(const [<T, T>{}]);
print(const [o is T]);
print(const [o is Class<T>]);
print(const [o as T]);
print(const [o as Class<T>]);
print(const [<Class<T>>[]]);
}
}
main() {}

View file

@ -0,0 +1,30 @@
// @dart = 2.9
import 'potentially_constant_type_lib1.dart';
import 'potentially_constant_type_lib2.dart';
T id<T>(T t) => t;
class Class<T> {
final field1;
final field5;
final field6;
final field7;
final field8;
final field9;
final field10;
final field11;
final field15;
const Class(o)
: field1 = T,
field5 = <T>[],
field6 = <T>{},
field7 = <T, T>{},
field8 = o is T,
field9 = o is Class<T>,
field10 = o as T,
field11 = o as Class<T>,
field15 = <Class<T>>[];
void method() {}
}
main() {}

View file

@ -0,0 +1,30 @@
// @dart = 2.9
import 'potentially_constant_type_lib1.dart';
import 'potentially_constant_type_lib2.dart';
T id<T>(T t) => t;
class Class<T> {
const Class(o)
: field1 = T,
field5 = <T>[],
field6 = <T>{},
field7 = <T, T>{},
field8 = o is T,
field9 = o is Class<T>,
field10 = o as T,
field11 = o as Class<T>,
field15 = <Class<T>>[];
final field1;
final field10;
final field11;
final field15;
final field5;
final field6;
final field7;
final field8;
final field9;
void method() {}
}
main() {}

View file

@ -0,0 +1,666 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:26:18: Error: Type variables can't be used as constants.
// : field1 = T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:27:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:27:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:28:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:28:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:30:23: Error: Type variables can't be used as constants.
// field8 = o is T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:31:29: Error: Type variables can't be used as constants.
// field9 = o is Class<T>,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:32:24: Error: Type variables can't be used as constants.
// field10 = o as T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:33:30: Error: Type variables can't be used as constants.
// field11 = o as Class<T>,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:34:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:34:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:40:20: Error: Type variables can't be used as constants.
// const local1 = T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:41:21: Error: Type variables can't be used as constants.
// const local5 = <T>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:42:21: Error: Type variables can't be used as constants.
// const local6 = <T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:43:21: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:43:24: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:44:25: Error: Type variables can't be used as constants.
// const local8 = o is T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:45:31: Error: Type variables can't be used as constants.
// const local9 = o is Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:46:26: Error: Type variables can't be used as constants.
// const local10 = o as T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:47:32: Error: Type variables can't be used as constants.
// const local11 = o as Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:48:28: Error: Type variables can't be used as constants.
// const local15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:63:18: Error: Type variables can't be used as constants.
// print(const [T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:64:19: Error: Type variables can't be used as constants.
// print(const [<T>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:65:19: Error: Type variables can't be used as constants.
// print(const [<T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:66:19: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:66:22: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:67:23: Error: Type variables can't be used as constants.
// print(const [o is T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:68:29: Error: Type variables can't be used as constants.
// print(const [o is Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:69:23: Error: Type variables can't be used as constants.
// print(const [o as T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:70:29: Error: Type variables can't be used as constants.
// print(const [o as Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:71:25: Error: Type variables can't be used as constants.
// print(const [<Class<T>>[]]);
// ^
//
import self as self;
import "dart:core" as core;
import "org-dartlang-testcase:///potentially_constant_type_lib1.dart";
import "org-dartlang-testcase:///potentially_constant_type_lib2.dart";
class Class<T extends core::Object* = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field15;
const constructor •(dynamic o) → self::Class<self::Class::T*>*
: self::Class::field1 = #C1, self::Class::field5 = #C2, self::Class::field6 = #C3, self::Class::field7 = #C4, self::Class::field8 = o is invalid-type, self::Class::field9 = o is self::Class<invalid-type>*, self::Class::field10 = o as invalid-type, self::Class::field11 = o as self::Class<invalid-type>*, self::Class::field15 = #C5, super core::Object::•()
;
method method() → void {
core::print(#C1);
core::print(#C2);
core::print(#C3);
core::print(#C4);
core::print(#C6);
core::print(#C7);
core::print(#C8);
core::print(#C8);
core::print(#C5);
core::print(#C9);
core::print(#C10);
core::print(#C11);
core::print(#C12);
core::print(#C13);
core::print(#C14);
core::print(#C15);
core::print(#C16);
core::print(#C17);
core::print(#C18);
}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static method id<T extends core::Object* = dynamic>(self::id::T* t) → self::id::T*
return t;
static method main() → dynamic {}
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:23:18: Error: Type variables can't be used as constants.
// : field1 = T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:24:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:24:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:25:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:25:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:31:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:31:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:37:20: Error: Type variables can't be used as constants.
// const local1 = T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:38:21: Error: Type variables can't be used as constants.
// const local5 = <T>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:39:21: Error: Type variables can't be used as constants.
// const local6 = <T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:40:21: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:40:24: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:41:25: Error: Type variables can't be used as constants.
// const local8 = o is T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:42:31: Error: Type variables can't be used as constants.
// const local9 = o is Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:43:26: Error: Type variables can't be used as constants.
// const local10 = o as T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:44:32: Error: Type variables can't be used as constants.
// const local11 = o as Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:45:28: Error: Type variables can't be used as constants.
// const local15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:60:18: Error: Type variables can't be used as constants.
// print(const [T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:61:19: Error: Type variables can't be used as constants.
// print(const [<T>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:62:19: Error: Type variables can't be used as constants.
// print(const [<T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:63:19: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:63:22: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:64:23: Error: Type variables can't be used as constants.
// print(const [o is T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:65:29: Error: Type variables can't be used as constants.
// print(const [o is Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:66:23: Error: Type variables can't be used as constants.
// print(const [o as T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:67:29: Error: Type variables can't be used as constants.
// print(const [o as Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:68:25: Error: Type variables can't be used as constants.
// print(const [<Class<T>>[]]);
// ^
//
import self as self2;
import "dart:core" as core;
class Class<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field15;
const constructor •(dynamic o) → self2::Class<self2::Class::T%>
: self2::Class::field1 = #C1, self2::Class::field5 = #C2, self2::Class::field6 = #C3, self2::Class::field7 = #C4, self2::Class::field8 = o is{ForNonNullableByDefault} self2::Class::T%, self2::Class::field9 = o is{ForNonNullableByDefault} self2::Class<self2::Class::T%>, self2::Class::field10 = o as{ForNonNullableByDefault} self2::Class::T%, self2::Class::field11 = o{self2::Class::T%} as{ForNonNullableByDefault} self2::Class<self2::Class::T%>, self2::Class::field15 = #C19, super core::Object::•()
;
method method() → void {
core::print(#C1);
core::print(#C2);
core::print(#C3);
core::print(#C4);
core::print(#C6);
core::print(#C7);
core::print(#C8);
core::print(#C8);
core::print(#C19);
core::print(#C20);
core::print(#C10);
core::print(#C11);
core::print(#C12);
core::print(#C13);
core::print(#C14);
core::print(#C15);
core::print(#C21);
core::print(#C22);
core::print(#C23);
}
}
static method id<T extends core::Object? = dynamic>(self2::id::T% t) → self2::id::T%
return t;
static method main() → dynamic {}
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:34:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:34:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:35:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:35:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:44:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:44:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:51:20: Error: Type variables can't be used as constants.
// const local1 = T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:52:26: Error: Type variables can't be used as constants.
// const local2 = Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:53:23: Error: Type variables can't be used as constants.
// const local3 = id<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:54:25: Error: Type variables can't be used as constants.
// const local4 = (id)<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:55:21: Error: Type variables can't be used as constants.
// const local5 = <T>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:56:21: Error: Type variables can't be used as constants.
// const local6 = <T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:57:21: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:57:24: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:58:25: Error: Type variables can't be used as constants.
// const local8 = o is T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:59:31: Error: Type variables can't be used as constants.
// const local9 = o is Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:60:26: Error: Type variables can't be used as constants.
// const local10 = o as T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:61:32: Error: Type variables can't be used as constants.
// const local11 = o as Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:62:27: Error: Type variables can't be used as constants.
// const local12 = Class<T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:63:23: Error: Type variables can't be used as constants.
// const local13 = F<T, T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:63:26: Error: Type variables can't be used as constants.
// const local13 = F<T, T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:64:30: Error: Type variables can't be used as constants.
// const local14 = id<Class<T>>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:65:28: Error: Type variables can't be used as constants.
// const local15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:66:23: Error: Type variables can't be used as constants.
// const local16 = G<T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:88:18: Error: Type variables can't be used as constants.
// print(const [T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:89:24: Error: Type variables can't be used as constants.
// print(const [Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:90:21: Error: Type variables can't be used as constants.
// print(const [id<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:91:23: Error: Type variables can't be used as constants.
// print(const [(id)<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:92:19: Error: Type variables can't be used as constants.
// print(const [<T>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:93:19: Error: Type variables can't be used as constants.
// print(const [<T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:94:19: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:94:22: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:95:23: Error: Type variables can't be used as constants.
// print(const [o is T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:96:29: Error: Type variables can't be used as constants.
// print(const [o is Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:97:23: Error: Type variables can't be used as constants.
// print(const [o as T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:98:29: Error: Type variables can't be used as constants.
// print(const [o as Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:99:24: Error: Type variables can't be used as constants.
// print(const [Class<T>.new]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:100:20: Error: Type variables can't be used as constants.
// print(const [F<T, T>.new]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:100:23: Error: Type variables can't be used as constants.
// print(const [F<T, T>.new]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:101:27: Error: Type variables can't be used as constants.
// print(const [id<Class<T>>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:102:25: Error: Type variables can't be used as constants.
// print(const [<Class<T>>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:103:20: Error: Type variables can't be used as constants.
// print(const [G<T>.new]);
// ^
//
import self as self3;
import "dart:core" as core;
typedef F<X extends core::Object? = dynamic, unrelated Y extends core::Object? = dynamic> = self3::Class<X%>;
typedef G<unrelated X extends core::Object? = dynamic> = self3::Class<core::int>;
class Class<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field2;
final field dynamic field3;
final field dynamic field4;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field12;
final field dynamic field13;
final field dynamic field14;
final field dynamic field15;
final field dynamic field16;
const constructor •(dynamic o) → self3::Class<self3::Class::T%>
: self3::Class::field1 = self3::Class::T%, self3::Class::field2 = self3::Class<self3::Class::T%>, self3::Class::field3 = #C24<self3::Class::T%>, self3::Class::field4 = #C24<self3::Class::T%>, self3::Class::field5 = #C2, self3::Class::field6 = #C3, self3::Class::field7 = #C4, self3::Class::field8 = o is{ForNonNullableByDefault} self3::Class::T%, self3::Class::field9 = o is{ForNonNullableByDefault} self3::Class<self3::Class::T%>, self3::Class::field10 = o as{ForNonNullableByDefault} self3::Class::T%, self3::Class::field11 = o{self3::Class::T%} as{ForNonNullableByDefault} self3::Class<self3::Class::T%>, self3::Class::field12 = #C25<self3::Class::T%>, self3::Class::field13 = #C25<self3::Class::T%>, self3::Class::field14 = #C24<self3::Class<self3::Class::T%>>, self3::Class::field15 = #C26, self3::Class::field16 = #C27, super core::Object::•()
;
method method() → void {
core::print(#C1);
core::print(#C28);
core::print(#C29);
core::print(#C29);
core::print(#C2);
core::print(#C3);
core::print(#C4);
core::print(#C6);
core::print(#C7);
core::print(#C8);
core::print(#C8);
core::print(#C30);
core::print(#C30);
core::print(#C31);
core::print(#C26);
core::print(#C27);
core::print(#C20);
core::print(#C10);
core::print(#C32);
core::print(#C33);
core::print(#C33);
core::print(#C11);
core::print(#C12);
core::print(#C13);
core::print(#C14);
core::print(#C15);
core::print(#C21);
core::print(#C34);
core::print(#C35);
core::print(#C35);
core::print(#C36);
core::print(#C37);
core::print(#C38);
}
}
static method id<T extends core::Object? = dynamic>(self3::id::T% t) → self3::id::T%
return t;
static method main() → dynamic {}
static method _#F#new#tearOff<X extends core::Object? = dynamic, unrelated Y extends core::Object? = dynamic>(dynamic o) → self3::Class<self3::_#F#new#tearOff::X%>
return new self3::Class::•<self3::_#F#new#tearOff::X%>(o);
static method _#G#new#tearOff<unrelated X extends core::Object? = dynamic>(dynamic o) → self3::Class<core::int>
return new self3::Class::•<core::int>(o);
constants {
#C1 = TypeLiteralConstant(invalid-type)
#C2 = <invalid-type>[]
#C3 = <invalid-type>{}
#C4 = <invalid-type, invalid-type>{)
#C5 = <self::Class<invalid-type>*>[]
#C6 = true
#C7 = false
#C8 = null
#C9 = <Null>[]
#C10 = <core::Type*>[#C1]
#C11 = <core::List<invalid-type>*>[#C2]
#C12 = <core::Set<invalid-type>*>[#C3]
#C13 = <core::Map<invalid-type, invalid-type>*>[#C4]
#C14 = <core::bool*>[#C6]
#C15 = <core::bool*>[#C7]
#C16 = <invalid-type>[#C8]
#C17 = <self::Class<invalid-type>*>[#C8]
#C18 = <core::List<self::Class<invalid-type>*>*>[#C5]
#C19 = <self2::Class<invalid-type>*>[]
#C20 = <Never*>[]
#C21 = <dynamic>[#C8]
#C22 = <self2::Class<invalid-type>*>[#C8]
#C23 = <core::List<self2::Class<invalid-type>*>*>[#C19]
#C24 = static-tearoff self3::id
#C25 = constructor-tearoff self3::Class::•
#C26 = <self3::Class<invalid-type>*>[]
#C27 = instantiation self3::Class::• <core::int*>
#C28 = TypeLiteralConstant(self3::Class<invalid-type>*)
#C29 = instantiation self3::id <invalid-type>
#C30 = instantiation self3::Class::• <invalid-type>
#C31 = instantiation self3::id <self3::Class<invalid-type>*>
#C32 = <core::Type*>[#C28]
#C33 = <(invalid-type) →* invalid-type>[#C29]
#C34 = <self3::Class<invalid-type>*>[#C8]
#C35 = <(dynamic) →* self3::Class<invalid-type>*>[#C30]
#C36 = <(self3::Class<invalid-type>*) →* self3::Class<invalid-type>*>[#C31]
#C37 = <core::List<self3::Class<invalid-type>*>*>[#C26]
#C38 = <(dynamic) →* self3::Class<core::int*>*>[#C27]
}

View file

@ -0,0 +1,274 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:26:18: Error: Type variables can't be used as constants.
// : field1 = T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:27:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:27:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:28:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:28:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:30:23: Error: Type variables can't be used as constants.
// field8 = o is T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:31:29: Error: Type variables can't be used as constants.
// field9 = o is Class<T>,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:32:24: Error: Type variables can't be used as constants.
// field10 = o as T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:33:30: Error: Type variables can't be used as constants.
// field11 = o as Class<T>,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:34:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:34:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[];
// ^
//
import self as self;
import "dart:core" as core;
import "dart:collection" as col;
import "org-dartlang-testcase:///potentially_constant_type_lib1.dart";
import "org-dartlang-testcase:///potentially_constant_type_lib2.dart";
class Class<T extends core::Object* = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field15;
const constructor •(dynamic o) → self::Class<self::Class::T*>*
: self::Class::field1 = invalid-type, self::Class::field5 = <invalid-type>[], self::Class::field6 = block {
final core::Set<invalid-type>* #t1 = col::LinkedHashSet::•<invalid-type>();
} =>#t1, self::Class::field7 = <invalid-type, invalid-type>{}, self::Class::field8 = o is invalid-type, self::Class::field9 = o is self::Class<invalid-type>*, self::Class::field10 = o as invalid-type, self::Class::field11 = o as self::Class<invalid-type>*, self::Class::field15 = <self::Class<invalid-type>*>[], super core::Object::•()
;
method method() → void
;
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static method id<T extends core::Object* = dynamic>(self::id::T* t) → self::id::T*
;
static method main() → dynamic
;
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:23:18: Error: Type variables can't be used as constants.
// : field1 = T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:24:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:24:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:25:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:25:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:31:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:31:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[];
// ^
//
import self as self2;
import "dart:core" as core;
import "dart:collection" as col;
class Class<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field15;
const constructor •(dynamic o) → self2::Class<self2::Class::T%>
: self2::Class::field1 = invalid-type, self2::Class::field5 = <invalid-type>[], self2::Class::field6 = block {
final core::Set<invalid-type> #t2 = col::LinkedHashSet::•<invalid-type>();
} =>#t2, self2::Class::field7 = <invalid-type, invalid-type>{}, self2::Class::field8 = o is{ForNonNullableByDefault} self2::Class::T%, self2::Class::field9 = o is{ForNonNullableByDefault} self2::Class<self2::Class::T%>, self2::Class::field10 = o as{ForNonNullableByDefault} self2::Class::T%, self2::Class::field11 = o{self2::Class::T%} as{ForNonNullableByDefault} self2::Class<self2::Class::T%>, self2::Class::field15 = <self2::Class<invalid-type>>[], super core::Object::•()
;
method method() → void
;
}
static method id<T extends core::Object? = dynamic>(self2::id::T% t) → self2::id::T%
;
static method main() → dynamic
;
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:34:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:34:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:35:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:35:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:44:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:44:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[],
// ^
//
import self as self3;
import "dart:core" as core;
import "dart:collection" as col;
typedef F<X extends core::Object? = dynamic, unrelated Y extends core::Object? = dynamic> = self3::Class<X%>;
typedef G<unrelated X extends core::Object? = dynamic> = self3::Class<core::int>;
class Class<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field2;
final field dynamic field3;
final field dynamic field4;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field12;
final field dynamic field13;
final field dynamic field14;
final field dynamic field15;
final field dynamic field16;
const constructor •(dynamic o) → self3::Class<self3::Class::T%>
: self3::Class::field1 = self3::Class::T%, self3::Class::field2 = self3::Class<self3::Class::T%>, self3::Class::field3 = self3::id<self3::Class::T%>, self3::Class::field4 = self3::id<self3::Class::T%>, self3::Class::field5 = <invalid-type>[], self3::Class::field6 = block {
final core::Set<invalid-type> #t3 = col::LinkedHashSet::•<invalid-type>();
} =>#t3, self3::Class::field7 = <invalid-type, invalid-type>{}, self3::Class::field8 = o is{ForNonNullableByDefault} self3::Class::T%, self3::Class::field9 = o is{ForNonNullableByDefault} self3::Class<self3::Class::T%>, self3::Class::field10 = o as{ForNonNullableByDefault} self3::Class::T%, self3::Class::field11 = o{self3::Class::T%} as{ForNonNullableByDefault} self3::Class<self3::Class::T%>, self3::Class::field12 = self3::Class::•<self3::Class::T%>, self3::Class::field13 = self3::Class::•<self3::Class::T%>, self3::Class::field14 = self3::id<self3::Class<self3::Class::T%>>, self3::Class::field15 = <self3::Class<invalid-type>>[], self3::Class::field16 = self3::Class::•<core::int>, super core::Object::•()
;
method method() → void
;
}
static method id<T extends core::Object? = dynamic>(self3::id::T% t) → self3::id::T%
;
static method main() → dynamic
;
static method _#F#new#tearOff<X extends core::Object? = dynamic, unrelated Y extends core::Object? = dynamic>(dynamic o) → self3::Class<self3::_#F#new#tearOff::X%>
return new self3::Class::•<self3::_#F#new#tearOff::X%>(o);
static method _#G#new#tearOff<unrelated X extends core::Object? = dynamic>(dynamic o) → self3::Class<core::int>
return new self3::Class::•<core::int>(o);
Extra constant evaluation status:
Evaluated: TypeLiteral @ org-dartlang-testcase:///potentially_constant_type.dart:26:18 -> TypeLiteralConstant(<invalid>)
Evaluated: TypeLiteral @ org-dartlang-testcase:///potentially_constant_type_lib1.dart:23:18 -> TypeLiteralConstant(<invalid>)
Evaluated: StaticTearOff @ org-dartlang-testcase:///potentially_constant_type_lib2.dart:32:18 -> StaticTearOffConstant(id)
Evaluated: StaticTearOff @ org-dartlang-testcase:///potentially_constant_type_lib2.dart:33:19 -> StaticTearOffConstant(id)
Evaluated: ConstructorTearOff @ org-dartlang-testcase:///potentially_constant_type_lib2.dart:41:19 -> ConstructorTearOffConstant(Class.)
Evaluated: ConstructorTearOff @ org-dartlang-testcase:///potentially_constant_type_lib2.dart:42:19 -> ConstructorTearOffConstant(Class.)
Evaluated: StaticTearOff @ org-dartlang-testcase:///potentially_constant_type_lib2.dart:43:19 -> StaticTearOffConstant(id)
Evaluated: Instantiation @ org-dartlang-testcase:///potentially_constant_type_lib2.dart:45:19 -> InstantiationConstant(Class.<int*>)
Extra constant evaluation: evaluated: 61, effectively constant: 8

View file

@ -0,0 +1,666 @@
library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:26:18: Error: Type variables can't be used as constants.
// : field1 = T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:27:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:27:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:28:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:28:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:29:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:30:23: Error: Type variables can't be used as constants.
// field8 = o is T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:31:29: Error: Type variables can't be used as constants.
// field9 = o is Class<T>,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:32:24: Error: Type variables can't be used as constants.
// field10 = o as T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:33:30: Error: Type variables can't be used as constants.
// field11 = o as Class<T>,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:34:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:34:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:40:20: Error: Type variables can't be used as constants.
// const local1 = T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:41:21: Error: Type variables can't be used as constants.
// const local5 = <T>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:42:21: Error: Type variables can't be used as constants.
// const local6 = <T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:43:21: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:43:24: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:44:25: Error: Type variables can't be used as constants.
// const local8 = o is T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:45:31: Error: Type variables can't be used as constants.
// const local9 = o is Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:46:26: Error: Type variables can't be used as constants.
// const local10 = o as T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:47:32: Error: Type variables can't be used as constants.
// const local11 = o as Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:48:28: Error: Type variables can't be used as constants.
// const local15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:63:18: Error: Type variables can't be used as constants.
// print(const [T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:64:19: Error: Type variables can't be used as constants.
// print(const [<T>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:65:19: Error: Type variables can't be used as constants.
// print(const [<T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:66:19: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:66:22: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:67:23: Error: Type variables can't be used as constants.
// print(const [o is T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:68:29: Error: Type variables can't be used as constants.
// print(const [o is Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:69:23: Error: Type variables can't be used as constants.
// print(const [o as T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:70:29: Error: Type variables can't be used as constants.
// print(const [o as Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type.dart:71:25: Error: Type variables can't be used as constants.
// print(const [<Class<T>>[]]);
// ^
//
import self as self;
import "dart:core" as core;
import "org-dartlang-testcase:///potentially_constant_type_lib1.dart";
import "org-dartlang-testcase:///potentially_constant_type_lib2.dart";
class Class<T extends core::Object* = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field15;
const constructor •(dynamic o) → self::Class<self::Class::T*>*
: self::Class::field1 = #C1, self::Class::field5 = #C2, self::Class::field6 = #C3, self::Class::field7 = #C4, self::Class::field8 = o is invalid-type, self::Class::field9 = o is self::Class<invalid-type>*, self::Class::field10 = o as invalid-type, self::Class::field11 = o as self::Class<invalid-type>*, self::Class::field15 = #C5, super core::Object::•()
;
method method() → void {
core::print(#C1);
core::print(#C2);
core::print(#C3);
core::print(#C4);
core::print(#C6);
core::print(#C7);
core::print(#C8);
core::print(#C8);
core::print(#C5);
core::print(#C9);
core::print(#C10);
core::print(#C11);
core::print(#C12);
core::print(#C13);
core::print(#C14);
core::print(#C15);
core::print(#C16);
core::print(#C17);
core::print(#C18);
}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
static method id<T extends core::Object* = dynamic>(self::id::T* t) → self::id::T*
return t;
static method main() → dynamic {}
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:23:18: Error: Type variables can't be used as constants.
// : field1 = T,
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:24:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:24:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:25:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:25:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:26:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:31:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:31:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:37:20: Error: Type variables can't be used as constants.
// const local1 = T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:38:21: Error: Type variables can't be used as constants.
// const local5 = <T>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:39:21: Error: Type variables can't be used as constants.
// const local6 = <T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:40:21: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:40:24: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:41:25: Error: Type variables can't be used as constants.
// const local8 = o is T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:42:31: Error: Type variables can't be used as constants.
// const local9 = o is Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:43:26: Error: Type variables can't be used as constants.
// const local10 = o as T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:44:32: Error: Type variables can't be used as constants.
// const local11 = o as Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:45:28: Error: Type variables can't be used as constants.
// const local15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:60:18: Error: Type variables can't be used as constants.
// print(const [T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:61:19: Error: Type variables can't be used as constants.
// print(const [<T>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:62:19: Error: Type variables can't be used as constants.
// print(const [<T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:63:19: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:63:22: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:64:23: Error: Type variables can't be used as constants.
// print(const [o is T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:65:29: Error: Type variables can't be used as constants.
// print(const [o is Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:66:23: Error: Type variables can't be used as constants.
// print(const [o as T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:67:29: Error: Type variables can't be used as constants.
// print(const [o as Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib1.dart:68:25: Error: Type variables can't be used as constants.
// print(const [<Class<T>>[]]);
// ^
//
import self as self2;
import "dart:core" as core;
class Class<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field15;
const constructor •(dynamic o) → self2::Class<self2::Class::T%>
: self2::Class::field1 = #C1, self2::Class::field5 = #C2, self2::Class::field6 = #C3, self2::Class::field7 = #C4, self2::Class::field8 = o is{ForNonNullableByDefault} self2::Class::T%, self2::Class::field9 = o is{ForNonNullableByDefault} self2::Class<self2::Class::T%>, self2::Class::field10 = o as{ForNonNullableByDefault} self2::Class::T%, self2::Class::field11 = o{self2::Class::T%} as{ForNonNullableByDefault} self2::Class<self2::Class::T%>, self2::Class::field15 = #C19, super core::Object::•()
;
method method() → void {
core::print(#C1);
core::print(#C2);
core::print(#C3);
core::print(#C4);
core::print(#C6);
core::print(#C7);
core::print(#C8);
core::print(#C8);
core::print(#C19);
core::print(#C20);
core::print(#C10);
core::print(#C11);
core::print(#C12);
core::print(#C13);
core::print(#C14);
core::print(#C15);
core::print(#C21);
core::print(#C22);
core::print(#C23);
}
}
static method id<T extends core::Object? = dynamic>(self2::id::T% t) → self2::id::T%
return t;
static method main() → dynamic {}
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:34:21: Error: Constant expression expected.
// Try inserting 'const'.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:34:19: Error: Type variables can't be used as constants.
// field5 = <T>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:35:21: Error: Constant expression expected.
// Try inserting 'const'.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:35:19: Error: Type variables can't be used as constants.
// field6 = <T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:24: Error: Constant expression expected.
// Try inserting 'const'.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:19: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:36:22: Error: Type variables can't be used as constants.
// field7 = <T, T>{},
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:44:29: Error: Constant expression expected.
// Try inserting 'const'.
// field15 = <Class<T>>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:44:26: Error: Type variables can't be used as constants.
// field15 = <Class<T>>[],
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:51:20: Error: Type variables can't be used as constants.
// const local1 = T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:52:26: Error: Type variables can't be used as constants.
// const local2 = Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:53:23: Error: Type variables can't be used as constants.
// const local3 = id<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:54:25: Error: Type variables can't be used as constants.
// const local4 = (id)<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:55:21: Error: Type variables can't be used as constants.
// const local5 = <T>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:56:21: Error: Type variables can't be used as constants.
// const local6 = <T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:57:21: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:57:24: Error: Type variables can't be used as constants.
// const local7 = <T, T>{};
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:58:25: Error: Type variables can't be used as constants.
// const local8 = o is T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:59:31: Error: Type variables can't be used as constants.
// const local9 = o is Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:60:26: Error: Type variables can't be used as constants.
// const local10 = o as T;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:61:32: Error: Type variables can't be used as constants.
// const local11 = o as Class<T>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:62:27: Error: Type variables can't be used as constants.
// const local12 = Class<T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:63:23: Error: Type variables can't be used as constants.
// const local13 = F<T, T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:63:26: Error: Type variables can't be used as constants.
// const local13 = F<T, T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:64:30: Error: Type variables can't be used as constants.
// const local14 = id<Class<T>>;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:65:28: Error: Type variables can't be used as constants.
// const local15 = <Class<T>>[];
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:66:23: Error: Type variables can't be used as constants.
// const local16 = G<T>.new;
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:88:18: Error: Type variables can't be used as constants.
// print(const [T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:89:24: Error: Type variables can't be used as constants.
// print(const [Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:90:21: Error: Type variables can't be used as constants.
// print(const [id<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:91:23: Error: Type variables can't be used as constants.
// print(const [(id)<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:92:19: Error: Type variables can't be used as constants.
// print(const [<T>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:93:19: Error: Type variables can't be used as constants.
// print(const [<T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:94:19: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:94:22: Error: Type variables can't be used as constants.
// print(const [<T, T>{}]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:95:23: Error: Type variables can't be used as constants.
// print(const [o is T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:96:29: Error: Type variables can't be used as constants.
// print(const [o is Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:97:23: Error: Type variables can't be used as constants.
// print(const [o as T]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:98:29: Error: Type variables can't be used as constants.
// print(const [o as Class<T>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:99:24: Error: Type variables can't be used as constants.
// print(const [Class<T>.new]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:100:20: Error: Type variables can't be used as constants.
// print(const [F<T, T>.new]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:100:23: Error: Type variables can't be used as constants.
// print(const [F<T, T>.new]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:101:27: Error: Type variables can't be used as constants.
// print(const [id<Class<T>>]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:102:25: Error: Type variables can't be used as constants.
// print(const [<Class<T>>[]]);
// ^
//
// pkg/front_end/testcases/general/constants/potentially_constant_type_lib2.dart:103:20: Error: Type variables can't be used as constants.
// print(const [G<T>.new]);
// ^
//
import self as self3;
import "dart:core" as core;
typedef F<X extends core::Object? = dynamic, unrelated Y extends core::Object? = dynamic> = self3::Class<X%>;
typedef G<unrelated X extends core::Object? = dynamic> = self3::Class<core::int>;
class Class<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field dynamic field1;
final field dynamic field2;
final field dynamic field3;
final field dynamic field4;
final field dynamic field5;
final field dynamic field6;
final field dynamic field7;
final field dynamic field8;
final field dynamic field9;
final field dynamic field10;
final field dynamic field11;
final field dynamic field12;
final field dynamic field13;
final field dynamic field14;
final field dynamic field15;
final field dynamic field16;
const constructor •(dynamic o) → self3::Class<self3::Class::T%>
: self3::Class::field1 = self3::Class::T%, self3::Class::field2 = self3::Class<self3::Class::T%>, self3::Class::field3 = #C24<self3::Class::T%>, self3::Class::field4 = #C24<self3::Class::T%>, self3::Class::field5 = #C2, self3::Class::field6 = #C3, self3::Class::field7 = #C4, self3::Class::field8 = o is{ForNonNullableByDefault} self3::Class::T%, self3::Class::field9 = o is{ForNonNullableByDefault} self3::Class<self3::Class::T%>, self3::Class::field10 = o as{ForNonNullableByDefault} self3::Class::T%, self3::Class::field11 = o{self3::Class::T%} as{ForNonNullableByDefault} self3::Class<self3::Class::T%>, self3::Class::field12 = #C25<self3::Class::T%>, self3::Class::field13 = #C25<self3::Class::T%>, self3::Class::field14 = #C24<self3::Class<self3::Class::T%>>, self3::Class::field15 = #C26, self3::Class::field16 = #C27, super core::Object::•()
;
method method() → void {
core::print(#C1);
core::print(#C28);
core::print(#C29);
core::print(#C29);
core::print(#C2);
core::print(#C3);
core::print(#C4);
core::print(#C6);
core::print(#C7);
core::print(#C8);
core::print(#C8);
core::print(#C30);
core::print(#C30);
core::print(#C31);
core::print(#C26);
core::print(#C27);
core::print(#C20);
core::print(#C10);
core::print(#C32);
core::print(#C33);
core::print(#C33);
core::print(#C11);
core::print(#C12);
core::print(#C13);
core::print(#C14);
core::print(#C15);
core::print(#C21);
core::print(#C34);
core::print(#C35);
core::print(#C35);
core::print(#C36);
core::print(#C37);
core::print(#C38);
}
}
static method id<T extends core::Object? = dynamic>(self3::id::T% t) → self3::id::T%
return t;
static method main() → dynamic {}
static method _#F#new#tearOff<X extends core::Object? = dynamic, unrelated Y extends core::Object? = dynamic>(dynamic o) → self3::Class<self3::_#F#new#tearOff::X%>
return new self3::Class::•<self3::_#F#new#tearOff::X%>(o);
static method _#G#new#tearOff<unrelated X extends core::Object? = dynamic>(dynamic o) → self3::Class<core::int>
return new self3::Class::•<core::int>(o);
constants {
#C1 = TypeLiteralConstant(invalid-type)
#C2 = <invalid-type>[]
#C3 = <invalid-type>{}
#C4 = <invalid-type, invalid-type>{)
#C5 = <self::Class<invalid-type>*>[]
#C6 = true
#C7 = false
#C8 = null
#C9 = <Null>[]
#C10 = <core::Type*>[#C1]
#C11 = <core::List<invalid-type>*>[#C2]
#C12 = <core::Set<invalid-type>*>[#C3]
#C13 = <core::Map<invalid-type, invalid-type>*>[#C4]
#C14 = <core::bool*>[#C6]
#C15 = <core::bool*>[#C7]
#C16 = <invalid-type>[#C8]
#C17 = <self::Class<invalid-type>*>[#C8]
#C18 = <core::List<self::Class<invalid-type>*>*>[#C5]
#C19 = <self2::Class<invalid-type>*>[]
#C20 = <Never*>[]
#C21 = <dynamic>[#C8]
#C22 = <self2::Class<invalid-type>*>[#C8]
#C23 = <core::List<self2::Class<invalid-type>*>*>[#C19]
#C24 = static-tearoff self3::id
#C25 = constructor-tearoff self3::Class::•
#C26 = <self3::Class<invalid-type>*>[]
#C27 = instantiation self3::Class::• <core::int*>
#C28 = TypeLiteralConstant(self3::Class<invalid-type>*)
#C29 = instantiation self3::id <invalid-type>
#C30 = instantiation self3::Class::• <invalid-type>
#C31 = instantiation self3::id <self3::Class<invalid-type>*>
#C32 = <core::Type*>[#C28]
#C33 = <(invalid-type) →* invalid-type>[#C29]
#C34 = <self3::Class<invalid-type>*>[#C8]
#C35 = <(dynamic) →* self3::Class<invalid-type>*>[#C30]
#C36 = <(self3::Class<invalid-type>*) →* self3::Class<invalid-type>*>[#C31]
#C37 = <core::List<self3::Class<invalid-type>*>*>[#C26]
#C38 = <(dynamic) →* self3::Class<core::int*>*>[#C27]
}

View file

@ -0,0 +1,72 @@
// Copyright (c) 2021, 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.
// Pre nonfunction-type-alias language version:
// @dart=2.12
T id<T>(T t) => t;
class Class<T> {
final field1;
final field5;
final field6;
final field7;
final field8;
final field9;
final field10;
final field11;
final field15;
const Class(o)
// Potentially constant context:
: field1 = T,
field5 = <T>[],
field6 = <T>{},
field7 = <T, T>{},
field8 = o is T,
field9 = o is Class<T>,
field10 = o as T,
field11 = o as Class<T>,
field15 = <Class<T>>[];
void method() {
const o = null;
// Required constant context:
const local1 = T;
const local5 = <T>[];
const local6 = <T>{};
const local7 = <T, T>{};
const local8 = o is T;
const local9 = o is Class<T>;
const local10 = o as T;
const local11 = o as Class<T>;
const local15 = <Class<T>>[];
const List<T> listOfNever = []; // ok
print(local1);
print(local5);
print(local6);
print(local7);
print(local8);
print(local9);
print(local10);
print(local11);
print(local15);
print(listOfNever);
// Inferred constant context:
print(const [T]);
print(const [<T>[]]);
print(const [<T>{}]);
print(const [<T, T>{}]);
print(const [o is T]);
print(const [o is Class<T>]);
print(const [o as T]);
print(const [o as Class<T>]);
print(const [<Class<T>>[]]);
}
}
main() {}

View file

@ -0,0 +1,107 @@
// Copyright (c) 2021, 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.
T id<T>(T t) => t;
typedef F<X, Y> = Class<X>;
typedef G<X> = Class<int>;
class Class<T> {
final field1;
final field2;
final field3;
final field4;
final field5;
final field6;
final field7;
final field8;
final field9;
final field10;
final field11;
final field12;
final field13;
final field14;
final field15;
final field16;
const Class(o)
// Potentially constant context:
: field1 = T,
field2 = Class<T>,
field3 = id<T>,
field4 = (id)<T>,
field5 = <T>[],
field6 = <T>{},
field7 = <T, T>{},
field8 = o is T,
field9 = o is Class<T>,
field10 = o as T,
field11 = o as Class<T>,
field12 = Class<T>.new,
field13 = F<T, T>.new,
field14 = id<Class<T>>,
field15 = <Class<T>>[],
field16 = G<T>.new;
void method() {
const o = null;
// Required constant context:
const local1 = T;
const local2 = Class<T>;
const local3 = id<T>;
const local4 = (id)<T>;
const local5 = <T>[];
const local6 = <T>{};
const local7 = <T, T>{};
const local8 = o is T;
const local9 = o is Class<T>;
const local10 = o as T;
const local11 = o as Class<T>;
const local12 = Class<T>.new;
const local13 = F<T, T>.new;
const local14 = id<Class<T>>;
const local15 = <Class<T>>[];
const local16 = G<T>.new;
const List<T> listOfNever = []; // ok
print(local1);
print(local2);
print(local3);
print(local4);
print(local5);
print(local6);
print(local7);
print(local8);
print(local9);
print(local10);
print(local11);
print(local12);
print(local13);
print(local14);
print(local15);
print(local16);
print(listOfNever);
// Inferred constant context:
print(const [T]);
print(const [Class<T>]);
print(const [id<T>]);
print(const [(id)<T>]);
print(const [<T>[]]);
print(const [<T>{}]);
print(const [<T, T>{}]);
print(const [o is T]);
print(const [o is Class<T>]);
print(const [o as T]);
print(const [o as Class<T>]);
print(const [Class<T>.new]);
print(const [F<T, T>.new]);
print(const [id<Class<T>>]);
print(const [<Class<T>>[]]);
print(const [G<T>.new]);
}
}
main() {}

View file

@ -156,7 +156,7 @@ class Foo<U extends core::Object* = dynamic> extends core::Object {
return null;
function foo6Prime() → core::List<invalid-type>*
return null;
invalid-type foo7 = (invalid-type y) → invalid-type => y;
(invalid-type) →* void foo7 = (invalid-type y) → invalid-type => y;
(core::List<invalid-type>*) →* void foo7Prime = (core::List<invalid-type>* y) → core::List<invalid-type>* => y;
}
static method foo8() → () →* invalid-type {

View file

@ -156,7 +156,7 @@ class Foo<U extends core::Object* = dynamic> extends core::Object {
return null;
function foo6Prime() → core::List<invalid-type>*
return null;
invalid-type foo7 = (invalid-type y) → invalid-type => y;
(invalid-type) →* void foo7 = (invalid-type y) → invalid-type => y;
(core::List<invalid-type>*) →* void foo7Prime = (core::List<invalid-type>* y) → core::List<invalid-type>* => y;
}
static method foo8() → () →* invalid-type {

View file

@ -174,7 +174,7 @@ static method Foo|foo3() → void {
return null;
function foo6Prime() → core::List<invalid-type>*
return null;
invalid-type foo7 = (invalid-type y) → invalid-type => y;
(invalid-type) →* void foo7 = (invalid-type y) → invalid-type => y;
(core::List<invalid-type>*) →* void foo7Prime = (core::List<invalid-type>* y) → core::List<invalid-type>* => y;
}
static method Foo|foo8() → () →* invalid-type {

View file

@ -174,7 +174,7 @@ static method Foo|foo3() → void {
return null;
function foo6Prime() → core::List<invalid-type>*
return null;
invalid-type foo7 = (invalid-type y) → invalid-type => y;
(invalid-type) →* void foo7 = (invalid-type y) → invalid-type => y;
(core::List<invalid-type>*) →* void foo7Prime = (core::List<invalid-type>* y) → core::List<invalid-type>* => y;
}
static method Foo|foo8() → () →* invalid-type {