diff options
author | Martin Odersky <odersky@gmail.com> | 2013-04-22 17:17:52 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-04-22 17:22:20 +0200 |
commit | 7bca39c57e31da15478033ac4d581705cbeb4bc9 (patch) | |
tree | 42940077a21d5d067583449ff8a2dffa7491c32a /src/dotty/tools/dotc/core/TypeOps.scala | |
parent | 4a93c8c132941ff3dae9ebf2dc27b37cd4f7cdec (diff) | |
download | dotty-7bca39c57e31da15478033ac4d581705cbeb4bc9.tar.gz dotty-7bca39c57e31da15478033ac4d581705cbeb4bc9.tar.bz2 dotty-7bca39c57e31da15478033ac4d581705cbeb4bc9.zip |
Some annotations and changes prompted by the code walkthrough.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index d3cfaba69..164335554 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -27,7 +27,16 @@ trait TypeOps { this: Context => if (sym.isStatic) tp else { val tp1 = tp.derivedNamedType(asSeenFrom(tp.prefix, pre, cls, theMap)) - // short-circuit instantiated type parameters + // Here's an explanation why we short-circuit instantiated type parameters. + // Say you have This is translated to: + // + // class List[type T] ==> class List { type T; val hd: T } + // xs: List[Int] ==> List { type T = Int } + // + // Then with the line above, xs.hd would have type xs.T + // + // But in Scala 2.x, its type is Int, which is the dealiased version + // of xs.T. With the logic below, we get the same outcome as for 2.x. if ((tp1 ne tp) && (sym is (TypeParam, butNot = Deferred))) tp1.dealias else tp1 } |