-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Test for SI-2856. #19
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gkossakowski
added a commit
to gkossakowski/scala
that referenced
this pull request
Jan 11, 2012
Second round of factory manifest implementation.
som-snytt
added a commit
to som-snytt/scala
that referenced
this pull request
Jul 16, 2013
The REPL :java -app command is a convenience to locate
the body of DelayedInit code. Now it will look for
new style delayedEndpoints on the class before it
falls back to showing the apply method of the
delayedInit$body closure.
```
apm@mara:~/tmp$ skala
Welcome to Scala version 2.11.0-20130711-153246-eb1c3137f5 (OpenJDK 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :javap -pv -app delayed.C
public final void delayedEndpoint$delayed$C$1();
flags: ACC_PUBLIC, ACC_FINAL
Code:
stack=2, locals=1, args_size=1
0: getstatic scala#29 // Field scala/Predef$.MODULE$:Lscala/Predef$;
3: ldc scala#31 // String this is the initialization code of C
5: invokevirtual scala#35 // Method scala/Predef$.println:(Ljava/lang/Object;)V
8: return
LocalVariableTable:
Start Length Slot Name Signature
0 9 0 this Ldelayed/C;
LineNumberTable:
line 11: 0
scala> :q
apm@mara:~/tmp$ rm delayed/*.class
apm@mara:~/tmp$ scalac delayed.scala
apm@mara:~/tmp$ skala
Welcome to Scala version 2.11.0-20130711-153246-eb1c3137f5 (OpenJDK 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :javap -pv -app delayed.C
public final java.lang.Object apply();
flags: ACC_PUBLIC, ACC_FINAL
Code:
stack=2, locals=1, args_size=1
0: getstatic scala#13 // Field scala/Predef$.MODULE$:Lscala/Predef$;
3: ldc scala#15 // String this is the initialization code of C
5: invokevirtual scala#19 // Method scala/Predef$.println:(Ljava/lang/Object;)V
8: getstatic scala#25 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
11: areturn
LocalVariableTable:
Start Length Slot Name Signature
0 12 0 this Ldelayed/C$delayedInit$body;
LineNumberTable:
line 11: 0
line 10: 8
```
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: 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
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
Jul 14, 2015
And do the same for the specialized variants.
Tested by a Java source file that uses lambda syntax to create
instances of generic and specialized `Function{0,1}`.
Here's how the interfaces look now:
```
% javap -c -classpath /tmp/function 'scala.Function1'
Compiled from "Function1.scala"
public interface scala.Function1<T1, R> {
public abstract R apply(T1);
public <A> scala.Function1<A, R> compose(scala.Function1<A, T1>);
Code:
0: aload_0
1: aload_1
2: invokestatic #18 // Method scala/Function1$class.compose:(Lscala/Function1;Lscala/Function1;)Lscala/Function1;
5: areturn
public <A> scala.Function1<T1, A> andThen(scala.Function1<R, A>);
Code:
0: aload_0
1: aload_1
2: invokestatic #24 // Method scala/Function1$class.andThen:(Lscala/Function1;Lscala/Function1;)Lscala/Function1;
5: areturn
public abstract java.lang.String toString();
public int apply$mcII$sp(int);
Code:
0: aload_0
1: iload_1
2: invokestatic #110 // Method scala/Function1$class.apply$mcII$sp:(Lscala/Function1;I)I
5: ireturn
public long apply$mcJI$sp(int);
Code:
0: aload_0
1: iload_1
2: invokestatic #115 // Method scala/Function1$class.apply$mcJI$sp:(Lscala/Function1;I)J
5: lreturn
...
}
% javap -c -classpath /tmp/function 'scala.Function1$mcII$sp'
Compiled from "Function1.scala"
public interface scala.Function1$mcII$sp extends scala.Function1<java.lang.Object, java.lang.Object> {
public java.lang.Object apply(java.lang.Object);
Code:
0: aload_0
1: aload_1
2: invokestatic #16 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I
5: invokeinterface #19, 2 // InterfaceMethod apply:(I)I
10: invokestatic #23 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
13: areturn
public abstract int apply$mcII$sp(int);
public int apply(int);
Code:
0: aload_0
1: iload_1
2: invokeinterface #30, 2 // InterfaceMethod apply$mcII$sp:(I)I
7: ireturn
}
```
retronym
referenced
this pull request
in retronym/scala
Jul 23, 2015
And do the same for the specialized variants.
Tested by a Java source file that uses lambda syntax to create
instances of generic and specialized `Function{0,1}`.
Here's how the interfaces look now:
```
% javap -c -classpath /tmp/function 'scala.Function1'
Compiled from "Function1.scala"
public interface scala.Function1<T1, R> {
public abstract R apply(T1);
public <A> scala.Function1<A, R> compose(scala.Function1<A, T1>);
Code:
0: aload_0
1: aload_1
2: invokestatic #18 // Method scala/Function1$class.compose:(Lscala/Function1;Lscala/Function1;)Lscala/Function1;
5: areturn
public <A> scala.Function1<T1, A> andThen(scala.Function1<R, A>);
Code:
0: aload_0
1: aload_1
2: invokestatic #24 // Method scala/Function1$class.andThen:(Lscala/Function1;Lscala/Function1;)Lscala/Function1;
5: areturn
public abstract java.lang.String toString();
public int apply$mcII$sp(int);
Code:
0: aload_0
1: iload_1
2: invokestatic #110 // Method scala/Function1$class.apply$mcII$sp:(Lscala/Function1;I)I
5: ireturn
public long apply$mcJI$sp(int);
Code:
0: aload_0
1: iload_1
2: invokestatic #115 // Method scala/Function1$class.apply$mcJI$sp:(Lscala/Function1;I)J
5: lreturn
...
}
% javap -c -classpath /tmp/function 'scala.Function1$mcII$sp'
Compiled from "Function1.scala"
public interface scala.Function1$mcII$sp extends scala.Function1<java.lang.Object, java.lang.Object> {
public java.lang.Object apply(java.lang.Object);
Code:
0: aload_0
1: aload_1
2: invokestatic #16 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I
5: invokeinterface #19, 2 // InterfaceMethod apply:(I)I
10: invokestatic #23 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
13: areturn
public abstract int apply$mcII$sp(int);
public int apply(int);
Code:
0: aload_0
1: iload_1
2: invokeinterface #30, 2 // InterfaceMethod apply$mcII$sp:(I)I
7: ireturn
}
```
SethTisue
pushed a commit
to SethTisue/scala
that referenced
this pull request
Aug 7, 2015
And do the same for the specialized variants.
Tested by a Java source file that uses lambda syntax to create
instances of generic and specialized `Function{0,1}`.
Here's how the interfaces look now:
```
% javap -c -classpath /tmp/function 'scala.Function1'
Compiled from "Function1.scala"
public interface scala.Function1<T1, R> {
public abstract R apply(T1);
public <A> scala.Function1<A, R> compose(scala.Function1<A, T1>);
Code:
0: aload_0
1: aload_1
2: invokestatic scala#18 // Method scala/Function1$class.compose:(Lscala/Function1;Lscala/Function1;)Lscala/Function1;
5: areturn
public <A> scala.Function1<T1, A> andThen(scala.Function1<R, A>);
Code:
0: aload_0
1: aload_1
2: invokestatic scala#24 // Method scala/Function1$class.andThen:(Lscala/Function1;Lscala/Function1;)Lscala/Function1;
5: areturn
public abstract java.lang.String toString();
public int apply$mcII$sp(int);
Code:
0: aload_0
1: iload_1
2: invokestatic scala#110 // Method scala/Function1$class.apply$mcII$sp:(Lscala/Function1;I)I
5: ireturn
public long apply$mcJI$sp(int);
Code:
0: aload_0
1: iload_1
2: invokestatic scala#115 // Method scala/Function1$class.apply$mcJI$sp:(Lscala/Function1;I)J
5: lreturn
...
}
% javap -c -classpath /tmp/function 'scala.Function1$mcII$sp'
Compiled from "Function1.scala"
public interface scala.Function1$mcII$sp extends scala.Function1<java.lang.Object, java.lang.Object> {
public java.lang.Object apply(java.lang.Object);
Code:
0: aload_0
1: aload_1
2: invokestatic scala#16 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I
5: invokeinterface scala#19, 2 // InterfaceMethod apply:(I)I
10: invokestatic scala#23 // Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
13: areturn
public abstract int apply$mcII$sp(int);
public int apply(int);
Code:
0: aload_0
1: iload_1
2: invokeinterface scala#30, 2 // InterfaceMethod apply$mcII$sp:(I)I
7: ireturn
}
```
This was referenced Apr 7, 2017
adriaanm
pushed a commit
that referenced
this pull request
May 25, 2017
Non local returns aren't eliminated after inlined in 2.11 or 2.12
```
⚡ scala
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.
scala> @inlune def foo(a: => Any) = if ("".isEmpty) a else ""
<console>:11: error: not found: type inlune
@inlune def foo(a: => Any) = if ("".isEmpty) a else ""
^
scala> @inline def foo(a: => Any) = if ("".isEmpty) a else ""
foo: (a: => Any)Any
scala> class InlineReturn { def test: Any = foo(return "") }
defined class InlineReturn
scala> :javap -c InlineReturn#test
public java.lang.Object test();
Code:
0: new #4 // class java/lang/Object
3: dup
4: invokespecial #32 // Method java/lang/Object."<init>":()V
7: astore_1
8: getstatic #36 // Field $line4/$read$$iw$$iw$.MODULE$:L$line4/$read$$iw$$iw$;
11: aload_1
12: invokedynamic #59, 0 // InvokeDynamic #0:apply:(Ljava/lang/Object;)Lscala/Function0;
17: invokevirtual #63 // Method $line4/$read$$iw$$iw$.foo:(Lscala/Function0;)Ljava/lang/Object;
20: goto 44
23: astore_2
24: aload_2
25: invokevirtual #66 // Method scala/runtime/NonLocalReturnControl.key:()Ljava/lang/Object;
28: aload_1
29: if_acmpne 39
32: aload_2
33: invokevirtual #69 // Method scala/runtime/NonLocalReturnControl.value:()Ljava/lang/Object;
36: goto 41
39: aload_2
40: athrow
41: goto 44
44: areturn
Exception table:
from to target type
8 20 23 Class scala/runtime/NonLocalReturnControl
```
```
⚡ ~/scala/2.11.8/bin/scala
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.
scala> @inline def foo(a: => Any) = if ("".isEmpty) a else ""
foo: (a: => Any)Any
scala> class InlineReturn { def test: Any = foo(return "") }
defined class InlineReturn
scala> :javap -c InlineReturn#test
public java.lang.Object test();
Code:
0: new #4 // class java/lang/Object
3: dup
4: invokespecial #13 // Method java/lang/Object."<init>":()V
7: astore_1
8: getstatic #19 // Field .MODULE$:L;
11: new #21 // class InlineReturn$$anonfun$test$1
14: dup
15: aload_0
16: aload_1
17: invokespecial #24 // Method InlineReturn$$anonfun$test$1."<init>":(LInlineReturn;Ljava/lang/Object;)V
20: invokevirtual #28 // Method .foo:(Lscala/Function0;)Ljava/lang/Object;
23: goto 39
26: astore_2
27: aload_2
28: invokevirtual #31 // Method scala/runtime/NonLocalReturnControl.key:()Ljava/lang/Object;
31: aload_1
32: if_acmpne 40
35: aload_2
36: invokevirtual #34 // Method scala/runtime/NonLocalReturnControl.value:()Ljava/lang/Object;
39: areturn
40: aload_2
41: athrow
Exception table:
from to target type
8 26 26 Class scala/runtime/NonLocalReturnControl
scala> :quit
```
OlivierBlanvillain
pushed a commit
to OlivierBlanvillain/scala
that referenced
this pull request
Jun 27, 2017
Fix exhaustivity check of `classOrArrayType`
szeiger
pushed a commit
to szeiger/scala
that referenced
this pull request
Mar 20, 2018
Add micro-benchmarks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding the test won't hurt, but waiting for Geoffrey (or someone else) to comment if this is completely fixed before closing it.