Skip to content
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

Fix PseudoType #1815

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Changes from 1 commit
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
Next Next commit
Fix for added member element3. Try to make the hack PseudoType more r…
…obust by implementing noSuchMethod to always throw.
nielsenko committed Jan 1, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 426eecd4415ab5f1e21e7bd1fc55db05d957b11c
Original file line number Diff line number Diff line change
@@ -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));
14 changes: 3 additions & 11 deletions packages/realm_generator/lib/src/pseudo_type.dart
Original file line number Diff line number Diff line change
@@ -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) {
@@ -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();
}