Skip to content

Commit

Permalink
Fix PseudoType (#1815)
Browse files Browse the repository at this point in the history
* Fix for added member element3. Try to make the hack PseudoType more robust by implementing noSuchMethod to always throw.

* Fix ejson_lint after LintCode from analyser has become public

* Update CHANGELOG

* Update CHANGELOG.ejson.md
  • Loading branch information
nielsenko authored Jan 2, 2025
1 parent 4e23227 commit d9746f5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Fixed
* For the Android platform, changed compileSdkVersion into 31 from 28 to fix the fatal `android:attr/lStar not found` error when using Flutter 3.24.
* Fix breakage of `PseudoType` after Flutter 3.27.1. (Issue [#1813](https://github.com/realm/realm-dart/issues/1813))

### Compatibility
* Realm Studio: 15.0.0 or later.
Expand Down
4 changes: 4 additions & 0 deletions packages/CHANGELOG.ejson.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.1

- Avoid name conflict on `LinkCode`.

## 0.4.0

- `fromEJson<T>` now accepts a `defaultValue` argument that is returned if
Expand Down
4 changes: 2 additions & 2 deletions packages/ejson_lint/lib/src/lints/mismatched_getter_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/error.dart' as error;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:ejson_analyzer/ejson_analyzer.dart';
Expand All @@ -13,7 +13,7 @@ class MismatchedGetterType extends DartLintRule {
code: const LintCode(
name: 'mismatched_getter_type',
problemMessage: 'Type of getter does not match type of constructor parameter',
errorSeverity: ErrorSeverity.ERROR,
errorSeverity: error.ErrorSeverity.ERROR,
),
);

Expand Down
4 changes: 2 additions & 2 deletions packages/ejson_lint/lib/src/lints/missing_getter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/error.dart' as error;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:ejson_analyzer/ejson_analyzer.dart';
Expand All @@ -13,7 +13,7 @@ class MissingGetter extends DartLintRule {
code: const LintCode(
name: 'missing_getter',
problemMessage: 'Missing getter for constructor parameter',
errorSeverity: ErrorSeverity.ERROR,
errorSeverity: error.ErrorSeverity.ERROR,
),
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 MongoDB, Inc.
// SPDX-License-Identifier: Apache-2.0

import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/error.dart' as error;
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:ejson_analyzer/ejson_analyzer.dart';
Expand All @@ -21,7 +21,7 @@ class TooManyAnnotatedConstructors extends DartLintRule {
code: const LintCode(
name: 'too_many_annotated_constructors',
problemMessage: 'Only one constructor can be annotated',
errorSeverity: ErrorSeverity.ERROR,
errorSeverity: error.ErrorSeverity.ERROR,
),
);

Expand Down
55 changes: 25 additions & 30 deletions packages/realm_dart/lib/src/cli/metrics/metrics.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import 'package:source_span/source_span.dart';

class ExpandedContextSpan with SourceSpanMixin implements FileSpan {
class ExpandedContextSpan extends SourceSpanMixin implements FileSpan {
final FileSpan _span, _contextSpan;

ExpandedContextSpan(this._span, Iterable<FileSpan> contextSpans) : _contextSpan = contextSpans.fold<FileSpan>(_span, (acc, c) => acc.expand(c));
Expand Down
14 changes: 3 additions & 11 deletions packages/realm_generator/lib/src/pseudo_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ class PseudoType extends TypeImpl {

PseudoType(this._name, {this.nullabilitySuffix = NullabilitySuffix.none});

Never get _never => throw UnimplementedError();

@override
R accept<R>(TypeVisitor<R> visitor) => _never;

@override
R acceptWithArgument<R, A>(TypeVisitorWithArgument<R, A> visitor, A argument) => _never;
R acceptWithArgument<R, A>(TypeVisitorWithArgument<R, A> visitor, A argument) => throw UnimplementedError();

@override
void appendTo(ElementDisplayStringBuilder builder) {
Expand All @@ -46,17 +41,14 @@ class PseudoType extends TypeImpl {
im.invoke(writeNullability, <dynamic>[nullabilitySuffix]); // #_writeNullability won't work
}

@override
String? get name => _never;

@override
PseudoType withNullability(NullabilitySuffix nullabilitySuffix) {
return PseudoType(_name, nullabilitySuffix: nullabilitySuffix);
}

@override
Element? get element2 => _never;
Element? get element => null;

@override
Element? get element => null;
Never noSuchMethod(Invocation invocation) => throw UnimplementedError();
}

0 comments on commit d9746f5

Please sign in to comment.