8000 Fixed use case signature problems in #5054 by VladUreche · Pull Request #45 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Fixed use case signature problems in #5054 #45

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

Closed
wants to merge 1 commit into from

Conversation

VladUreche
Copy link
Contributor

The flags attached to symbols depend on the order of access and this
affects use cases. For a workaround, flags are copied from the full
signature, which is always correct. Closes #5054, will open another
bug for the html itself.

The flags attached to symbols depend on the order of access and this
affects use cases. For a workaround, flags are copied from the full
signature, which is always correct. Closes scala#5054, will open another
bug for the html itself.
@paulp
Copy link
Contributor
paulp commented Dec 7, 2011

Can you configure your editor not to introduce tabs, and resubmit?

@paulp paulp closed this Dec 7, 2011
@VladUreche
Copy link
Contributor Author

On Thu, Dec 8, 2011 at 12:39 AM, Paul Phillips <
reply@reply.github.com

wrote:

Can you configure your editor not to introduce tabs, and resubmit?

Okay, will do. Might take a while, I want to also address another comment
by Simon.

Vlad

@VladUreche
Copy link
Contributor Author

On Thu, Dec 8, 2011 at 12:45 AM, Vlad Ureche vlad.ureche@gmail.com wrote:

Okay, will do. Might take a while, I want to also address another comment
by Simon.

Hi Paul. I created pull request 46
https://github.com/scala/scala/pull/46without the tabs. Please let
me know if there's anything more I should
add/change so you can accept it in trunk.

Thanks,
Vlad

retronym referenced this pull request in retronym/scala May 19, 2015
See also: https://github.com/retronym/indy-structural

```
qscalac -target:jvm-1.8 -Ybackend:GenBCode sandbox/structural.scala && qscala Test && javap -v 'Test$' | cat -v
warning: there was one feature warning; re-run with -feature for details
one warning found

QUACK! A
QUICK! A

Classfile /Users/jason/code/scala2/Test$.class
{
  public static final Test$ MODULE$;
    descriptor: LTest$;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL

  public void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC
    Code:
      stack=4, locals=2, args_size=2
         0: getstatic     #19                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
         3: aload_0
         4: new           #21                 // class C
         7: dup
         8: invokespecial #22                 // Method C."<init>":()V
        11: invokevirtual #26                 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String;
        14: invokevirtual #30                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
        17: getstatic     #19                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
        20: aload_0
        21: new           #32                 // class D
        24: dup
        25: invokespecial #33                 // Method D."<init>":()V
        28: invokevirtual #26                 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String;
        31: invokevirtua
10000
l #30                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
        34: return

  public java.lang.String duckduck(java.lang.Object);
    descriptor: (Ljava/lang/Object;)Ljava/lang/String;
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: aload_1
         1: ldc           #38                 // String A
         3: invokedynamic #49,  0             // InvokeDynamic #0:"dyn:callMethod:quack":(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;
         8: checkcast     #51                 // class java/lang/String
        11: areturn

}
BootstrapMethods:
  0: #45 invokestatic jdk/internal/dynalink/DefaultBootstrapper.bootstrap:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
    Method arguments:

```
retronym referenced this pull request in retronym/scala May 19, 2015
See also: https://github.com/retronym/indy-structural

```
// sandbox/structural.scala
object Test {
  def main(args: Array[String]): Unit = {
    println(duckduck(new C))
    println(duckduck(new D))
  }

  def duckduck(a: { def quack(a: String): String }): String = {
    a.quack("A")
  }

}

class C {
  def quack(a: String) = "QUACK! " + a
}

class D {
  def quack(a: String) = "QUICK! " + a
}
```

