diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-02 18:13:01 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-02 18:19:24 +0100 |
commit | 9955a2fd64af1ff7b9992fa12662a85e07d82fc7 (patch) | |
tree | 20af8ab4d4e060c98bc7767262665d34bef46eac /src/dotty/tools/dotc/ast/TreeInfo.scala | |
parent | 1aaca404f83020a06a460d56841cd0a6b82b989b (diff) | |
download | dotty-9955a2fd64af1ff7b9992fa12662a85e07d82fc7.tar.gz dotty-9955a2fd64af1ff7b9992fa12662a85e07d82fc7.tar.bz2 dotty-9955a2fd64af1ff7b9992fa12662a85e07d82fc7.zip |
Fixing a type problem where code does not compile under dotty.
... and I believe should not compile under Scala2x either. The problem is in line 361 of TreeInfo.scala
methPart(tree) match { ...
Here,
tree: tpd.Tree
methPart: (tree: this.Tree): Tree
So we need to show that
tpd.Tree <: this.Tree
LHS expands to
ast.Tree[Type]
RHS expands to
ast.Tree[T] where T >: Untyped is TreeInfo's type parameter
Since Tree is contravariant, we need to etablish
T <: Type
but I see nothing that could prove this. The Dotty typechecker detected the problem, yet Scala2x's didn't. Need to follow up on why not. For now, adding the necessary constraint to the codebase.
Diffstat (limited to 'src/dotty/tools/dotc/ast/TreeInfo.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/TreeInfo.scala | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/ast/TreeInfo.scala b/src/dotty/tools/dotc/ast/TreeInfo.scala index e1715ae26..8957d8813 100644 --- a/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -7,7 +7,10 @@ import Flags._, Trees._, Types._, Contexts._ import Names._, StdNames._, NameOps._, Decorators._, Symbols._ import util.HashSet -trait TreeInfo[T >: Untyped] { self: Trees.Instance[T] => +trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] => + + // Note: the <: Type constraint looks necessary (and is needed to make the file compile in dotc). + // But Scalac accepts the program happily without it. Need to find out why. def unsplice[T >: Untyped](tree: Trees.Tree[T]): Trees.Tree[T] = tree.asInstanceOf[untpd.Tree] match { case untpd.TypedSplice(tree1) => tree1.asInstanceOf[Trees.Tree[T]] |