dart_eval icon indicating copy to clipboard operation
dart_eval copied to clipboard

type 'BridgeEnumDef' is not a subtype of type 'BridgeClassDef' in type cast

Open HXiaoMing opened this issue 11 months ago • 0 comments

test cast


import 'package:dart_eval/dart_eval.dart';
import 'package:test/test.dart';

import 'bridge_lib.dart';

void main() {
  group('Bridge tests', () {
    late Compiler compiler;

    setUp(() {
      compiler = Compiler();
    });

    test('Using a bridged enum', () {
      compiler.defineBridgeEnum($TestEnum.$declaration);
      final program = compiler.compile({
        'example': {
          'main.dart': '''
            import 'package:bridge_lib/bridge_lib.dart';
            int main() {
              return TestEnum.two.index;
            }
          '''
        }
      });

      final runtime = Runtime.ofProgram(program);

      runtime.registerBridgeEnumValues(
          'package:bridge_lib/bridge_lib.dart', 'TestEnum', $TestEnum.$values);

      expect(runtime.executeLib('package:example/main.dart', 'main').$value,
          TestEnum.two.index);
    });
  });
}

package:dart_eval/src/eval/compiler/type.dart 360:29 TypeRef.lookupFieldType package:dart_eval/src/eval/compiler/variable.dart 305:27 Variable.getProperty package:dart_eval/src/eval/compiler/expression/property_access.dart 38:12 compilePropertyAccess package:dart_eval/src/eval/compiler/expression/expression.dart 44:12 compileExpression package:dart_eval/src/eval/compiler/statement/return.dart 24:9 compileReturn package:dart_eval/src/eval/compiler/statement/statement.dart 32:12 compileStatement package:dart_eval/src/eval/compiler/statement/block.dart 19: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 493:11 Compiler.compileSources.. dart:collection _LinkedHashMapMixin.forEach package:dart_eval/src/eval/compiler/compiler.dart 482:15 Compiler.compileSources. dart:collection _LinkedHashMapMixin.forEach package:dart_eval/src/eval/compiler/compiler.dart 478:32 Compiler.compileSources package:dart_eval/src/eval/compiler/compiler.dart 164:12 Compiler.compile test/bridge_test.dart 21:32 main..

type 'BridgeEnumDef' is not a subtype of type 'BridgeClassDef' in type cast

HXiaoMing avatar Mar 06 '24 11:03 HXiaoMing