Files
sdk/tests/language/malformed/inheritance_test.dart
T
Konstantin Shcheglov 8de8a1c226 Move codes from StaticTypeWarningCode into CompileTimeErrorCode.
They are all errors now.

Change-Id: If48d38e38e845fd5b5a950dd5514bf1cbbce03d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-27 16:44:15 +00:00

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
// [cfe] Can't use type arguments with type variable 'A'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
{
}
class C7<A>
extends A<Unresolved>
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTENDS_NON_CLASS
// [cfe] Can't use type arguments with type variable 'A'.
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
// ^^^^^^^^^^
// [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
// [cfe] Can't use type arguments with type variable 'A'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
{
}
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
// [cfe] Can't use type arguments with type variable 'A'.
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
// ^^^^^^^^^^
// [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
// [cfe] Can't use type arguments with type variable 'A'.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
{
}
class C11<A>
implements A<Unresolved>
// ^
// [analyzer] COMPILE_TIME_ERROR.IMPLEMENTS_NON_CLASS
// [cfe] Can't use type arguments with type variable 'A'.
// ^^^^^^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.WRONG_NUMBER_OF_TYPE_ARGUMENTS
// ^^^^^^^^^^
// [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>();
}