Skip to content

Commit

Permalink
[cfe] Add test for flutter issue 100888
Browse files Browse the repository at this point in the history
Add test that show that the compile-time error is correctly emitted.

This issue was fixed by https://dart-review.googlesource.com/c/sdk/+/236540

Change-Id: Ic56fcd584a32d38aa9f73a28ff5237341193b14f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253760
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
  • Loading branch information
johnniwinther authored and Commit Bot committed Aug 5, 2022
1 parent 35413ac commit 5b489e6
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/front_end/test/spell_checking_list_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ adapter
adaptor
adopted
advantages
af
albeit
aligns
allocations
Expand Down
22 changes: 22 additions & 0 deletions pkg/front_end/testcases/general/flutter_issue100888.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2022, 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.

abstract class ChannelA {
ChannelB? get channel;
}

abstract class ChannelB {
ActiveFrom? get activeFrom;
}

abstract class ActiveFrom {
DateTime toLocal();
}

void method(ChannelA channel) {
DateTime? af = channel.channel?.activeFrom != null ? DateTime(
channel.channel!.activeFrom!.toLocal().year,
channel.channel!.activeFrom!.toLocal().month,
channel.channel!.activeFrom!.toLocal().day);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
abstract class ChannelA {
ChannelB? get channel;
}

abstract class ChannelB {
ActiveFrom? get activeFrom;
}

abstract class ActiveFrom {
DateTime toLocal();
}

void method(ChannelA channel) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
abstract class ActiveFrom {
DateTime toLocal();
}

abstract class ChannelA {
ChannelB? get channel;
}

abstract class ChannelB {
ActiveFrom? get activeFrom;
}

void method(ChannelA channel) {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: Expected ':' before this.
// channel.channel!.activeFrom!.toLocal().day);
// ^
//
// pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: Expected an identifier, but got ';'.
// Try inserting an identifier before ';'.
// channel.channel!.activeFrom!.toLocal().day);
// ^
//
import self as self;
import "dart:core" as core;

abstract class ChannelA extends core::Object {
synthetic constructor •() → self::ChannelA
: super core::Object::•()
;
abstract get channel() → self::ChannelB?;
}
abstract class ChannelB extends core::Object {
synthetic constructor •() → self::ChannelB
: super core::Object::•()
;
abstract get activeFrom() → self::ActiveFrom?;
}
abstract class ActiveFrom extends core::Object {
synthetic constructor •() → self::ActiveFrom
: super core::Object::•()
;
abstract method toLocal() → core::DateTime;
}
static method method(self::ChannelA channel) → void {
core::DateTime? af = !((let final self::ChannelB? #t1 = channel.{self::ChannelA::channel}{self::ChannelB?} in #t1 == null ?{self::ActiveFrom?} null : #t1{self::ChannelB}.{self::ChannelB::activeFrom}{self::ActiveFrom?}) == null) ?{invalid-type} new core::DateTime::•(channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::year}{core::int}, channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::month}{core::int}, channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::day}{core::int}) : invalid-expression "pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: This couldn't be parsed.
channel.channel!.activeFrom!.toLocal().day);
^";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: Expected ':' before this.
// channel.channel!.activeFrom!.toLocal().day);
// ^
//
// pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: Expected an identifier, but got ';'.
// Try inserting an identifier before ';'.
// channel.channel!.activeFrom!.toLocal().day);
// ^
//
import self as self;
import "dart:core" as core;

abstract class ChannelA extends core::Object {
synthetic constructor •() → self::ChannelA
: super core::Object::•()
;
abstract get channel() → self::ChannelB?;
}
abstract class ChannelB extends core::Object {
synthetic constructor •() → self::ChannelB
: super core::Object::•()
;
abstract get activeFrom() → self::ActiveFrom?;
}
abstract class ActiveFrom extends core::Object {
synthetic constructor •() → self::ActiveFrom
: super core::Object::•()
;
abstract method toLocal() → core::DateTime;
}
static method method(self::ChannelA channel) → void {
core::DateTime? af = !((let final self::ChannelB? #t1 = channel.{self::ChannelA::channel}{self::ChannelB?} in #t1 == null ?{self::ActiveFrom?} null : #t1{self::ChannelB}.{self::ChannelB::activeFrom}{self::ActiveFrom?}) == null) ?{invalid-type} new core::DateTime::•(channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::year}{core::int}, channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::month}{core::int}, channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::day}{core::int}) : invalid-expression "pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: This couldn't be parsed.
channel.channel!.activeFrom!.toLocal().day);
^";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;

abstract class ChannelA extends core::Object {
synthetic constructor •() → self::ChannelA
;
abstract get channel() → self::ChannelB?;
}
abstract class ChannelB extends core::Object {
synthetic constructor •() → self::ChannelB
;
abstract get activeFrom() → self::ActiveFrom?;
}
abstract class ActiveFrom extends core::Object {
synthetic constructor •() → self::ActiveFrom
;
abstract method toLocal() → core::DateTime;
}
static method method(self::ChannelA channel) → void
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: Expected ':' before this.
// channel.channel!.activeFrom!.toLocal().day);
// ^
//
// pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: Expected an identifier, but got ';'.
// Try inserting an identifier before ';'.
// channel.channel!.activeFrom!.toLocal().day);
// ^
//
import self as self;
import "dart:core" as core;

abstract class ChannelA extends core::Object {
synthetic constructor •() → self::ChannelA
: super core::Object::•()
;
abstract get channel() → self::ChannelB?;
}
abstract class ChannelB extends core::Object {
synthetic constructor •() → self::ChannelB
: super core::Object::•()
;
abstract get activeFrom() → self::ActiveFrom?;
}
abstract class ActiveFrom extends core::Object {
synthetic constructor •() → self::ActiveFrom
: super core::Object::•()
;
abstract method toLocal() → core::DateTime;
}
static method method(self::ChannelA channel) → void {
core::DateTime? af = !((let final self::ChannelB? #t1 = channel.{self::ChannelA::channel}{self::ChannelB?} in #t1 == null ?{self::ActiveFrom?} null : #t1{self::ChannelB}.{self::ChannelB::activeFrom}{self::ActiveFrom?}) == null) ?{invalid-type} new core::DateTime::•(channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::year}{core::int}, channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::month}{core::int}, channel.{self::ChannelA::channel}{self::ChannelB?}!.{self::ChannelB::activeFrom}{self::ActiveFrom?}!.{self::ActiveFrom::toLocal}(){() → core::DateTime}.{core::DateTime::day}{core::int}) : invalid-expression "pkg/front_end/testcases/general/flutter_issue100888.dart:21:50: Error: This couldn't be parsed.
channel.channel!.activeFrom!.toLocal().day);
^";
}

0 comments on commit 5b489e6

Please sign in to comment.