-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// ignore_for_file: unnecessary_type_check | ||
|
||
import 'dart:core'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group("base ", () { | ||
test("description", () {}); | ||
}); | ||
} | ||
|
||
base mixin BaseMixin {} | ||
base class BaseClass {} | ||
|
||
// base具有传播性,父类base,子类也必须base | ||
base class AA with BaseMixin {} | ||
|
||
// base具有传播性,父类base,子类也必须base | ||
base class ImplA implements BaseMixin {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'base.dart'; | ||
|
||
// 编译错误无法implement一个base mixin 或class | ||
// 非常棒,这就是要的效果 | ||
// base class ImplA implements BaseMixin {} | ||
// base class ExtendBaseClass implements BaseClass {} | ||
|
||
base class WithBaseMixin with BaseMixin {} | ||
|
||
base class ExtendBaseClass extends BaseClass {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ignore_for_file: unnecessary_type_check | ||
|
||
import 'dart:core'; | ||
|
||
import 'package:checks/checks.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group("interface ", () { | ||
test("description", () { | ||
A a = A(); | ||
check(a.x()).equals("x"); | ||
AA aa = AA(); | ||
check(aa.x()).equals("x"); | ||
|
||
}); | ||
}); | ||
} | ||
|
||
interface class A { | ||
x() => "x"; | ||
} | ||
class AA extends A { | ||
} | ||
// implements 就得实现父类所有方法 | ||
class ImplA implements A { | ||
@override | ||
x() => throw UnimplementedError(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ignore_for_file: unnecessary_type_check | ||
|
||
import 'dart:core'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group("base ", () { | ||
test("description", () {}); | ||
}); | ||
} | ||
|
||
mixin A { | ||
x() => "x"; | ||
} | ||
|
||
// base具有传播性,父类base,子类也必须base | ||
class AA with A {} | ||
|
||
// base具有传播性,父类base,子类也必须base | ||
class ImplA implements A { | ||
@override | ||
x() => throw UnimplementedError(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ignore_for_file: unnecessary_type_check | ||
|
||
import 'dart:core'; | ||
|
||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
group("base ", () { | ||
test("description", () {}); | ||
}); | ||
} | ||
|
||
sealed class A { | ||
x() => "x"; | ||
} | ||
|
||
// base具有传播性,父类base,子类也必须base | ||
class AA extends A {} | ||
|
||
// base具有传播性,父类base,子类也必须base | ||
class ImplA implements A { | ||
@override | ||
x() => throw UnimplementedError(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
// 编译错误,sealed 的类无法被继承或实现 | ||
// class ImplA implements A { | ||
// } | ||
// class WithA extends A { | ||
// } |