Skip to content

Commit

Permalink
Fixes #1198. Add more e<typeArgs> tests instead
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Sep 17, 2021
1 parent e55fdff commit 52587af
Show file tree
Hide file tree
Showing 9 changed files with 353 additions and 0 deletions.
36 changes: 36 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A05_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise, if e has a static type which is a generic function type, then
/// e<typeArgs> is equivalent to the instantiated method-tear off
/// e.call<typeArgs>.
///
/// @description Checks that if e has a static type which is a generic function
/// type, then e<typeArgs> is equivalent to the instantiated method-tear off
/// e.call<typeArgs>
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

import "../../Utils/expect.dart";

T foo<T>(T t) => t;

main() {
T bar<T>(T t) => t;

var c1 = foo<int>;
Expect.isFalse(c1 is Type);
Expect.isTrue(c1 is int Function(int));
Expect.equals(c1.toString(), foo.call<int>.toString());

var c2 = bar<int>;
Expect.isFalse(c2 is Type);
Expect.isTrue(c2 is int Function(int));
Expect.equals(c2.toString(), bar.call<int>.toString());
}
37 changes: 37 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A05_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise, if e has a static type which is a generic function type, then
/// e<typeArgs> is equivalent to the instantiated method-tear off
/// e.call<typeArgs>.
///
/// @description Checks that if e has a static type which is a generic function
/// type, then e<typeArgs> is equivalent to the instantiated method-tear off
/// e.call<typeArgs>
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

import "../../Utils/expect.dart";

class C {
static T foo<T>(T t) => t;
T bar<T>(T t) => t;
}
main() {
var c1 = C.foo<int>;
Expect.isFalse(c1 is Type);
Expect.isTrue(c1 is int Function(int));
Expect.equals(c1.toString(), C.foo.call<int>.toString());

C c = new C();
var c2 = c.bar<int>;
Expect.isFalse(c2 is Type);
Expect.isTrue(c2 is int Function(int));
Expect.equals(c2.toString(), c.bar.call<int>.toString());
}
39 changes: 39 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e has a type dynamic
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

T foo<T>(T t) => t;

main() {
T bar<T>(T t) => t;

dynamic func1 = foo;
var c1 = func1<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified

dynamic func2 = bar;
var c2 = func2<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
39 changes: 39 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t02.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e has a type Function
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

T foo<T>(T t) => t;

main() {
T bar<T>(T t) => t;

Function func1 = foo;
var c1 = func1<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified

Function func2 = bar;
var c2 = func2<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
40 changes: 40 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t03.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e has a type dynamic
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

class C {
static T foo<T>(T t) => t;
T bar<T>(T t) => t;
}

main() {
dynamic func1 = C.foo;
var c1 = func1<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified

dynamic func2 = C().bar;
var c2 = func2<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
39 changes: 39 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t04.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e has a type Function
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

class C {
static T foo<T>(T t) => t;
T bar<T>(T t) => t;
}
main() {
Function func1 = foo;
var c1 = func1<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified

Function func2 = bar;
var c2 = func2<int>;
// ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
38 changes: 38 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t05.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e denoting a
/// constructor
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

class C {
C();
C.id();
}
main() {
var c1 = C.new<int>;
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified

var c2 = C.id<int>;
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
}
43 changes: 43 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t06.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e denoting a
/// factory constructor
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

class C {
factory C() = D;
factory C.id() = D;
}

class D implements C {
D();
}

main() {
var c1 = C.new<int>;
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified

var c2 = C.id<int>;
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
}
42 changes: 42 additions & 0 deletions LanguageFeatures/Constructor-tear-offs/expression_A06_t07.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (c) 2021, 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.

/// @assertion For an expression of the form e<typeArgs>, which is not followed
/// by an argument list (that would turn it into a generic function invocation),
/// the meaning of e<typeArgs> depends on the expression e:
/// ...
/// - Otherwise the expression is a compile-time error.
/// This includes e having the static type dynamic or Function. We do not
/// support implicit or explicit instantiation of functions where we do not know
/// the number and bounds of the type parameters at compile-time.
/// It also includes e denoting a constructor. (We reserve this syntax for
/// denoting instantiation of generic constructors, should the language add
/// generic constructors in the future. Instead just write (C.name)<typeArgs> or
/// C<typeArgs>.name.)
///
/// @description Checks that it is a compile-time error if e denoting a
/// forwarding constructor introduced by mixin application
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs

class A {
A();
A.id();
}

mixin M {}
class C = A with M;

main() {
var c1 = C.new<int>;
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified

var c2 = C.id<int>;
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
}

0 comments on commit 52587af

Please sign in to comment.