Created
February 7, 2012 09:27
-
-
Save misto/1758655 to your computer and use it in GitHub Desktop.
Scala Trait linearization
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
Welcome to Scala version 2.9.1.r0-b20120125223512 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_02). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> trait A | |
defined trait A | |
scala> trait C extends A | |
defined trait C | |
scala> trait B extends A | |
defined trait B | |
scala> trait D extends B | |
defined trait D | |
scala> trait E extends C | |
defined trait E | |
scala> class D extends A with D with E | |
<console>:12: error: class D inherits itself | |
class D extends A with D with E | |
^ | |
scala> class F extends A with D with E | |
defined class F | |
scala> :power | |
** Power User mode enabled - BEEP BOOP SPIZ ** | |
** :phase has been set to 'typer'. ** | |
** scala.tools.nsc._ has been imported ** | |
** global._ and definitions._ also imported ** | |
** Try :help, vals.<tab>, power.<tab> ** | |
scala> intp.types("F").tpe.baseTypeSeq.toList | |
res0: List[$r.intp.global.Type] = List(F, D, E, C, B, ScalaObject, A, java.lang.Object, Any) | |
Tada! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works:
Documentation for the method is here: https://github.com/scala/scala/blob/v2.12.4/src/reflect/scala/reflect/internal/Types.scala#L909