```
qscalac -target:jvm-1.8 -Ybackend:GenBCode sandbox/structural.scala && qscala Test && javap -v 'Test$' | cat -v
warning: there was one feature warning; re-run with -feature for details
one warning found

QUACK! A
QUICK! A

Classfile /Users/jason/code/scala2/Test$.class
{
  public static final Test$ MODULE$;
    descriptor: LTest$;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL

  public void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC
    Code:
      stack=4, locals=2, args_size=2
         0: getstatic     #19                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
         3: aload_0
         4: new           #21                 // class C
         7: dup
         8: invokespecial #22                 // Method C."<init>":()V
        11: invokevirtual #26                 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String;
        14: invokevirtual #30                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
        17: getstatic     #19                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
        20: aload_0
        21: new           #32                 // class D
        24: dup
        25: invokespecial #33                 // Method D."<init>":()V
        28: invokevirtual #26                 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String;
        31: invokevirtual #30                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
        34: return

  public java.lang.String duckduck(java.lang.Object);
    descriptor: (Ljava/lang/Object;)Ljava/lang/String;
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: aload_1
         1: ldc           #38                 // String A
         3: invokedynamic #49,  0             // InvokeDynamic #0:"dyn:callMethod:quack":(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;
         8: checkcast     #51                 // class java/lang/String
        11: areturn

}
BootstrapMethods:
  0: #45 invokestatic jdk/internal/dynalink/DefaultBootstrapper.bootstrap:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
    Method arguments:

```
retronym referenced this pull request in retronym/scala May 19, 2015
See also: https://github.com/retronym/indy-structural

```
// sandbox/structural.scala
object Test {
  def main(args: Array[String]): Unit = {
    println(duckduck(new C))
    println(duckduck(new D))
  }

  def duckduck(a: { def quack(a: String): String }): String = {
    a.quack("A")
  }

}

class C {
  def quack(a: String) = "QUACK! " + a
}

class D {
  def quack(a: String) = "QUICK! " + a
}
```

```
qscalac -target:jvm-1.8 -Ybackend:GenBCode sandbox/structural.scala && qscala Test && javap -v 'Test$' | cat -v
warning: there was one feature warning; re-run with -feature for details
one warning found

QUACK! A
QUICK! A

Classfile /Users/jason/code/scala2/Test$.class
{
  public static final Test$ MODULE$;
    descriptor: LTest$;
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL

  public void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC
    Code:
      stack=4, locals=2, args_size=2
         0: getstatic     #19                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
         3: aload_0
         4: new           #21                 // class C
         7: dup
         8: invokespecial #22                 // Method C."<init>":()V
        11: invokevirtual #26                 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String;
        14: invokevirtual #30                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
        17: getstatic     #19                 // Field scala/Predef$.MODULE$:Lscala/Predef$;
        20: aload_0
        21: new           #32                 // class D
        24: dup
        25: invokespecial #33                 // Method D."<init>":()V
        28: invokevirtual #26                 // Method duckduck:(Ljava/lang/Object;)Ljava/lang/String;
        31: invokevirtual #30                 // Method scala/Predef$.println:(Ljava/lang/Object;)V
        34: return

  public java.lang.String duckduck(java.lang.Object);
    descriptor: (Ljava/lang/Object;)Ljava/lang/String;
    flags: ACC_PUBLIC
    Code:
      stack=2, locals=2, args_size=2
         0: aload_1
         1: ldc           #38                 // String A
         3: invokedynamic #49,  0             // InvokeDynamic #0:"dyn:callMethod:quack":(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/String;
         8: checkcast     #51                 // class java/lang/String
        11: areturn

}
BootstrapMethods:
  0: #45 invokestatic jdk/internal/dynalink/DefaultBootstrapper.bootstrap:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
    Method arguments:

```
retronym referenced this pull request in retronym/scala Mar 30, 2016
Rather than in implementation of the abstract method in the
expanded anonymous class.

This leads to more more efficient use of the constant pool,
code shapes more amenable to SAM inlining, and is compatible
with the old behaviour of `-Xexperimental` in Scala 2.11,
which ScalaJS now relies upon.

Manual test:

