@@ -1008,23 +1008,16 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1008
1008
val refineCls = createSymbol(refineClsDef).asClass
1009
1009
val TypeDef (_, impl : Template ) = typed(refineClsDef)
1010
1010
val refinements1 = impl.body
1011
- val seen = mutable.Set [Symbol ]()
1012
1011
assert(tree.refinements.length == refinements1.length, s " ${tree.refinements} != $refinements1" )
1013
- def addRefinement (parent : Type , refinement : Tree ): Type = {
1012
+ val seen = mutable.Set [Symbol ]()
1013
+ for (refinement <- refinements1) { // TODO: get clarity whether we want to enforce these conditions
1014
1014
typr.println(s " adding refinement $refinement" )
1015
1015
checkRefinementNonCyclic(refinement, refineCls, seen)
1016
1016
val rsym = refinement.symbol
1017
1017
if (rsym.is(Method ) && rsym.allOverriddenSymbols.isEmpty)
1018
- ctx.error(i " refinement $rsym without matching type in parent $parent" , refinement.pos)
1019
- val rinfo = if (rsym is Accessor ) rsym.info.resultType else rsym.info
1020
- RefinedType (parent, rsym.name, rinfo)
1021
- // todo later: check that refinement is within bounds
1018
+ ctx.error(i " refinement $rsym without matching type in parent $tpt1" , refinement.pos)
1022
1019
}
1023
- val refined = (tpt1.tpe /: refinements1)(addRefinement)
1024
- val res = cpy.RefinedTypeTree (tree)(tpt1, refinements1).withType(
1025
- RecType .closeOver(rt => refined.substThis(refineCls, RecThis (rt))))
1026
- typr.println(i " typed refinement: ${res.tpe}" )
1027
- res
1020
+ assignType(cpy.RefinedTypeTree (tree)(tpt1, refinements1), tpt1, refinements1, refineCls)
1028
1021
}
1029
1022
1030
1023
def typedAppliedTypeTree (tree : untpd.AppliedTypeTree )(implicit ctx : Context ): Tree = track(" typedAppliedTypeTree" ) {
0 commit comments