dotlin-org/dotlin

classes ClosedRange / IntRange: isEmpty: Error: Can't declare a member that conflicts with an inherited one.

Closed this issue · 2 comments

../../../GitHub/dotlin/packages/dotlin/lib/src/kotlin/ranges/ranges.dt.g.dart:22:24: Error: Can't declare a member that conflicts with an inherited one.
    @override bool get isEmpty {
                       ^^^^^^^
../../../GitHub/dotlin/packages/dotlin/lib/src/kotlin/ranges/range.dt.g.dart:9:10: Context: This is the inherited member.
    bool isEmpty() {
         ^^^^^^^

Ranges:

import "package:meta/meta.dart";

import "progressions.dt.g.dart" show IntProgression;
import "range.dt.g.dart" show start, endInclusive, ClosedRange;

@sealed
class IntRange extends IntProgression implements ClosedRange<int> {
    IntRange(int start, int endInclusive,) : super(start, endInclusive, 1);

    @override int get start {
        return this.first;
    }

    @override int get endInclusive {
        return this.last;
    }

    @override bool has(int value) {
        return this.first <= value && value <= this.last;
    }

    @override bool get isEmpty {
        return this.first > this.last;
    }

ClosedRange:

abstract class ClosedRange<T extends Comparable<dynamic>> {
    abstract final T start;
    abstract final T endInclusive;

    bool has(T value) {
        return value.compareTo(this.start) >= 0 && value.compareTo(this.endInclusive) <= 0;
    }

    bool isEmpty() {
        return this.start.compareTo(this.endInclusive) > 0;
    }
}

Interesting! This error only comes up when you actually run the code, instead of when analyzing. All generated Dart code gets analyzed in tests, but this was missed because of that 🤔

Closing because of Dirt.