```
scala> :paste -raw
// Entering paste mode (ctrl-D to finish)

package p1; trait T { val x = 0; def apply(): Any }; class DelambdafyInline { def t: T = (() => "") }

// Exiting paste mode, now interpreting.

scala> :javap -c p1.DelambdafyInline
Compiled from "<pastie>"
public class p1.DelambdafyInline {
  public p1.T t();
    Code:
       0: new           #10                 // class p1/DelambdafyInline$$anonfun$t$1
       3: dup
       4: aload_0
       5: invokespecial #16                 // Method p1/DelambdafyInline$$anonfun$t$1."<init>":(Lp1/DelambdafyInline;)V
       8: areturn

  public final java.lang.Object p1$DelambdafyInline$$$anonfun$1();
    Code:
       0: ldc           #22                 // String
       2: areturn

  public p1.DelambdafyInline();
    Code:
       0: aload_0
       1: invokespecial #25                 // Method java/lang/Object."<init>":()V
       4: return
}

scala> :javap -c p1.DelambdafyInline$$anonfun$t$1
Compiled from "<pastie>"
public final class p1.DelambdafyInline$$anonfun$t$1 implements p1.T,scala.Serializable {
  public static final long serialVersionUID;

  public int x();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:I
       4: ireturn

  public void p1$T$_setter_$x_$eq(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #25                 // Field x:I
       5: return

  public final java.lang.Object apply();
    Code:
       0: aload_0
       1: getfield      #34                 // Field $outer:Lp1/DelambdafyInline;
       4: invokevirtual #37                 // Method p1/DelambdafyInline.p1$DelambdafyInline$$$anonfun$1:()Ljava/lang/Object;
       7: areturn

  public p1.DelambdafyInline$$anonfun$t$1(p1.DelambdafyInline);
    Code:
       0: aload_1
       1: ifnonnull     6
       4: aconst_null
       5: athrow
       6: aload_0
       7: aload_1
       8: putfield      #34                 // Field $outer:Lp1/DelambdafyInline;
      11: aload_0
      12: invokespecial #42                 // Method java/lang/Object."<init>":()V
      15: aload_0
      16: invokespecial #45                 // Method p1/T.$init$:()V
      19: return
}

scala> :quit
```
retronym referenced this pull request in retronym/scala Mar 30, 2016
Rather than in implementation of the abstract method in the
expanded anonymous class.

This leads to more more efficient use of the constant pool,
code shapes more amenable to SAM inlining, and is compatible
with the old behaviour of `-Xexperimental` in Scala 2.11,
which ScalaJS now relies upon.

Manual test:

```
scala> :paste -raw
// Entering paste mode (ctrl-D to finish)

package p1; trait T { val x = 0; def apply(): Any }; class DelambdafyInline { def t: T = (() => "") }

// Exiting paste mode, now interpreting.

scala> :javap -c p1.DelambdafyInline
Compiled from "<pastie>"
public class p1.DelambdafyInline {
  public p1.T t();
    Code:
       0: new           #10                 // class p1/DelambdafyInline$$anonfun$t$1
       3: dup
       4: aload_0
       5: invokespecial #16                 // Method p1/DelambdafyInline$$anonfun$t$1."<init>":(Lp1/DelambdafyInline;)V
       8: areturn

  public final java.lang.Object p1$DelambdafyInline$$$anonfun$1();
    Code:
       0: ldc           #22                 // String
       2: areturn

  public p1.DelambdafyInline();
    Code:
       0: aload_0
       1: invokespecial #25                 // Method java/lang/Object."<init>":()V
       4: return
}

scala> :javap -c p1.DelambdafyInline$$anonfun$t$1
Compiled from "<pastie>"
public final class p1.DelambdafyInline$$anonfun$t$1 implements p1.T,scala.Serializable {
  public static final long serialVersionUID;

  public int x();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:I
       4: ireturn

  public void p1$T$_setter_$x_$eq(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #25                 // Field x:I
       5: return

  public final java.lang.Object apply();
    Code:
       0: aload_0
       1: getfield      #34                 // Field $outer:Lp1/DelambdafyInline;
       4: invokevirtual #37                 // Method p1/DelambdafyInline.p1$DelambdafyInline$$$anonfun$1:()Ljava/lang/Object;
       7: areturn

  public p1.DelambdafyInline$$anonfun$t$1(p1.DelambdafyInline);
    Code:
       0: aload_1
       1: ifnonnull     6
       4: aconst_null
       5: athrow
       6: aload_0
       7: aload_1
       8: putfield      #34                 // Field $outer:Lp1/DelambdafyInline;
      11: aload_0
      12: invokespecial #42                 // Method java/lang/Object."<init>":()V
      15: aload_0
      16: invokespecial #45                 // Method p1/T.$init$:()V
      19: return
}

scala> :quit
```
adriaanm pushed a commit to adriaanm/scala that referenced this pull request Mar 30, 2016
Rather than in implementation of the abstract method in the
expanded anonymous class.

