From 9955a2fd64af1ff7b9992fa12662a85e07d82fc7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 2 Jan 2014 18:13:01 +0100 Subject: 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. --- src/dotty/tools/dotc/ast/TreeInfo.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/ast/TreeInfo.scala') 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]] -- cgit v1.2.3