Skip to content

Kernel's VM specific mixin transformation generates classes with incompatible overrides #30674

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

Open
mraleph opened this issue Sep 12, 2017 · 2 comments
Assignees
Labels
front-end-fasta front-end-kernel legacy-area-front-end Legacy: Use area-dart-model instead. P2 A bug or feature request we're likely to work on

Comments

@mraleph
Copy link
Member

mraleph commented Sep 12, 2017

When I compile the following Dart code below:

abstract class I<T> {
  void map(void f(T e));
}


class A<T> {
  void map(void f(T e)) {

  }
}

abstract class B implements I<int> {
}

class Good extends A<int> with B implements I<int> {
}

In Kernel I get:

  abstract class _A&B^#U0^<#U0 extends core::Object> extends y::A<y::_A&B^#U0^::#U0> implements y::B {
    constructor •() → void
      : super y::A::•()
      ;
  }
  class Good extends y::_A&B^#U0^<core::int> implements y::I<core::int> {
    default constructor •() → void
      : super y::_A&B^#U0^::•()
      ;
  }

The artificial class introduced by mixin transformation actually introduces incompatible override: A<#U0> provides A<#U0>.map of type ((#U0) -> void) -> void, but implements y::B requires map of type ((int) -> void) -> void. These types are incompatible.

@kmillikin
Copy link

That's not generated by the transformation, it was in the program before transformation:

abstract class _A&B^#U0^<#U0 extends core::Object> = self::A<self::_A&B^#U0^::#U0> with self::B {
}
class Good extends self::_A&B^#U0^<core::int> implements self::I<core::int> {
  default constructor •() → void
    : super self::A::•()
    ;
}

I think instead we'd like to have something like this for the unnamed mixin application:

abstract class _A&B = self::A<core::int> with self::B {
}
class Good extends self::_A&B^#U0^<core::int> implements self::I<core::int> {
  default constructor •() → void
    : super self::A::•()
    ;
}

@peter-ahe-google

@peter-ahe-google
Copy link
Contributor

@mraleph as we discussed offline, if you use a named mixin application this doesn't happen.

The root cause of this is how Fasta canonicalizes unnamed mixin applications, and we generally seem to want to keep the canonicalization as this has a positive effect on the number of classes generated overall.

Obviously, we need to fix this somehow, but it is not a high priority at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
front-end-fasta front-end-kernel legacy-area-front-end Legacy: Use area-dart-model instead. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

4 participants