This leads to more more efficient use of the constant pool,
code shapes more amenable to SAM inlining, and is compatible
with the old behaviour of `-Xexperimental` in Scala 2.11,
which ScalaJS now relies upon.

Manual test:

```
scala> :paste -raw
// Entering paste mode (ctrl-D to finish)

package p1; trait T { val x = 0; def apply(): Any }; class DelambdafyInline { def t: T = (() => "") }

// Exiting paste mode, now interpreting.

scala> :javap -c p1.DelambdafyInline
Compiled from "<pastie>"
public class p1.DelambdafyInline {
  public p1.T t();
    Code:
       0: new           #10                 // class p1/DelambdafyInline$$anonfun$t$1
       3: dup
       4: aload_0
       5: invokespecial #16                 // Method p1/DelambdafyInline$$anonfun$t$1."<init>":(Lp1/DelambdafyInline;)V
       8: areturn

  public final java.lang.Object p1$DelambdafyInline$$$anonfun$1();
    Code:
       0: ldc           #22                 // String
       2: areturn

  public p1.DelambdafyInline();
    Code:
       0: aload_0
       1: invokespecial #25                 // Method java/lang/Object."<init>":()V
       4: return
}

scala> :javap -c p1.DelambdafyInline$$anonfun$t$1
Compiled from "<pastie>"
public final class p1.DelambdafyInline$$anonfun$t$1 implements p1.T,scala.Serializable {
  public static final long serialVersionUID;

  public int x();
    Code:
       0: aload_0
       1: getfield      #25                 // Field x:I
       4: ireturn

  public void p1$T$_setter_$x_$eq(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #25                 // Field x:I
       5: return

  public final java.lang.Object apply();
    Code:
       0: aload_0
       1: getfield      scala#34                 // Field $outer:Lp1/DelambdafyInline;
       4: invokevirtual scala#37                 // Method p1/DelambdafyInline.p1$DelambdafyInline$$$anonfun$1:()Ljava/lang/Object;
       7: areturn

  public p1.DelambdafyInline$$anonfun$t$1(p1.DelambdafyInline);
    Code:
       0: aload_1
       1: ifnonnull     6
       4: aconst_null
       5: athrow
       6: aload_0
       7: aload_1
       8: putfield      scala#34                 // Field $outer:Lp1/DelambdafyInline;
      11: aload_0
      12: invokespecial scala#42                 // Method java/lang/Object."<init>":()V
      15: aload_0
      16: invokespecial scala#45                 // Method p1/T.$init$:()V
      19: return
}

scala> :quit
```

Adriaan is to `git blame` for `reflection-mem-typecheck.scala`.
szeiger added a commit to szeiger/scala that referenced this pull request Mar 20, 2018
Abstractions for constrained collection types
szeiger added a commit to szeiger/scala that referenced this pull request Mar 20, 2018
`BuildFrom` is like `FromSpecificIterable` but with an extra `From`
argument, like in the final version of scala#45. `FromSpecificIterable`
existed conceptually in that version as `BuildFrom[Any, …]` but didn’t
have a separate type.

This new version has separate abstractions for buildable (strict)
collection types in the form of `StrictBuildFrom` and
`FromSpecificIterableWithBuilder`. Since we can get a surrogate builder
(through one of the new `Builder.from` methods) for any lazy collection
and we can restrict code to work only with strict collections via the
`Buildable` trait, this is not strictly necessary. The only reason for
separating the `Builder` abstractions is to avoid exposing them in
`FromSpecificIterable`. Even though everything can be built in a strict
way, these abstractions sit on top of the lazy ones, not below them.
bishabosha added a commit to bishabosha/scala that referenced this pull request Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0