Skip to content

Instantly share code, notes, and snippets.

@retronym
Created December 18, 2009 08:32
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 retronym/259378 to your computer and use it in GitHub Desktop.
Save retronym/259378 to your computer and use it in GitHub Desktop.
A foray into dependant types
type HasTree = { type Tree }
def r[HT <: HasTree](x: HT)(y: x.Tree) = null
//r: [HT <: HasTree](x$0:HT)(x$0:<param 1.0>#Tree)Null
trait T { type Tree }
//defined trait T
r(new T{ type Tree = Int})(1)
/*Exception in thread "main" java.lang.AssertionError: assertion failed: <param 1.0>.type Tree does no longer exist, phase = namer
at scala.tools.nsc.symtab.Types$adaptToNewRunMap$.adaptToNewRun(Types.scala:3529)
at scala.tools.nsc.symtab.Types$adaptToNewRunMap$.apply(Types.scala:3569)
at scala.tools.nsc.symtab.Symbols$Symbol.adaptToNewRun$1(Symbols.scala:853)
at scala.tools.nsc.symtab.Symbols$Symbol.adaptInfos(Symbols.scala:857)
at scala.tools.nsc.symtab.Symbols$Symbol.rawInfo(Symbols.scala:815)
at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:772)
at scala.tools.nsc.symtab.Types$TypeMap$$anonfun$15.apply(Types.scala:28*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment