Skip to content

Instantly share code, notes, and snippets.

@b-studios
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b-studios/e06f741434b2119ed0f2 to your computer and use it in GitHub Desktop.
Save b-studios/e06f741434b2119ed0f2 to your computer and use it in GitHub Desktop.
class E[F]
class A
class B
class C
trait TypeMember {
type X
id(value) // This call throws an AbstractMethodError
def value: X
def id(x: X): X
}
object TypeMemberTest {
type F = A with B
object Test extends TypeMember {
type X = E[F with C]
// works if replaced by:
// type X = E[A with B with C]
//
// See `comparison.diff` for a byte code comparison
val value = new E[F with C]
def id(x: X) = x
}
}
trait TypeParam[X] {
id(value)
def value: X
def id(x: X): X
}
// Equivalent code with type params works
object TypeParamTest {
type F = A with B
object Test extends TypeParam[E[F with C]] {
val value = new E[F with C]
def id(x: E[F with C]) = x
}
}
--- <unnamed>
+++ <unnamed>
@@ -1,4 +1,4 @@
-// Working version
+// Broken version
Compiled from "bug.scala"
public class TypeMemberTest$Test$ implements TypeMember {
@@ -21,32 +21,24 @@
0: aload_1
1: areturn
- public java.lang.Object id(java.lang.Object);
- Code:
- 0: aload_0
- 1: aload_1
- 2: checkcast #27 // class E
- 5: invokevirtual #29 // Method id:(LE;)LE;
- 8: areturn
-
public java.lang.Object value();
Code:
0: aload_0
- 1: invokevirtual #33 // Method value:()LE;
+ 1: invokevirtual #27 // Method value:()LE;
4: areturn
public TypeMemberTest$Test$();
Code:
0: aload_0
- 1: invokespecial #34 // Method java/lang/Object."<init>":()V
+ 1: invokespecial #28 // Method java/lang/Object."<init>":()V
4: aload_0
- 5: putstatic #36 // Field MODULE$:LTypeMemberTest$Test$;
+ 5: putstatic #30 // Field MODULE$:LTypeMemberTest$Test$;
8: aload_0
- 9: invokestatic #42 // Method TypeMember$class.$init$:(LTypeMember;)V
+ 9: invokestatic #36 // Method TypeMember$class.$init$:(LTypeMember;)V
12: aload_0
- 13: new #27 // class E
+ 13: new #38 // class E
16: dup
- 17: invokespecial #43 // Method E."<init>":()V
+ 17: invokespecial #39 // Method E."<init>":()V
20: putfield #20 // Field value:LE;
23: return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment