Skip to content

Commit d63bfe9

Browse files
Dan Rubelcommit-bot@chromium.org
authored andcommitted
nullable function type formal param test
Change-Id: Ib2bd27c6c5f8d98a0a07754dce425eab1be9d9c0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105000 Commit-Queue: Dan Rubel <danrubel@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Auto-Submit: Dan Rubel <danrubel@google.com>
1 parent 637cae2 commit d63bfe9

10 files changed

Lines changed: 340 additions & 0 deletions

pkg/front_end/testcases/legacy.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ invocations: Fail
3838
micro: Fail # External method marked abstract.
3939
minimum_int: Crash # Min int literal not supported in non-strong mode.
4040
named_parameters: Fail # Missing types and unnecessary default values.
41+
nnbd/nullable_param: RuntimeError
4142
operator_method_not_found: RuntimeError # Expected
4243
optional: Fail # Unnecessary default values.
4344
rasta/abstract_constructor: Fail
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
class Foo {
5+
int? field;
6+
int? bar(int? x);
7+
}
8+
9+
main() {
10+
Foo foo = new Foo();
11+
foo.field = 5;
12+
foo.bar(6);
13+
14+
test_nullable_function_type_formal_param(f: () => 2);
15+
}
16+
17+
int test_nullable_function_type_formal_param({int f()? : null}) {
18+
return f() ?? -1;
19+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Object:
2+
superclasses:
3+
interfaces:
4+
classMembers:
5+
Object._haveSameRuntimeType
6+
Object.toString
7+
Object.runtimeType
8+
Object._toString
9+
Object._simpleInstanceOf
10+
Object._hashCodeRnd
11+
Object._instanceOf
12+
Object.noSuchMethod
13+
Object._objectHashCode
14+
Object._identityHashCode
15+
Object.hashCode
16+
Object._simpleInstanceOfFalse
17+
Object._simpleInstanceOfTrue
18+
Object.==
19+
classSetters:
20+
21+
Foo:
22+
superclasses:
23+
Object
24+
interfaces:
25+
classMembers:
26+
Foo.bar
27+
Object.toString
28+
Object.runtimeType
29+
Object._simpleInstanceOf
30+
Foo.field
31+
Object._instanceOf
32+
Object.noSuchMethod
33+
Object._identityHashCode
34+
Object.hashCode
35+
Object._simpleInstanceOfFalse
36+
Object._simpleInstanceOfTrue
37+
Object.==
38+
classSetters:
39+
Foo.field
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/nullable_param.dart:5:6: Error: This requires the 'non-nullable' experiment to be enabled.
6+
// Try enabling this experiment by adding it to the command line when compiling and running.
7+
// int? field;
8+
// ^
9+
//
10+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:6: Error: This requires the 'non-nullable' experiment to be enabled.
11+
// Try enabling this experiment by adding it to the command line when compiling and running.
12+
// int? bar(int? x);
13+
// ^
14+
//
15+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:15: Error: This requires the 'non-nullable' experiment to be enabled.
16+
// Try enabling this experiment by adding it to the command line when compiling and running.
17+
// int? bar(int? x);
18+
// ^
19+
//
20+
// pkg/front_end/testcases/nnbd/nullable_param.dart:17:54: Error: This requires the 'non-nullable' experiment to be enabled.
21+
// Try enabling this experiment by adding it to the command line when compiling and running.
22+
// int test_nullable_function_type_formal_param({int f()? : null}) {
23+
// ^
24+
//
25+
// pkg/front_end/testcases/nnbd/nullable_param.dart:4:7: Error: The non-abstract class 'Foo' is missing implementations for these members:
26+
// - Foo.bar
27+
// Try to either
28+
// - provide an implementation,
29+
// - inherit an implementation from a superclass or mixin,
30+
// - mark the class as abstract, or
31+
// - provide a 'noSuchMethod' implementation.
32+
//
33+
// class Foo {
34+
// ^^^
35+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:8: Context: 'Foo.bar' is defined here.
36+
// int? bar(int? x);
37+
// ^^^
38+
//
39+
import self as self;
40+
import "dart:core" as core;
41+
42+
class Foo extends core::Object {
43+
field core::int field = null;
44+
synthetic constructor •() → self::Foo
45+
: super core::Object::•()
46+
;
47+
abstract method bar(core::int x) → core::int;
48+
}
49+
static method main() → dynamic {
50+
self::Foo foo = new self::Foo::•();
51+
foo.field = 5;
52+
foo.bar(6);
53+
self::test_nullable_function_type_formal_param(f: () → dynamic => 2);
54+
}
55+
static method test_nullable_function_type_formal_param({() → core::int f = null}) → core::int {
56+
return let final dynamic #t1 = f.call() in #t1.==(null) ? 1.unary-() : #t1;
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/nullable_param.dart:5:6: Error: This requires the 'non-nullable' experiment to be enabled.
6+
// Try enabling this experiment by adding it to the command line when compiling and running.
7+
// int? field;
8+
// ^
9+
//
10+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:6: Error: This requires the 'non-nullable' experiment to be enabled.
11+
// Try enabling this experiment by adding it to the command line when compiling and running.
12+
// int? bar(int? x);
13+
// ^
14+
//
15+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:15: Error: This requires the 'non-nullable' experiment to be enabled.
16+
// Try enabling this experiment by adding it to the command line when compiling and running.
17+
// int? bar(int? x);
18+
// ^
19+
//
20+
// pkg/front_end/testcases/nnbd/nullable_param.dart:17:54: Error: This requires the 'non-nullable' experiment to be enabled.
21+
// Try enabling this experiment by adding it to the command line when compiling and running.
22+
// int test_nullable_function_type_formal_param({int f()? : null}) {
23+
// ^
24+
//
25+
// pkg/front_end/testcases/nnbd/nullable_param.dart:4:7: Error: The non-abstract class 'Foo' is missing implementations for these members:
26+
// - Foo.bar
27+
// Try to either
28+
// - provide an implementation,
29+
// - inherit an implementation from a superclass or mixin,
30+
// - mark the class as abstract, or
31+
// - provide a 'noSuchMethod' implementation.
32+
//
33+
// class Foo {
34+
// ^^^
35+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:8: Context: 'Foo.bar' is defined here.
36+
// int? bar(int? x);
37+
// ^^^
38+
//
39+
import self as self;
40+
import "dart:core" as core;
41+
42+
class Foo extends core::Object {
43+
field core::int field = null;
44+
synthetic constructor •() → self::Foo
45+
: super core::Object::•()
46+
;
47+
abstract method bar(core::int x) → core::int;
48+
}
49+
static method main() → dynamic {
50+
self::Foo foo = new self::Foo::•();
51+
foo.field = 5;
52+
foo.bar(6);
53+
self::test_nullable_function_type_formal_param(f: () → dynamic => 2);
54+
}
55+
static method test_nullable_function_type_formal_param({() → core::int f = null}) → core::int {
56+
return let final dynamic #t1 = f.call() in #t1.==(null) ? 1.unary-() : #t1;
57+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/nullable_param.dart:5:6: Error: This requires the 'non-nullable' experiment to be enabled.
6+
// Try enabling this experiment by adding it to the command line when compiling and running.
7+
// int? field;
8+
// ^
9+
//
10+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:6: Error: This requires the 'non-nullable' experiment to be enabled.
11+
// Try enabling this experiment by adding it to the command line when compiling and running.
12+
// int? bar(int? x);
13+
// ^
14+
//
15+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:15: Error: This requires the 'non-nullable' experiment to be enabled.
16+
// Try enabling this experiment by adding it to the command line when compiling and running.
17+
// int? bar(int? x);
18+
// ^
19+
//
20+
// pkg/front_end/testcases/nnbd/nullable_param.dart:17:54: Error: This requires the 'non-nullable' experiment to be enabled.
21+
// Try enabling this experiment by adding it to the command line when compiling and running.
22+
// int test_nullable_function_type_formal_param({int f()? : null}) {
23+
// ^
24+
//
25+
// pkg/front_end/testcases/nnbd/nullable_param.dart:4:7: Error: The non-abstract class 'Foo' is missing implementations for these members:
26+
// - Foo.bar
27+
// Try to either
28+
// - provide an implementation,
29+
// - inherit an implementation from a superclass or mixin,
30+
// - mark the class as abstract, or
31+
// - provide a 'noSuchMethod' implementation.
32+
//
33+
// class Foo {
34+
// ^^^
35+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:8: Context: 'Foo.bar' is defined here.
36+
// int? bar(int? x);
37+
// ^^^
38+
//
39+
import self as self;
40+
import "dart:core" as core;
41+
42+
class Foo extends core::Object {
43+
field core::int field;
44+
synthetic constructor •() → self::Foo
45+
;
46+
abstract method bar(core::int x) → core::int;
47+
}
48+
static method main() → dynamic
49+
;
50+
static method test_nullable_function_type_formal_param({() → core::int f}) → core::int
51+
;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/nullable_param.dart:5:6: Error: This requires the 'non-nullable' experiment to be enabled.
6+
// Try enabling this experiment by adding it to the command line when compiling and running.
7+
// int? field;
8+
// ^
9+
//
10+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:6: Error: This requires the 'non-nullable' experiment to be enabled.
11+
// Try enabling this experiment by adding it to the command line when compiling and running.
12+
// int? bar(int? x);
13+
// ^
14+
//
15+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:15: Error: This requires the 'non-nullable' experiment to be enabled.
16+
// Try enabling this experiment by adding it to the command line when compiling and running.
17+
// int? bar(int? x);
18+
// ^
19+
//
20+
// pkg/front_end/testcases/nnbd/nullable_param.dart:17:54: Error: This requires the 'non-nullable' experiment to be enabled.
21+
// Try enabling this experiment by adding it to the command line when compiling and running.
22+
// int test_nullable_function_type_formal_param({int f()? : null}) {
23+
// ^
24+
//
25+
// pkg/front_end/testcases/nnbd/nullable_param.dart:4:7: Error: The non-abstract class 'Foo' is missing implementations for these members:
26+
// - Foo.bar
27+
// Try to either
28+
// - provide an implementation,
29+
// - inherit an implementation from a superclass or mixin,
30+
// - mark the class as abstract, or
31+
// - provide a 'noSuchMethod' implementation.
32+
//
33+
// class Foo {
34+
// ^^^
35+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:8: Context: 'Foo.bar' is defined here.
36+
// int? bar(int? x);
37+
// ^^^
38+
//
39+
import self as self;
40+
import "dart:core" as core;
41+
42+
class Foo extends core::Object {
43+
field core::int field = null;
44+
synthetic constructor •() → self::Foo
45+
: super core::Object::•()
46+
;
47+
abstract method bar(core::int x) → core::int;
48+
}
49+
static method main() → dynamic {
50+
self::Foo foo = new self::Foo::•();
51+
foo.{self::Foo::field} = 5;
52+
foo.{self::Foo::bar}(6);
53+
self::test_nullable_function_type_formal_param(f: () → core::int => 2);
54+
}
55+
static method test_nullable_function_type_formal_param({() → core::int f = null}) → core::int {
56+
return let final core::int #t1 = f.call() in #t1.==(null) ?{core::int} 1.{core::int::unary-}() : #t1;
57+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/nullable_param.dart:5:6: Error: This requires the 'non-nullable' experiment to be enabled.
6+
// Try enabling this experiment by adding it to the command line when compiling and running.
7+
// int? field;
8+
// ^
9+
//
10+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:6: Error: This requires the 'non-nullable' experiment to be enabled.
11+
// Try enabling this experiment by adding it to the command line when compiling and running.
12+
// int? bar(int? x);
13+
// ^
14+
//
15+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:15: Error: This requires the 'non-nullable' experiment to be enabled.
16+
// Try enabling this experiment by adding it to the command line when compiling and running.
17+
// int? bar(int? x);
18+
// ^
19+
//
20+
// pkg/front_end/testcases/nnbd/nullable_param.dart:17:54: Error: This requires the 'non-nullable' experiment to be enabled.
21+
// Try enabling this experiment by adding it to the command line when compiling and running.
22+
// int test_nullable_function_type_formal_param({int f()? : null}) {
23+
// ^
24+
//
25+
// pkg/front_end/testcases/nnbd/nullable_param.dart:4:7: Error: The non-abstract class 'Foo' is missing implementations for these members:
26+
// - Foo.bar
27+
// Try to either
28+
// - provide an implementation,
29+
// - inherit an implementation from a superclass or mixin,
30+
// - mark the class as abstract, or
31+
// - provide a 'noSuchMethod' implementation.
32+
//
33+
// class Foo {
34+
// ^^^
35+
// pkg/front_end/testcases/nnbd/nullable_param.dart:6:8: Context: 'Foo.bar' is defined here.
36+
// int? bar(int? x);
37+
// ^^^
38+
//
39+
import self as self;
40+
import "dart:core" as core;
41+
42+
class Foo extends core::Object {
43+
field core::int field = null;
44+
synthetic constructor •() → self::Foo
45+
: super core::Object::•()
46+
;
47+
abstract method bar(core::int x) → core::int;
48+
}
49+
static method main() → dynamic {
50+
self::Foo foo = new self::Foo::•();
51+
foo.{self::Foo::field} = 5;
52+
foo.{self::Foo::bar}(6);
53+
self::test_nullable_function_type_formal_param(f: () → core::int => 2);
54+
}
55+
static method test_nullable_function_type_formal_param({() → core::int f = null}) → core::int {
56+
return let final core::int #t1 = f.call() in #t1.==(null) ?{core::int} 1.{core::int::unary-}() : #t1;
57+
}

pkg/front_end/testcases/strong.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ invocations: RuntimeError
7777
issue34899: TypeCheckError
7878
micro: RuntimeError
7979
mixin_application_override: TypeCheckError
80+
nnbd/nullable_param: RuntimeError
8081
operator_method_not_found: RuntimeError # Expected
8182
optional: TypeCheckError
8283
override_check_accessor_after_inference: TypeCheckError # Issue #31620

pkg/front_end/testcases/text_serialization.status

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ named_parameters: TextSerializationFailure # Was: Pass
707707
native_as_name: TextSerializationFailure # Was: Pass
708708
nested_implicit_const_with_env_var: TextSerializationFailure # Was: Pass
709709
new_const_insertion/simple: TextSerializationFailure # Was: Pass
710+
nnbd/nullable_param: TextSerializationFailure
710711
no_such_method_forwarders/abstract_accessors_from_field: TextSerializationFailure # Was: Pass
711712
no_such_method_forwarders/abstract_accessors_from_field_arent_mixed_in: TextSerializationFailure # Was: Pass
712713
no_such_method_forwarders/abstract_accessors_from_field_one_defined: TextSerializationFailure # Was: Pass

0 commit comments

Comments
 (0)