dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.58k forks source link

Dart allows to extend deferred classes. #42031

Open iarkh opened 4 years ago

iarkh commented 4 years ago

Dart VM version: 2.9.0-10.0.dev (dev) (Tue May 19 15:16:48 2020 +0200) on "windows_x64"

The following source code declares a class which extends deferred class:

import "dart:core" deferred as core;

class A extends core.ArgumentError {}

main() {
  new A();
}

Analyzer throws a compile error here whereas dart passes without any errors and warnings. Sample output is:

$> dartanalyzer test.dart Analyzing test.dart... error - Classes can't extend deferred classes. - test.dart:3:17 - extends_deferred_class 1 error found.

$> dart test.dart $

Seems like according to the Dart Language Spec dart also should throw an exception here.

johnniwinther commented 4 years ago

See #30273

sgrekhov commented 4 years ago

The same issue exists for mixins as well. Analyzed doesn't allow to mixin deferred classes but CFE allows

import 'deferred_lib.dart' deferred as d;

class B {
}

class C extends B with d.A {} // No isses in CFE, in analyzer error - Classes can't mixin deferred classes.

main() {
  new C();
}
sgrekhov commented 1 year ago

The issue is still exists on CFE