dart_eval
dart_eval copied to clipboard
type 'VariableDeclarationImpl' is not a subtype of type 'MethodDeclaration' in type cast
add a test in 'Bridge tests' at bridge_test.dart.
test('Using a subclassed bridge class with function', () {
compiler.defineBridgeClasses([$TestClass.$declaration]);
final program = compiler.compile({
'example': {
'main.dart': '''
import 'package:bridge_lib/bridge_lib.dart';
class MyTestClass extends TestClass {
MyTestClass(int someNumber, this.testSum) : super(someNumber);
final int Function(int num) testSum;
@override
bool runTest(int a, {String b = 'wow'}) {
return super.runTest(a + 2 + someNumber, b: b);
}
}
int main() {
final test = MyTestClass(18, (num) {
return num + 1;
});
return test.testSum(1);
}
'''
}
});
final runtime = Runtime.ofProgram(program);
runtime.registerBridgeFunc('package:bridge_lib/bridge_lib.dart',
'TestClass.', $TestClass.$construct,
isBridge: true);
expect(runtime.executeLib('package:example/main.dart', 'main'), true);
});
Error:
package:dart_eval/src/eval/compiler/expression/method_invocation.dart 366:26 resolveInstanceMethod
package:dart_eval/src/eval/compiler/expression/method_invocation.dart 259:12 _invokeWithTarget
package:dart_eval/src/eval/compiler/expression/method_invocation.dart 55:12 compileMethodInvocation
package:dart_eval/src/eval/compiler/expression/expression.dart 38:12 compileExpression
package:dart_eval/src/eval/compiler/statement/return.dart 24:9 compileReturn
package:dart_eval/src/eval/compiler/statement/statement.dart 31:12 compileStatement
package:dart_eval/src/eval/compiler/statement/block.dart 17:20 compileBlock
package:dart_eval/src/eval/compiler/declaration/function.dart 84:14 compileFunctionDeclaration
package:dart_eval/src/eval/compiler/declaration/declaration.dart 24:5 compileDeclaration
package:dart_eval/src/eval/compiler/compiler.dart 492:11 Compiler.compileSources.
type 'VariableDeclarationImpl' is not a subtype of type 'MethodDeclaration' in type cast