Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Singleton types should be inferred wherever there is a bound of <: Singleton #27

Closed
milessabin opened this issue Sep 6, 2014 · 6 comments
Labels

Comments

@milessabin
Copy link
Member

This would be a fix for SI-5103 which has an incomplete patch by Jason.

@milessabin
Copy link
Member Author

See also #15.

@paulp
Copy link

paulp commented Sep 6, 2014

Like Jason I've tried and failed to implement this. I forget the details.

milessabin pushed a commit that referenced this issue Aug 12, 2016
This corrects an error in the change to the trait encoding
in scala#5003: getters in traits should have empty bodies and
be emitted as abstract.

```
% ~/scala/2.12.0-M4/bin/scalac sandbox/test.scala && javap -c T
Compiled from "test.scala"
public interface T {
  public abstract void T$_setter_$x_$eq(int);

  public int x();
    Code:
       0: aload_0
       1: invokeinterface #15,  1           // InterfaceMethod x:()I
       6: ireturn

  public int y();
    Code:
       0: aload_0
       1: invokeinterface #20,  1           // InterfaceMethod y:()I
       6: ireturn

  public void y_$eq(int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #24,  2           // InterfaceMethod y_$eq:(I)V
       7: return

  public void $init$();
    Code:
       0: aload_0
       1: bipush        42
       3: invokeinterface #29,  2           // InterfaceMethod T$_setter_$x_$eq:(I)V
       8: aload_0
       9: bipush        24
      11: invokeinterface #24,  2           // InterfaceMethod y_$eq:(I)V
      16: return
}

% qscalac sandbox/test.scala && javap -c T
Compiled from "test.scala"
public interface T {
  public abstract void T$_setter_$x_$eq(int);

  public abstract int x();

  public abstract int y();

  public abstract void y_$eq(int);

  public static void $init$(T);
    Code:
       0: aload_0
       1: bipush        42
       3: invokeinterface #21,  2           // InterfaceMethod T$_setter_$x_$eq:(I)V
       8: aload_0
       9: bipush        24
      11: invokeinterface #23,  2           // InterfaceMethod y_$eq:(I)V
      16: return

  public void $init$();
    Code:
       0: aload_0
       1: invokestatic  #27                 // Method $init$:(LT;)V
       4: return
}
```
@milessabin
Copy link
Member Author

This is fixed in the SIP-23 PR which will be included in the 2.12.0-RC1 release.

@SethTisue
Copy link
Member

I thought SIP-23 was targeted for 2.12.1, not 2.12.0-RC1?

@milessabin
Copy link
Member Author

This is the Typelevel Scala parallel release which hasn't been announced just yet ... watch this space.

@SethTisue
Copy link
Member

ah, news to me! ok thx

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants