Skip to content

Validate only needed summaries in expression_compiler_service #1920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dwds/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Return error on expression evaluation if expression evaluator stopped.
- Update SDK constraint to `>=3.0.0-134.0.dev <4.0.0`.
- Update `package:vm_service` constraint to `>=10.1.0 <12.0.0`.
- Fix expression compiler throwing when weak SDK summary is not found.

**Breaking changes**
- Include an optional param to `Dwds.start` to indicate whether it is running
Expand Down
7 changes: 6 additions & 1 deletion dwds/lib/src/services/expression_compiler_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ class _Compiler {
List<String> experiments,
bool verbose,
) async {
sdkConfiguration.validate();
sdkConfiguration.validateSdkDir();
if (soundNullSafety) {
sdkConfiguration.validateSoundSummaries();
} else {
sdkConfiguration.validateWeakSummaries();
}

final librariesUri = sdkConfiguration.librariesUri!;
final workerUri = sdkConfiguration.compilerWorkerUri!;
Expand Down
7 changes: 7 additions & 0 deletions fixtures/_webdevSoundSmoke/web/scopes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>

<head>
<script defer src="scopes_main.dart.js"></script>
</head>

</html>
152 changes: 152 additions & 0 deletions fixtures/_webdevSoundSmoke/web/scopes_main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
// Copyright (c) 2020, 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.

/// An example with more complicated scope
import 'dart:async';
import 'dart:collection';

final libraryPublicFinal = MyTestClass();

final _libraryPrivateFinal = 1;
Object? libraryNull;
var libraryPublic = <String>['library', 'public', 'variable'];
var notAList = NotReallyAList();

var _libraryPrivate = ['library', 'private', 'variable'];

var identityMap = <String, int>{};

var map = <Object, Object>{};

void staticFunction(int formal) {
print(formal); // Breakpoint: staticFunction
}

void main() async {
print('Initial print from scopes app');
var local = 'local in main';
var intLocalInMain = 42;
var testClass = MyTestClass();
Object? localThatsNull;
identityMap['a'] = 1;
identityMap['b'] = 2;
map['a'] = [1, 2, 3];
map['b'] = 'something';
notAList.add(7);

String nestedFunction<T>(T parameter, Object aClass) {
var another = int.tryParse('$parameter');
return '$local: parameter, $another'; // Breakpoint: nestedFunction
}

dynamic nestedWithClosure(String banana) {
return () => '$local + $banana';
}

Timer.periodic(const Duration(seconds: 1), (Timer t) {
var ticks = t.tick;
// ignore: unused_local_variable, prefer_typing_uninitialized_variables
var closureLocal;
libraryPublicFinal.printCount();
staticFunction(1);
print('ticking... $ticks (the answer is $intLocalInMain)');
print(nestedFunction('$ticks ${testClass.message}', Timer));
print(localThatsNull);
print(libraryNull);
var localList = libraryPublic;
print(localList);
localList.add('abc');
var f = testClass.methodWithVariables();
print(f('parameter'));
});

print(_libraryPrivateFinal);
print(_libraryPrivate);
print(nestedFunction(_libraryPrivate.first, Object));
print(nestedWithClosure(_libraryPrivate.first)());
}

String libraryFunction(String arg) {
print('calling a library function with $arg');
var concat = 'some constant plus $arg plus whatever';
print(concat);
return concat;
}

class MyTestClass<T> {
final String message;

late String notFinal;

MyTestClass({this.message = 'world'}) {
myselfField = this;
tornOff = toString;
}

String hello() => message;

String Function(String) methodWithVariables() {
var local = '$message + something';
print(local);
return (String parameter) {
// Be sure to use a field from this, so it isn't entirely optimized away.
var closureLocalInsideMethod = '$message/$local/$parameter';
print(closureLocalInsideMethod);
return closureLocalInsideMethod; // Breakpoint: nestedClosure
};
}

//ignore: avoid_returning_this
MyTestClass get myselfGetter => this;

late MyTestClass myselfField;

var count = 0;

// An easy location to add a breakpoint.
void printCount() {
print('The count is ${++count}');
libraryFunction('abc'); // Breakpoint: printMethod
}

final _privateField = 'a private field';

// ignore: unused_element
String privateMethod(String s) => '$s : $_privateField';

@override
String toString() => 'A test class with message $message';

bool equals(Object other) {
if (other is MyTestClass) return message == other.hello();
return false;
}

Function closure = someFunction;

late String Function() tornOff;
}

Function? someFunction() => null;

// ignore: unused_element
int _libraryPrivateFunction(int a, int b) => a + b;

class NotReallyAList extends ListBase {
final List<Object?> _internal;

NotReallyAList() : _internal = [];

@override
Object? operator [](x) => _internal[x];

@override
operator []=(x, y) => _internal[x] = y as Object?;

@override
int get length => _internal.length;

@override
set length(x) => _internal.length = x;
}
1 change: 1 addition & 0 deletions webdev/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
to the build runner and the expression compiler service.
- Update SDK constraint to `>=3.0.0-134.0.dev <4.0.0`.
- Update `package:vm_service` constraint to `>=10.1.0 <12.0.0`.
- Make all tests use sound null safety fixtures.

**Breaking changes**

Expand Down
2 changes: 1 addition & 1 deletion webdev/test/daemon/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Future<String> waitForAppId(TestProcess webdev) async {

Future<String> prepareWorkspace() async {
var exampleDirectory =
p.absolute(p.join(p.current, '..', 'fixtures', '_webdevSmoke'));
p.absolute(p.join(p.current, '..', 'fixtures', '_webdevSoundSmoke'));

var process = await TestProcess.start(dartPath, ['pub', 'upgrade'],
workingDirectory: exampleDirectory, environment: getPubEnvironment());
Expand Down