-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate language_2/abstract to NNBD.
Change-Id: I265933f36f68df6f8e542a3f85ce0b04e1dfd549 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134205 Auto-Submit: Bob Nystrom <rnystrom@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com>
- Loading branch information
1 parent
1d932f7
commit 68e904e
Showing
3 changed files
with
97 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,40 @@ | ||
// TODO(multitest): This was automatically migrated from a multitest and may | ||
// contain strange or dead code. | ||
|
||
// 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. | ||
|
||
// Regression test for dart2js that used to duplicate some `Object` | ||
// methods to handle `noSuchMethod`. | ||
|
||
import "package:expect/expect.dart"; | ||
import "../compiler_annotations.dart"; | ||
|
||
class Foo { | ||
noSuchMethod(im) => 42; | ||
} | ||
|
||
@DontInline() | ||
returnFoo() { | ||
(() => 42)(); | ||
return new Foo(); | ||
} | ||
|
||
class Bar { | ||
operator ==(other) => false; | ||
} | ||
|
||
var a = [false, true, new Object(), new Bar()]; | ||
|
||
main() { | ||
if (a[0] as bool) { | ||
// This `==` call will make the compiler create a selector with an | ||
// exact `TypeMask` of `Foo`. Since `Foo` is abstract, such a call | ||
// cannot happen, but we still used to generate a `==` method on | ||
// the `Object` class to handle `noSuchMethod`. | ||
print(returnFoo() == 42); | ||
} else { | ||
Expect.isFalse(a[2] == 42); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/language/abstract/factory_constructor_runtime_test.dart
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,34 @@ | ||
// TODO(multitest): This was automatically migrated from a multitest and may | ||
// contain strange or dead code. | ||
|
||
// Copyright (c) 2012, 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. | ||
// Dart test program for constructors and initializers. | ||
|
||
// Exercises issue 2282, factory constructors in abstract classes should | ||
// not emit a static type warning | ||
|
||
class B extends A1 { | ||
B() {} | ||
method() {} | ||
} | ||
|
||
abstract class A1 { | ||
A1() {} | ||
method(); // Abstract. | ||
factory A1.make() { | ||
return new B(); | ||
} | ||
} | ||
|
||
class A2 { | ||
// Intentionally abstract method. | ||
|
||
A2.make() {} | ||
} | ||
|
||
main() { | ||
new A1.make(); | ||
|
||
} |
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,23 @@ | ||
// TODO(multitest): This was automatically migrated from a multitest and may | ||
// contain strange or dead code. | ||
|
||
// Copyright (c) 2012, 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 "package:expect/expect.dart"; | ||
|
||
main() { | ||
var b = new B(); | ||
Expect.equals(42, b.foo()); | ||
} | ||
|
||
class A { | ||
|
||
|
||
} | ||
|
||
class B extends A { | ||
foo() => 42; | ||
bar() => 87; | ||
} |