Last active
June 17, 2016 18:32
-
-
Save dwijnand/5217ef03cd495f9deb2b73aabed70f26 to your computer and use it in GitHub Desktop.
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
class Thingy(val unThingy: String) extends AnyVal | |
class Rocket(val unRocket: Thingy) extends AnyVal |
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
object Func { | |
def thingyAAA = new Thingy("AAA") | |
def rocketAAA = new Rocket(thingyAAA) | |
def rocketBBB = new Rocket(new Thingy("BBB")) | |
} |
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
object Test extends App { println(Func.thingyAAA) } |
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
object Test extends App { println(Func.rocketAAA) } |
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
object Test extends App { println(Func.rocketBBB) } |
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
$ qscala sandbox/data.scala && qscalac -Xprint:erasure,posterasure sandbox/func.scala && { qscala sandbox/run1.scala; qscala sandbox/run2.scala; qscala sandbox/run3.scala; } | |
[[syntax trees at end of erasure]] // func.scala | |
package <empty> { | |
object Func extends Object { | |
def <init>(): Func.type = { | |
Func.super.<init>(); | |
() | |
}; | |
def thingyAAA(): ErasedValueType(class Thingy, String) = new Thingy("AAA".$asInstanceOf[String]()).unThingy().$asInstanceOf[ErasedValueType(class Thingy, String)](); | |
def rocketAAA(): ErasedValueType(class Rocket, String) = new Thingy(Func.this.thingyAAA().$asInstanceOf[String]()).$asInstanceOf[String](); | |
def rocketBBB(): ErasedValueType(class Rocket, String) = new Rocket("BBB".$asInstanceOf[ErasedValueType(class Thingy, String)]()).unRocket().$asInstanceOf[ErasedValueType(class Rocket, String)]() | |
} | |
} | |
[[syntax trees at end of posterasure]] // func.scala | |
package <empty> { | |
object Func extends Object { | |
def <init>(): Func.type = { | |
Func.super.<init>(); | |
() | |
}; | |
def thingyAAA(): String = "AAA"; | |
def rocketAAA(): String = new Thingy(Func.this.thingyAAA()).$asInstanceOf[String](); | |
def rocketBBB(): String = "BBB" | |
} | |
} | |
Thingy(AAA) | |
java.lang.ClassCastException: Thingy cannot be cast to java.lang.String | |
at Func$.rocketAAA(func.scala:4) | |
at Main$.delayedEndpoint$Main$1(run2.scala:1) | |
... | |
Rocket(Thingy(BBB)) |
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
$ qscala sandbox/data.scala && qscalac -Xprint:erasure,posterasure sandbox/func.scala && { qscala sandbox/run1.scala; qscala sandbox/run2.scala; qscala sandbox/run3.scala; } | |
[[syntax trees at end of erasure]] // func.scala | |
package <empty> { | |
object Func extends Object { | |
def <init>(): Func.type = { | |
Func.super.<init>(); | |
() | |
}; | |
def thingyAAA(): ErasedValueType(class Thingy, String) = new Thingy("AAA".$asInstanceOf[String]()).unThingy().$asInstanceOf[ErasedValueType(class Thingy, String)](); | |
def rocketAAA(): ErasedValueType(class Rocket, ErasedValueType(class Thingy, String)) = Func.this.thingyAAA(); | |
def rocketBBB(): ErasedValueType(class Rocket, ErasedValueType(class Thingy, String)) = "BBB".$asInstanceOf[Thingy]().unThingy().$asInstanceOf[ErasedValueType(class Thingy, String)]() | |
} | |
} | |
[[syntax trees at end of posterasure]] // func.scala | |
package <empty> { | |
object Func extends Object { | |
def <init>(): Func.type = { | |
Func.super.<init>(); | |
() | |
}; | |
def thingyAAA(): String = "AAA"; | |
def rocketAAA(): String = Func.this.thingyAAA(); | |
def rocketBBB(): String = "BBB".$asInstanceOf[Thingy]().unThingy() | |
} | |
} | |
Thingy(AAA) | |
Rocket(Thingy(AAA)) | |
java.lang.ClassCastException: java.lang.String cannot be cast to Thingy | |
at Func$.rocketBBB(func.scala:5) | |
at Main$.delayedEndpoint$Main$1(run3.scala:1) | |
... |
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
--- /s/before.txt 2016-06-17 20:29:12.000000000 +0200 | |
+++ /s/after.txt 2016-06-17 20:29:12.000000000 +0200 | |
@@ -6,8 +6,8 @@ | |
() | |
}; | |
def thingyAAA(): ErasedValueType(class Thingy, String) = new Thingy("AAA".$asInstanceOf[String]()).unThingy().$asInstanceOf[ErasedValueType(class Thingy, String)](); | |
- def rocketAAA(): ErasedValueType(class Rocket, String) = new Thingy(Func.this.thingyAAA().$asInstanceOf[String]()).$asInstanceOf[String](); | |
- def rocketBBB(): ErasedValueType(class Rocket, String) = new Rocket("BBB".$asInstanceOf[ErasedValueType(class Thingy, String)]()).unRocket().$asInstanceOf[ErasedValueType(class Rocket, String)]() | |
+ def rocketAAA(): ErasedValueType(class Rocket, ErasedValueType(class Thingy, String)) = Func.this.thingyAAA(); | |
+ def rocketBBB(): ErasedValueType(class Rocket, ErasedValueType(class Thingy, String)) = "BBB".$asInstanceOf[Thingy]().unThingy().$asInstanceOf[ErasedValueType(class Thingy, String)]() | |
} | |
} | |
@@ -19,7 +19,7 @@ | |
() | |
}; | |
def thingyAAA(): String = "AAA"; | |
- def rocketAAA(): String = new Thingy(Func.this.thingyAAA()).$asInstanceOf[String](); | |
- def rocketBBB(): String = "BBB" | |
+ def rocketAAA(): String = Func.this.thingyAAA(); | |
+ def rocketBBB(): String = "BBB".$asInstanceOf[Thingy]().unThingy() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment