summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 20797b87b8..37b47325f4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1182,6 +1182,12 @@ trait Typers { self: Analyzer =>
}
}
+ private def checkStructuralCondition(refinement: Symbol, vparam: ValDef) {
+ val tp = vparam.symbol.tpe
+ if (tp.typeSymbol.isAbstractType && !(tp.typeSymbol.ownerChain contains refinement))
+ error(vparam.tpt.pos,"Parameter type in structural refinement may not refer to abstract type defined outside that same refinement")
+ }
+
/**
* @param ddef ...
* @return ...
@@ -1218,6 +1224,11 @@ trait Typers { self: Analyzer =>
phase.id <= currentRun.typerPhase.id && !reporter.hasErrors)
computeParamAliases(meth.owner, vparamss1, rhs1)
if (tpt1.tpe.typeSymbol != AllClass && !context.returnsSeen) rhs1 = checkDead(rhs1)
+
+ if (meth.owner.isRefinementClass && meth.allOverriddenSymbols.isEmpty)
+ for (vparams <- ddef.vparamss; vparam <- vparams)
+ checkStructuralCondition(meth.owner, vparam)
+
copy.DefDef(ddef, ddef.mods, ddef.name, tparams1, vparamss1, tpt1, rhs1) setType NoType
}