diff options
author | Martin Odersky <odersky@gmail.com> | 2013-10-27 18:33:57 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-10-27 18:33:57 +0100 |
commit | 52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53 (patch) | |
tree | 7f029c717a8f8ea0787f669412ce2047e68a630d /src/dotty/tools/dotc/ast/TypedTrees.scala | |
parent | 41e7d9d46177650d23447f99989e8347aca56e71 (diff) | |
download | dotty-52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53.tar.gz dotty-52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53.tar.bz2 dotty-52a8a0aec9da8a4eaa3faf95ec7acd3ecfbabf53.zip |
Fixed unpickling of polymorphic constructors.
Constructors of parameterized classes now get polymorphic types when unpickled, as is the case when defining them or when reading them from a Java classfile. This caused a ripple of other faults which this commit also fixes.
Diffstat (limited to 'src/dotty/tools/dotc/ast/TypedTrees.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/TypedTrees.scala | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/ast/TypedTrees.scala b/src/dotty/tools/dotc/ast/TypedTrees.scala index a498346f5..827e6cd87 100644 --- a/src/dotty/tools/dotc/ast/TypedTrees.scala +++ b/src/dotty/tools/dotc/ast/TypedTrees.scala @@ -46,8 +46,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { case fntpe @ MethodType(pnames, ptypes) => check(sameLength(ptypes, args), s"${fn.show}: ${fntpe.show} to ${args.map(_.show).mkString(", ")}") fntpe.instantiate(args map (_.tpe)) - case _ => - check(false) + case t => + check(false, s"fn = $fn, args = $args, tp = $t") ErrorType } untpd.Apply(fn, args).withType(owntype).checked @@ -308,12 +308,15 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { // ------ Creating typed equivalents of trees that exist only in untyped form ------- /** new C(args) */ - def New(tp: Type, args: List[Tree])(implicit ctx: Context): Apply = + def New(tp: Type, args: List[Tree])(implicit ctx: Context): Apply = { + val targs = tp.typeArgs Apply( Select( - New(tp), - TermRef.withSym(tp.normalizedPrefix, tp.typeSymbol.primaryConstructor.asTerm)), + New(tp withoutArgs targs), + TermRef.withSym(tp.normalizedPrefix, tp.typeSymbol.primaryConstructor.asTerm)) + .appliedToTypes(targs), args) + } /** An object def * @@ -399,6 +402,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { def changeOwner(from: Symbol, to: Symbol)(implicit ctx: Context): ThisTree = new TreeMapper(ownerMap = (sym => if (sym == from) to else sym)).apply(tree) + + def appliedToTypes(targs: List[Type])(implicit ctx: Context): Tree = + if (targs.isEmpty) tree else TypeApply(tree, targs map (TypeTree(_))) } implicit class ListOfTreeDecorator(val xs: List[tpd.Tree]) extends AnyVal { |