mirror of
https://github.com/dart-lang/sdk
synced 2024-10-07 10:26:00 +00:00
[cfe] Add conditional import tests
Change-Id: If309f74ab7420e933c0942388780b57e8c3d63dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221622 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
aa5c2b3da6
commit
1926ff8c67
|
@ -158,6 +158,7 @@ cb
|
|||
cc
|
||||
ccc
|
||||
cell
|
||||
certificate
|
||||
cf
|
||||
characteristics
|
||||
charset
|
||||
|
|
37
pkg/front_end/testcases/dart2js/conditional_import.dart
Normal file
37
pkg/front_end/testcases/dart2js/conditional_import.dart
Normal file
|
@ -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.
|
||||
|
||||
// All three libraries have an HttpRequest class.
|
||||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
|
||||
// All three libraries have an HttpRequest class.
|
||||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
testA(a.HttpRequest request) {
|
||||
request.certificate; // error (from dart:io)
|
||||
request.response; // ok (from dart:io and dart:html)
|
||||
request.readyState; // ok (from dart:html)
|
||||
request.hashCode; // ok
|
||||
}
|
||||
|
||||
testB(b.HttpRequest request) {
|
||||
request.certificate; // error
|
||||
request.response; // error
|
||||
request.readyState; // error
|
||||
request.hashCode; // ok
|
||||
}
|
||||
|
||||
void main() {
|
||||
expect(false, const bool.fromEnvironment("dart.library.io"));
|
||||
expect(true, const bool.fromEnvironment("dart.library.html"));
|
||||
expect(false, const bool.fromEnvironment("dart.library.foo"));
|
||||
}
|
||||
|
||||
expect(expected, actual) {
|
||||
if (expected != actual) throw 'Expected $expected, actual $actual';
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
testA(a.HttpRequest request) {}
|
||||
testB(b.HttpRequest request) {}
|
||||
void main() {}
|
||||
expect(expected, actual) {}
|
|
@ -0,0 +1,11 @@
|
|||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
expect(expected, actual) {}
|
||||
testA(a.HttpRequest request) {}
|
||||
testB(b.HttpRequest request) {}
|
||||
void main() {}
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic
|
||||
;
|
||||
static method testB(self::HttpRequest request) → dynamic
|
||||
;
|
||||
static method main() → void
|
||||
;
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic
|
||||
;
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dart2js/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dart2js/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
37
pkg/front_end/testcases/dartdevc/conditional_import.dart
Normal file
37
pkg/front_end/testcases/dartdevc/conditional_import.dart
Normal file
|
@ -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.
|
||||
|
||||
// All three libraries have an HttpRequest class.
|
||||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
|
||||
// All three libraries have an HttpRequest class.
|
||||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
testA(a.HttpRequest request) {
|
||||
request.certificate; // error (from dart:io)
|
||||
request.response; // ok (from dart:io and dart:html)
|
||||
request.readyState; // ok (from dart:html)
|
||||
request.hashCode; // ok
|
||||
}
|
||||
|
||||
testB(b.HttpRequest request) {
|
||||
request.certificate; // error
|
||||
request.response; // error
|
||||
request.readyState; // error
|
||||
request.hashCode; // ok
|
||||
}
|
||||
|
||||
void main() {
|
||||
expect(false, const bool.fromEnvironment("dart.library.io"));
|
||||
expect(true, const bool.fromEnvironment("dart.library.html"));
|
||||
expect(false, const bool.fromEnvironment("dart.library.foo"));
|
||||
}
|
||||
|
||||
expect(expected, actual) {
|
||||
if (expected != actual) throw 'Expected $expected, actual $actual';
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
testA(a.HttpRequest request) {}
|
||||
testB(b.HttpRequest request) {}
|
||||
void main() {}
|
||||
expect(expected, actual) {}
|
|
@ -0,0 +1,11 @@
|
|||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
expect(expected, actual) {}
|
||||
testA(a.HttpRequest request) {}
|
||||
testB(b.HttpRequest request) {}
|
||||
void main() {}
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic
|
||||
;
|
||||
static method testB(self::HttpRequest request) → dynamic
|
||||
;
|
||||
static method main() → void
|
||||
;
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic
|
||||
;
|
|
@ -0,0 +1,84 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // ok (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
static method _#new#tearOff() → self::HttpRequest
|
||||
return new self::HttpRequest::•();
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // ok (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/dartdevc/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/dartdevc/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(false, #C1);
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
37
pkg/front_end/testcases/general/conditional_import.dart
Normal file
37
pkg/front_end/testcases/general/conditional_import.dart
Normal file
|
@ -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.
|
||||
|
||||
// All three libraries have an HttpRequest class.
|
||||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
|
||||
// All three libraries have an HttpRequest class.
|
||||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
testA(a.HttpRequest request) {
|
||||
request.certificate; // ok (from dart:io)
|
||||
request.response; // ok (from dart:io and dart:html)
|
||||
request.readyState; // error (from dart:html)
|
||||
request.hashCode; // ok
|
||||
}
|
||||
|
||||
testB(b.HttpRequest request) {
|
||||
request.certificate; // error
|
||||
request.response; // error
|
||||
request.readyState; // error
|
||||
request.hashCode; // ok
|
||||
}
|
||||
|
||||
void main() {
|
||||
expect(true, const bool.fromEnvironment("dart.library.io"));
|
||||
expect(false, const bool.fromEnvironment("dart.library.html"));
|
||||
expect(false, const bool.fromEnvironment("dart.library.foo"));
|
||||
}
|
||||
|
||||
expect(expected, actual) {
|
||||
if (expected != actual) throw 'Expected $expected, actual $actual';
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
testA(a.HttpRequest request) {}
|
||||
testB(b.HttpRequest request) {}
|
||||
void main() {}
|
||||
expect(expected, actual) {}
|
|
@ -0,0 +1,11 @@
|
|||
import "conditional_import.dart" if (dart.library.foo) "dart:foo" as b;
|
||||
import "conditional_import.dart"
|
||||
if (dart.library.io) "dart:io"
|
||||
if (dart.library.html) "dart:html" as a;
|
||||
|
||||
class HttpRequest {}
|
||||
|
||||
expect(expected, actual) {}
|
||||
testA(a.HttpRequest request) {}
|
||||
testB(b.HttpRequest request) {}
|
||||
void main() {}
|
|
@ -0,0 +1,82 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
;
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic
|
||||
;
|
||||
static method testB(self::HttpRequest request) → dynamic
|
||||
;
|
||||
static method main() → void
|
||||
;
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic
|
||||
;
|
|
@ -0,0 +1,82 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'dart:_http'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error (from dart:html)
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
// request.certificate; // error
|
||||
// ^^^^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
// request.response; // error
|
||||
// ^^^^^^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
// - 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
// Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
// request.readyState; // error
|
||||
// ^^^^^^^^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
import "dart:_http" as _ht;
|
||||
import "dart:io" as io;
|
||||
|
||||
import "dart:io" as a;
|
||||
import "org-dartlang-testcase:///conditional_import.dart" as b;
|
||||
|
||||
class HttpRequest extends core::Object {
|
||||
synthetic constructor •() → self::HttpRequest
|
||||
: super core::Object::•()
|
||||
;
|
||||
}
|
||||
static method testA(_ht::HttpRequest request) → dynamic {
|
||||
request.{_ht::HttpRequest::certificate}{io::X509Certificate?};
|
||||
request.{_ht::HttpRequest::response}{_ht::HttpResponse};
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:18:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'dart:_http'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error (from dart:html)
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method testB(self::HttpRequest request) → dynamic {
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:23:11: Error: The getter 'certificate' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'certificate'.
|
||||
request.certificate; // error
|
||||
^^^^^^^^^^^" in request{<unresolved>}.certificate;
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:24:11: Error: The getter 'response' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'response'.
|
||||
request.response; // error
|
||||
^^^^^^^^" in request{<unresolved>}.response;
|
||||
invalid-expression "pkg/front_end/testcases/general/conditional_import.dart:25:11: Error: The getter 'readyState' isn't defined for the class 'HttpRequest'.
|
||||
- 'HttpRequest' is from 'pkg/front_end/testcases/general/conditional_import.dart'.
|
||||
Try correcting the name to the name of an existing getter, or defining a getter or field named 'readyState'.
|
||||
request.readyState; // error
|
||||
^^^^^^^^^^" in request{<unresolved>}.readyState;
|
||||
request.{core::Object::hashCode}{core::int};
|
||||
}
|
||||
static method main() → void {
|
||||
self::expect(true, #C1);
|
||||
self::expect(false, #C1);
|
||||
self::expect(false, #C1);
|
||||
}
|
||||
static method expect(dynamic expected, dynamic actual) → dynamic {
|
||||
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
|
||||
throw "Expected ${expected}, actual ${actual}";
|
||||
}
|
||||
|
||||
constants {
|
||||
#C1 = false
|
||||
}
|
|
@ -33,6 +33,7 @@ general/bug30695: TypeCheckError
|
|||
general/bug31124: RuntimeError
|
||||
general/call: RuntimeError
|
||||
general/cascade: RuntimeError
|
||||
general/conditional_import: RuntimeError # Issue 47814
|
||||
general/constructor_initializer_invalid: RuntimeError
|
||||
general/covariant_field: TypeCheckError
|
||||
general/covariant_generic: RuntimeError
|
||||
|
|
|
@ -46,6 +46,7 @@ general/bug30695: TypeCheckError
|
|||
general/bug31124: RuntimeError # Test has no main method (and we shouldn't add one).
|
||||
general/call: RuntimeError
|
||||
general/cascade: RuntimeError
|
||||
general/conditional_import: RuntimeError # Issue 47814
|
||||
general/constructor_initializer_invalid: RuntimeError # Fails execution after recovery
|
||||
general/covariant_field: TypeCheckError
|
||||
general/covariant_generic: RuntimeError
|
||||
|
|
Loading…
Reference in a new issue