mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:01:19 +00:00
2b79d2b747
Various cleanups to the TypeBuilder classes: TypeBuilder: * Remove `origin` parameter from TypeBuilder.build and instead make FunctionType.typedefType mutable and set if after creation. * Remove `charOffset` and `fileUri` parameters from TypeBuilder.buildSupertype/buildMixedInType * Remove `bind`, `resolveIn`, and `check` from TypeBuilder so that these are only present on NamedTypeBuilder * Remove TypeBuilder.buildTypeLiteralType and instead pass an argument to NamedTypeBuilder that determines what type to create on `build`. NamedTypeBuilder: * Make NamedTypeBuilder.instanceTypeVariableAccess private * Add NamedTypeBuilder.forDartType for prebuilt types * Add NamedTypeBuilder.forInvalidType for types created for errors * Make NamedTypeBuilder.declaration private and corresponding getter * Check most type use errors on NamedTypeBuilder.bind * Make NamedTypeBuilder helper methods private * Add `TypeVariableBuilder.isClassParameter` to support checking for valid type variable use through the `NamedTypeBuilder.bind` method. * Remove checking of type variable in static context from BodyBuilder since it is now checking on `NamedTypeBuilder.bind`. FunctionTypeBuilder: * Cache result of FunctionTypeBuilder.build TypeBuilderComputer: * Cache "constant" type declarations in TypeBuilderComputer Change-Id: Ibaedcb255487eecc5efe70b84e5cbd5a118c1e0b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239023 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
147 lines
3.8 KiB
Dart
147 lines
3.8 KiB
Dart
// Copyright (c) 2013, 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.
|
|
|
|
// Tests that malformed types used in extends, implements, and with clauses
|
|
// cause compile-time errors.
|
|
|
|
class A<T> {}
|
|
|
|
class C
|
|
extends Unresolved
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C1
|
|
extends A<Unresolved>
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_AS_TYPE_ARGUMENT
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C2
|
|
// ^
|
|
// [cfe] The type 'Unresolved' can't be mixed in.
|
|
extends Object with Unresolved
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C3
|
|
extends Object with A<Unresolved>
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_AS_TYPE_ARGUMENT
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C4
|
|
implements Unresolved
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C5
|
|
implements A<Unresolved>
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_AS_TYPE_ARGUMENT
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C6<A>
|
|
extends A<int>
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
|
|
// ^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
|
|
// [cfe] Can't use type arguments with type variable 'A'.
|
|
{
|
|
}
|
|
|
|
class C7<A>
|
|
extends A<Unresolved>
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
|
|
// ^^^^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
|
|
// [cfe] Can't use type arguments with type variable 'A'.
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_AS_TYPE_ARGUMENT
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C8<A>
|
|
// ^
|
|
// [cfe] The type 'A<int>' can't be mixed in.
|
|
extends Object with A<int>
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
|
|
// ^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
|
|
// [cfe] Can't use type arguments with type variable 'A'.
|
|
{
|
|
}
|
|
|
|
class C9<A>
|
|
// ^
|
|
// [cfe] The type 'A<Unresolved>' can't be mixed in.
|
|
extends Object with A<Unresolved>
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.MIXIN_OF_NON_CLASS
|
|
// ^^^^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
|
|
// [cfe] Can't use type arguments with type variable 'A'.
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_AS_TYPE_ARGUMENT
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
class C10<A>
|
|
implements A<int>
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
|
|
// ^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
|
|
// [cfe] Can't use type arguments with type variable 'A'.
|
|
{
|
|
}
|
|
|
|
class C11<A>
|
|
implements A<Unresolved>
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
|
|
// ^^^^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
|
|
// [cfe] Can't use type arguments with type variable 'A'.
|
|
// ^^^^^^^^^^
|
|
// [analyzer] COMPILE_TIME_ERROR.NON_TYPE_AS_TYPE_ARGUMENT
|
|
// [cfe] Type 'Unresolved' not found.
|
|
{
|
|
}
|
|
|
|
void main() {
|
|
new C();
|
|
new C1();
|
|
new C2();
|
|
new C3();
|
|
new C4();
|
|
new C5();
|
|
new C6<Object>();
|
|
new C7<Object>();
|
|
new C8<Object>();
|
|
new C9<Object>();
|
|
new C10<Object>();
|
|
new C11<Object>();
|
|
}
|