[cfe] Report error when implementing a base class.

Change-Id: Iff3c31b4883d3d4fc4c392c6ac8207617ce65761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279648
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
This commit is contained in:
Kallen Tu 2023-01-26 16:01:55 +00:00 committed by Commit Queue
parent 5668aa4732
commit 7cf49ba433
30 changed files with 919 additions and 13 deletions

View file

@ -340,6 +340,60 @@ const MessageCode messageAwaitNotAsync = const MessageCode("AwaitNotAsync",
problemMessage:
r"""'await' can only be used in 'async' or 'async*' methods.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String
name)> templateBaseClassImplementedOutsideOfLibrary = const Template<
Message Function(String name)>(
problemMessageTemplate:
r"""The class '#name' can't be implemented outside of its library because it's a base class.""",
withArguments: _withArgumentsBaseClassImplementedOutsideOfLibrary);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeBaseClassImplementedOutsideOfLibrary =
const Code<Message Function(String name)>(
"BaseClassImplementedOutsideOfLibrary",
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsBaseClassImplementedOutsideOfLibrary(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeBaseClassImplementedOutsideOfLibrary,
problemMessage:
"""The class '${name}' can't be implemented outside of its library because it's a base class.""",
arguments: {'name': name});
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(
String
name)> templateBaseMixinImplementedOutsideOfLibrary = const Template<
Message Function(String name)>(
problemMessageTemplate:
r"""The mixin '#name' can't be implemented outside of its library because it's a base mixin.""",
withArguments: _withArgumentsBaseMixinImplementedOutsideOfLibrary);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Message Function(String name)>
codeBaseMixinImplementedOutsideOfLibrary =
const Code<Message Function(String name)>(
"BaseMixinImplementedOutsideOfLibrary",
);
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
Message _withArgumentsBaseMixinImplementedOutsideOfLibrary(String name) {
if (name.isEmpty) throw 'No name provided';
name = demangleMixinApplicationName(name);
return new Message(codeBaseMixinImplementedOutsideOfLibrary,
problemMessage:
"""The mixin '${name}' can't be implemented outside of its library because it's a base mixin.""",
arguments: {'name': name});
}
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<
Message Function(

View file

@ -2097,8 +2097,35 @@ severity: $severity
cls.charOffset,
noLength);
}
}
// Report an error for a class implementing a base class outside of
// its library.
List<TypeBuilder>? interfaceBuilders = cls.interfaceBuilders;
if (supertype.isBase && interfaceBuilders != null) {
for (TypeBuilder interfaceBuilder in interfaceBuilders) {
TypeDeclarationBuilder? builder = interfaceBuilder.declaration;
while (builder is TypeAliasBuilder) {
builder = builder.type.declaration;
}
if (builder == supertype) {
if (supertype.isMixinDeclaration) {
cls.addProblem(
templateBaseMixinImplementedOutsideOfLibrary
.withArguments(supertype.fullNameForErrors),
cls.charOffset,
noLength);
} else {
cls.addProblem(
templateBaseClassImplementedOutsideOfLibrary
.withArguments(supertype.fullNameForErrors),
cls.charOffset,
noLength);
}
break;
}
}
}
}
// Report error for subtyping outside of sealed supertype's library.
if (cls.libraryBuilder.libraryFeatures.sealedClass.isEnabled &&
supertype.isSealed) {

View file

@ -39,6 +39,10 @@ AwaitAsIdentifier/example: Fail
AwaitInLateLocalInitializer/analyzerCode: Fail
AwaitInLateLocalInitializer/example: Fail
AwaitNotAsync/example: Fail
BaseClassImplementedOutsideOfLibrary/analyzerCode: Fail
BaseClassImplementedOutsideOfLibrary/part_wrapped_script: Fail # Uses imports
BaseMixinImplementedOutsideOfLibrary/analyzerCode: Fail
BaseMixinImplementedOutsideOfLibrary/part_wrapped_script: Fail # Uses imports
BuiltInIdentifierAsType/example: Fail
BuiltInIdentifierInDeclaration/example: Fail
BytecodeLimitExceededTooManyArguments/analyzerCode: Fail

View file

@ -6060,6 +6060,26 @@ CantUseClassAsMixin:
lib.dart:
class A {}
BaseClassImplementedOutsideOfLibrary:
problemMessage: "The class '#name' can't be implemented outside of its library because it's a base class."
experiments: class-modifiers
script:
main.dart:
import 'lib.dart';
class B implements A {}
lib.dart:
base class A {}
BaseMixinImplementedOutsideOfLibrary:
problemMessage: "The mixin '#name' can't be implemented outside of its library because it's a base mixin."
experiments: class-modifiers
script:
main.dart:
import 'lib.dart';
class B implements A {}
lib.dart:
base mixin A {}
UnspecifiedGetterNameInObjectPattern:
problemMessage: "The getter name is not specified explicitly, and the pattern is not a variable. Try specifying the getter name explicitly, or using a variable pattern."
experiments: patterns

View file

@ -0,0 +1,9 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'main_lib.dart';
class ImplementsBaseClass implements A {}
class ImplementsBaseMixin implements M {}

View file

@ -0,0 +1,40 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClass implements A {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:9:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixin implements M {}
// ^
//
import self as self;
import "dart:core" as core;
import "main_lib.dart" as mai;
import "org-dartlang-testcase:///main_lib.dart";
class ImplementsBaseClass extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClass
: super core::Object::•()
;
}
class ImplementsBaseMixin extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixin
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,40 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClass implements A {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:9:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixin implements M {}
// ^
//
import self as self;
import "dart:core" as core;
import "main_lib.dart" as mai;
import "org-dartlang-testcase:///main_lib.dart";
class ImplementsBaseClass extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClass
: super core::Object::•()
;
}
class ImplementsBaseMixin extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixin
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,5 @@
import 'main_lib.dart';
class ImplementsBaseClass implements A {}
class ImplementsBaseMixin implements M {}

View file

@ -0,0 +1,5 @@
import 'main_lib.dart';
class ImplementsBaseClass implements A {}
class ImplementsBaseMixin implements M {}

View file

@ -0,0 +1,40 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClass implements A {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:9:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixin implements M {}
// ^
//
import self as self;
import "dart:core" as core;
import "main_lib.dart" as mai;
import "org-dartlang-testcase:///main_lib.dart";
class ImplementsBaseClass extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClass
: super core::Object::•()
;
}
class ImplementsBaseMixin extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixin
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,28 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClass implements A {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:9:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixin implements M {}
// ^
//
import self as self;
import "dart:core" as core;
import "main_lib.dart" as mai;
import "org-dartlang-testcase:///main_lib.dart";
class ImplementsBaseClass extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClass
: super core::Object::•()
;
}
class ImplementsBaseMixin extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixin
: super core::Object::•()
;
}

View file

@ -0,0 +1,37 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClass implements A {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:9:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixin implements M {}
// ^
//
import self as self;
import "dart:core" as core;
import "main_lib.dart" as mai;
import "org-dartlang-testcase:///main_lib.dart";
class ImplementsBaseClass extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClass
;
}
class ImplementsBaseMixin extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixin
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
base class A extends core::Object {
synthetic constructor •() → mai::A
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,40 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClass implements A {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/outside_library/main.dart:9:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixin implements M {}
// ^
//
import self as self;
import "dart:core" as core;
import "main_lib.dart" as mai;
import "org-dartlang-testcase:///main_lib.dart";
class ImplementsBaseClass extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClass
: super core::Object::•()
;
}
class ImplementsBaseMixin extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixin
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,7 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
base class A {}
base mixin M {}

View file

@ -0,0 +1 @@
main_lib.dart

View file

@ -0,0 +1,21 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'main_lib.dart';
class ImplementsBaseClassTypedef implements ATypeDef {}
class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
class ImplementsBaseMixinTypeDef implements MTypeDef {}
class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
typedef AOutsideTypedef = A;
typedef MOutsideTypedef = M;
class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}

View file

@ -0,0 +1,82 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef implements ATypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:9:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:11:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef implements MTypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:13:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:19:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:21:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
// ^
//
import self as self;
import "main_lib.dart" as mai;
import "dart:core" as core;
import "org-dartlang-testcase:///main_lib.dart";
typedef AOutsideTypedef = mai::A;
typedef MOutsideTypedef = mai::M;
class ImplementsBaseClassTypedef extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef
: super core::Object::•()
;
}
class ImplementsBaseClassTypedef2 extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef2
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef2 extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef2
: super core::Object::•()
;
}
class ImplementsBaseClassTypedefOutside extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedefOutside
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDefOutside extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDefOutside
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
typedef ATypeDef = mai::A;
typedef ATypeDef2 = mai::A;
typedef MTypeDef = mai::M;
typedef MTypeDef2 = mai::M;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,82 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef implements ATypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:9:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:11:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef implements MTypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:13:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:19:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:21:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
// ^
//
import self as self;
import "main_lib.dart" as mai;
import "dart:core" as core;
import "org-dartlang-testcase:///main_lib.dart";
typedef AOutsideTypedef = mai::A;
typedef MOutsideTypedef = mai::M;
class ImplementsBaseClassTypedef extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef
: super core::Object::•()
;
}
class ImplementsBaseClassTypedef2 extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef2
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef2 extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef2
: super core::Object::•()
;
}
class ImplementsBaseClassTypedefOutside extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedefOutside
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDefOutside extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDefOutside
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
typedef ATypeDef = mai::A;
typedef ATypeDef2 = mai::A;
typedef MTypeDef = mai::M;
typedef MTypeDef2 = mai::M;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,16 @@
import 'main_lib.dart';
class ImplementsBaseClassTypedef implements ATypeDef {}
class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
class ImplementsBaseMixinTypeDef implements MTypeDef {}
class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
typedef AOutsideTypedef = A;
typedef MOutsideTypedef = M;
class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}

View file

@ -0,0 +1,16 @@
import 'main_lib.dart';
class ImplementsBaseClassTypedef implements ATypeDef {}
class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
class ImplementsBaseMixinTypeDef implements MTypeDef {}
class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
typedef AOutsideTypedef = A;
typedef MOutsideTypedef = M;

View file

@ -0,0 +1,82 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef implements ATypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:9:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:11:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef implements MTypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:13:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:19:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:21:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
// ^
//
import self as self;
import "main_lib.dart" as mai;
import "dart:core" as core;
import "org-dartlang-testcase:///main_lib.dart";
typedef AOutsideTypedef = mai::A;
typedef MOutsideTypedef = mai::M;
class ImplementsBaseClassTypedef extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef
: super core::Object::•()
;
}
class ImplementsBaseClassTypedef2 extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef2
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef2 extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef2
: super core::Object::•()
;
}
class ImplementsBaseClassTypedefOutside extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedefOutside
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDefOutside extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDefOutside
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
typedef ATypeDef = mai::A;
typedef ATypeDef2 = mai::A;
typedef MTypeDef = mai::M;
typedef MTypeDef2 = mai::M;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,66 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef implements ATypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:9:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:11:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef implements MTypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:13:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:19:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:21:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
// ^
//
import self as self;
import "main_lib.dart" as mai;
import "dart:core" as core;
import "org-dartlang-testcase:///main_lib.dart";
typedef AOutsideTypedef = mai::A;
typedef MOutsideTypedef = mai::M;
class ImplementsBaseClassTypedef extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef
: super core::Object::•()
;
}
class ImplementsBaseClassTypedef2 extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef2
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef2 extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef2
: super core::Object::•()
;
}
class ImplementsBaseClassTypedefOutside extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedefOutside
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDefOutside extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDefOutside
: super core::Object::•()
;
}

View file

@ -0,0 +1,75 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef implements ATypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:9:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:11:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef implements MTypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:13:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:19:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:21:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
// ^
//
import self as self;
import "main_lib.dart" as mai;
import "dart:core" as core;
import "org-dartlang-testcase:///main_lib.dart";
typedef AOutsideTypedef = mai::A;
typedef MOutsideTypedef = mai::M;
class ImplementsBaseClassTypedef extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef
;
}
class ImplementsBaseClassTypedef2 extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef2
;
}
class ImplementsBaseMixinTypeDef extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef
;
}
class ImplementsBaseMixinTypeDef2 extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef2
;
}
class ImplementsBaseClassTypedefOutside extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedefOutside
;
}
class ImplementsBaseMixinTypeDefOutside extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDefOutside
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
typedef ATypeDef = mai::A;
typedef ATypeDef2 = mai::A;
typedef MTypeDef = mai::M;
typedef MTypeDef2 = mai::M;
base class A extends core::Object {
synthetic constructor •() → mai::A
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,82 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:7:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef implements ATypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:9:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedef2 implements ATypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:11:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef implements MTypeDef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:13:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDef2 implements MTypeDef2 {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:19:7: Error: The class 'A' can't be implemented outside of its library because it's a base class.
// class ImplementsBaseClassTypedefOutside implements AOutsideTypedef {}
// ^
//
// pkg/front_end/testcases/class_modifiers/base/typedef/main.dart:21:7: Error: The mixin 'M' can't be implemented outside of its library because it's a base mixin.
// class ImplementsBaseMixinTypeDefOutside implements MOutsideTypedef {}
// ^
//
import self as self;
import "main_lib.dart" as mai;
import "dart:core" as core;
import "org-dartlang-testcase:///main_lib.dart";
typedef AOutsideTypedef = mai::A;
typedef MOutsideTypedef = mai::M;
class ImplementsBaseClassTypedef extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef
: super core::Object::•()
;
}
class ImplementsBaseClassTypedef2 extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedef2
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDef2 extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDef2
: super core::Object::•()
;
}
class ImplementsBaseClassTypedefOutside extends core::Object implements mai::A {
synthetic constructor •() → self::ImplementsBaseClassTypedefOutside
: super core::Object::•()
;
}
class ImplementsBaseMixinTypeDefOutside extends core::Object implements mai::M {
synthetic constructor •() → self::ImplementsBaseMixinTypeDefOutside
: super core::Object::•()
;
}
library /*isNonNullableByDefault*/;
import self as mai;
import "dart:core" as core;
typedef ATypeDef = mai::A;
typedef ATypeDef2 = mai::A;
typedef MTypeDef = mai::M;
typedef MTypeDef2 = mai::M;
base class A extends core::Object {
synthetic constructor •() → mai::A
: super core::Object::•()
;
}
abstract base class M extends core::Object /*isMixinDeclaration*/ {
}

View file

@ -0,0 +1,15 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
base class A {}
typedef ATypeDef = A;
typedef ATypeDef2 = ATypeDef;
base mixin M {}
typedef MTypeDef = M;
typedef MTypeDef2 = MTypeDef;

View file

@ -0,0 +1 @@
main_lib.dart

View file

@ -9,14 +9,14 @@
import 'base_class_implement_lib.dart';
abstract class AOutside implements BaseClass {}
// ^
// ^
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
// [analyzer] unspecified
// [cfe] unspecified
class BOutside implements BaseClass {
// ^
// ^
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
// [analyzer] unspecified
// [cfe] unspecified
@override
int foo = 1;
}

View file

@ -9,9 +9,20 @@
import 'base_class_typedef_lib.dart';
class BTypeDef implements BaseClassTypeDef {
// ^
// ^
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
// [analyzer] unspecified
@override
int foo = 1;
}
// Testing another layer of typedefs outside of the library.
typedef BaseClassTypeDef2 = BaseClassTypeDef;
class BTypeDef2 implements BaseClassTypeDef2 {
// ^
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
// [analyzer] unspecified
// [cfe] unspecified
@override
int foo = 1;
}

View file

@ -13,8 +13,8 @@ import 'base_class_typedef_used_outside_lib.dart';
typedef ATypeDef = BaseClass;
class B implements ATypeDef {
// ^
// ^
// [cfe] The class 'BaseClass' can't be implemented outside of its library because it's a base class.
// [analyzer] unspecified
// [cfe] unspecified
int foo = 1;
}

View file

@ -9,14 +9,14 @@
import 'base_mixin_implement_lib.dart';
abstract class AOutside implements BaseMixin {}
// ^
// ^
// [cfe] The mixin 'BaseMixin' can't be implemented outside of its library because it's a base mixin.
// [analyzer] unspecified
// [cfe] unspecified
class BOutside implements BaseMixin {
// ^
// ^
// [cfe] The mixin 'BaseMixin' can't be implemented outside of its library because it's a base mixin.
// [analyzer] unspecified
// [cfe] unspecified
@override
int foo = 1;
}