diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-17 23:28:27 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-17 23:28:27 +0100 |
commit | 6b106397a683b9de4bf05da7e768ebf747085c55 (patch) | |
tree | fbbca5080536d195034eed0d8a0a8c77e48a0624 /src | |
parent | 9e8d0709e9f43fbb1dc40baaab4f0891538d8e9c (diff) | |
download | dotty-6b106397a683b9de4bf05da7e768ebf747085c55.tar.gz dotty-6b106397a683b9de4bf05da7e768ebf747085c55.tar.bz2 dotty-6b106397a683b9de4bf05da7e768ebf747085c55.zip |
Fixes to parent types.
The previous addition of checkClassTypeWithStablePrefix to Namer#classSig needs to be adjusted.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/Inferencing.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Inferencing.scala b/src/dotty/tools/dotc/typer/Inferencing.scala index 1d1220824..80fd9de90 100644 --- a/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/src/dotty/tools/dotc/typer/Inferencing.scala @@ -235,7 +235,7 @@ object Inferencing { /** Check that `tp` is a class type with a stable prefix. * @return Underlying class type if type checks out OK, ObjectClass.typeRef if not. */ - def checkClassTypeWithStablePrefix(tp: Type, pos: Position)(implicit ctx: Context): Type = tp.dealias match { + def checkClassTypeWithStablePrefix(tp: Type, pos: Position)(implicit ctx: Context): TypeRef = tp.dealias match { case tp: TypeRef if tp.symbol.isClass => checkStable(tp.prefix, pos) tp diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 9d0ec539c..1908cbafd 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -348,9 +348,9 @@ class Namer { typer: Typer => } val Select(New(tpt), nme.CONSTRUCTOR) = core val targs1 = targs map (typedAheadType(_)) - var ptype = typedAheadType(tpt).tpe appliedTo targs1.tpes - if (ptype.uninstantiatedTypeParams.nonEmpty) ptype = typedAheadExpr(constr).tpe - checkClassTypeWithStablePrefix(ptype, core.pos) + val ptype = typedAheadType(tpt).tpe appliedTo targs1.tpes + if (ptype.uninstantiatedTypeParams.isEmpty) ptype + else typedAheadExpr(constr).tpe } val TypeDef(_, name, impl @ Template(constr, parents, self, body)) = cdef @@ -366,9 +366,13 @@ class Namer { typer: Typer => cls.info = adjustIfModule(ClassInfo(cls.owner.thisType, cls, Nil, decls, selfInfo)) val parentTypes = parents map parentType val parentRefs = ctx.normalizeToRefs(parentTypes, cls, decls) + val parentClsRefs = + for ((parentRef, constr) <- parentRefs zip parents) + yield checkClassTypeWithStablePrefix(parentRef, constr.pos) + index(constr) index(rest)(inClassContext(selfInfo)) - ClassInfo(cls.owner.thisType, cls, parentRefs, decls, selfInfo) + ClassInfo(cls.owner.thisType, cls, parentClsRefs, decls, selfInfo) } def adjustIfModule(sig: Type): Type = |